Skip to content

Instantly share code, notes, and snippets.

#!/usr/bin/perl
# Description: http://daringfireball.net/2010/08/open_urls_in_safari_tabs
# License: See below.
# http://gist.github.com/507356
use strict;
use warnings;
use URI::Escape;
anonymous
anonymous / PaddedStringFormatInfo
Created August 18, 2010 07:48
public sealed class PaddedStringFormatInfo : IFormatProvider, ICustomFormatter {
public object GetFormat(Type formatType)
{
if (typeof(ICustomFormatter).Equals(formatType)) return this;
return null;
}
public string Format(string format, object arg, IFormatProvider formatProvider)
{
if (arg == null)
// 1: how could you rewrite the following to make it shorter?
if (foo) {
bar.doSomething(el);
} else {
bar.doSomethingElse(el);
}
@stettberger
stettberger / sqlite-diff.py
Created October 5, 2010 13:18
diff two sqlite databases
#!/usr/bin/python
import sys, sqlite3, tempfile, subprocess, os
def do_select(connection, table, fields):
connection.row_factory = sqlite3.Row
c = connection.cursor()
# If no fields are given, use all fields
if fields == []:
#!/bin/bash
# Plant rope vim's plugin
# This is a script to install or update 'ropevim'
# Copyright Alexander Artemenko, 2008
# Contact me at svetlyak.40wt at gmail com
function create_dirs
{
mkdir -p src
@sifu
sifu / USAGE.txt
Created November 3, 2010 14:27
jsoneval
eg. to print the ids of all documents within a couchdb database:
curl "http://127.0.0.1:5984/somedb/_all_docs" | jsoneval.js "body.rows.forEach( function( r ){ console.info( r.id ) } );"
@jchris
jchris / couchapp.html
Created November 27, 2010 15:14
the smallest possible CouchApp
<!DOCTYPE html>
<html>
<!-- This should be the simplest possible jQuery based CouchApp. Install by uploading to a design document in Futon or putting in _attachments/index.html and running `couchapp push` -->
<head><title>Tiny CouchApp</title></head>
<body>
<h1>Tiny CouchApp</h1>
<ul id="databases"></ul>
</body>
<script src="/_utils/script/jquery.js"></script>
<script src="/_utils/script/jquery.couch.js"></script>
@sjl
sjl / google-jslint.vim
Created December 2, 2010 17:13
Use Google's JSLint with Vim. Now you can use :make when in a .js file to run gjslint on it and get a list of errors in the quickfix window. This was thrown together hastily and Vim's errorformat is confusing as hell, so feel free to fork and improve
au BufNewFile,BufRead *.js set makeprg=gjslint\ %
" The ^G at the end is an actual <Ctrl-G> char.
" Gist won't let me include it, so you'll have to delete the last two characters
" and insert it yourself with <Ctrl-V><Ctrl-G>
au BufNewFile,BufRead *.js set errorformat=%-P-----\ FILE\ \ :\ \ %f\ -----,Line\ %l\\,\ E:%n:\ %m,%-Q,%-GFound\ %s,%-GSome\ %s,%-Gfixjsstyle%s,%-Gscript\ can\ %s,%-G^G
@dividuum
dividuum / gist:730105
Created December 6, 2010 10:31
Detecting faces and adding santa claus hats for fun and profit
# Based on
# http://japskua.wordpress.com/2010/08/04/detecting-eyes-with-python-opencv/
# http://stackoverflow.com/questions/1650568/how-do-i-create-an-opencv-image-from-a-pil-image
import os
import sys
import logging
from cStringIO import StringIO
import cv
@mattkirman
mattkirman / Twitter MacHeist Preferences
Created January 6, 2011 21:23
The super secret MacHeist preferences for Twitter for Mac (Tweetie 2)
defaults write com.twitter.twitter-mac UserTimelineDerepeater -bool true
defaults write com.twitter.twitter-mac ScrollingMakesKeyAndOrdersFront -bool true
defaults write com.twitter.twitter-mac TypeAnywhereToTweet -bool true
defaults write com.twitter.twitter-mac HideInBackground -bool true
defaults write com.twitter.twitter-mac NormalComposeWindowLevel -bool false
defaults write com.twitter.twitter-mac ESCClosesComposeWindow -bool true