Skip to content

Instantly share code, notes, and snippets.

View adragomir's full-sized avatar

Andrei Dragomir adragomir

View GitHub Profile
@adragomir
adragomir / js2py.py
Created October 25, 2010 07:40 — forked from anonymous/js2py.py
import os, sys
PREAMBLE = '''# Preamble
import sys
def Array(n):
return [0]*n
# Body
export WORKING_DIR=~/work/textaurant
cd $WORKING_DIR; mvim; gitx
tmux start-server
tmux new-session -d -s Textaurant -n work
tmux new-window -tTextaurant:1 -n server
tmux new-window -tTextaurant:2 -n test
tmux send-keys -tTextaurant:0 'cd $WORKING_DIR' C-m
@adragomir
adragomir / refactor.py
Created December 18, 2010 07:14 — forked from jdp/refactor.py
#!/usr/bin/env python
import sys
import types
import operator
class Runtime:
def __init__(self, env={}, stack=[]):
self.env = {
# Primitive words, not an impressive base but it works
@adragomir
adragomir / tmux.conf
Created January 12, 2011 10:44 — forked from bryanl/tmux.conf
# ~/.tmux.conf
#
# See the following files:
#
# /opt/local/share/doc/tmux/t-williams.conf
# /opt/local/share/doc/tmux/screen-keys.conf
# /opt/local/share/doc/tmux/vim-keys.conf
#
# URLs to read:
#
@adragomir
adragomir / pong.go
Created April 11, 2011 20:15 — forked from manveru/pong.go
package main
import (
"sdl"
"math"
"time"
"rand"
"flag"
"fmt"
)
@adragomir
adragomir / RWMutex.go
Created April 13, 2012 12:20 — forked from raczman/RWMutex.go
RWMutex with TryLock
package sync
import (
"sync"
"sync/atomic"
)
type nullLocker struct {}
func (n *nullLocker) Lock() {}
@adragomir
adragomir / insane_kernel_macro_solution.c
Created April 13, 2012 12:20 — forked from hank/insane_kernel_macro_solution.c
The solution to Linus' question on resolving undefined macros in the preprocessor to 0, as well as resolving defined macros to their values.
#include <stdio.h>
#define CONFIG_FOO 1
#define CONFIG_NOO 0
#define is_set(macro) is_set_(macro)
#define macrotest_1 ,
#define is_set_(value) is_set__(macrotest_##value)
#define is_set__(comma) is_set___(comma 1, 0)
#define is_set___(_, v, ...) v
@adragomir
adragomir / latency.txt
Created May 31, 2012 17:32 — forked from hellerbarde/latency.markdown
Latency numbers every programmer should know
L1 cache reference 0.5 ns
Branch mispredict 5 ns
L2 cache reference 7 ns
Mutex lock/unlock 25 ns
Main memory reference 100 ns
Compress 1K bytes with Zippy 3,000 ns 3 µs
Send 2K bytes over 1 Gbps network 20,000 ns 20 µs
Read 1 MB sequentially from memory 250,000 ns 250 µs
Round trip within same datacenter 500,000 ns 0.5 ms
Disk seek 10,000,000 ns 10 ms
@adragomir
adragomir / mountain-lion-brew-setup.markdown
Created August 3, 2012 10:33 — forked from myobie/mountain-lion-brew-setup.markdown
Get Mountain Lion and Homebrew to Be Happy

Get Mountain Lion and Homebrew to Be Happy

1) Install XCode 4.4 into /Applications

Get it from the App Store.

2) Install Command Line Tools

In XCode's Preferences > Downloads you can install command line tools.

set pc, kernel_start
:clock
dat 0xffff
:get_hardware; () -> void
hwn i
.loop
sub i, 1
hwq i