Skip to content

Instantly share code, notes, and snippets.

View ssokolow's full-sized avatar

Stephan Sokolow ssokolow

View GitHub Profile
@acdha
acdha / webfaction modern python app install notes.rst
Created November 23, 2009 00:24
Installation notes after installing a Django web app on WebFaction

Python 2.6 + Virtualenv + Django 1.1 + Postgres on WebFaction

  1. mkdir -p ~/bin ~/lib/python2.6/site-packages
  2. Configure the environment by putting something like this in your .bashrc and sourcing it:

    export CFLAGS=-I/usr/local/pgsql/include 
    export LDFLAGS=-L/usr/local/pgsql/lib
@timtrueman
timtrueman / django_cached_count_proxy.py
Created November 18, 2010 00:15
Django cached .count() proxy for querysets that is generic and works with pagination in object_list (which clones and overrides any monkeypatched count method so you have to override the clone method first).
class CachedCountCloneProxy(object):
''' This allows us to monkey-patch count() on QuerySets so we can cache it and speed things up.
._clone is called so we have to monkey-patch that first...
'''
def __init__(self, queryset):
self._queryset = queryset
self._queryset._clone_original = self._queryset._clone
def __call__(self):
@ilkka
ilkka / archivegenerator.rb
Created November 20, 2010 15:44
Jekyll archive page generator plugin
module Jekyll
class ArchiveGenerator < Generator
safe true
def generate(site)
collate_by_month(site.posts).each do |month, posts|
page = ArchivePage.new(site, month, posts)
site.pages << page
end
end
@rsvp
rsvp / noise.sh
Last active April 18, 2024 14:18
noise : relaxing ambient Brown noise generator (cf. white noise) | Linux bash script using sox | CogSci notes
#!/usr/bin/env bash
# bash 4.1.5(1) Linux Ubuntu 10.04 Date : 2019-01-02
#
# _______________| noise : ambient Brown noise generator (cf. white noise).
#
# Usage: noise [minutes=59] [band-pass freq center=1786] [wave]
# ^minutes can be any positive integer.
# Command "noise 1" will display peak-level meter.
#
# Dependencies: play (from sox package)
@JeffreyWay
JeffreyWay / gist:1525217
Created December 27, 2011 21:29
Instant Server for Current Directory
alias server='open http://localhost:8000 && python -m SimpleHTTPServer'
@friggeri
friggeri / gist:1570840
Created January 6, 2012 14:30
More CoffeeScriptish
do ($ = jQuery) ->
$.fn.zebraTable = (options) ->
defaults =
evenColor: '#ccc'
oddColor : '#eee'
options = $.extend(defaults, options)
@each ->
$("tr:even", @).css('background-color', options.evenColor)
$("tr:odd", @).css('background-color', options.oddColor)
@dupuy
dupuy / README.rst
Last active April 23, 2024 23:38
Common markup for Markdown and reStructuredText

Markdown and reStructuredText

GitHub supports several lightweight markup languages for documentation; the most popular ones (generally, not just at GitHub) are Markdown and reStructuredText. Markdown is sometimes considered easier to use, and is often preferred when the purpose is simply to generate HTML. On the other hand, reStructuredText is more extensible and powerful, with native support (not just embedded HTML) for tables, as well as things like automatic generation of tables of contents.

@kg
kg / decodeFloat.js
Created March 25, 2012 10:53
Decode 32/64-bit float from bytes in JavaScript
// Derived from http://stackoverflow.com/a/8545403/106786
function decodeFloat(bytes, signBits, exponentBits, fractionBits, eMin, eMax, littleEndian) {
var totalBits = (signBits + exponentBits + fractionBits);
var binary = "";
for (var i = 0, l = bytes.length; i < l; i++) {
var bits = bytes[i].toString(2);
while (bits.length < 8)
bits = "0" + bits;
@jboner
jboner / latency.txt
Last active April 24, 2024 00:20
Latency Numbers Every Programmer Should Know
Latency Comparison Numbers (~2012)
----------------------------------
L1 cache reference 0.5 ns
Branch mispredict 5 ns
L2 cache reference 7 ns 14x L1 cache
Mutex lock/unlock 25 ns
Main memory reference 100 ns 20x L2 cache, 200x L1 cache
Compress 1K bytes with Zippy 3,000 ns 3 us
Send 1K bytes over 1 Gbps network 10,000 ns 10 us
Read 4K randomly from SSD* 150,000 ns 150 us ~1GB/sec SSD
@arantius
arantius / grant-none-shim.js
Last active May 21, 2022 14:47
Greasemonkey "@grant none" compatibility shim.
/*
The MIT License (MIT)
Copyright (c) 2014 Anthony Lieuallen
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is