Skip to content

Instantly share code, notes, and snippets.


David Dias daviddias

View GitHub Profile
View i94-count-days-in-usa.js
// This script counts how many days you have been in the USA
// This is a personal script, use it at your own risk
// This is not an official tool and it can do wrong calculations
// which might result in loss in visa status, green card, citizenship
// and whatever you can think of
// This extracts data from the i94 website from the history result view
function daysInYear(year) {
var recs = angular.element(".history-results").scope().vm.recs
├── actions
│   ├── config.js
│   ├── errors.js
│   ├── files.js
│   ├── index.js
│   ├── pages.js
│   ├── preview.js
│   ├── router.js
│   └── utils.js
View gist:4fe5f6f99e99cfa7940a6f16d96568ea
it.only('sends the mss multicodec', (done) => {
const p = pullPair()
const dialer = multiplex.dialer(p[0])
const listener = multiplex.listener(p[1])
let dialerConn
let listenerConn
listener.on('stream', (conn) => {
View aaaaaaa.js
/* eslint-env mocha */
/* eslint max-nested-callbacks: ["error", 8] */
'use strict'
const chai = require('chai')
const expect = chai.expect
const pair = require('pull-pair/duplex')
const pull = require('pull-stream')
const parallel = require('async/parallel')
View test.js
test('underlying error is propagated to muxed streams', function (t) {
var plex1 = multiplex()
var plex2 = multiplex()
var socket
plex2.on('stream', function (stream) {
console.log('stream incomming plex2')
View thisishtml.html
<!DOCTYPE html>
<html lang="en">
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="icon" href="/img/favicon.ico">
daviddias /
Created Dec 19, 2016 — forked from substack/
peermaps p2p data format for ad-hoc openstreetmap extracts

peermaps data is ready

Peermaps is a project to bring OpenStreetMap data to the p2p web.

I've just finished a big part of this project: subdividing planet-latest.osm.pbf to support ad-hoc extracts. With ad-hoc extracts over p2p networks, you can download only the parts of planet osm that you need without having to download the whole 34G thing and process it using tens of gigabytes of RAM. Using the peermaps data archive, you can build tile sets for the entire planet on very modest hardware. Every .o5m.gz file is at most 1M. More details below.

daviddias / distritos-concelhos-freguesias-Portugal.json
Created Nov 14, 2016 — forked from tomahock/distritos-concelhos-freguesias-Portugal.json
Level 1 = Distrito, Level 2 = Concelho, Level 3 = Freguesia. Update de 12-07-2016
View distritos-concelhos-freguesias-Portugal.json
"level": 1,
"code": 1,
"name": "Aveiro"
"level": 2,
"code": 101,
"name": "Águeda"
View eth-block-message.proto
message Message {
message Wantlist {
repeated Entry entries = 1; // a list of wantlist entries
optional bool full = 2; // whether this is the full wantlist. default to false
message Entry {
optional bytes block = 1; // the block key
optional bool cancel = 2; // whether this revokes an entry
» npm test
> ethereum-libp2p@0.0.0 test /Users/daviddias/code/js-ethereum-libp2p
> PHANTOM=off gulp test
[18:57:19] Using gulpfile ~/code/js-ethereum-libp2p/gulpfile.js
[18:57:19] Starting 'test'...
[18:57:19] Starting 'test:node'...
[18:57:19] Starting 'libnode:start'...
[18:57:19] Finished 'libnode:start' after 127 ms