Skip to content

Instantly share code, notes, and snippets.

View topliceanu's full-sized avatar
💭
🚀

Alexandru Topliceanu topliceanu

💭
🚀
View GitHub Profile
@topliceanu
topliceanu / testUtil.coffee
Last active August 29, 2015 13:58
A implementation of the _.any api but for asynchronous computation and Q promises.
assert = (require 'chai').assert
Q = require 'q'
util = require './util'
describe '.any()', ->
it 'should fail when no promise resolves', (done) ->
fns = [
@dmitshur
dmitshur / gist:6927554
Last active September 17, 2023 07:35
[Legacy GOPATH mode] How to `go get` private repos using SSH key auth instead of password auth.

WARNING: This gist was created in 2013 and targets the legacy GOPATH mode. If you're reading this in 2021 or later, you're likely better served by reading https://tip.golang.org/cmd/go/#hdr-Configuration_for_downloading_non_public_code and https://golang.org/ref/mod#private-modules.

$ ssh -A vm
$ git config --global url."git@github.com:".insteadOf "https://github.com/"
$ cat ~/.gitconfig
[url "git@github.com:"]
	insteadOf = https://github.com/
$ go get github.com/private/repo && echo Success!
Success!
@basarat
basarat / cardinaldirections.js
Last active November 14, 2022 17:44
Snapping an angle to the nearest cardinal direction in javascript
/**
* Given "0-360" returns the nearest cardinal direction "N/NE/E/SE/S/SW/W/NW"
*/
export function getCardinal(angle) {
/**
* Customize by changing the number of directions you have
* We have 8
*/
const degreePerDirection = 360 / 8;
@owainlewis
owainlewis / trie.ml
Created November 13, 2012 14:36
OCaml Trie
module type S = sig
type key
type +'a t
val empty : 'a t
val is_empty : 'a t -> bool
val add : key -> 'a -> 'a t -> 'a t
val find : key -> 'a t -> 'a
val remove : key -> 'a t -> 'a t
val mem : key -> 'a t -> bool
val iter : (key -> 'a -> unit) -> 'a t -> unit
@tobiash
tobiash / qredis.coffee
Created June 6, 2012 20:30
Q + node_redis
# Applies Q.nbind to all redis operations and returns a wrapped client
_ = require("underscore")._
Q = require "q"
nbindOps = (client) ->
functions = _.functions client
# All the ops are available as upper/lowercase functions, I exploit this
# to filter out the Redis operations from the other functions of the client
#
@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

@jboner
jboner / latency.txt
Last active May 3, 2024 15:17
Latency Numbers Every Programmer Should Know
Latency Comparison Numbers (~2012)
----------------------------------
L1 cache reference 0.5 ns
Branch mispredict 5 ns
L2 cache reference 7 ns 14x L1 cache
Mutex lock/unlock 25 ns
Main memory reference 100 ns 20x L2 cache, 200x L1 cache
Compress 1K bytes with Zippy 3,000 ns 3 us
Send 1K bytes over 1 Gbps network 10,000 ns 10 us
Read 4K randomly from SSD* 150,000 ns 150 us ~1GB/sec SSD
@topliceanu
topliceanu / extend.es5.js
Created March 6, 2012 11:43
extends objects, similar in functionality to $.extend or _.extend
// jquery style `extend` work in ES5 compatible envs
var extend = function (obj) {
var args = Array.prototype.slice.call(arguments, 1);
args.forEach( function (source) {
for (var prop in source)
if (source.hasOwnProperty(prop)) obj[prop] = source[prop];
});
return obj;
};

tmux cheatsheet

As configured in my dotfiles.

start new:

tmux

start new with session name: