Skip to content

Instantly share code, notes, and snippets.

View iwillspeak's full-sized avatar
🚲
The status is always bike

Will Speak iwillspeak

🚲
The status is always bike
View GitHub Profile
@iwillspeak
iwillspeak / SampleGreeter.leet
Created November 2, 2012 09:13
Sketch of the class syntax for Leet
module sample
import io
/**
* Greeting class.
*
* Stores a list of greetings and prints them to the
* screen upon request
*/
@iwillspeak
iwillspeak / hello.s
Last active October 12, 2015 13:47
Hello World in Assembly, OS X
/* compile with clang -m32 */
.text
.global _main
_main:
pushl %ebp
movl %esp, %ebp
/* we need to access data relative to the instruction pointer in OS X.
* This register is not readable in 32 bit mode so this trick is needed */
@iwillspeak
iwillspeak / bytes.c
Created November 11, 2012 15:56
HHD Byte Count
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <string.h>
#include <inttypes.h>
#define BLOCK_SIZE (4096 * 1024)
typedef struct {
uint8_t byte;
@iwillspeak
iwillspeak / gengrassmann.py
Created January 23, 2013 17:45
Grassmannian unit test generation script
#! /usr/bin/env python
import random
import string
import mdp
def foo():
return random.sample(xrange(255), 32)
def bar(n):
ret = []
@iwillspeak
iwillspeak / strfind.cpp
Created March 11, 2013 15:09
C++ Program to find a string in a file. Use `strfind file text` to search for <text> in <file>
extern "C" {
#include <sys/mman.h>
#include <fcntl.h>
}
#include <cstring>
#include <cerrno>
#include <iostream>
int main(int argc, char* argv[]) {
@iwillspeak
iwillspeak / .snooper.yaml
Last active December 15, 2015 03:08
Example Snooper configuration file
# Snooper configuration file
# This is YAML
base_path: .
# default to watching the whole tree
paths:
# watch lex, c, and makefiles.
filters: [\.l$, \.c$, \.h$, \.mk$]
@iwillspeak
iwillspeak / complex.c
Last active December 15, 2015 21:59
An example of computing R and Theta for a complex number in C99
#include <stdio.h>
#include <stdlib.h>
#include <complex.h>
int main(int argc, char* argv[])
{
float _Complex number = 1 + (1 * _Complex_I);
printf("%g, %g", cabs(number), carg(number));
@iwillspeak
iwillspeak / fact.c
Last active December 16, 2015 03:59
# Compute the factorial of almost any number Mainly an excuse to use GMP
#include <stdlib.h>
#include <stdio.h>
#include <gmp.h>
/**
* Compute a Factorial
*
* returns a string representation of the number `n` in base 10.
*/
@iwillspeak
iwillspeak / bitfields.c
Created April 30, 2013 20:42
Comparison of the speed of accessing various C structures The timer code is from bitbucket.org/iwillspeak/moonbase
#include <stdlib.h>
#include <stdio.h>
#include <stdint.h>
#include <inttypes.h>
#include "timer.h"
struct aligned {
uint32_t o:8;
uint32_t d:8;
@iwillspeak
iwillspeak / emacs
Last active December 17, 2015 02:59
Emacs.app Launch ScriptThis script will nestle in yo' `/usr/local/bin` spawnin yo' Emacs.app processes to edit yo' files.
#!/usr/bin/env python
import sys
import subprocess
import tempfile
import time
# Emacs is in the Cellar, installed by Homebrew
emacspath="/usr/local/Cellar/emacs/24.3/Emacs.app/Contents/MacOS/Emacs"
def run(cmd, args):