Skip to content

Instantly share code, notes, and snippets.

Connor Lane Smith cls

  • Oxford Nanopore
  • Berkshire, UK
Block or report user

Report or block cls

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
cls / roman.c
Last active Aug 29, 2015
Roman numeral parser
View roman.c
#include <stdio.h>
enum { I, V, X, L, C, D, M, StackSize };
const int values[] = { 1, 5, 10, 50, 100, 500, 1000 };
unroman(const char *s)
int stack[StackSize];
cls / debruijn.hs
Last active Oct 21, 2017
Untyped lambda calculus with De Bruijn indices as a nested data type
View debruijn.hs
import Control.Applicative (liftA2)
data Term a = App (Term a) (Term a)
| Lam (Term (Maybe a))
| Var a
instance Functor Term where
fmap f (App s t) = App (fmap f s) (fmap f t)
fmap f (Lam t) = Lam (fmap (fmap f) t)
fmap f (Var x) = Var (f x)
cls /
Last active May 27, 2016
Script to execute the next binary along in $PATH
unset flag
set -f
cls /
Last active Aug 29, 2015
Adaptor for covariant iterators in Java
import java.util.Iterator;
public class CovariantIterator<T extends U, U> implements Iterator<U>
private Iterator<T> iter;
public CovariantIterator(Iterator<T> it)
this.iter = it;
cls / intern.c
Last active Aug 29, 2015
Interning strings with a prefix tree
View intern.c
#include <limits.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
const char *
intern(const char *s)
union tree {
const char *str;
cls / mircrev.c
Last active May 23, 2016
Reversal of mIRC rich text (ASCII only)
View mircrev.c
#include <ctype.h>
#define BIT(X) (1 << (X))
#define CTRL(X) ((X) - '@')
enum { None = -1 };
enum {
Bold = CTRL('B'),
Colour = CTRL('C'),
cls /
Last active Jun 1, 2018
Script to grep objects' symbol tables
if [ $# -gt 1 ]
GREP_OPTIONS="$GREP_OPTIONS --with-filename"
cls /
Last active Feb 10, 2017
Python regular expression bytecode disassembler
import re
import sre_compile
import sre_parse
from sre_constants import *
opcodes = dict((v,k) for (k,v) in OPCODES.items())
atcodes = dict((v,k) for (k,v) in ATCODES.items())
chcodes = dict((v,k) for (k,v) in CHCODES.items())
def print_dis(s, indent):
cls /
Last active Feb 16, 2017
Repacking structs to minimise bit wastage
from queue import PriorityQueue
class Field:
def __init__(self, size, align):
self.size = size
self.align = align
class Struct:
def __init__(self, fields):
size = 0
cls /
Created Feb 20, 2017
Calculating the Catalan number series
from fractions import Fraction
def catalan(n):
c = 1
for k in range(2, n + 1):
c *= Fraction(n + k, k)
return int(c)
You can’t perform that action at this time.