Skip to content

Instantly share code, notes, and snippets.

View r1b's full-sized avatar
🌍
(hack planet)

r1b

🌍
(hack planet)
View GitHub Profile
@simonw
simonw / recover_source_code.md
Last active May 30, 2024 00:39
How to recover lost Python source code if it's still resident in-memory

How to recover lost Python source code if it's still resident in-memory

I screwed up using git ("git checkout --" on the wrong file) and managed to delete the code I had just written... but it was still running in a process in a docker container. Here's how I got it back, using https://pypi.python.org/pypi/pyrasite/ and https://pypi.python.org/pypi/uncompyle6

Attach a shell to the docker container

Install GDB (needed by pyrasite)

apt-get update && apt-get install gdb
@grindfuk
grindfuk / interface.js
Created April 27, 2016 16:45
Node.js ES6 Class Interface
'use strict';
class NotImplementedException extends Error {
}
class InvalidInitialization extends Error {
}
function abc(cls, options) {
let iname = options ? options.interfaceName : 'Interface';
let metaData = {
@bishboria
bishboria / springer-free-maths-books.md
Last active April 25, 2024 06:27
Springer made a bunch of books available for free, these were the direct links
@scottnonnenberg
scottnonnenberg / output.txt
Last active September 7, 2018 22:42
What happens in node.js when you start a setInterval(), but do some synchronous work? setInterval() calls get dropped.
2015-03-23T19:41:49.232Z
2015-03-23T19:41:49.367Z
2015-03-23T19:41:49.470Z
2015-03-23T19:41:49.571Z
sync task start
sync task done
2015-03-23T19:41:50.632Z
2015-03-23T19:41:50.733Z
2015-03-23T19:41:50.834Z
^C
@jboner
jboner / latency.txt
Last active June 2, 2024 06:32
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
@cdown
cdown / gist:1163649
Last active April 9, 2024 01:10
Bash urlencode and urldecode
urlencode() {
# urlencode <string>
old_lc_collate=$LC_COLLATE
LC_COLLATE=C
local length="${#1}"
for (( i = 0; i < length; i++ )); do
local c="${1:$i:1}"
case $c in