Skip to content

Instantly share code, notes, and snippets.

javascript:(function()%7Bvar%20t=window.getSelection?window.getSelection().toString():document.selection.createRange().text;window.location='tweetbot:///post?text='+t+'%20:%20'+encodeURIComponent(window.location.href);%7D)()
@altphi
altphi / index.html
Last active May 4, 2018 20:18 — forked from dreyescat/index.html
Webpack config to expose bundle in a variable in the global context
<html>
<head>
</head>
<body>
<script src="lib/yourlib.js"></script>
<script>
window.onload = function () {
EntryPoint.run();
};
</script>
@altphi
altphi / post-merge.sh
Last active June 12, 2017 14:54
post-merge git hook to create OSX alert when any package.json file changed
#!/usr/bin/env bash
# move this file to .git/hooks/post-merge
diff_results=$( git diff-tree --name-status -t -r --root HEAD@{1}..HEAD | grep -e '^M.*package.json$' )
[[ "$?" == "0" ]] && (
msg="display alert \"A package.json file changed! See list below.\" message \"${diff_results}\""
osascript -e "${msg}" >/dev/null &
)
exit 0
@altphi
altphi / git-clear-whitespace-changes.sh
Last active May 4, 2017 19:29
Clear all whitespace-only-changes from files in a git repository.
#!/usr/bin/env sh
# leaves a backup of all changes in git stash, creates a patch ignoring whitespace changes, clears changes, applies patch
cd "$(git rev-parse --show-toplevel)"
git stash && git stash apply && git diff -w > changes.patch && git checkout . && git apply --whitespace=fix changes.patch && rm changes.patch
@altphi
altphi / threen.clj
Created October 29, 2016 14:12
3n + 1 problem
;; 3n + 1 problem
;; https://en.wikipedia.org/wiki/Collatz_conjecture
(defn threen
([n]
(threen n 0))
([n k]
(let [newK (if (>= n 1) (+ k 1) k)]
(if (= n 1)
@altphi
altphi / keybase.md
Created August 19, 2014 18:20
keybase.md

Keybase proof

I hereby claim:

  • I am altphi on github.
  • I am altphi (https://keybase.io/altphi) on keybase.
  • I have a public key whose fingerprint is 492B 128E 72EC 6EC7 E73A 363A FF67 3119 BCEF 6D0D

To claim this, I am signing this object: