Skip to content

Instantly share code, notes, and snippets.

View adragomir's full-sized avatar

Andrei Dragomir adragomir

View GitHub Profile
#!/bin/bash
# get the absolute path of the executable
SELF_PATH=$(cd -P -- "$(dirname -- "$0")" && pwd -P) && SELF_PATH=$SELF_PATH/$(basename -- "$0")
# resolve symlinks
while [ -h $SELF_PATH ]; do
# 1) cd to directory of the symlink
# 2) cd to the directory of where the symlink points
# 3) get the pwd
@agaoglu
agaoglu / MockHTable.java
Created October 6, 2010 11:34
MockHTable
/**
* This file is licensed to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance with the
* License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@adragomir
adragomir / pong.go
Created April 11, 2011 20:15 — forked from manveru/pong.go
package main
import (
"sdl"
"math"
"time"
"rand"
"flag"
"fmt"
)
@paulmillr
paulmillr / dart.md
Last active July 15, 2023 13:36
Leaked internal google dart email

---------- Forwarded message ----------

From: Mark S. Miller <erights@google.com>
Date: Tue, Nov 16, 2010 at 3:44 PM
Subject: "Future of Javascript" doc from our internal "JavaScript Summit"
last week
To: javascript-standard@google.com
@hank
hank / insane_kernel_macro_solution.c
Created April 12, 2012 07:10
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 / 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() {}
@hellerbarde
hellerbarde / latency.markdown
Created May 31, 2012 13:16 — forked from jboner/latency.txt
Latency numbers every programmer should know

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
SSD random read ........................ 150,000 ns  = 150 µs

Read 1 MB sequentially from memory ..... 250,000 ns = 250 µs

set pc, kernel_start
:clock
dat 0xffff
:get_hardware; () -> void
hwn i
.loop
sub i, 1
hwq i
@joshbode
joshbode / gist:3403318
Created August 20, 2012 11:20
Hack Hadoop (1.0.3) to compile native libraries on OS X (so rmr does not fall back to non-native)
deps:
brew install md5sha1sum automake snappy hadoop
tweak OS X:
# export JAVA_HOME=$(/usr/libexec/java_home)
hack jvm:
# sudo mkdir -p ${JAVA_HOME}/lib/{i386,x86_64}/server
# sudo ln -s ${JAVA_HOME}/{../Libraries,lib/i386/server}/libjvm.dylib
# sudo ln -s ${JAVA_HOME}/{../Libraries,lib/x86_64/server}/libjvm.dylib
@codelahoma
codelahoma / get-your-vim-on.md
Last active August 5, 2020 17:22
Get Your Vim On

Get Your Vim On

Rod Knowlton (@codelahoma)

Tulsa Web Devs - 8/20/2012

Last Updated: - 10/11/2013

First Things First