Skip to content

Instantly share code, notes, and snippets.

Stephen Paulger stephenpaulger

  • Cambridge, UK
Block or report user

Report or block stephenpaulger

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@stephenpaulger
stephenpaulger / function_identifiers.go
Created Aug 6, 2018
Extract golang function identifiers
View function_identifiers.go
package main
import (
"errors"
"fmt"
"go/ast"
"go/parser"
"go/token"
)
@stephenpaulger
stephenpaulger / bubble_sort.asm
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:
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
@stephenpaulger
stephenpaulger / otp.py
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))
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"))
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.