Skip to content

Instantly share code, notes, and snippets.

View robbrit's full-sized avatar
🏠
Working from home

Rob robbrit

🏠
Working from home
View GitHub Profile
/**
* This program reads an L-system from standard input and outputs a PGM image.
* The following characters are possible:
* uppercase: Move forward with pen down
* lowercase: Move forward with pen up
* +: turn left
* -: turn right
* [: push current turtle state
* ]: pop turtle state
* usage: turtle ANGLE STEP_SIZE > output.pgm
#!/usr/bin/env ruby
grammar, iterations, extra = ARGV
if grammar == nil or !File.exists?(grammar)
puts "no grammar file"
exit
end
symbols = {}
#include <SDL/SDL.h>
#include <stdlib.h>
#include <time.h>
#include <math.h>
#define SIZE 800
#define PRECISION 300000
struct paird{
double x, y;
/* This program uses SDL.
* To install:
*
* sudo apt-get install libsdl1.2-dev
*
* To compile:
*
* gcc -lSDL filename.c
*
*/
/**
* This needs Nvidia's CUDA library, and SDL installed.
* You can compile using nvcc:
*
* nvcc -L/path/to/cuda/lib64 -lcudart `sdl-config --libs --cflags`
*
*/
#include <stdio.h>
#include <assert.h>
#include <SDL/SDL.h>
#include <SDL/SDL_thread.h>
#include <cmath>
#include <iostream>
using namespace std;
double scale = 1.0;
double x_offset = 0.0, y_offset = 0.0;
require 'benchmark'
require 'andand'
class Hash
def except(*blacklist)
{}.tap do |h|
(keys - blacklist).each { |k| h[k] = self[k] }
end
end
@robbrit
robbrit / gist:33610
Created December 8, 2008 21:04 — forked from edward/gist:32225
class Hash
def except(*blacklist)
self.reject {|key, value| blacklist.include?(key) }
end
def only(*whitelist)
self.reject {|key, value| !whitelist.include?(key) }
end
end