Skip to content

Instantly share code, notes, and snippets.

@trikitrok
trikitrok / lostincallbackhell.js
Created June 30, 2024 13:45 — forked from jboner/lostincallbackhell.js
Lost In Callback Hell
lost(arg, function(err, result) {
if(err) return console.log(err);
In(result, function(err, result) {
if(err) return console.log(err);
callback(result, function(err, result) {
if(err) return console.log(err);
hell(result);
});
});
});
@trikitrok
trikitrok / latency.txt
Created June 30, 2024 13:45 — forked from jboner/latency.txt
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
@trikitrok
trikitrok / Search my gists.md
Created June 30, 2024 12:57 — forked from santisbon/Search my gists.md
How to search gists.

Enter this in the search box along with your search terms:

Get all gists from the user santisbon.
user:santisbon

Find all gists with a .yml extension.
extension:yml

Find all gists with HTML files.
language:html

class BankAccount {
public void Spend(double amount) { ... }
}
/* ---- */
class OneClient {
...
bankAccount.Spend(amount);
...
}
Budget {
public double CalculateTotal() { ... }
}
/* ---- */
OneClient {
...
budget.CalculateTotal();
...
}
@trikitrok
trikitrok / Server.java
Created May 29, 2024 15:25 — forked from michaelfeathers/Server.java
Scratch Refactoring Exercise
package server;
import java.io.BufferedReader;
import java.io.FileReader;
import java.util.Date;
import java.util.Properties;
import java.util.Vector;
import javax.mail.*;
import javax.mail.internet.*;
@trikitrok
trikitrok / Working Effectively with Legacy Code.md
Created April 16, 2024 19:58 — forked from jeremy-w/Working Effectively with Legacy Code.md
Notes on Michael Feathers' *Working Effectively with Legacy Code*.

Working Effectively with Legacy Code

Notes by Jeremy W. Sherman, October 2013, based on:

Feathers, Michael. Working Effectively with Legacy Code. Sixth printing, July 2007.

Foreword:

  • Software systems degrade into a mess.
  • Requirements ALWAYS change.
  • Your goal as a software developer: Create designs that tolerate change.
@trikitrok
trikitrok / Robert Annett - Modern Legacy Systems.md
Created April 16, 2024 19:58 — forked from jeremy-w/Robert Annett - Modern Legacy Systems.md
Notes taken while listening to Robert Annett's talk on Modern Legacy Systems at QCon London 2012.
@trikitrok
trikitrok / Working Effectively with Legacy Code, Block 2.md
Created April 16, 2024 19:55 — forked from jeremy-w/Working Effectively with Legacy Code, Block 2.md
Notes on chapters 11, 15, 17, and 20 of Michael Feathers' *Working Effectively with Legacy Code.* Read as part of the BNR Book Club, October 2013.

Working Effectively with Legacy Code

Michael C. Feathers

Notes by Jeremy W. Sherman, 14 Oct 2013.

Chapter 11: I need to make a change. What methods should I test?

Use effect sketches to figure out where to target your characterization tests prior to making changes. Big fan-in means a big bang for your test-writing buck.

  • Prior to changing, write characterization tests to pin down existing behavior.
  • Characterization test: A test that characterizes the actual behavior of a piece of code (186).