Skip to content

Instantly share code, notes, and snippets.

View ddugovic's full-sized avatar
💭
I may be slow to respond.

Daniel Dugovic ddugovic

💭
I may be slow to respond.
View GitHub Profile
@EvanHahn
EvanHahn / gist:2587465
Last active October 9, 2023 01:26
Caesar shift in JavaScript
/*
JavaScript Caesar shift
by Evan Hahn (evanhahn.com)
"Encrypt" like this:
caesarShift('Attack at dawn!', 12); // Returns "Mffmow mf pmiz!"
And "decrypt" like this:
@jboner
jboner / latency.txt
Last active April 26, 2024 03:40
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
@hellerbarde
hellerbarde / latency.markdown
Created May 31, 2012 13:16 — forked from jboner/latency.txt
Latency numbers every programmer should know

Latency numbers every programmer should know

L1 cache reference ......................... 0.5 ns
Branch mispredict ............................ 5 ns
L2 cache reference ........................... 7 ns
Mutex lock/unlock ........................... 25 ns
Main memory reference ...................... 100 ns             
Compress 1K bytes with Zippy ............. 3,000 ns  =   3 µs
Send 2K bytes over 1 Gbps network ....... 20,000 ns  =  20 µs
SSD random read ........................ 150,000 ns  = 150 µs

Read 1 MB sequentially from memory ..... 250,000 ns = 250 µs

@yanatan16
yanatan16 / spsa.py
Last active March 15, 2024 19:05
Simultaneous Perturbation Stochastic Approximation code in python
'''
Simultaneous Perturbation Stochastic Approximation
Author: Jon Eisen
License: MIT
This code defines runs SPSA using iterators.
A quick intro to iterators:
Iterators are like arrays except that we don't store the whole array, we just
store how to get to the next element. In this way, we can create infinite
iterators. In python, iterators can act very similar to arrays.
anonymous
anonymous / fish.py
Created August 30, 2013 17:41
><> python interpreter.
#!/usr/local/bin/python3.2
"""
Python interpreter for the esoteric language ><> (pronounced /ˈfɪʃ/).
Usage: ./fish.py --help
More information: http://esolangs.org/wiki/Fish
Requires python 2.7/3.2 or higher.
@staltz
staltz / introrx.md
Last active April 25, 2024 04:18
The introduction to Reactive Programming you've been missing

Lichess games CSV export

This is a direct export from lichess database. Some fields are binary encoded.

Head

_id,so,s,v,if,us,p0.ai,p0.e,p1.ai,p1.e,c,mt,w,an,ra,pg,ca
"04tbfylw",1,33,,,"[ ""miroslavm970"", ""redlightning530"" ]",,1480,,1072,0500000884000B930000000000,4665B5,true,,true,23242B55806A801C6140,2013-11-14T07:59:10.945Z
@niklasf
niklasf / bratko-kopec.py
Last active February 24, 2020 15:37
An implementation of the Bratko-Kopec Test using python-chess
#!/usr/bin/python
import chess
import chess.uci
import sys
import time
MOVETIME = 120.0
@lolzballs
lolzballs / HelloWorld.java
Created March 22, 2015 00:21
Hello World Enterprise Edition
import java.io.FileDescriptor;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.io.PrintStream;
public class HelloWorld{
private static HelloWorld instance;
public static void main(String[] args){
instantiateHelloWorldMainClassAndRun();
@niklasf
niklasf / fuzz-engine.py
Last active September 17, 2015 03:49
Fuzz testing for UCI engines
#!/usr/bin/python3
# Fuzz testing for UCI engines using python-chess.
import chess
import chess.uci
import random
import logging
import sys
random.seed(123456)