Skip to content

Instantly share code, notes, and snippets.

View asfaltboy's full-sized avatar

Pavel Savchenko asfaltboy

View GitHub Profile
@eligrey
eligrey / object-watch.js
Created April 30, 2010 01:38
object.watch polyfill in ES5
/*
* object.watch polyfill
*
* 2012-04-03
*
* By Eli Grey, http://eligrey.com
* Public Domain.
* NO WARRANTY EXPRESSED OR IMPLIED. USE AT YOUR OWN RISK.
*/
@kig
kig / gzip.js
Last active August 1, 2019 08:59
TarGZ = function(){};
// Load and parse archive, calls onload after loading all files.
TarGZ.load = function(url, onload, onstream, onerror) {
var o = new TarGZ();
o.onload = onload;
o.onerror = onerror;
o.onstream = onstream;
o.load(url);
return o;
@mdellavo
mdellavo / xls-dict-reader.py
Created October 21, 2010 18:59
XLS to Dict Reader using xlrd
try:
import xlrd
def XLSDictReader(f, sheet_index=0):
data = mmap.mmap(f.fileno(), 0, access=mmap.ACCESS_READ)
book = xlrd.open_workbook(file_contents=data)
sheet = book.sheet_by_index(sheet_index)
def item(i, j):
return (sheet.cell_value(0,j), sheet.cell_value(i,j))
@mathiasbynens
mathiasbynens / appify
Created November 12, 2010 13:46 — forked from subtleGradient/appify
appify — create the simplest possible Mac app from a shell script
#!/bin/bash
if [ "$1" = "-h" -o "$1" = "--help" -o -z "$1" ]; then cat <<EOF
appify v3.0.1 for Mac OS X - http://mths.be/appify
Creates the simplest possible Mac app from a shell script.
Appify takes a shell script as its first argument:
`basename "$0"` my-script.sh
@johnantoni
johnantoni / postgresql + homebrew
Created February 22, 2011 23:55
postgres install with homebrew
brew install postgres
initdb /usr/local/var/postgres
psql postgres -c "create role postgres with login superuser"
psql postgres -c "alter user postgres with password 'password'"
@kesor
kesor / sqldump_middleware.py
Created September 20, 2011 17:12
Django SQL dump middleware
from django.conf import settings
from django.db import connection
class SqldumpMiddleware(object):
def process_response(self, request, response):
if settings.DEBUG and 'sqldump' in request.GET:
response.content = str(connection.queries)
response['Content-Type'] = 'text/plain'
return response
@gaveen
gaveen / .vimrc-snip
Created December 9, 2011 19:27
Part of my vimrc which sets indentation (tabs, spaces, etc.)
" I'm using the following config to make my code look the same everywhere.
set bs=indent,eol,start " allow backspacing over everything
set autoindent " enable auto-indentation
set tabstop=2 " no. of spaces for tab in file
set shiftwidth=2 " no. of spaces for step in autoindent
set softtabstop=2 " no. of spaces for tab when editing
set expandtab " expand tabs into spaces
set smarttab " smart tabulation and backspace
@tkaemming
tkaemming / querytools.py
Created January 15, 2012 05:59
querystring template tag helpers for django
from copy import copy
from urllib import urlencode
from urlparse import parse_qs, urlparse, urlunparse
from django import template
register = template.Library()
@register.filter
def with_querystring(value, request):
#!/bin/sh
# Shell script to install your public key on a remote machine
# Takes the remote machine name as an argument.
# Obviously, the remote machine must accept password authentication,
# or one of the other keys in your ssh-agent, for this to work.
#
# http://www.devthought.com/2009/09/19/get-ssh-copy-id-in-mac-os-x/
#
@slickplaid
slickplaid / doubleEnterTheDragon.js
Created March 12, 2012 13:09
Stop double submission
var formSubmitted = false;
$(document).on('submit', '.form', function(e) {
if(formSubmitted) {
e.preventDefault();
} else {
formSubmitted = true;
}
});