Skip to content

Instantly share code, notes, and snippets.


Andrew Childs andrewchilds

View GitHub Profile
andrewchilds / clientCache.js
Last active Jun 22, 2022
Proposal: A client-side key-value store interface
View clientCache.js
const tableName = 'crayons';
const crayons = [
{ id: 1, color: 'blue', updated_at: new Date('2022-02-10T11:31:25-0500') },
{ id: 2, color: 'black', updated_at: new Date('2022-02-10T11:31:25-0500') },
{ id: 3, color: 'brown', updated_at: new Date('2022-02-10T11:31:25-0500') },
{ id: 4, color: 'green', updated_at: new Date('2022-02-10T11:31:25-0500') },
// Upsert multiple entries to a table, returning number of rows changed
andrewchilds / getTimezoneOffset.js
Created May 3, 2022
Convert a minute-based timezone offset like `240` to an offset like `"-04:00"`.
View getTimezoneOffset.js
// Converts a getTimezoneOffset() offset to one that can be used in new Date().
// Examples:
// Eastern Standard Time: 240 -> '-04:00'
// India Standard Time: -330 -> '+05:30'
// Australian Central Western Standard Time: -525 -> '+08:45'
export function getTimezoneOffset(d) {
return convertTimezoneOffset(d.getTimezoneOffset());
export function convertTimezoneOffset(offset) {
andrewchilds / deepClone.js
Created Apr 28, 2022
Simple, standalone, vanilla implementation of lodash.cloneDeep
View deepClone.js
// Simple implementation of lodash.cloneDeep
// Does not clone functions or handle recursive references.
export function deepClone(original) {
if (original instanceof RegExp) {
return new RegExp(original);
} else if (original instanceof Date) {
return new Date(original.getTime());
} else if (Array.isArray(original)) {
} else if (typeof original === 'object' && original !== null) {
andrewchilds / deepGet.js
Last active Aug 5, 2022 — forked from harish2704/lodash.get.js
Simple, standalone, vanilla implementation of lodash.get
View deepGet.js
// Simple implementation of lodash.get
// Handles arrays, objects, and any nested combination of the two.
// Also handles undefined as a valid value - see test case for details.
// Based on:
export function deepGet(obj, query, defaultVal) {
query = Array.isArray(query) ? query : query.replace(/(\[(\d)\])/g, '.$2').replace(/^\./, '').split('.');
if (!(query[0] in obj)) {
return defaultVal;
obj = obj[query[0]];
andrewchilds / google-meet-kindergarten-edition.css
Last active Sep 25, 2020
Google Meet: Kindergarten Edition
View google-meet-kindergarten-edition.css
This is a quick attempt to make Google Meet work better for someone in Kindergarten
(one in particular - it may or may not work for yours).
- I used the "Stylebot" extension to make this CSS work, but any other related extension should also work.
- Hides the "who's here" rotating carousel which is distracting.
andrewchilds / redirect.js
Created Nov 1, 2017
How long does it take to stop JS execution during a location redirect?
View redirect.js
for (var i = 0; i < 1000; i++) {
window.location.href = window.location.href;
function logAndRedirect(i) {
setTimeout(function () {
}, i);
andrewchilds /
Created Jul 3, 2017
Creates a histogram CSV file of the age of every line of code in a directory
set -e
pushd $APP_DIR
andrewchilds /
Last active Aug 4, 2016
Moving Clubhouse Stories to Deployed
# Define the range of commits in this deploy.
# Define a comment to be posted to each story.
comment="This story was deployed as part of $deploy_id.$deploy_url"
# Move stories to deployed and post a comment.
andrewchilds /
Last active Aug 4, 2016
Extracting Clubhouse story IDs from a set of git commits
git log $old_sha..$new_sha --oneline
# 2d5b22d Merge pull request #6 from company/me/ch345/my-story-name
# e730351 Fix bug
# c410ba0 Fix other bug [ch1004]
function clubhouse_find_stories_in_commit_range {
andrewchilds /
Last active Sep 14, 2016
Clubhouse Branch & Commit Formatting Examples
# Associate a branch with story 123:
git checkout -b ac/ch123/my-story-name
# Or, you might want to associate a single commit with story 123:
git commit -m "Fix bug [ch234]"