Skip to content

Instantly share code, notes, and snippets.

View codejoust's full-sized avatar

Iain codejoust

View GitHub Profile
@codejoust
codejoust / gist:25beb7a5ad690c529cb0
Created October 30, 2014 17:20
for fun :) hacksc foods
(duh?)
... jk ... anything I can nom nom nom.
:)
And coffee.
FEED ME CODE
from Tkinter import *
import json
import urllib2
def get_location():
req = urllib2.urlopen('http://freegeoip.net/json/')
req_str = req.read()
return json.loads(req_str)
def get_todays_weather(coords):
import alsaaudio
import serial
#import numpy
import struct
import math
ser = serial.Serial('/dev/ttyUSB0', 19200)
inp = alsaaudio.PCM(alsaaudio.PCM_CAPTURE, alsaaudio.PCM_NORMAL, 'Device')
inp.setchannels(1)
function doSearch(text){
var registrations = window.registrations;
for (var i = 0; i < registrations.length; i++){
var str = registrations[i].first_name + ' ' + registrations[i].last_name + ' ' + registrations[i].email;
if (str.toLowerCase().indexOf(text.toLowerCase()) != -1){
$('<li/>').html(registrations[i].id + ': ').append($('<a/>', {href: '/admin_stats/add_registration/' + registrations[i].id, text: str})).appendTo('#results');
}
}
}
<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;
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/
#include <iostream>
#include <iomanip>
#include <cmath>
#include <cmath>
using namespace std;
int main()
{
int A, B, C, dec;
@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();
@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 / 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);
}