Skip to content

Instantly share code, notes, and snippets.

Avatar

Will Speak iwillspeak

View GitHub Profile
View wordexp_test.c
#include <wordexp.h>
#include <stdio.h>
void expand_word(const char * word) {
wordexp_t words = {0};
puts(word);
wordexp(word, &words, WRDE_NOCMD);
View Lexer.cpp
#include <string>
#include <iostream>
#define CAPTURE_TOKEN(t) \
token->value = std::string(ts, te-ts); \
token->type = Token::t
%%{
machine ExampleLexer;
@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 / euler12.wren
Created Oct 25, 2015
Another Implementation of the Solution to Project Euler 12
View euler12.wren
class Euler12 {
construct new(cutoff) {
_cutoff = cutoff
}
find_divisors(n) {
var nod = 0
var sqrt = n.sqrt.floor
@iwillspeak
iwillspeak / cargo.toml
Last active Oct 25, 2015
Now Slightly Less Hacky Brute Force of Projec Euler 12 in Rust
View cargo.toml
[package]
name = "euler12"
version = "0.1.0"
[[bin]]
name = "euler12"
path = "euler12.rs"
@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$]