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
from django.utils import timezone | |
def parse_timestamp(ts): | |
if ts is not None: | |
dt = datetime.datetime.fromtimestamp(ts) | |
dt = dt.replace(tzinfo=timezone.utc) | |
return dt | |
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 JSON_stringify(s, emit_unicode) | |
{ | |
var json = JSON.stringify(s); | |
return emit_unicode ? json : json.replace(/[\u007f-\uffff]/g, | |
function(c) { | |
return '\\u'+('0000'+c.charCodeAt(0).toString(16)).slice(-4); | |
} | |
); | |
} |
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 Collection() { | |
this.push.apply( this, arguments ); | |
} | |
Collection.prototype = []; | |
Collection.prototype.push = function( item ) { // we need to wrap this.push in a function or we'll get a recursion error from | |
if ( arguments.length > 1 ) { // the arguments.length always being > 1 since the Array index is passed to the iterator | |
this.slice.call( arguments ).map( function( val ) { this.push( val ); }, this ); | |
return this.length; |
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
# Uses method of least proportions to apportion House members among states. | |
# http://en.wikipedia.org/wiki/United_States_congressional_apportionment#The_Method_of_Equal_Proportions | |
# use like this: | |
# python apportion.py --built-in 2010 | |
# python apportion.py --file file.csv --key <column name> | |
# python apportion.py --file file.csv --key <column name> --reps 444 | |
# python apportion.py --file file.csv --key <column name> --distsize 500000 | |
from __future__ import division, print_function | |
import sys | |
import csv |
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
package main | |
import ( | |
"log" | |
"strings" | |
) | |
func isVowel(chr_ rune) bool { | |
chr := string(chr_) | |
if (strings.EqualFold(chr, "a") || strings.EqualFold(chr, "e") || |
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
Allers Bottom | |
Culack | |
Swrarby | |
Fenwall St Eastake | |
Anbarth | |
St Ninhope | |
Thawkanham Water Green | |
Mige Lane | |
Up Maling | |
Firley Dinch |
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
Date time=[2013/03/15-10:43:16];date time setting,format yyyy/mm/dd hh:mm:ss, | |
Movie resolution=[0];Movie resolution setting,0:720p 30fps,1:wvga 30fps,2:vga 30fps, | |
Movie cycle time=[1];movie cycle time,0:5 minutes,1:20 minutes,2:40 minutes,3: 70 minutes, | |
movie Loop Recording=[0];set loop recording on or off,0:off,1:on, | |
Movie stamp=[0];set date / time stamp on or off,0:off,1:on, | |
Movie sound=[2];set movie sound,0:mute,1:level 1,2:level 2,3:level 3, | |
LED=[0];set LED flicker when recording,0:off,1:on, | |
Movie quality=[1];set movie quality,set movie data rate,0:10 Mbps,1:7 Mbps, | |
Power off=[1];set system auto power off time when system pending,0:off,1:30 seconds,2:1 minutes,3:2 minutes, | |
Movie Flip=[0];set movie rotate,0:off,1:on, |
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
20:10 dat-gitter-bot> (scriptjs) @mafintosh can you contrast hyperlog vs hypercore for their log capabilities, you dropped hypercore at some point. Is hypercore by itself as useful for an append only log use case? | |
20:10 <•mafintosh> @scriptjs right | |
20:10 <•mafintosh> so hyperlog is a DAG structure (a merkle dag even) | |
20:10 <•mafintosh> where data you insert can point to other data you insert | |
20:10 <•mafintosh> which is really great if you have multiple peers collaborating on the same data structure | |
20:11 <•mafintosh> a hyperlog is also always fully replicated since that makes the replication protocol pretty trivial | |
20:11 <•mafintosh> (i really need to write some white paper on that at some point) | |
20:11 <•mafintosh> hypercore is just simple single-writer append-only logs | |
20:11 <•mafintosh> so abstraction-wise hyperlog > hypercore | |
20:12 <•mafintosh> we could even make hyperlog run on top of hypercore which i really wanna do |
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
runtime: nodejs8 |
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 webrtc = require('webrtc-swarm') | |
var signalhub = require('signalhub') | |
var hyperdrive = require('hyperdrive') | |
var memdb = require('memdb') | |
var pump = require('pump') | |
var DEFAULT_SIGNALHUBS = 'https://signalhub.mafintosh.com' | |
var drive = hyperdrive(memdb()) |
OlderNewer