Skip to content

Instantly share code, notes, and snippets.

import axios from 'axios'
const baseUrl = SOME_URL
const fetchAllData = async () => {
let allData = []
let apiResponse = await axios.get(baseUrl)
allData.push(apiResponse.data_you_care_about)
while (apiResponse.next_cursor) {
apiResponse = await axios.get(baseUrl + `next_cursor=${apiResponse.next_cursor}`)
@rweald
rweald / clock_time.rb
Created November 17, 2017 05:42
Hacky little ruby scripts to generate race pace charts
paces = (13..18).to_a
aid_station_miles = [0.0,3.5,6.5,11.8,17.7,20.5,23.5,26.4,32.4]
start_time = 420
puts (['Miles'] + paces.map { |m| "#{m} min/mi" }).join(',')
aid_station_miles.each do |milage|
elapsed_time = paces.reduce([]) do |times, pace|
total_mins = (milage * pace).round(2)
/Users/Ryan/code/lantern/xealth-partner-sample-code/partner-api/gulper.js:78
function runCommand(cmd, args, verbosity = 0) {
^
SyntaxError: Unexpected token =
at exports.runInThisContext (vm.js:54:16)
at Module._compile (module.js:375:25)
at loader (/Users/Ryan/code/lantern/xealth-partner-sample-code/partner-api/node_modules/babel-register/lib/node.js:144:5)
at Object.require.extensions.(anonymous function) [as .js] (/Users/Ryan/code/lantern/xealth-partner-sample-code/partner-api/node_modules/babel-register/lib/node.js:154:7)
at Module.load (module.js:345:32)
reference value kafka of package <root> refers to nonexisting symbol. in file .../JobRunner.scala
scala.tools.nsc.symtab.Types$TypeError: class file needed by StreamingContext is missing.
reference value kafka of package <root> refers to nonexisting symbol.
at scala.tools.nsc.symtab.classfile.UnPickler$CompileScan.toTypeError(UnPickler.scala:66)
at scala.tools.nsc.symtab.classfile.UnPickler$CompileScan$LazyTypeRef.complete(UnPickler.scala:79)
at scala.tools.nsc.symtab.classfile.UnPickler$CompileScan$LazyTypeRef.complete(UnPickler.scala:69)
at scala.tools.nsc.symtab.Symbols$Symbol.info(Symbols.scala:730)
at scala.tools.nsc.symtab.Types$TypeMap$$anonfun$16.apply(Types.scala:3234)
at scala.tools.nsc.symtab.Types$TypeMap$$anonfun$16.apply(Types.scala:3231)
#!/bin/sh
exec scala -savecompiled "$0" "$@"
!#
// Get the shell scripting enrichments
import scala.sys.process._
val alwaysKeep = Set("develop", "master")
// Now delete any merged branches"
val branches: String = "git branch".!!
@rweald
rweald / lower-extract-low-confidence-nip-geocodes.sh
Last active December 12, 2015 05:18
Grab NPI numbers that could not be geocoded with high degree of confidence
#!/usr/bin/env bash
# Requires CSVKit to be installed
# To install use pip install csvkit
cat geocoded_npi.csv | ruby -e 'STDIN.each { |l| fields = l.split(","); puts l if fields[3].to_f < 0.5 }' > lower-confidence-npis.csv
# Depending which address field you want to use you should change the column indexes
csvcut -c 1,29-33 full_nip_datadump.csv > npi-to-address.csv
csvjoin -c 1 npi-to-address.csv lower-confidence-npis.csv
@rweald
rweald / convert-lat-long-to-state.R
Created February 6, 2013 06:40
Convert (long,lat) pairs into state names
#Code taken from SO
#http://stackoverflow.com/questions/8751497/latitude-longitude-coordinates-to-state-code-in-r/8751965#8751965
library(sp)
library(maps)
library(maptools)
# The single argument to this function, pointsDF, is a data.frame in which:
# - column 1 contains the longitude in degrees (negative in the US)
# - column 2 contains the latitude in degrees
@rweald
rweald / install-postgres-driver.sh
Created January 14, 2013 23:02
Installing postgres driver for apache sqoop
cd /tmp
wget "http://jdbc.postgresql.org/download/postgresql-9.2-1002.jdbc4.jar"
cp postgresql-9.2-1002.jdbc4.jar /usr/share/java/
ln -s /usr/share/java/postgresql-9.2-1002.jdbc4.jar /usr/lib/sqoop/lib/postgresql-9.2-1002.jdbc4.jar
library(maps)
library(geosphere)
library(plyr)
library(ggplot2)
library(sp)
airports <- read.csv("http://www.stanford.edu/~cengel/cgi-bin/anthrospace/wp-content/uploads/2012/03/airports.csv", as.is=TRUE, header=TRUE)
flights <- read.csv("http://www.stanford.edu/~cengel/cgi-bin/anthrospace/wp-content/uploads/2012/03/PEK-openflights-export-2012-03-19.csv", as.is=TRUE, header=TRUE)
# aggregate nunber of flights
@rweald
rweald / geocode-ips.rb
Last active December 10, 2015 21:38
Read IP addresses from STDIN geocode IPs and print 2-tuple (long, lat) to STDOUT
#!/usr/bin/env ruby -W0
require 'geoip'
geocity_file_location = ARGV[0] || "./GeoLiteCity.dat"
geocoder = GeoIP.new(geocity_file_location)
i = 0
STDIN.each do |ip|
STDERR.write("Processing Line: #{i}\n") if i % 1000 == 0
i += 1