This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* | |
* Base64 encode / decode | |
* http://www.webtoolkit.info/ | |
* | |
**/ | |
var Base64 = { | |
// private property |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React, { useState } from 'react' | |
import './DebounceApp.css' | |
function debounce(fn, delay) { | |
let handlerId | |
return (...args) => { | |
clearTimeout(handler) | |
handlerId = window.setTimeout(() => { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import random | |
unshuffled_array = [1, 2, 3, 4, 5] | |
def shuffle_array_v1(arr): | |
output = [] | |
count_of_items_in_arr = len(arr) | |
while count_of_items_in_arr: | |
random_index = random.randint(0, count_of_items_in_arr - 1) | |
item = arr[random_index] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# /* | |
# There are N people | |
# Some subset of the N people know the secret | |
# There are M meetings which are encoded as subsets of the N people | |
# There is a total order over the meetings that tells you the order in which they occur | |
# When people meet they share the secret | |
# Calculate the set of people who know the secret after all the meetings | |
# */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"basics": { | |
"name": "Andrew Gerst", | |
"label": "Senior Software Engineer" | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function flatten(obj) { | |
const result = {}; | |
for (const key of Object.keys(obj)) { | |
if (typeof obj[key] === 'object') { | |
const nested = flatten(obj[key]); | |
for (const nestedKey of Object.keys(nested)) { | |
result[`${key}.${nestedKey}`] = nested[nestedKey]; | |
} | |
} else { | |
result[key] = obj[key]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# execute commands at a specified interval of seconds | |
function watch.command { | |
# USAGE: watch.commands [seconds] [commands...] | |
# EXAMPLE: watch.command 5 date | |
# EXAMPLE: watch.command 5 date echo 'ls -l' echo 'ps | grep "kubectl\\\|node\\\|npm\\\|puma"' | |
# EXAMPLE: watch.command 5 'date; echo; ls -l; echo; ps | grep "kubectl\\\|node\\\|npm\\\|puma"' echo date 'echo; ls -1' | |
local cmds=() | |
for arg in "${@:2}"; do | |
echo $arg | sed 's/; /;/g' | tr \; \\n | while read cmd; do | |
cmds+=($cmd) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(async () => { | |
const gitlabHost = window.location.host; | |
const gitlabUser = 'andrew'; | |
const workingDirPath = '~/Desktop'; | |
const snippetDirName = 'gitlab-snippets'; | |
const getSnippetInfoForIds = async ids => { | |
const rawResponse = await fetch(`https://${gitlabHost}/api/graphql`, { | |
method: 'POST', | |
headers: { | |
'Content-Type': 'application/json', |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env sh | |
# ASCII: http://patorjk.com/software/taag/#p=display&f=Graffiti&t=Create%20Github%20GPG%20Key | |
# SOURCE: https://gist.github.com/Gerst20051/ | |
function double_echo { | |
echo && echo | |
} | |
function newline { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env sh | |
# ASCII: http://patorjk.com/software/taag/#p=display&f=Graffiti&t=Docker%20Setup%20Script | |
# SOURCE: https://gist.github.com/Gerst20051/bf1341448bd43f430761c1f8150fb1b7 | |
function double_echo { | |
echo && echo | |
} | |
function newline { |
NewerOlder