Skip to content

Instantly share code, notes, and snippets.

View jamiecook's full-sized avatar

Jamie Cook jamiecook

View GitHub Profile
#!/usr/bin/env python
import sys
import bs4 as bs
import urllib.request
import pandas as pd
import seaborn as sns
splats = ['buggy', 'wissler', 'cook, jamie', 'gossow']
hamilton_abbr = ['hamilton', 'hwcc']
@jamiecook
jamiecook / db_complete.sh
Last active June 11, 2020 02:16
Bash completion for connecting psql to lots of databases. Combine with a ~/.pgpass file for easy db connections.
#!/bin/bash
DB_SEARCH_DIRS="$HOME/Projects $HOME/src /opt $HOME/src/vlc $HOME/Projects/vlc $HOME/p $HOME/src/bdk"
# See https://stackoverflow.com/questions/1494178/how-to-define-hash-tables-in-bash
setup_database_list() {
declare -Ag databases
databases["short_name"]="psql -U user -h hostname -p 5432 db_name"
databases["short_name_number_2"]="psql -U different_user -h different_hostname -p 5432 different_db_name"
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE TemplateHaskell #-}
{-# LANGUAGE TypeFamilies #-}
module HakunaStack where
import Control.Lens
// 6 - Check WKB -> Geo -> WKB roundtrip
// See https://github.com/ewestern/geos/pull/22
template<>
template<>
void object::test<5>()
{
std::string initialWkb = "0105000020C46E000001000000010200000004000000EE2DE25E859A20410829F224364B5A41BD757FB6679A204115C6D8E9304B5A4177111862469A2041A03F04E32C4B5A41BC1D3ADD459A2041793C8CD92C4B5A41";
geos::geom::Geometry *geom = wkbreader.readHex(initialWkb);
std::stringstream result_stream;
readHex :: BC.ByteString -> Some Geometry
readHex bs = runGeos $ do
r <- S.createReader
g <- S.readHex r bs
convertGeometryFromRaw g
readLotsOfHex :: [BC.ByteString] -> [Some Geometry]
readLotsOfHex bs = runGeos $ do
r <- S.createReader
x <- mapM (S.readHex r) bs
0103000020E6100000010000000500000026A94C318721634065FED137695E3BC0B81FF0C0802163404D4BAC8C465E3BC05A65A6B47E216340E5D2F885575E3BC0F7729F1C8521634066A032FE7D5E3BC026A94C318721634065FED137695E3BC0
0103000020E610000001000000050000004BADF71BED206340BB99D18F866F3BC04BADF71BED206340BB5F05F86E6F3BC02F1686C8E9206340BB5F05F86E6F3BC02F1686C8E9206340BB99D18F866F3BC04BADF71BED206340BB99D18F866F3BC0
0103000020E6100000010000000500000049D8B7930822634013656F29E7533BC049D8B79308226340132BA391CF533BC015FF774405226340132BA391CF533BC015FF77440522634013656F29E7533BC049D8B7930822634013656F29E7533BC0
0103000020E61000000100000005000000BEF8A23D5E2063409EB29AAE27523BC0D8F0F44A592063405D8940F50F523BC0D367075C5720634003780B2428523BC09B560A815C2063409372F7393E523BC0BEF8A23D5E2063409EB29AAE27523BC0
0103000020E61000000100000005000000D9976C3C582063403AEB538EC96E3BC0CF6BEC12552063405358A9A0A26E3BC0EEEC2B0F522063404F20EC14AB6E3BC075ADBD4F55206340C2A38D23D66E3BC0D9976C3C582063403AEB538EC96E3BC0
0103000020E61000000100000005000000D21A834E0820634
0103000020E6100000010000000500000026A94C318721634065FED137695E3BC0B81FF0C0802163404D4BAC8C465E3BC05A65A6B47E216340E5D2F885575E3BC0F7729F1C8521634066A032FE7D5E3BC026A94C318721634065FED137695E3BC0
0103000020E610000001000000050000004BADF71BED206340BB99D18F866F3BC04BADF71BED206340BB5F05F86E6F3BC02F1686C8E9206340BB5F05F86E6F3BC02F1686C8E9206340BB99D18F866F3BC04BADF71BED206340BB99D18F866F3BC0
0103000020E6100000010000000500000049D8B7930822634013656F29E7533BC049D8B79308226340132BA391CF533BC015FF774405226340132BA391CF533BC015FF77440522634013656F29E7533BC049D8B7930822634013656F29E7533BC0
0103000020E61000000100000005000000BEF8A23D5E2063409EB29AAE27523BC0D8F0F44A592063405D8940F50F523BC0D367075C5720634003780B2428523BC09B560A815C2063409372F7393E523BC0BEF8A23D5E2063409EB29AAE27523BC0
0103000020E61000000100000005000000D9976C3C582063403AEB538EC96E3BC0CF6BEC12552063405358A9A0A26E3BC0EEEC2B0F522063404F20EC14AB6E3BC075ADBD4F55206340C2A38D23D66E3BC0D9976C3C582063403AEB538EC96E3BC0
0103000020E61000000100000005000000D21A834E0820634
data PercentageBase100 = PercentageBase100 Double deriving (Eq,Show)
instance FromField PercentageBase100 where
parseField p = pure $ (f . read . BS8.unpack) p
where f = checkPercentageBounds (0.0, 100.0) PercentageBase100
checkPercentageBounds :: (Double,Double) ->
(Double -> a) -> Scientific -> a
checkPercentageBounds (low, high) f s
| ((d < low) || (d > high)) = error $ "That's an invalid percentage, expected " ++ (show d) ++ " to be in the range " ++ (show (low,high))
[
{
"id": 142465,
"location_id": 19592,
"latitude": -27.4661,
"longitude": 153.025998,
"format": "Bus/Rail - Platform/Concourse",
"percent_board": 66,
"percent_alight": 66,
"section": "Concourse",
This file has been truncated, but you can view the full file.
[
{
"nodenr": 6001,
"geoloc": "0101000020E61000008A1F63EEDA20634079CA6ABA9E783BC0"
},
{
"nodenr": 6002,
"geoloc": "0101000020E6100000088ECBB8A9226340CA6FD1C952673AC0"
},
{