Instantly share code, notes, and snippets.

# Stephen Paulgerstephenpaulger

• Sort options
Created Aug 6, 2018
Extract golang function identifiers
View function_identifiers.go
 package main import ( "errors" "fmt" "go/ast" "go/parser" "go/token" )
Created Jun 3, 2017
Assembler simulator bubble sort
View bubble_sort.asm
 ; Runs on https://schweigi.github.io/assembler-simulator/ ; https://en.wikipedia.org/wiki/Bubble_sort MOV C, data ; C tracks the address of end ADD C, 16 ; of the unsorted section of data. start: DEC C ; One byte is sorted each pass MOV D, data ; Start of the data bubble:
Last active Dec 20, 2015
View sum_digits.py
 import timeit import random from math import log, ceil def sum_digits(num): sum_dig = 0 while num > 0: last_digit = num % 10 # extract the last digit
Created Mar 12, 2012
Why two time pads are a BadThing™
View otp.py
 #!/usr/bin/env python def xor_int_tuple(tup): return reduce(lambda a,b:a^b, tup) def xor_tuple(tup): return ord(tup[0]) ^ ord(tup[1]) def encrypt(m, k, op=xor_tuple): return map(op, zip(m, k))
Created Jan 18, 2012
SIGQUIT handler
View sigquit.py
 import signal import sys import time def handle(sig, frame): print all_signals[sig] all_signals = dict((getattr(signal, attr), attr) for attr in dir(signal) if attr.startswith("SIG"))
Created Apr 7, 2010
View erlang sieve of eratosthenes.erl
 -module(sieve). -export([sieve/1]). sieve(N) -> [1 | sieve(lists:seq(2, N), N)]. sieve([Head|L], N) when Head * 2 < N -> [Head | sieve(L -- lists:seq(Head * 2, N, Head), N)]; sieve([Head|L], _) ->
You can’t perform that action at this time.