View empty_bucket.sh
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 bash | |
set -eEo pipefail | |
shopt -s inherit_errexit >/dev/null 2>&1 || true | |
if [[ ! "$#" -eq 2 || "$1" != --bucket ]]; then | |
echo -e "USAGE: $(basename "$0") --bucket <bucket>" | |
exit 2 | |
fi |
View instagram.js
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
content = await(await fetch('https://www.instagram.com/nkbtnk/')).text() | |
doc = new DOMParser().parseFromString(content, 'text/html') | |
dataEl = Array.from(doc.querySelectorAll('script:not([src])')).find(s => s.innerText.includes('window._sharedData = ')) | |
match = dataEl.innerText.match(/\{.+}/) | |
data = JSON.parse(match[0]) | |
last12posts = data.entry_data.ProfilePage[0].graphql.user.edge_owner_to_timeline_media.edges |
View git-rewrite-commit-date.sh
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
GIT_COMMITTER_DATE="Wed Nov 20 07:15:57 WITA 2019" git commit --amend --no-edit --date "Wed Nov 20 07:15:57 WITA 2019" |
View example.jsx
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, { useMemo } from "react"; | |
import useSubscription from "./useSubscription"; | |
// In this example, "source" is an event dispatcher (e.g. an HTMLInputElement) | |
// but it could be anything that emits an event and has a readable current value. | |
function Example({ source }) { | |
// In order to avoid removing and re-adding subscriptions each time this hook is called, | |
// the parameters passed to this hook should be memoized. | |
const subscription = useMemo( | |
() => ({ |
View osx-home-end.sh
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
mkdir -p $HOME/Library/KeyBindings | |
echo '{ | |
/* Remap Home / End keys to be correct */ | |
"\UF729" = "moveToBeginningOfLine:"; /* Home */ | |
"\UF72B" = "moveToEndOfLine:"; /* End */ | |
"$\UF729" = "moveToBeginningOfLineAndModifySelection:"; /* Shift + Home */ | |
"$\UF72B" = "moveToEndOfLineAndModifySelection:"; /* Shift + End */ | |
"^\UF729" = "moveToBeginningOfDocument:"; /* Ctrl + Home */ | |
"^\UF72B" = "moveToEndOfDocument:"; /* Ctrl + End */ | |
"$^\UF729" = "moveToBeginningOfDocumentAndModifySelection:"; /* Shift + Ctrl + Home */ |
View glob.js
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
const process = require('process'); | |
const fs = require('fs'); | |
const util = require('util'); | |
const readdir = util.promisify(fs.readdir); | |
const realpath = util.promisify(fs.realpath); | |
const stat = util.promisify(fs.stat); | |
const ls = async (cwd, paths = []) => { | |
for (let p of (await readdir(cwd))) { | |
const rp = await realpath(`${cwd}/${p}`); |
View perf.js
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
const perfCache = {start: {}, end: {}}; | |
const perf = key => { | |
if (key in perfCache.end) { | |
return perfCache.end[key]; | |
} | |
if (key in perfCache.start) { | |
const [s, ns] = process.hrtime(perfCache.start[key]); | |
Object.assign(perfCache.end, {[key]: (s + ns / 1e9)}); | |
return perfCache.end[key]; | |
} |
View node-require-url.js
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
const https = require('https'); | |
const vm = require('vm'); | |
const requireCache = {}; | |
const requireUrl = url => new Promise((resolve, reject) => url in requireCache ? | |
resolve(requireCache[url]) : | |
https.get(url, res => { | |
const result = []; | |
res.on('data', chunk => result.push(chunk.toString('utf-8'))); |
View facebook.css
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
#leftCol { | |
position: fixed; | |
} | |
#rightCol{ | |
display:none; | |
} | |
#pagelet_sidebar { | |
display:none; |
View pr-remote.gitconfig
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
[remote "pr"] | |
url = git@github.com:nkbt/react-collapse.git | |
fetch = +refs/pull/*/head:refs/remotes/pr/* |
NewerOlder