Skip to content

Instantly share code, notes, and snippets.

View codejoust's full-sized avatar

Iain codejoust

View GitHub Profile
@codejoust
codejoust / basic_vectors.rb
Created January 27, 2012 20:50
Some Basic Vector Classes and Functions
# encoding: utf-8
#require 'rubygems'
#require 'fraction'
class Base3D
attr_accessor :x, :y, :z
def initialize(x, y, z)
@x = x; @y = y; @z = z
end
@codejoust
codejoust / compile_site.js
Created February 15, 2012 04:13
Nodejs Static Site Builder / Watcher - Jade/Styl -> HTML/CSS
var stylus = require('stylus'),
jade = require('jade'),
fs = require('fs');
function compile_jade(){
console.log('compiling html index');
var fn = jade.compile(fs.readFileSync('index.jade', 'utf8'), {pretty: true});
if (fn){
fs.writeFileSync('index.html', fn());
} else {
@codejoust
codejoust / recurse.c
Created February 28, 2012 14:24
tricky recursion
// in c
#include <stdio.h>
void loopz(int num){
num += 1;
if (num < 10) {
loopz(num);
puts("Cannot Compute");
} else {
puts("Stopping");
}
@codejoust
codejoust / ss_clean_db.php
Created March 2, 2012 04:31
Silverstripe Database Cleanup Script
<?php
class Director { public function set_dev_servers($arg){} };
class SSViewer { public function set_theme($arg){} };
include_once('../public_html/mpt/_config.php');
$sql = "DELETE FROM SiteTree_versions
WHERE CONCAT_WS('_', RecordID, Version) NOT IN
@codejoust
codejoust / make-site.js
Created March 3, 2012 02:28
simple static site compiler for node
var styluscomp = require('stylus'),
jadecomp = require('jade'),
fs = require('fs');
function jade(data, cb, filename){
cb(false, jadecomp.compile(data, { pretty: true, filename: filename })());
}
function styl(data, cb, filename){
styluscomp.render(data, { pretty: true, filename: filename }, cb);
}
@codejoust
codejoust / serial_arduino.js
Created April 7, 2012 22:51
serial_arduino
var express = require('express'),
socketio = require('socket.io'),
app = express.createServer(),
serialport = require('serialport'),
serial_term = new serialport.SerialPort('/dev/tty.usbmodem1d11'),
sio = socketio.listen(app);
var databuf = '';
sio.sockets.on('connection', function(socket){
@codejoust
codejoust / benchmark_for_in.js
Created May 16, 2012 20:20
benchmark_for_in
sparks% cat benchmark.js
var obj = {}, num_in = 1000000;
while(num_in--){
obj[(Math.random()*10000).toString()] = Math.random().toString();
}
function time_it(fn_tm){
var start_time = new Date().getTime();
fn_tm();
var end_time = new Date().getTime();
#include <iostream>
#include <iomanip>
#include <cmath>
#include <cmath>
using namespace std;
int main()
{
int A, B, C, dec;
http://catalogue.usc.edu/schools/architecture/courses/
http://catalogue.usc.edu/schools/business/courses/
http://catalogue.usc.edu/schools/accounting/courses/
http://catalogue.usc.edu/schools/business/courses/
http://catalogue.usc.edu/schools/accounting/courses/
http://catalogue.usc.edu/schools/business/courses/
http://catalogue.usc.edu/schools/accounting/courses/
http://catalogue.usc.edu/schools/cinema/courses/
http://catalogue.usc.edu/schools/college/amst/courses/
http://catalogue.usc.edu/schools/college/anth/courses/
<script src="//js.leapmotion.com/0.2.2/leap.min.js"></script>
<script>
window.addEventListener('load', function(){
var ctl = new Leap.Controller({enableGestures: true});
var swiper = ctl.gesture('swipe');
var totalDistance = 0;