Skip to content

Instantly share code, notes, and snippets.

View adragomir's full-sized avatar

Andrei Dragomir adragomir

View GitHub Profile
@zmaril
zmaril / softwarehelpskill.md
Last active August 3, 2021 04:52
I want to write software that helps kill people.

I want to write software that helps kill people.

Please, before you call the police and get my github account put on lockdown, allow me a moment to explain. What I really want to do is work on projects that advance the human condition and improve people's lives. I've been in a mad dash to learn how to program for the past four or five years exactly because I realized how much good I could do for the world with a computer.

@diverted247
diverted247 / App.light
Created March 28, 2013 16:40
A small light.ly hello world app.
//imports
appjs : import = js/app.js
core: import = light/core.js
html: import = light/html.js
easeljs : import = js/easel.js
//references
application:@ = core.application
event:@ = core.listener
hc:@ = html.canvas
@rxin
rxin / ByteBufferPerf.scala
Last active May 14, 2018 21:27
Comparison of performance over various approaches to read Java ByteBuffer. The best way is to use Unsafe, which also enables reading multiple primitive data types from the same buffer.
/**
* To compile:
* scalac -optimize ByteBufferPerf.scala
*
* JAVA_OPTS="-Xmx2g" scala IntArrayPerf 10
* 49 62 48 45 48 45 48 50 47 45
*
* JAVA_OPTS="-Xmx2g" scala ByteBufferPerf 10
* 479 491 484 480 484 481 477 477 472 473
@vy
vy / MergeNodeAlgorithm.hpp
Created November 29, 2012 21:17
Merging Two Binary Search Trees in O(logn) Space
#ifndef MERGE_NODE_ALGORITHM_HPP
#define MERGE_NODE_ALGORITHM_HPP
template <class T>
class MergeNodeAlgorithm {
public:
virtual bool empty() const = 0;
virtual void pop() = 0;
virtual T get() const = 0;
@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

@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
set pc, kernel_start
:clock
dat 0xffff
:get_hardware; () -> void
hwn i
.loop
sub i, 1
hwq i
@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

@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() {}
@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