Skip to content

Instantly share code, notes, and snippets.

View adragomir's full-sized avatar

Andrei Dragomir adragomir

View GitHub Profile
@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:
#
#include <stdio.h>
typedef enum _endian {little_endian, big_endian} EndianType;
EndianType CheckCPUEndian() {
unsigned short x;
unsigned char c;
EndianType CPUEndian;
x = 0x0001;;
c = *(unsigned char *)(&x);
if( c == 0x01 )
@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 / gist:1996275
Created March 7, 2012 21:10
install thrift 0.5.0
wget http://archive.apache.org/dist/incubator/thrift/0.5.0-incubating/thrift-0.5.0.tar.gz
tar zxf thrift-0.5.0.tar.gz
pushd thrift-0.5.0
./configure && make && make install
pushd lib/py
sudo python setup.py install
popd
echo "Done. To install extra language libraries, come back here and do it by hand"
popd
@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 / gist:2764307
Created May 21, 2012 19:59
install thrift 0.8.0
wget http://mirrors.hostingromania.ro/apache.org/thrift/0.8.0/thrift-0.8.0.tar.gz
tar zxf thrift-0.8.0.tar.gz
pushd thrift-0.8.0
wget https://issues.apache.org/jira/secure/attachment/12511532/thrift-1465_1.patch
patch -p0 < thrift-1465_1.patch
./configure --without-erlang --without-haskell --without-ocaml && make && make install
pushd lib/py
sudo python setup.py install
popd
echo "Done. To install extra language libraries, come back here and do it by hand"
@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
Started GET "/dashboard" for 127.0.0.1 at Fri Jun 15 16:00:51 -0700 2012
Processing by DashboardController#index as HTML
User Load (0.7ms) SELECT "users".* FROM "users" WHERE "users"."id" = 2 LIMIT 1
Project Load (0.5ms) SELECT "projects".* FROM "projects"
Project Load (2.5ms) SELECT "projects".* FROM "projects" INNER JOIN "project_revisions" ON "project_revisions"."project_id" = "projects"."id" INNER JOIN "reviews" ON "reviews"."project_revision_id" = "project_revisions"."id" WHERE "projects"."user_id" = 2 GROUP BY projects.id, projects.user_id, projects.created_at, projects.updated_at, projects.private, projects.slots, projects.title, projects.description
Rendered dashboard/_submitter.html.erb (213.0ms)
Project Load (0.4ms) SELECT "projects".* FROM "projects" INNER JOIN "project_revisions" ON "project_revisions"."project_id" = "projects"."id" INNER JOIN "reviews" ON "reviews"."project_revision_id" = "project_revisions"."id" WHERE "reviews"."user_id" = 2
Project Load (1.0ms) SELECT projects