Skip to content

Instantly share code, notes, and snippets.

View mantoni's full-sized avatar
💭
Amending fixup commits

Maximilian Antoni mantoni

💭
Amending fixup commits
View GitHub Profile
diff --git a/lib/module.js b/lib/module.js
index 6130394..80559f4 100644
--- a/lib/module.js
+++ b/lib/module.js
@@ -25,6 +25,7 @@ var runInThisContext = Script.runInThisContext;
var runInNewContext = Script.runInNewContext;
var assert = require('assert').ok;
+var timeRequire = +process.env.NODE_TIME_REQUIRE;
@cjohansen
cjohansen / gist:4135065
Created November 23, 2012 10:43
Naming this in nested functions

tl;dr

If you must nest functions in a way that requires access to multiple this', alias outer this to something meaningful - describe the value it's holding. Treat this as the invisible first argument.

In general though, avoiding the situation (nested functions and frivolous use of this) will frequently produce clearer results.

Naming this in nested functions

I was accidentally included in a discussion on how to best name this in nested functions in JavaScript. +1's were given to this suggestion of using _this.

Giving style advice on naming nested this without a meaningful context isn't too helpful in my opinion. Examples below have been altered to have at least some context, although a completely contrived and stupid one.

@jboner
jboner / latency.txt
Last active May 7, 2025 10:07
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
@felixge
felixge / command.sh
Created October 29, 2011 13:43
Bash stuff for fighting a weak DOS attack
# Here a few bash one-liners that helped me analyze / fight a weak DOS attack against debuggable.com. Mostly for future reference.
# The attacker was opening lots of tcp connections without sending data, I believe it's called a SYN flood, see: http://tools.ietf.org/html/rfc4987#section-3.2
# Step 0: Check what is going on at port 80
$ netstat -tan | grep ':80 ' | awk '{print $6}' | sort | uniq -c
# Step 1: Increase the number of available fds
$ ulimit -n 32000
# Step 2: Restart your webserver, for me:

Rebasing Merge Commits in Git

This morning I discovered a nasty little problem with git-rebase that can have pretty unexpected and unwanted results - how it handles a merge commit.

The TL;DR version is this: Always use git rebase -p

Why I use pull --rebase

I think a lot of people are using git pull --rebase as their default to avoid unnecessary merge commits when fetching the latest code from master. There are a few blog posts on the matter, such as [1] [2]