Skip to content

Instantly share code, notes, and snippets.

require 'digest/md5'
def gfm(text)
# Extract pre blocks
extractions = {}
text.gsub!(%r{<pre>.*?</pre>}m) do |match|
md5 = Digest::MD5.hexdigest(match)
extractions[md5] = match
"{gfm-extraction-#{md5}}"
end
@bryanl
bryanl / tmux.conf
Created November 30, 2010 05:17
I copied this from somewhere. It is a good start, though
# ~/.tmux.conf
#
# See the following files:
#
# /opt/local/share/doc/tmux/t-williams.conf
# /opt/local/share/doc/tmux/screen-keys.conf
# /opt/local/share/doc/tmux/vim-keys.conf
#
# URLs to read:
#
@mikeyk
mikeyk / redis_session_backend.py
Created April 8, 2011 18:01
A redis backend for Django Sessions, tested on Django 1.3+
from django.contrib.sessions.backends.base import SessionBase, CreateError
from django.conf import settings
from django.utils.encoding import force_unicode
import redis
class SessionStore(SessionBase):
""" Redis store for sessions"""
def __init__(self, session_key=None):
self.redis = redis.Redis(
@simonmichael
simonmichael / gist:1185421
Created September 1, 2011 03:59
ghc-pkg-clean, ghc-pkg-reset
# unregister broken GHC packages. Run this a few times to resolve dependency rot in installed packages.
# ghc-pkg-clean -f cabal/dev/packages*.conf also works.
function ghc-pkg-clean() {
for p in `ghc-pkg check $* 2>&1 | grep problems | awk '{print $6}' | sed -e 's/:$//'`
do
echo unregistering $p; ghc-pkg $* unregister $p
done
}
# remove all installed GHC/cabal packages, leaving ~/.cabal binaries and docs in place.
@canton7
canton7 / 0main.md
Last active November 7, 2023 08:16
Local versions of tracked config files

How to have local versions of tracked config files in git

This is a fairly common question, and there isn't a One True Answer.

These are the most common techniques:

If you can modify your application

@hoelzro
hoelzro / key-callbacks.rb
Created January 30, 2013 14:30
Adding callbacks in Ruby
class Client
def initialize
@callbacks = {}
set_key 'q', method(:quit)
end
def set_key(key, callback)
@callbacks[key] = callback
end
@ruslander
ruslander / mailgun.erl
Last active August 24, 2016 20:14
Update the api key to reflect your account
%curl -s --user 'api:key-8av0ox9abrs2icvagny' \
% https://api.mailgun.net/v2/bang.mailgun.org/messages \
% -F from='Excited User <postmaster@bang.mailgun.org>' \
% -F to=masquerade2ruslan@gmail.com \
% -F subject='Hello' \
% -F text='Testing some Mailgun awesomness!'
-module(mailgun).
-compile(export_all).
@jbenet
jbenet / simple-git-branching-model.md
Last active July 31, 2024 06:29
a simple git branching model

a simple git branching model (written in 2013)

This is a very simple git workflow. It (and variants) is in use by many people. I settled on it after using it very effectively at Athena. GitHub does something similar; Zach Holman mentioned it in this talk.

Update: Woah, thanks for all the attention. Didn't expect this simple rant to get popular.

@andrzejsliwa
andrzejsliwa / exampe.edl
Created December 9, 2013 21:49
starting all apps declared in app file
start() ->
a_start(yourapp, permanent).
...
a_start(App, Type) ->
start_ok(App, Type, application:start(App, Type)).
start_ok(_App, _Type, ok) -> ok;
start_ok(_App, _Type, {error, {already_started, _App}}) -> ok;
@tsloughter
tsloughter / gist:9173507
Last active August 29, 2015 13:56
Erlang Package Manager Components