Skip to content

Instantly share code, notes, and snippets.

@henrik
henrik / .bashrc
Created December 3, 2008 17:56
Git branch and dirty state in Bash prompt.
# http://henrik.nyh.se/2008/12/git-dirty-prompt
# http://www.simplisticcomplexity.com/2008/03/13/show-your-git-branch-name-in-your-prompt/
# username@Machine ~/dev/dir[master]$ # clean working directory
# username@Machine ~/dev/dir[master*]$ # dirty working directory
function parse_git_dirty {
[[ $(git status 2> /dev/null | tail -n1) != "nothing to commit (working directory clean)" ]] && echo "*"
}
function parse_git_branch {
git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e "s/* \(.*\)/[\1$(parse_git_dirty)]/"
In this gist we will first show that we can beat the arc challenge
(http://www.paulgraham.com/arcchallenge.html), and then build the library that
shows how we did it. This gist is Literate Haskell and is of course executable. The packages needed are happstack-server and applicative-extras, installable using cabal.
Let's start with some imports (for now, you can ignore these)
> {-# LANGUAGE GADTs, TypeSynonymInstances #-}
> module ArcChallenge where
>
> import Control.Applicative
@isaacs
isaacs / comma-first-var.js
Created April 6, 2010 19:24
A better coding convention for lists and object literals in JavaScript
// See comments below.
// This code sample and justification brought to you by
// Isaac Z. Schlueter, aka isaacs
// standard style
var a = "ape",
b = "bat",
c = "cat",
d = "dog",
import logging
import time
logger = logging.getLogger(__name__)
def useful():
logger.debug('Hello from webapplib!')
time.sleep(0.01)
@ryankirkman
ryankirkman / couchdb_delete_non_design_docs.js
Created March 17, 2011 06:51
Delete all non-design docs in CouchDB (using cradle)
var cradle = require('cradle');
var database = 'app';
cradle.setup({
host: '127.0.0.1',
port: 5984,
auth: { username: "YOUR_USERNAME", password: "YOUR_PASSWORD" }
});
@ChillyBwoy
ChillyBwoy / cookie.js
Created May 26, 2011 00:35
Cookie functions for underscore.js
@michiel
michiel / cors-nginx.conf
Created July 5, 2011 10:41
Wide-open CORS config for nginx
#
# Wide-open CORS config for nginx
#
location / {
if ($request_method = 'OPTIONS') {
add_header 'Access-Control-Allow-Origin' '*';
#
@jaseemabid
jaseemabid / jquerify.js
Created August 5, 2011 17:26
Run this line of js in your browser addressbar to add jQuery into the page you are viewing
javascript:var s=document.createElement('script');s.setAttribute('src','http://code.jquery.com/jquery.js');document.getElementsByTagName('body')[0].appendChild(s);
@jaseemabid
jaseemabid / git for dummies.md
Created September 11, 2011 20:54
Git for dummies

Git for dummies

As the source code is handled by the version control system Git, it's useful to know some features used.

Submodules

The repository uses submodules, which normally are handled directly by the Makefile, but sometimes you want to be able to work with them manually.

@nzakas
nzakas / stack.js
Created September 12, 2011 19:24
Stack implementation using ES6 proxies
/*
* Another ES6 Proxy experiment. This one creates a stack whose underlying
* implementation is an array. The proxy is used to filter out everything
* but "push", "pop", and "length" from the interface, making it a pure
* stack where you can't manipulate the contents.
*/
var Stack = (function(){
var stack = [],