Skip to content

Instantly share code, notes, and snippets.

View paulkaplan's full-sized avatar

Paul Kaplan paulkaplan

View GitHub Profile
@paulkaplan
paulkaplan / demo.html
Last active August 29, 2015 13:56
Tiny jQuery plugin to make walkthroughs
<script src="http://code.jquery.com/jquery-1.11.0.min.js"></script>
<script src="walkthrough.js"></script>
<link rel="stylesheet" href="walkthrough.css" />
<body>
<div class='walkthrough-container'>
<div class="walkthrough-steps">
<div
@paulkaplan
paulkaplan / spark-request.m
Last active August 29, 2015 14:03
Getting started with remote function calls on Spark Core
- (void) makeSparkRequest {
NSString *sparkApi = @"https://api.spark.io/v1/devices";
NSString *deviceId = @"<YOUR_DEVICE_ID>";
NSString *functionName = @"<YOUR_FUNCTION_NAME>"; // registered to cloud using Spark.function("FUNCTION_NAME", FUNCTION);
NSString *accessToken = @"<YOUR_ACCESS_TOKEN>";
NSURL *url = [NSURL URLWithString: [NSString stringWithFormat:@"%@/%@/%@\?access_token=%@",
sparkApi,
deviceId,
@paulkaplan
paulkaplan / arduino_ir_receiver.ino
Last active August 29, 2015 14:04
Record incoming IR pulses with an IR Receiver on an Arduino
/* Raw IR decoder sketch!
This sketch/program uses the Arduno and a PNA4602 to
decode IR received. This can be used to make a IR receiver
(by looking for a particular code)
or transmitter (by pulsing an IR LED at ~38KHz for the
durations detected
Code is public domain, check out www.ladyada.net and adafruit.com
for more tutorials!
@paulkaplan
paulkaplan / text_input.coffee
Last active August 29, 2015 14:05
React input component in Coffeescript
TextInput = React.createClass
propTypes:
className: React.PropTypes.string,
id: React.PropTypes.string,
placeholder: React.PropTypes.string,
onSave: React.PropTypes.func.isRequired,
value: React.PropTypes.string
getInitialState: ->
value: @props.value or ''
@paulkaplan
paulkaplan / yosemite_fixes.sh
Created October 18, 2014 15:50
Fixing dev environment on Yosemite
# xcode command line tools are gone
# reinstall them
xcode-select --install
# Pow is broken, update to 0.5.0
curl get.pow.cx | sh
# PG is broken, Yosemite removes needed dirs
# http://stackoverflow.com/questions/25970132/pg-tblspc-missing-after-installation-of-os-x-yosemite-beta
mkdir /usr/local/var/postgres/pg_tblspc
@paulkaplan
paulkaplan / font-scaling.js
Created August 4, 2011 00:13
Scaling $(body) font-size to window size
$(document).ready(function() {
var $body = $('body'); //Cache this for performance
var setBodyScale = function() {
var scaleSource = $body.width(),
scaleFactor = 0.9,
maxScale = 1000,
minScale = 30;
var fontSize = scaleSource * scaleFactor;
@paulkaplan
paulkaplan / gist:1203651
Created September 8, 2011 15:19
Don't render layout on ajax call (for fancybox or the like
layout proc {|controller| controller.request.xhr? ? false : "application" }
@paulkaplan
paulkaplan / email_to_name.rb
Created October 5, 2011 04:05
API for accessing full names from CNet ID's
require 'nokogiri'
cnet = ARGV[0]
raw = `curl -d "cnetid=#{cnet}&commit=Search" http://directory.uchicago.edu/`
doc = Nokogiri::HTML( raw )
name = doc.xpath('//td[@headers="fullname"]').text
puts name
@paulkaplan
paulkaplan / name_histogram.rb
Created October 5, 2011 04:07
Get alphabetical histogram from census data (census.gov/genealogy/name
f = File.open("dist.all.last", 'r')
full = []
h = {}
last = 0
while( line = f.gets )
data = []
line.split(" ").each {|x| data << x}
full << data
@paulkaplan
paulkaplan / tranloc.rb
Created October 30, 2011 03:39
Track UChicago local bus system using defined 'stops'
# TODO html/jquery for getting all the points on the route
require 'yaml'
require 'json'
require 'open-uri'
require 'redis'
ROUTE = 1000299
ERROR = 0.0001 #This is radial wiggle room for arriving buses, in lat/lng