Skip to content

Instantly share code, notes, and snippets.

View aarongilly's full-sized avatar

Aaron Gillespie aarongilly

View GitHub Profile
@aarongilly
aarongilly / test-gist.md
Last active February 6, 2022 20:08
This is just a test.

Test Gist

This is a gist I made. I fully don't get it yet.

Seems unnecessary for my purposes.

@aarongilly
aarongilly / tiny-timestamp.ts
Created February 22, 2022 01:42
Three examples of single line functions to create tiny timestamps, tiny unique IDs, and parse dates from them.
//This is a few lines of code that produces a base36 timestamp
function mkTt() { return new Date().getTime().toString(36)}
//len is any number between 0 and 10
function mkId(len=3){ return new Date().getTime().toString(36)+"."+Math.random().toString(36).slice(13-len).padStart(len,"0") }
//this will pull the date portion of the mkId and will parse the mkTt
function parseDate(tinyId){new Date(parseInt(tinyId.split(".")[0],36))}
@aarongilly
aarongilly / Domino-train.js
Last active December 11, 2022 21:34
Dominoes Valid Train Finder
/**
* Will find all permutations of the given set of 'dominos' that can
* be laid in a single line end to end to form a valid domino train.
*/
function start() {
const dominos = ['05','60','54','66','40','43','21','35','03','24','32','52','11'];
dominos.forEach(domino=>{
let remaining = dominos.filter(d=>d!=domino);
lookForValidTrain([domino], remaining);
})
@aarongilly
aarongilly / filedropComp.svelte
Created September 29, 2023 17:27
Svelte File Input Component
<script lang="ts">
/**
* When a file is dropped here (or selected via browsing) this is the function that will be called back
*/
export let fileCallback: (file: File)=>any
function handleDrop(ev: any) {
// Prevent default behavior (Prevent file from being opened)
ev.preventDefault();
(<HTMLDivElement>ev.target).classList.remove("drug");
@aarongilly
aarongilly / timeTriggered.js
Created October 19, 2023 01:08
Basic "New Row" Code for Google Apps Script bound to a particular type of Sheet
var workbook = SpreadsheetApp.getActiveSpreadsheet();
var daySheet = workbook.getSheetByName("Days");
var weekSheet = workbook.getSheetByName("Weeks");
var monthSheet = workbook.getSheetByName("Months");
var yearSheet = workbook.getSheetByName("Years");
/////////////////////////////////////////////////////
//This is the function that is triggered each night//
/////////////////////////////////////////////////////
function oneAM(){