Skip to content

Instantly share code, notes, and snippets.

@cuadue
cuadue / rAF.js
Last active August 29, 2015 14:06 — forked from paulirish/rAF.js
// http://paulirish.com/2011/requestanimationframe-for-smart-animating/
// http://my.opera.com/emoller/blog/2011/12/20/requestanimationframe-for-smart-er-animating
// requestAnimationFrame polyfill by Erik Möller. fixes from Paul Irish and Tino Zijdel
// MIT license
(function() {
var lastTime = 0;
var vendors = ['ms', 'moz', 'webkit', 'o'];
@cuadue
cuadue / setres.sh
Created March 12, 2014 18:44
Set the X11 resolution
#!/usr/bin/bash
# For example, to set 1920x1080 at 60Hz:
# . 1920 1080 60
MODE=$(cvt $* | tail -n1)
NAME=$(echo $MODE | cut -d' ' -f2 | sed 's/"//g')
MODELINE=$(echo $MODE | cut -d' ' -f3-)
xrandr --newmode "$NAME" $MODELINE > /dev/null 2>&1
xrandr --addmode VBOX0 $NAME > /dev/null 2>&1
xrandr --output VBOX0 --mode $NAME
@cuadue
cuadue / cubism-websockets.html
Created September 3, 2013 17:43
Streaming data to cubism.js with websockets
<!DOCTYPE html>
<meta charset='utf-8'>
<head>
<title>Cubism + Websockets</title>
<script language='javascript' src='d3.min.js'></script>
<script language='javascript' src='cubism.v1.js'></script>
<script language='javascript'>
/* I can never seem to remember:
Array.push() appends to the end, and returns the new length
@cuadue
cuadue / tornado_task
Created May 17, 2013 04:08
Tornado Task implementation?
# OK here's one that spawns it's own Python thread per request. But this
# obviously won't work because I have one synchronous, non-threadsafe
# handle to /dev/i2c-1. So I have to schedule each transaction myself. This
# sounds a lot like what Tornado is already doing
from tornado import web
from tornado import gen
from functools import wraps
import threading
def run_async(func):
@cuadue
cuadue / random_imgur.py
Created July 12, 2012 17:23
random imgur downloader
#!/usr/bin/env python
import os
import sys
import random
import time
from urllib2 import Request, urlopen, URLError, HTTPError
CHARS = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghiklmnopqrstuvwxyz"
# functions
@cuadue
cuadue / .vimrc
Created February 29, 2012 17:57
My .vimrc
syn on
set scrolloff=4
set ruler
set smarttab
set softtabstop=4
set autoindent
set expandtab
set tabstop=4
set shiftwidth=4
set undodir=~/.vim_runtime/undodir
@cuadue
cuadue / hexdump.py
Created February 3, 2012 20:50
Explode a number into hex and binary representations
#!/usr/bin/python
''' Formats a number into its hex and binary representations. Possibly useful
for manipulating bit masks and writing assembly.
>>> hd(0xfdff)
65023
0x f d f f
0b 1111 1101 1111 1111
'''