Skip to content

Instantly share code, notes, and snippets.

View kalloc's full-sized avatar
🌋

kalloc kalloc

🌋
View GitHub Profile
@jboner
jboner / latency.txt
Last active July 5, 2024 02:48
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
@barbuza
barbuza / bottomgirl.py
Created July 28, 2013 07:29
bottomgirl is not middleman
# -*- coding: utf-8 -*-
import os
import sys
import json
from argparse import ArgumentParser
parser = ArgumentParser()
parser.add_argument("--haml", dest="haml", action="store_true", default=False,
package main
import (
"fmt"
"log"
"flag"
"net/http"
)
@planetbeing
planetbeing / gist:9637899
Last active September 12, 2016 12:45
Make FaceTime always on top
lldb --attach-name FaceTime
expr NSArray* $windows = (NSArray*)[(NSApplication*)[NSApplication sharedApplication] windows];
expr unsigned int $count = [$windows count]
expr -- for(unsigned int i = 0; i < $count; ++i) { [(NSWindow*)[$windows objectAtIndex:i] setLevel:5]; }
expr Class $window = (Class)NSClassFromString(@"NSWindow")
expr void* $setLevel = (void*)class_getInstanceMethod($window, @selector(setLevel:))
expr void* $description = (void*)class_getMethodImplementation($window, @selector(description))
call (void)method_setImplementation($setLevel, $description)
process detach
quit
@mimoo
mimoo / plaidctf.sage
Last active May 2, 2016 10:34
plaid
# plaid ctf triplets
data = [
[0xfd2066554e7f2005082570ddf50e535f956679bf5611a11eb1734268ffe32eb0f2fc0f105dd117d9d739767f300918a67dd97f52a3985483aca8aa54998a5c475842a16f2a022a3f5c389a70faeaf0500fa2d906537802ee2088a83f068aba828cc24cc83acc74f04b59a0764de7b64c82f469db4fecd71876eb6021090c7981, 0xa23ac312c144ce829c251457b81d60171161655744b2755af9b2bd6b70923456a02116b54136e848eb19756c89c4c46f229926a48d5ac030415ef40f3ea185446fa15b5b5f11f2ec2f0f971394e285054182d77490dc2e7352d7e9f72ce25793a154939721b6a2fa176087125ee4f0c3fb6ec7a9fdb15510c97bd3783e998719, 0x593c561db9a04917e6992328d1ecadf22aefe0741e5d9abbbc12d5b6f9485a1f3f1bb7c010b19907fe7bdecb7dbc2d6f5e9b350270002e23bd7ae2b298e06ada5f4caa1f5233f33969075c5c2798a98dd2fd57646ad906797b9e1ce77194791d3d0b097de31f135ba2dc7323deb5c1adabcf625d97a7bd84cdf96417f05269f4],
[0xcb26469a1b726d964cc0d3c8f2e486860b7252643b3c974857abc04cc93eca7167138e0cc5cbaa39b4c47daa6ccc5d546d6bfd4171f3ed3f1b0bfe30c22010e3376ec551ba46380cfa25495c7b1299ae7b02409523845fc1b3ccba46a19a4f58dd92c330a
@elliptic-shiho
elliptic-shiho / ed25519.py
Created April 18, 2016 00:11
sCTF 2016 Q1: Ed25519 Writeup
import hashlib
b = 256
q = 2**255 - 19
l = 2**252 + 27742317777372353535851937790883648493
def H(m):
return hashlib.sha512(m).digest()
def expmod(b,e,m):
@chriseth
chriseth / async.md
Last active December 26, 2023 09:13
Async Solidity Contracts

Having seen @pirapira's sketch of Bamboo ( https://github.com/pirapira/bamboo/ ), which proposed to add better control about the "smart contract program flow", even across calls, I thought that this should certainly be added to Solidity, and actually, it might even be possible now to a certain degree using inline assembly.

The problem is that with many functions in a contract, it is not always clear which can be called at which stage in the contract's lifetime. Certain smart contracts would be easier to understand if written as follows:

@srdjan
srdjan / 100+ different counter apps...
Last active May 6, 2024 05:13
100+ different js counter apps...
100+ different js counter apps...
anonymous
anonymous / File tree
Created March 2, 2017 16:26
# build result
/bin
# bootstrap result
/bin/gb
/bin/gb-vendor
# build result
/bin/BINARY_NAME
contract PatriciaTree {
// List of all keys, not necessarily sorted.
bytes[] keys;
// Mapping of hash of key to value
mapping (bytes32 => bytes) values;
struct Label {
bytes32 data;
uint length;
}