Skip to content

Instantly share code, notes, and snippets.

Steve Losh sjl

Block or report user

Report or block sjl

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
@samn
samn / lock_less_monster.clj
Last active Dec 18, 2015
The Lock Less Monster
View lock_less_monster.clj
#_(
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 Sep 7, 2012
Support for both curried and uncurried application in functional JavaScript
View currying.js
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 Jan 19, 2012
Form letter template for acquired startups
View gist:1641705
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 Sep 5, 2011
Swap iTerm2 cursors in vim insert mode when using tmux
View .vimrc
" 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 Jun 20, 2011
Running pallet with manual specification of a server; example with vagrant virtualbox
View vagrant_pallet.clj
(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 Jun 20, 2011
Markdown folding for Vim
View markdown.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 Jun 3, 2011
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 Apr 9, 2011
Bookmarklet for uploading the image currently loaded in your browser to imgur
View imgur-bookmarklet.js
// 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 Mar 14, 2011
Multi-Firefox Fixer: Run multiple versions of Firefox simultaneously! (note: doesn't work on Windows)
View multi-firefox-fixer.sh
#!/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 Jul 6, 2010
`git todo` alias is the hotness.
View .gitconfig
[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
You can’t perform that action at this time.