Skip to content

Instantly share code, notes, and snippets.

View gonz's full-sized avatar

Gonz Saavedra gonz

  • Montevideo, Uruguay
View GitHub Profile
/*
* Widget that tracks the state of a togglable item. To toggle, click on the
* item. No visible action is taken directly, but events and callbacks are
* fired (via _trigger()) so that callbacks may change state
*/
$.widget("ui.toggle", {
/*
* Constructor -- attach a click handler which calls the toggle() function.
*/
_init: function(){
@kennyp
kennyp / todo.vim
Created March 29, 2011 06:08
Find todos under current directory.
function! s:ToDoList ()
cclose
let task_list = []
for row in split(system('ack --column "(TODO|CHANGED|FIXME)"'), '\n')
let t = split(row, ':')
let task_dict = {'filename': t[0], 'lnum': t[1], 'col': t[2]}
let task_dict.text = substitute(join(t[3:-1]), '\s\+', ' ', '')
let task_list += [task_dict]
endfor
call setqflist(task_list, 'r')
import logging
l = logging.getLogger('django.db.backends')
l.setLevel(logging.DEBUG)
l.addHandler(logging.StreamHandler())
@emulbreh
emulbreh / tm.py
Created April 30, 2011 19:03
A Turing Machine Simulator Written in Django Template Language
import sys, os, re
from django import template
from django.template import loader
TURING_MACHINE = """
{% if not current_state %}
{% with INITIAL_STATE as current_state %}
{% with INITIAL_HEAD|default:0|add:1 as pos %}
{% with "@"|add:TAPE as tape %}
{% with "TURING_MACHINE" as tm_tpl %}
@maccman
maccman / juggernaut_heroku.md
Created June 2, 2011 01:26
Juggernaut on Heroku

Clone repo:

git clone git://github.com/maccman/juggernaut.git
cd juggernaut

Create Heroku app:

heroku create myapp --stack cedar
heroku addons:add redistogo:nano

git push heroku master

class MyRender << Fiasco::Render
def render(name, locals = {})
if ENV['RACK_ENV'] == 'development' && @templates[name]
@compiled.delete(name)
declare(name, @templates[name].filename)
end
super(name, locals)
end
end
@camertron
camertron / measure.rb
Created June 15, 2012 22:48
Measure the memory taken by a Ruby object (by Robert Klemme)
#!/bin/env ruby
# lazy hack from Robert Klemme
module Memory
# sizes are guessed, I was too lazy to look
# them up and then they are also platform
# dependent
REF_SIZE = 4 # ?
OBJ_OVERHEAD = 4 # ?
@cavedave
cavedave / NBAPLayers
Last active September 30, 2016 20:20
---
title: "Basketball Size"
output: html_notebook
gif is up at http://imgur.com/dobmMWM
---
This is a copy of this NFL visualisation.<http://noahveltman.com/nflplayers/>
I couldnt find the R code to recreate it. I could find data for basketball at <https://github.com/simonwarchol/NBA-Height-Weight>.
First get Simon Warchols data and stitch his csvs together