Skip to content

Instantly share code, notes, and snippets.

View paulkaplan's full-sized avatar

Paul Kaplan paulkaplan

View GitHub Profile
@paulkaplan
paulkaplan / get_map_points.html
Created October 30, 2011 05:49
Google Map click generates marker and yaml with coordinates
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
<style type="text/css">
html { height: 100% }
body { height: 100%; margin: 0; padding: 0 }
#map_canvas { height: 100% }
</style>
<script type="text/javascript"
@paulkaplan
paulkaplan / reminder_time.rb
Created November 1, 2011 03:37
Hash features of a natural language time declaration
class String
def scan_first(pattern)
a = self.scan(pattern)
a = a.first while a.is_a? Array unless a.empty?
return a
end
end
time_tokens = {}
given = ARGV[0]
@paulkaplan
paulkaplan / listing.c
Created November 22, 2011 19:39
Requesting and parsing json data from rails app in objective-c
+(NSMutableArray *) loadRemoteListings {
NSMutableArray *listings = [NSMutableArray arrayWithCapacity:20];
NSURL *url = [[NSURL alloc] initWithString:@"http://localhost:3000"];
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url];
[request setValue:@"application/json" forHTTPHeaderField:@"Accept"];
NSURLResponse *response;
NSError *error;
@paulkaplan
paulkaplan / gist:3036353
Created July 2, 2012 23:24 — forked from olistik/gist:2627011
Ubuntu 12.04 setup (rbenv, janus, postgres)

Basic pre-requisites

  • Some utilities:
sudo apt-get install vim tmux git
  • Copy/paste from the command line:
sudo apt-get install xclip
@paulkaplan
paulkaplan / bookmarklet.js
Created October 23, 2015 14:25
Customized stats.js bookmarklet
javascript:(function() {
var script = document.createElement('script');
script.onload = function() {
/* Remove existing stats if it exists */
var existingStatsElement = document.getElementById('stats');
if (existingStatsElement) {
existingStatsElement.parentNode.removeChild(existingStatsElement);
class STL
class Writer
attr_accessor :tris, :size
def initialize tris
@tris = tris
@size = tris.length*50 + 80 + 4
end
def write_stl_header f
80.times {|n| f << [0].pack("C") } #uint8
@paulkaplan
paulkaplan / Scene.rb
Created January 29, 2013 06:50
Scene writer for POVRay, with a simple ruby API
class Scene
attr_accessor :lights, :objects, :camera
def initialize
@lights = []
@objects = []
end
def add_light light
@lights.push light
end
@paulkaplan
paulkaplan / index.js
Created February 24, 2013 03:59
voxel.js game
var createEngine = require('voxel-engine')
var game = createEngine({
generate: function(x, y, z) {
if (x*x + y*y + z*z > 20*20) return 0;
return Math.floor(Math.random() * 4) + 1;
},
texturePath: './',
materials: [ 'dirt', 'grass', 'crate', 'brick' ]
});
game.appendTo('#container');
@paulkaplan
paulkaplan / index.js
Created February 24, 2013 04:07
voxel.js game
var createGame = require('voxel-engine')
function sphereWorld(x, y, z) {
// return the index of the material you want to show up
// 0 is air
if (x*x + y*y + z*z > 15*15) return 0
return 3
}
var game = createGame({
@paulkaplan
paulkaplan / index.js
Created February 24, 2013 04:11
voxel.js game
var createGame = require('voxel-engine')
function sphereWorld(x, y, z) {
// return the index of the material you want to show up
// 0 is air
if (x*x + y*y + z*z > 15*15) return 0
return 3
}
var game = createGame({