Skip to content

Instantly share code, notes, and snippets.

View gregmacfarlane's full-sized avatar

Greg Macfarlane gregmacfarlane

View GitHub Profile
@gregmacfarlane
gregmacfarlane / shp2xml.py
Created September 15, 2014 20:50
A script to convert a lines shapefile into a MATSim network
# Code to read the FAF network
# Greg Macfarlane | Parsons Brinckerhoff
# ORNL provides the FAF network as a TransCAD network, and also as a shapefile
# that I think is probably exported from the TransCAD network. Kyle Ward in the
# Raleigh office tried to export an xml file from TransCAD, but it wasn't quite
# right. So I decided to write this script to make an xml MATSim network from
# the shapefile.
@gregmacfarlane
gregmacfarlane / check_temperature.R
Last active November 8, 2015 21:14
Check the temperature for a hike
check_temperature <- function(temperature){
if(temperature > 85){
print("It's hot. Bring water and sunscreen.")
} else {
print("Looks like a great day to hike!")
}
}
check_temperature(68)
@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(){
@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 / git_lfs_fetch.sh
Created January 8, 2017 01:32
git lfs fetch: Trace
hwyc55z@7D6420SWIM2 MINGW64 ~
$ git clone [email protected]: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 / 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 / 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 / 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 / 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 / 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)