Skip to content

Instantly share code, notes, and snippets.

View evansiroky's full-sized avatar

Evan Siroky evansiroky

  • Scotts Valley, CA
  • 12:32 (UTC -08:00)
View GitHub Profile
@evansiroky
evansiroky / dbStreamerCsvInserter.js
Last active September 29, 2015 19:15
dbStreamer csv insert example
var csv = require('csv'),
dbStreamer = require('db-streamer'),
fs = require('fs');
var input = fs.createReadStream(filename);
var parser = csv.parse({
columns: true,
relax: true
});
@evansiroky
evansiroky / sequelizeBulkInsert.js
Created September 29, 2015 19:13
Insert CSV using sequelize bulk insert
var fs = require('fs'),
async = require('async'),
csv = require('csv');
var input = fs.createReadStream(filename);
var parser = csv.parse({
columns: true,
relax: true
});
function coinSums(denominations, targetValue) {
var numCombos = 0,
cache = [],
combos = [];
var addFn = function(curValue, curCombo) {
for(var i=0; i < denominations.length; i++) {
var curDenom = denominations[i],
sum = curValue + curDenom,
@evansiroky
evansiroky / README.md
Last active November 13, 2015 21:03 — forked from irees/README.md

Transitland Frequency Visualization

Accompanies blog post: Transit dimensions: Transitland Schedule API

The frequency.py script:

  • Fetches all trips on a given date, between a start time and end time, inside of a bounding box
  • Calculates the number of connections between every stop
  • Uses a colormap and line width to show more frequent service
  • Outputs a GeoJSON map as output.geojson
@evansiroky
evansiroky / icon.js
Created September 27, 2016 00:57
Mocking children components with Jest - does this make sense?
import React from 'react'
export default class Icon extends React.Component {
render () {
const {type, className} = this.props
return (
<i
className={`fa fa-${type} fa-fw ${className}`}
{...this.props}
@evansiroky
evansiroky / gist:30174cc29171aa9c26264f9ecbf12f1b
Created May 1, 2017 17:53
California State Assembly Committee on Revenue and Taxation
# This is used to encrypt sessions and next page URLs before serving them to
# the client.
#
# This should be a hex string that's exactly 64 bytes long. For example:
#
# d7211b215341871968869dontusethisc0ff1789fc88e0ac6e296ba36703edf8
#
# Don't reuse that key - you can generate a random key by running:
#
# openssl rand -hex 32
@evansiroky
evansiroky / ibi_post_process.py
Created October 25, 2023 21:54
Migrate Fares v2 and remove route_colors (IBI workflow)
# Does some post-processing after receiving an export from IBI data tools. Does these things:
# - copies fares v2 data from another folder into the current one
# - removes route color column
#
# Copy fares v2 data from one folder to another. It is assumed that the first input
# is a folder that contains the following:
# - file: fare_leg_rules.txt
# - file: fare_media.txt
# - file: fare_products.txt
# - file: routes.txt with a column of `network_id`
{
"Name": "Download-Applications-From-ECOS",
"CreationDate": "2024-2-13",
"Commands": [
{
"Command": "store",
"Target": "fast",
"Value": "!replayspeed",
"Description": ""
},