Skip to content

Instantly share code, notes, and snippets.

View trevorbernard's full-sized avatar

Trevor Bernard trevorbernard

View GitHub Profile
@jbrisbin
jbrisbin / DisruptorTest.java
Created December 30, 2011 17:22
Disruptor RingBuffer-based simplistic NIO HTTP test server
import java.io.IOException;
import java.net.InetSocketAddress;
import java.net.ServerSocket;
import java.net.StandardSocketOptions;
import java.nio.ByteBuffer;
import java.nio.channels.CancelledKeyException;
import java.nio.channels.ReadableByteChannel;
import java.nio.channels.SelectionKey;
import java.nio.channels.Selector;
import java.nio.channels.ServerSocketChannel;
@jboner
jboner / latency.txt
Last active November 18, 2024 08:23
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
@Jud
Jud / Price-Time Matching Engine.c
Created June 1, 2012 23:56
Price-Time Matching Engine
/*****************************************************************************
* QuantCup 1: Price-Time Matching Engine
*
* Submitted by: voyager
*
* Design Overview:
* In this implementation, the limit order book is represented using
* a flat linear array (pricePoints), indexed by the numeric price value.
* Each entry in this array corresponds to a specific price point and holds
* an instance of struct pricePoint. This data structure maintains a list
@hintjens
hintjens / census1.c
Created March 26, 2013 19:08
Census pattern
// The Census Pattern
// Model 1, over XPUB-XSUB
#include "czmq.h"
static void
counter_task (void *args, zctx_t *ctx, void *pipe)
{
void *counter = zsocket_new (ctx, ZMQ_XPUB);
zsocket_set_xpub_verbose (counter, 1);
@neomatrix369
neomatrix369 / PerformanceRelated.md
Last active November 3, 2023 20:27
Interesting links in the areas of HPC, low latency, mechanical harmony/sympathy, garbage collection
@claws
claws / authentication.py
Last active July 24, 2021 19:37
An authentication module for pyzmq based on zauth from czmq. See the included test file for usage. To run the test function use: python test_authentication.py
'''
An authentication module for pyzmq modelled on zauth from czmq.
The functions to read and generate certificates should be interoperable
with czmq's zcert's - though are not as fully featured.
'''
import datetime
import glob
import json
@NYKevin
NYKevin / accounting.sql
Last active November 14, 2024 15:25
Basic double-entry bookkeeping system, for PostgreSQL.
CREATE TABLE accounts(
id serial PRIMARY KEY,
name VARCHAR(256) NOT NULL
);
CREATE TABLE entries(
id serial PRIMARY KEY,
description VARCHAR(1024) NOT NULL,
amount NUMERIC(20, 2) NOT NULL CHECK (amount > 0.0),
-- Every entry is a credit to one account...
@doctorevil
doctorevil / review.md
Last active February 13, 2021 15:30
NXT Crypto Review of Curve25519.java & Crypto.java

Crypto Review of Curve25519.java & Crypto.java

By DoctorEvil on Nextcoin.org

Sponsored by MSIN on BitcoinTalk.org

TL;DR

NXT's Crypto.java and Curve25519.java look kosher aside from a signing bug that is currently being worked around.

General Methodology

@doctorevil
doctorevil / curve25519.py
Created March 13, 2014 02:51
curve25519 ec-kcdsa python impl
# a pedagogical implementation of curve25519 with ec-kcdsa
# coded by doctorevil to validate nxt's port of Matthijs van Duin's implementation
# warning: this implementation is not timing attack resistant
# ec arithmetic equations from http://hyperelliptic.org/EFD/g1p/auto-montgom.html
from hashlib import sha256
from ecdsa.numbertheory import square_root_mod_prime, SquareRootError, inverse_mod
CURVE_P = 2**255 - 19
CURVE_A = 486662
@0m15
0m15 / Carousel.coffee
Last active March 25, 2020 13:28
A ReactJS based carousel. No dom manipulation, no jQuery, all based on ReactJS states and intelligent rendering and the aid of `ReactCSSTransitionGroup`. Check also the css: https://gist.github.com/zimok/10018721