Skip to content

Instantly share code, notes, and snippets.

curl https://raw.github.com/dejay/youtube-mp3/master/install | sh
@dheaney
dheaney / post.md
Created August 3, 2012 17:38
Gist.io Test
@dheaney
dheaney / logic.c
Created December 26, 2012 19:09
Joystick "Top Hat" logic
#include "JoystickDriver.c"
task main() {
while(true) {
if( joystick.joy1_TopHat == 0 ) {
// top button pressed
}
if( joystick.joy1_TopHat == 2 ) {
//right button pressed
}
@dheaney
dheaney / force sensor logic.c
Last active December 10, 2015 04:38
Force Sensor Logic
#pragma config(Sensor, S2, snsrforce, sensorLightInactive)
bool checkWeight(int sensor_value) {
const int thresh = 375;
bool weighted;
if(sensor_value > thresh) {
weighted = true;
} else {
weighted = false;
@dheaney
dheaney / download.py
Created December 27, 2012 05:18
Download files with urllib2. Display percentage of file downloaded based off of bytes. Write file chunks instead of holding data in memory. Awesome.
import urllib2
import sys
url = "http://example.com/file.mp3"
request = urllib2.urlopen(url)
file = open('file.mp3', 'wb')
filesize = int(request.info().getheaders("Content-Length")[0])
print "Downloading: %s Bytes: %s" % (url.split('/')[-1], filesize)
RestClient.post("http://localhost:5000/", "{\"message\":\"hello\"}")
@dheaney
dheaney / index.erb
Created February 17, 2013 21:19
QR codes in Sinatra
<style type="text/css">
table {
border-width: 0;
border-style: none;
border-color: #0000ff;
border-collapse: collapse;
}
td {
@dheaney
dheaney / whit-path-tests.py
Last active December 14, 2015 03:29
Trying to handle user input for whit
#!/usr/bin/python
# whit-path-tests.py
# This file is part of whit.
#
# Copyright (C) 2013 - dejay
#
# Whit is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
@dheaney
dheaney / process.sh
Created February 24, 2013 06:05
Using the GCC preprocessor
#$file must have the ".c" extension
gcc -w -E $file -o $output
@dheaney
dheaney / Air1.js
Last active December 14, 2015 06:48
Air1.js
#!/usr/bin/env phantomjs
// Copyright (C) 2013 - dejay
//
// Air1.js is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Air1.js is distributed in the hope that it will be useful,