Skip to content

Instantly share code, notes, and snippets.

Avatar

Will Speak iwillspeak

View GitHub Profile
@iwillspeak
iwillspeak / SampleGreeter.leet
Created Nov 2, 2012
Sketch of the class syntax for Leet
View SampleGreeter.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 Oct 12, 2015
Hello World in Assembly, OS X
View hello.s
/* 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 Nov 11, 2012
HHD Byte Count
View bytes.c
#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 Jan 23, 2013
Grassmannian unit test generation script
View gengrassmann.py
#! /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 Mar 11, 2013
C++ Program to find a string in a file. Use `strfind file text` to search for <text> in <file>
View strfind.cpp
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 Dec 15, 2015
Example Snooper configuration file
View .snooper.yaml
# 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 Dec 15, 2015
An example of computing R and Theta for a complex number in C99
View complex.c
#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 Dec 16, 2015
# Compute the factorial of almost any number Mainly an excuse to use GMP
View fact.c
#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 Apr 30, 2013
Comparison of the speed of accessing various C structures The timer code is from bitbucket.org/iwillspeak/moonbase
View bitfields.c
#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 Dec 17, 2015
Emacs.app Launch ScriptThis script will nestle in yo' `/usr/local/bin` spawnin yo' Emacs.app processes to edit yo' files.
View emacs
#!/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):