Skip to content

Instantly share code, notes, and snippets.

Johan Sundström johan

Block or report user

Report or block johan

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@johan
johan / index.html
Last active May 20, 2018
Vacation Day Planner
View index.html
<html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<base href="https://www.timeanddate.com/date/workdays.html?d1=01&amp;m1=05&amp;y1=2018&amp;d2=9&amp;m2=7&amp;y2=2018&amp;">
<title>Vacation Day Planner</title>
<script>
const sumUp = (td) => { const t = td.parentNode.parentNode, r = t.rows[t.rows.length-1], c = r.cells[r.cells.length-1]; c.textContent = Array.from(t.querySelectorAll('td')).filter(c => c.classList.contains('hl-b') || c.classList.contains('hl')).length; c.style.color = '#000'; }
document.onclick = (e) => { if (e.target.nodeName === 'TD') { const t = e.target, cl = t.classList; cl.contains('hl-b') || cl.contains('hl') ? cl.remove('hl-b', 'hl') : cl.add('hl'); sumUp(t); } };
const pad = (n) => (n < 10 ? '0' : '') + n;
const date = (t) => t.getFullYear() + '-' + pad(t.getMonth() + 1) + '-' + pad(t.getDate());
const ONE_DAY = 864e5;
const ghostThePast = () => {
@johan
johan / .gitignore
Last active Mar 22, 2018
Dig up dates in/out of [the continental] US from your http://www.moves-export.com/ logs; handy for taking stock of your visa type travel history
View .gitignore
/date-from.txt
/date-to.txt
/dates.txt
/export_dir.txt
/in-us.js
/json
/node_modules
/us.txt
/world.geo.json
@johan
johan / index.html
Last active Oct 5, 2017
People in congress sponsored by the NRA in the 2016 cycle
View index.html
<!DOCTYPE html>
<html><head>
<meta charset="utf-8">
<base href="https://ballotpedia.org/">
<title>NRA Sponsored US Members of Congress</title>
</head><body>
<h1>NRA Sponsored US Members of Congress</h1>
Sources: these tables were compiled on October 4, 2017 from the
View fb-friends-to-csv.sh
#! /bin/sh
# path to your unzipped Facebook html/friends.htm file
friends="$1"
year=$(
egrep -o '<div class="footer">Downloaded by .* on \w+, \d+ \w+ (\d+)' "$friends" \
| awk '{print $NF}'
)
@johan
johan / .gitconfig
Last active Jul 12, 2017
git swap - swaps top two commits; git drop [revision] - nukes that revision (or HEAD); git hoist <revision> - rebases that revision to be the most recent commit, so you can tweak it
View .gitconfig
[alias]
swap = "!GIT_SEQUENCE_EDITOR=\"sed -i '' -n 'h;1n;2p;g;p'\" git rebase -i HEAD~2"
drop = "!f() { GIT_SEQUENCE_EDITOR=\"sed -i '' '/^pick '$(git log -n 1 --pretty='%h' ${1:-HEAD})/d\" git rebase -i ${1:-HEAD}^^; }; f"
hoist = "!f() { GIT_SEQUENCE_EDITOR=\"git log -n 1 --pretty='pick %h' $1|~/bin/hoist-lines.pike\" git rebase -i $1^; }; f"
View _git_commit
_git_commit ()
{
case "$prev" in
(-c | -C) __gitcomp_nl "$(__git_refs)" "" "${cur}"
return ;;
(-m) __gitcomp "feat: fix: docs: style: refactor: test: chore:
" "" "${cur}"
return
;;
esac
View git-fold
#! /bin/sh
# git-fold (a k a "git fold") fetches the main branch upstream,
# and if your current branch has already been landed upstreams,
# then check out the master branch, delete the landed branch,
# and catch up master with origin
# optional reference branch to check folding against and move to - or master
master="${1:-master}"
@johan
johan / index.html
Created Apr 13, 2017
HTML5 drag/drop
View index.html
<html>
<head>
<title>HTML5 drag/drop files to console.log them</title>
</head>
<body>
<script>
// this should probably be a more interesting function in your case
function show(...files) {
console.log(...files);
View mac-specs.sh
#! /bin/sh
# runs on any mac, gives its apple specs
curl -is https://support.apple.com/en-us/HT201300 \
| grep -B 1 $( system_profiler SPHardwareDataType -detailLevel mini \
| awk '/Model Identifier/ { print $3 }' \
) \
| egrep -o '<a href=.*</a>'
View eureka.md

EUREKA

1: Prehistoric Man

S, T!, N, E, T, E, U, T!, S!, T, M AXE (from flint and bone),
SW, T!, W!, W!, SE!, J! (the tyrannosaurus falls into the hole),
SW, W, T, E, E, J (over the hole),
S, SE, CUT TREE, M RAFT (from trees and creeper),
E, E, L (you see a stairway),
You can’t perform that action at this time.