Skip to content

Instantly share code, notes, and snippets.

View jfirebaugh's full-sized avatar

John Firebaugh jfirebaugh

View GitHub Profile
const numFeatures = 100;
const numPolygons = 5;
const numRings = 10;
const numPoints = 10000;
console.time('populate storage');
const features = [];
for (let i = 0; i < numFeatures; i++) {
@jfirebaugh
jfirebaugh / playground.rs
Created October 16, 2016 21:15 — forked from anonymous/playground.rs
Shared via Rust Playground
enum Expression {
Literal(u32),
Add(Box<Expression>, Box<Expression>),
Sub(Box<Expression>, Box<Expression>)
}
impl Expression {
fn map<F: Fn(Expression) -> Expression>(self, f: F) -> Expression {
match self {
Expression::Literal(_) => self,
@jfirebaugh
jfirebaugh / README.md
Last active August 29, 2015 14:09 — forked from tmcw/README.md

Crashes in Chrome Version 38.0.2125.104

@jfirebaugh
jfirebaugh / index.html
Last active December 27, 2015 02:39 — forked from And-How/index.html
<!DOCTYPE html>
<html>
<head>
<meta charset=utf-8 />
<title></title>
<script src='http://api.tiles.mapbox.com/mapbox.js/v1.4.0/mapbox.uncompressed.js'></script>
<link href='http://api.tiles.mapbox.com/mapbox.js/v1.4.0/mapbox.css' rel='stylesheet' />
<!--[if lte IE 8]>
<link href='//api.tiles.mapbox.com/mapbox.js/v1.4.0/mapbox.ie.css' rel='stylesheet'>
<![endif]-->
@jfirebaugh
jfirebaugh / index.html
Last active December 20, 2015 18:49 — forked from mbostock/.block
Geocake Model
<!DOCTYPE html>
<meta charset="utf-8">
<body>
<script src="http://d3js.org/d3.v3.min.js"></script>
<script src="http://d3js.org/topojson.v1.min.js"></script>
<style>
path {
fill: none;
stroke-linejoin: round;
}
@jfirebaugh
jfirebaugh / README.md
Last active December 18, 2015 15:39 — forked from mbostock/.block

The current solar terminator is shown.

Thanks to Ben Elsen and NOAA for help implementing the correct equations for the position of the sun, which turned out to be quite a bit more complicated than I expected.

@jfirebaugh
jfirebaugh / index.html
Last active December 16, 2015 16:19 — forked from tmcw/index.html
<!DOCTYPE html>
<html>
<head>
<script src='http://api.tiles.mapbox.com/mapbox.js/v1.0.1/mapbox.js'></script>
<link href='http://api.tiles.mapbox.com/mapbox.js/v1.0.1/mapbox.css' rel='stylesheet' />
<!--[if lte IE 8]>
<link href='http://api.tiles.mapbox.com/mapbox.js/v1.0.1/mapbox.ie.css' rel='stylesheet' >
<![endif]-->
<style>
body { margin:0; padding:0; }
@jfirebaugh
jfirebaugh / index.html
Created December 18, 2012 21:44 — forked from tmcw/index.html
<!DOCTYPE html>
<html>
<head>
<title></title>
<style>
body {
font:normal 14px/20px 'Georgia', serif;
}
</style>
</head>
@jfirebaugh
jfirebaugh / rle.rb
Created May 9, 2012 23:04 — forked from masverba/rle.rb
Function to do run-length encoding on an Array
class Array
# See https://en.wikipedia.org/wiki/Run-length_encoding.
def rle
chunk {|e| e }.map {|e, a| [e, a.length] }
end
end
raise "Incorrect rle function." unless [1,1,1,2,3,3].rle == [
require 'java'
require 'benchmark'
def foo
Benchmark.measure {
sc = org.jruby.embed.ScriptingContainer.new(org.jruby.embed.LocalContextScope::SINGLETHREAD, org.jruby.embed.LocalVariableBehavior::TRANSIENT)
sc.runScriptlet("require 'ffi'")
sc.runScriptlet <<-RUBY
Fork = Object.new
lib = FFI::DynamicLibrary.open('/usr/lib/libc.dylib', FFI::DynamicLibrary::RTLD_LAZY | FFI::DynamicLibrary::RTLD_GLOBAL)