Skip to content

Instantly share code, notes, and snippets.

View anishpatel's full-sized avatar

Anish Patel anishpatel

View GitHub Profile
@antirez
antirez / lmdb.tcl
Created April 28, 2017 15:40
LMDB -- First version of Redis written in Tcl
# LVDB - LLOOGG Memory DB
# Copyriht (C) 2009 Salvatore Sanfilippo <antirez@gmail.com>
# All Rights Reserved
# TODO
# - cron with cleanup of timedout clients, automatic dump
# - the dump should use array startsearch to write it line by line
# and may just use gets to read element by element and load the whole state.
# - 'help','stopserver','saveandstopserver','save','load','reset','keys' commands.
# - ttl with milliseconds resolution 'ttl a 1000'. Check ttl in dump!
@obfusk
obfusk / break.py
Last active May 1, 2024 20:32
python "breakpoint" (more or less equivalent to ruby's binding.pry); for a proper debugger, use https://docs.python.org/3/library/pdb.html
import code; code.interact(local=dict(globals(), **locals()))
@Diego81
Diego81 / WordCounter.scala
Last active December 12, 2021 12:36
Simple Word Counter implemented using Akka
import akka.actor.{ Actor, ActorRef, Props, ActorSystem }
case class ProcessStringMsg(string: String)
case class StringProcessedMsg(words: Integer)
class StringCounterActor extends Actor {
def receive = {
case ProcessStringMsg(string) => {
val wordsInLine = string.split(" ").length
sender ! StringProcessedMsg(wordsInLine)
# Jekyll error
# invalid byte sequence in US-ASCII
# Error reading file /PATH/TO/FILE : invalid byte sequence in US-ASCII
# Liquid Exception: invalid byte sequence in US-ASCII in index.html
# Add This variables that change your local settings
# In your prompt
LC_CTYPE="en_US.UTF-8"
@bseibold
bseibold / lazy-ssh-agent.sh
Created February 28, 2013 14:09
Lazy Loading for ssh-agent keys. Loads default SSH identities on demand. Tested with bash and zsh.
function wrapssh() {
setopt shwordsplit &>/dev/null
# load agent if it's not running
if [ -z "$SSH_AUTH_SOCK" ]; then
eval $(ssh-agent) &>/dev/null
fi
# load keys if necessary
DO_ADD=0
@jboner
jboner / latency.txt
Last active June 21, 2024 04:31
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