Skip to content

Instantly share code, notes, and snippets.

View sjl's full-sized avatar

Steve Losh sjl

View GitHub Profile
@samn
samn / lock_less_monster.clj
Last active April 4, 2022 01:45
The Lock Less Monster
#_(
Let's say you have a threadpool doing work that requires access to some shared resource.
And this resource needs to be refreshed at times. E.g. an OAuth bearer token that can expire or be revoked.
If this resource were expensive to refresh, or subject to rate limiting (OAuth tokens are often both)
then it's desirable to refresh as little as possible.
It's undesirable, however, to mix complicated synchronization code for updating the resource in
with the business logic consuming it.
Enter the lock less monster, a lock free method for coordinating updates to a shared reference.
@puffnfresh
puffnfresh / currying.js
Created September 7, 2012 07:13
Support for both curried and uncurried application in functional JavaScript
function curry(f) {
return function(x) {
var g = f.bind(this, x);
if(g.length == 0) return g();
if(arguments.length > 1) return curry(g).apply(this, [].slice.call(arguments, 1));
return curry(g);
};
}
var sum = curry(function(x, y) {
@panicsteve
panicsteve / gist:1641705
Created January 19, 2012 18:26
Form letter template for acquired startups
Dear soon-to-be-former user,
We've got some fantastic news! Well, it's great news for us anyway. You, on
the other hand, are fucked.
We've just been acquired by:
[ ] Facebook
[ ] Google
[ ] Twitter
@andyfowler
andyfowler / .vimrc
Created September 5, 2011 18:08
Swap iTerm2 cursors in vim insert mode when using tmux
" tmux will only forward escape sequences to the terminal if surrounded by a DCS sequence
" http://sourceforge.net/mailarchive/forum.php?thread_name=AANLkTinkbdoZ8eNR1X2UobLTeww1jFrvfJxTMfKSq-L%2B%40mail.gmail.com&forum_name=tmux-users
if exists('$TMUX')
let &t_SI = "\<Esc>Ptmux;\<Esc>\<Esc>]50;CursorShape=1\x7\<Esc>\\"
let &t_EI = "\<Esc>Ptmux;\<Esc>\<Esc>]50;CursorShape=0\x7\<Esc>\\"
else
let &t_SI = "\<Esc>]50;CursorShape=1\x7"
let &t_EI = "\<Esc>]50;CursorShape=0\x7"
endif
@chapmanb
chapmanb / vagrant_pallet.clj
Created June 20, 2011 11:26
Running pallet with manual specification of a server; example with vagrant virtualbox
(ns distblast-cluster.vagrant
(:require [pallet.compute :as compute]
[pallet.phase :as phase]
[pallet.core :as core]
[pallet.utils :as utils]
[pallet.compute.node-list :as node-list]
[pallet.action.exec-script :as exec-script]))
(defn test-script [session]
(-> session
@vim-voom
vim-voom / markdown.vim
Created June 20, 2011 02:23
Markdown folding for Vim
" folding for Markdown headers, both styles (atx- and setext-)
" http://daringfireball.net/projects/markdown/syntax#header
"
" this code can be placed in file
" $HOME/.vim/after/ftplugin/markdown.vim
" In Markdown, setext-style overrides atx-style, so we first check for an
" underline. Empty lines should be ignored when underlined.
func! Foldexpr_markdown(lnum)
let l1 = getline(a:lnum)
@sjl
sjl / gist:1006307
Created June 3, 2011 13:11
Stop apps from spamming the system logs (both files are in /etc/, use `killall syslogd` to restart it after editing).
We couldn’t find that file to show.
@johnholdun
johnholdun / imgur-bookmarklet.js
Created April 9, 2011 22:43
Bookmarklet for uploading the image currently loaded in your browser to imgur
// that is, navigate to the direct URL for an image hosted on the world wide web, then >>>INVOKE<<<
// i wanted the bookmarklet to redirect to the new direct image URL but that was out of scope!
javascript:void(window.location="http://api.imgur.com/2/upload.json?url="+encodeURIComponent(window.location.href));
@cowboy
cowboy / multi-firefox-fixer.sh
Created March 14, 2011 02:17
Multi-Firefox Fixer: Run multiple versions of Firefox simultaneously! (note: doesn't work on Windows)
#!/bin/bash
if [ "$1" = "-h" -o "$1" = "--help" ]; then cat <<EOF
Multi-Firefox Fixer - v0.2 - 4/26/2011
http://benalman.com/
Usage: `basename "$0"`
Run this shell script from beside (in the same parent directory as) one or more
Firefox*.app or Aurora*.app applications and it will "fix" those Firefoxes to
@bobthecow
bobthecow / .gitconfig
Created July 6, 2010 00:56
`git todo` alias is the hotness.
[alias]
# install t first: http://github.com/sjl/t
todo = !python ~/path/to/t.py --task-dir "$(git rev-parse --show-toplevel)" --list TODO
bug = !python ~/path/to/t.py --task-dir "$(git rev-parse --show-toplevel)" --list BUGS