Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View gregmacfarlane's full-sized avatar

Greg Macfarlane gregmacfarlane

View GitHub Profile
@gregmacfarlane
gregmacfarlane / LinkTablesToOSMConverter.java
Created May 6, 2022 15:15
Generate an OSM PBF from link and node csv tables
package beam.utils;
import com.conveyal.osmlib.Node;
import com.conveyal.osmlib.OSM;
import com.conveyal.osmlib.Way;
import com.univocity.parsers.common.record.Record;
import com.univocity.parsers.csv.CsvParser;
import com.univocity.parsers.csv.CsvParserSettings;
import org.matsim.core.utils.misc.Counter; // This creates a geometric counter that helped me keep track of things, but isn't necessary
import org.slf4j.Logger;
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@gregmacfarlane
gregmacfarlane / accuracy.py
Created May 10, 2018 17:10
Test doppelganger on different-sized marginals
import csv
import os
os.chdir('/Users/gregmacfarlane/tf/doppelganger/examples')
import pandas as pd
import logging
log = logging.getLogger(__name__)
logging.basicConfig(level=logging.DEBUG)
@gregmacfarlane
gregmacfarlane / tcad2omx.R
Created February 19, 2018 20:55
Load a series of binary matrices into OMX
library(tidyverse)
library(omxr) # gregmacfarlane/omxr
library(tcadr) # pbsag/tcad
library(sf)
# number of zones + number of external stations
n <- 672
periods <- c("am", "pm", "md", "nt")
@gregmacfarlane
gregmacfarlane / test_shiny.Rmd
Created June 2, 2017 14:49
Demo shiny Rmd with topojson file
---
title: "Test RMD"
output: html_document
runtime: shiny
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
library(tidyverse)
library(leaflet)
@gregmacfarlane
gregmacfarlane / topojson_depends.txt
Created June 2, 2017 14:48
rsconnect::appDependencies() output for topojson application.
package version source
1 BH 1.62.0-1 CRAN
2 MASS 7.3-47 CRAN
3 R6 2.2.1 CRAN
4 RColorBrewer 1.1-2 CRAN
5 Rcpp 0.12.11 CRAN
6 V8 1.5 CRAN
7 assertthat 0.2.0 CRAN
8 backports 1.1.0 CRAN
9 base64enc 0.1-3 CRAN
@gregmacfarlane
gregmacfarlane / console
Last active April 30, 2017 01:57
Console error for private AV
2017-04-29 21:14:31,482 INFO Injector:79 ==full==> ConstructorBinding{key=Key[type=org.matsim.analysis.VolumesAnalyzer, annotation=[none]], source=org.matsim.analysis.VolumesAnalyzerModule.install(VolumesAnalyzerModule.java:31), scope=eager singleton}
2017-04-29 21:14:31,483 INFO Injector:77 org.matsim.analysis.LegHistogram
2017-04-29 21:14:31,483 INFO Injector:78 -> com.google.inject.internal.ConstructorBindingImpl$Factory@27adc16e
2017-04-29 21:14:31,483 INFO Injector:79 ==full==> ConstructorBinding{key=Key[type=org.matsim.analysis.LegHistogram, annotation=[none]], source=org.matsim.analysis.LegHistogramModule.install(LegHistogramModule.java:30), scope=Scopes.NO_SCOPE}
2017-04-29 21:14:31,483 INFO Injector:77 org.matsim.analysis.CalcLegTimes
2017-04-29 21:14:31,483 INFO Injector:78 -> com.google.inject.internal.ConstructorBindingImpl$Factory@563e4951[Scopes.SINGLETON]
2017-04-29 21:14:31,483 INFO Injector:79 ==full==> ConstructorBinding{key=Key[type=org.matsim.analysis.CalcLegTimes, ann
@gregmacfarlane
gregmacfarlane / git_lfs_fetch.sh
Created January 8, 2017 01:32
git lfs fetch: Trace
hwyc55z@7D6420SWIM2 MINGW64 ~
$ git clone git@github.com:pbsag/tlumip
Cloning into 'tlumip'...
remote: Counting objects: 17075, done.
remote: Total 17075 (delta 0), reused 0 (delta 0), pack-reused 17075
Receiving objects: 100% (17075/17075), 119.26 MiB | 808.00 KiB/s, done.
Resolving deltas: 100% (9214/9214), done.
Checking out files: 100% (816/816), done.
@gregmacfarlane
gregmacfarlane / temp_check.py
Created November 14, 2015 16:29
Temperature check in Python
def check_temp(temp):
if temp > 85:
print "It's hot outside. Better bring water."
else:
print "It's a good day for a hike!"
if __name__ == '__main__':
check_temp(90)
@gregmacfarlane
gregmacfarlane / temp_convert.c
Last active November 14, 2015 16:29
Temperature converter in C
#import<stdio.h>
double convert_temp(double temp_f){
double temp_c;
temp_c = (temp_f - 32) * 5/9;
return(temp_c);
}
int main(){