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
@joepie91
joepie91 / index.js
Last active June 23, 2023 23:42
Breaking CloudFlare's "I'm Under Attack" challenge
'use strict';
const parseExpression = require("./parse-expression");
function findAll(regex, target) {
let results = [], match;
while (match = regex.exec(target)) {
results.push(match);
}
@arobson
arobson / abstractions.md
Last active October 14, 2021 06:46
Rabbit.MQ + Node.js Notes

Abstraction Suggestions

Summary: use good/established messaging patterns like Enterprise Integration Patterns. Don't make up your own. Don't expose transport implementation details to your application.

Broker

As much as possible, I prefer to hide Rabbit's implementation details from my application. In .Net we have a Broker abstraction that can communicate through a lot of different transports (rabbit just happens to be our preferred one). The broker allows us to expose a very simple API which is basically:

  • publish
  • request
  • start/stop subscription

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

@ragingwind
ragingwind / Backend Architectures Keywords and References.md
Last active April 17, 2024 10:51
Backend Architectures Keywords and References

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

@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;
@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){
@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);
@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
@jboner
jboner / latency.txt
Last active April 26, 2024 21:27
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