Skip to content

Instantly share code, notes, and snippets.

View makeusabrew's full-sized avatar
💭
I may be slow to respond.

Nick Payne makeusabrew

💭
I may be slow to respond.
View GitHub Profile
@makeusabrew
makeusabrew / client.js
Created December 13, 2011 08:52
Asynchronous recursive self executing ping function
/**
* Assume our client object manages all communication with the server and other wonderful stuff
*/
var Client = function() {
var that = {};
that.ping = function(limit, cb) {
var results = [];
(function _doPing(iteration) {
@JamieMason
JamieMason / escapedRx.js
Created January 12, 2012 09:33
Get a RegExp from an unescaped RegExp String
function escapedRx (text, flags)
{
return new RegExp(text.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&"), flags || '');
}
@jboner
jboner / latency.txt
Last active November 16, 2024 21:28
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
@djaiss
djaiss / gist:4033452
Created November 7, 2012 18:32
The Top 500 Worst Passwords of All Time
(based on http://www.whatsmypass.com/the-top-500-worst-passwords-of-all-time)
123456
porsche
firebird
prince
rosebud
password
guitar
butter
@JamieMason
JamieMason / until.js
Created December 7, 2012 13:05
until(fn:Function, delay:Number):Function
/**
* Returns a function which won't be invoked until delay has elapsed, without further calls being made during that interval.
* If further calls are made, the delay is reset and the cycle repeats.
* @param {Function} fn Behaviour to be wrapped in this delay
* @param {Number} delay Duration in milliseconds
* @return {Function}
*/
function until(fn, delay) {
var timeoutId;
var scheduledCall = setTimeout.bind(window, fn, delay);
@tomnomnom
tomnomnom / trait-deps.php
Created December 30, 2012 14:00
An experiment: using traits for dependency injection
<?php
// An experiment: using traits for dependency injection
// A trait provides a way to inject a Logger and a way to use it
trait aLogger {
protected $logger = null;
public function setLogger(Logger $logger){
$this->logger = $logger;
}
public function log($msg){
@stephenmelrose
stephenmelrose / inheritance.js
Last active December 11, 2015 03:28
Prototypical inheritance
function MyObject() {}
MyObject.prototype.doSomething = function() {
console.log('MyObject.doSomething()');
}
// -----
var parent = MyObject;
@adamwiggins
adamwiggins / adams-heroku-values.md
Last active November 5, 2024 21:40
My Heroku values

Make it real

Ideas are cheap. Make a prototype, sketch a CLI session, draw a wireframe. Discuss around concrete examples, not hand-waving abstractions. Don't say you did something, provide a URL that proves it.

Ship it

Nothing is real until it's being used by a real user. This doesn't mean you make a prototype in the morning and blog about it in the evening. It means you find one person you believe your product will help and try to get them to use it.

Do it with style

@ragingwind
ragingwind / Backend Architectures Keywords and References.md
Last active July 4, 2024 13:00
Backend Architectures Keywords and References

Latency numbers every programmer should know

L1 cache reference ......................... 0.5 ns
Branch mispredict ............................ 5 ns                     on recent CPU
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 µ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 4X memory