👨👩👧👦
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class OldFormatter < Daybreak::Format | |
VERSION = 1 | |
# The mask a record uses to check for deletion. | |
DELETION_MASK = 1 << 31 | |
def initialize(serializer) | |
@serializer = serializer | |
end | |
# The serialized representation of the key value pair plus the CRC. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'thread' | |
require 'zlib' | |
class Daybreak | |
include Enumerable | |
def initialize(file) | |
@file = file | |
@out = File.open(@file, 'ab') | |
@queue = Queue.new |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
with synchronous writes 1.8.7: | |
# Running benchmarks: | |
benchmarks 1 10 100 1000 10000 | |
bench_inserting_keys 0.000092 0.000492 0.005099 0.012749 0.744639 | |
bench_keys_with_sync 0.000208 0.001195 0.011567 0.118403 1.900468 | |
bench_reading_keys 0.000035 0.000139 0.000907 0.010472 0.263106 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$(function(){ | |
$("#article-big-image").replaceWith($("<div/>").attr({"id": "map-cont"}).html([ | |
'<img id="background" src="//www.propublica.org/projects/migration-map/images/background.png">' | |
, '<img class="year year-1890" src="//www.propublica.org/projects/migration-map/images/1890.png" style="display: block;">' | |
, '<img class="year year-1900" src="//www.propublica.org/projects/migration-map/images/1900.png">' | |
, '<img class="year year-1910" src="//www.propublica.org/projects/migration-map/images/1910.png">' | |
, '<img class="year year-1920" src="//www.propublica.org/projects/migration-map/images/1920.png">' | |
, '<img class="year year-1930" src="//www.propublica.org/projects/migration-map/images/1930.png">' | |
, '<img class="year year-1940" src="//www.propublica.org/projects/migration-map/images/1940.png">' | |
, '<img class="year year-1950" src="//www.propublica.org/projects/migration-map/images/1950.png">' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'rubygems' | |
require 'simpler_tiles' | |
breaks = [0.05, 0.15, 0.30, 0.45, 0.60] | |
cbreaks = [0.40, 0.50, 0.60, 0.70, 0.80] | |
colors = [[236, 231, 242], [166, 189, 219], [116, 169, 207], [54, 144, 192], [5, 112, 176], [3, 78, 123]] | |
def color(color) | |
sprintf("#%2x%2x%2x", *color).gsub(" ", "0") | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var canvas = document.createElement("canvas"); | |
document.body.appendChild(canvas); | |
var gl = canvas.getContext("webgl") || canvas.getContext("experimental-webgl"); | |
canvas.width = canvas.height = 400; | |
gl.viewport(0, 0, canvas.width, canvas.height); | |
gl.clearColor(0.0, 0.0, 0.0, 1.0); | |
gl.enable(gl.DEPTH_TEST); | |
var Sphere = function(lat, lng){ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
buckets : function(year, bins) { | |
var sorted = _.sortBy(this.counties, function(c) { return c.indexFor(year); }); | |
var bsearch = function(v) { | |
var low = 0, high = sorted.length; | |
while (low < high) { | |
var mid = (low + high) >>> 1; | |
sorted[mid].indexFor(year) < v ? low = mid + 1 : high = mid; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
buckets : function(year, bins) { | |
var sorted = _.sortBy(this.counties, function(c) { return c.indexFor(year); }); | |
var bsearch = function(v) { | |
var low = 0, high = sorted.length; | |
while (low < high) { | |
var mid = (low + high) >>> 1; | |
sorted[mid].indexFor(year) < v ? low = mid + 1 : high = mid; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
buckets : function(year, bins) { | |
var sorted = _.sortBy(this.counties, function(c) { return c.indexFor(year); }); | |
var bsearch = function(v) { | |
var low = 0, high = sorted.length; | |
while (low < high) { | |
var mid = (low + high) >>> 1; | |
sorted[mid].indexFor(year) < v ? low = mid + 1 : high = mid; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
command=$1 | |
bucket=$2 | |
file=$3 | |
USAGE="Use add <bucket> <file glob> or sync" | |
case "$command" in | |
add) | |
if [ -z $file ] && [ -z $bucket ] | |
then | |
echo $USAGE |