Skip to content

Instantly share code, notes, and snippets.

@TurplePurtle
TurplePurtle / apod.py
Created August 9, 2012 04:38
APOD Wallpaperer
import os
import urllib2
import re
import ctypes
from _winreg import *
def apod():
url = "http://apod.nasa.gov/apod/"
@TurplePurtle
TurplePurtle / api.lua
Created August 24, 2012 00:52
Basic reddit API functions
--[[
Currently implemented functions are:
login(user, passwd)
me(auth)
submit(title, isSelf, content, subreddit, auth)
comment(thing_id, text, auth)
]]
local json = require "json"
local util = require "reddit.util"
@TurplePurtle
TurplePurtle / mylittlestreambot.rb
Created August 24, 2012 17:19
My Little StreamLogger Bot
require 'snoo'
bot = Snoo::Client.new 'http://www.reddit.com', 'r/mylittlestreamlog bot'
puts 'Logging in...'
bot.log_in(ARGV[0], ARGV[1])
def is_stream(item)
data = item['data']
if /(?<!main)stream/i.match(data['title'])
@TurplePurtle
TurplePurtle / eyegen.html
Created October 7, 2012 01:39
Eye Generator
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8">
<title>Eye</title>
<style>
html, body { background-color: #333; color: #eee; margin: 0; padding: 0; }
canvas { background-color: #000; color: #fff; display: block; margin: 16px auto 0; outline: 1px solid #555;}
</style>
</head>
@TurplePurtle
TurplePurtle / sourceFromFile.js
Created October 27, 2012 21:36
Load sound from local file for Web Audio API
// Audio Buffer Source
var fileInput = $("#audio-file");
bufferSource.gain.value = 1;
bufferSource.loop = true;
bufferSource.connect(oscillatorGain);
fileInput.addEventListener("change", function() {
var reader = new FileReader();
reader.onload = function(ev) {
context.decodeAudioData(ev.target.result, function(buffer) {
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>WebRTC p2p data</title>
<script src="https://webrtc-samples.googlecode.com/svn/trunk/apprtc/js/adapter.js"></script>
</head>
<body>
Testing WebRTC connection.
@TurplePurtle
TurplePurtle / mathy.lua
Created October 17, 2013 02:57
Math expression evaluator and expression solver.
--------------------------------
-- StringBuffer (for printing out Trees)
--------------------------------
local stringBuffer
do
local function insert(buffer, item)
local len = buffer.length + 1
buffer.length = len
buffer[len] = item
end
@TurplePurtle
TurplePurtle / robot_frames.ino
Last active December 27, 2015 17:09
Robot keyframe movement.
#include <Servo.h>
// El numero de motores
static const unsigned int numServos = 2;
// Los motores, sus pins, y su posicion actual
static Servo servos[numServos];
static unsigned int servoPins[numServos] = {9,10};
static unsigned int servoPos[numServos] = {0};
@TurplePurtle
TurplePurtle / classifier.rb
Created June 27, 2014 20:43
Bayes Classifier
require 'fast_stemmer'
require 'set'
class BayesClassifier
def initialize(categories)
raise "categories must be an Array" unless categories.is_a? Array
raise "At least 2 categories are needed" if categories.size < 2
@categories = categories.clone.freeze
@TurplePurtle
TurplePurtle / gist:695be98a9fd6d2ac59ee
Created October 9, 2014 19:36
Arduino Balance Bot Code
/*
Coded by Santiago Jaramillo 2012
Connection setup:
=== ITG-3200 ===
VDD -> 3.3V
VIO -> 3.3V
GND -> GND
SDA -> A4