Skip to content

Instantly share code, notes, and snippets.

View emmaly's full-sized avatar
👾
Invading Space

Emmaly emmaly

👾
Invading Space
View GitHub Profile
@emmaly
emmaly / Convert-ACLToCustomObject.ps1
Created February 7, 2024 02:45
Convert-ACLToCustomObject
function Convert-ACLToCustomObject {
param ([Parameter(Mandatory = $true)]$ACL)
# Define a custom type
class CustomADObject {
[object]$ADObject
[string]$Guid
CustomADObject([object]$ADObject, [string]$Guid) {
$this.ADObject = $ADObject
@emmaly
emmaly / code.gs
Created December 15, 2023 02:29
Google Sheet Apps Script: change data validation ranges
/** @OnlyCurrentDoc */
/**
* Fixes the dropdown pickers on the Elections sheet if they need it.
*/
function fixPickers() {
const spreadsheet = SpreadsheetApp.getActiveSpreadsheet();
const sheet = (spreadsheet.getSheets().filter((sheet) => sheet.getSheetId() === 123123) || []).shift();
const pickListsSheet = (spreadsheet.getSheets().filter((sheet) => sheet.getSheetId() === 234234) || []).shift();
const pickers = spreadsheet.getRangeByName("ProductPickers");
@emmaly
emmaly / code.gs
Created December 4, 2023 23:41
Apps Script Helper Functions for Google Sheets
/** @OnlyCurrentDoc */
/**
* @param {any} value - value to test
* @returns {boolean} - `true` if a number, `false` otherwise
*/
function isNumber(value) {
return typeof value == 'number' && isFinite(value);
}
@emmaly
emmaly / code.gs
Created December 4, 2023 23:39
Apps Script: Cached Key Helpers & Named Range Lookup
/**
* Retrieves a value from the cache if it's still valid.
* @param {string} key - The key for the cached data.
* @param {number} expirationInMinutes - The time after which data should be considered stale.
* @returns {any} - The cached data, or null if it's stale or not present.
*/
function getCachedValue(key, expirationInMinutes) {
Logger.log("getCachedValue(%s, %s)", key, expirationInMinutes.toFixed(0));
var cache = PropertiesService.getScriptProperties();
@emmaly
emmaly / gfb.html
Created November 5, 2023 05:22
Glowy Floaty Balls
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Glowy Floaty Balls</title>
<style>
body {
background-color: #222;
@emmaly
emmaly / KV to JSON.buildship
Created September 22, 2023 19:51
BuildShip Node: KV to JSON
{
"meta": {
"id": "f803c041-7f48-48d0-852c-22adff386327",
"icon": {
"url": null,
"type": "URL"
},
"description": "Converts Key/Value list to JSON",
"name": "KV to JSON"
},
@emmaly
emmaly / Jinja2 Type Testing.txt
Last active September 14, 2023 06:23
Jinja2 Type Testing (useful for constrained environments)
None:
- none
True:
- boolean
False:
- boolean
65535:
- number
- integer
123:
@emmaly
emmaly / email-regex.md
Last active August 25, 2023 00:17
Email Regular Expression

Email RegEx

Go

var emailAddressRE = regexp.MustCompile(`^(?i)(?:(?:\"[^\"]+\")|[a-z0-9!#$%&'*+\-\/=?^_` + "`" + `{|}~]+(?:\.[a-z0-9!#$%&'*+\-\/=?^_` + "`" + `{|}~]+)*)@(?:(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?)\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?$`)
if !emailAddressRE.MatchString("emmaly@example.com") {
  panic("oops")
}
@emmaly
emmaly / getSheetById.gs
Created August 21, 2023 19:08
getSheetById.gs
/**
* @OnlyCurrentDoc
*/
/**
* @param {SpreadsheetApp.Spreadsheet} spreadsheet
* @param {number} sheetId
* @returns SpreadsheetApp.Sheet
*/
function getSheetById(
@emmaly
emmaly / wakeup.rb
Created May 22, 2023 22:38
Sonic Pi: Majestic Wakeup Routine, says GPT-4
use_bpm 60
use_synth :kalimba
define :calm_section do
play_pattern_timed [:c4, :e4, :g4, :c5], [0.5, 0.5, 0.5, 1]
play_pattern_timed [:c4, :e4, :g4, :b4], [0.5, 0.5, 0.5, 1]
play_pattern_timed [:c4, :d4, :g4, :a4], [0.5, 0.5, 0.5, 1]
play_pattern_timed [:c4, :d4, :g4, :g4], [0.5, 0.5, 0.5, 1]
end