Skip to content

Instantly share code, notes, and snippets.

View magical's full-sized avatar
🙀
🐛

Andrew Ekstedt magical

🙀
🐛
View GitHub Profile
Utilities
---------
htop
tree
atool
the_silver_searcher (silversearcher-ag)
whois
mtr
mosh
vim
@magical
magical / gist:d65a4487ae1814c9ab87c5cca3c48663
Created April 14, 2016 06:44
Reverse engineering tools
- objdump (from binutils)
- ndisasm (from nasm)
- file
- xxd
- vbindiff
- strace
@magical
magical / gist:920e05b1ed769c35e5928cf638b9e6fa
Last active May 28, 2016 22:57
XYZZY awards transcript
ifMUD
An interactive conversation
Copyright 1997-2007 by Loungent Technologies, a wholly owned subsidiary of
rec.[arts|games].int-fiction; All rights reserved.
Release 4 / Serial number 990908 / perlMUD v2.1z
"The characters were mostly of the cardboard cutout variety.
I wanted to punch everyone except the one Scottish guy."
--Jearl
@magical
magical / readersource.go
Created August 10, 2016 00:40
An implementation of rand.Source which reads from an io.Reader
package main
import (
"fmt"
"io"
"math/rand"
"strings"
)
type ReaderSource struct {
@magical
magical / latency.markdown
Created October 9, 2016 07:17 — forked from hellerbarde/latency.markdown
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

Item Stats Structure
0x00 uint16 Purchase Price (in units of $10)
0x02 uint8 Held effect?
0x03 uint8 Effect argument
0x04 uint8 Natural Gift effect
0x05 uint8 Fling effect
0x06 uint8 Fling power
0x07 uint8 Natural Gift power
0x08 uint16 Bits 0-4: Natural Gift type (31=n/a)
Flags?
import Control.Monad (fail)
import Control.Monad.Trans (lift, liftIO)
import Text.Parsec ((<|>), (<?>))
import Text.Read (readMaybe)
import System.IO (hFlush, stdout)
import qualified Control.Monad.Trans.State.Strict as State
import qualified Data.HashMap.Strict as HashMap
import qualified Text.Parsec as P
@magical
magical / quickmerge.py
Created August 4, 2017 19:27
quicksort + mergesort
def quicksort(list):
#print "quick>", list
if len(list) <= 1:
return list
pivot = list[len(list)//2]
a = mergesort([x for x in list if x <= pivot])
b = mergesort([x for x in list if not x <= pivot])
#print "quick<", a+b
return a + b
@magical
magical / pi14.go
Last active August 20, 2017 02:21
package main
import (
"flag"
"fmt"
"time"
)
type pair struct{ End, Start Point }
@magical
magical / regexp.ml
Last active October 18, 2017 04:59
NFA -> Regular Expression conversion in OCaml
type node = { accept: bool; links: link list }
and link = Link of char * node
type nfa_type = NFA of node list * node
type regexp =
| Empty
| Epsilon
| Single of char