Skip to content

Instantly share code, notes, and snippets.

View dinomite's full-sized avatar

Drew Stephens dinomite

View GitHub Profile
package com.fasterxml.jackson.module.kotlin.test.github.failing
import com.fasterxml.jackson.databind.type.TypeFactory
import com.fasterxml.jackson.module.kotlin.KotlinModule
import com.fasterxml.jackson.module.kotlin.jacksonTypeRef
import com.fasterxml.jackson.module.kotlin.jsonMapper
import com.fasterxml.jackson.module.kotlin.readValue
import org.junit.Test
import kotlin.test.assertEquals
@dinomite
dinomite / Location.kt
Created March 12, 2019 14:47
Testing data classes in Kotlin
import java.time.Instant
data class Location(@JsonProperty val userId: Int,
@JsonProperty val geohash: String,
@JsonProperty val createdAt: Instant,
@JsonProperty val updatedAt: Instant?)
@dinomite
dinomite / Location.kt
Last active March 12, 2019 14:50
Testing data class serialization
import java.time.Instant
data class Location(@JsonProperty val userId: Int,
@JsonProperty val geohash: String,
@JsonProperty val createdAt: Instant,
@JsonProperty val updatedAt: Instant?)
/**
* Not thread safe due to asJson() indentation switching, but good enough for testing
*/
@NotThreadSafe
@SuppressFBWarnings(value = ["ST_WRITE_TO_STATIC_FROM_INSTANCE_METHOD"],
justification = "Findbugs doesn't understand Kotlin init")
object Json {
val objectMapper: ObjectMapper = ObjectMapper()
init {
@dinomite
dinomite / lxc-backup.sh
Last active May 22, 2021 21:20
Simple script to backup LXC containers
#!/usr/bin/env bash
set -ex
BACKUP_DIR=/path/to/where/backups/should/live
HOSTS=($(lxc list -c n --format csv))
for HOST in "${HOSTS[@]}"
do
BACKUP_NAME=${HOST}-$(date +"%Y-%m-%d")
#cloud-config
ssh_authorized_keys:
- ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDaqc90pQAmovrv7+48uBwS9HZwMCBwrqCadf4uKD7yMJY8r+mJ0zSDpqtUHeIKaB13jkTqOJxirVm1o3I1GNgt2EvZ2JSNlQci/D/j0ixlzS1mVpt+OzDk2e7xKe5KoZEbODLUbEYxDh+E9aZfAiDUoK6eInODdVD5sT59pJfljH4YqPkHM9VZtuBcuOGluzFwSkn2OmsQFL9+zAqNFLNt/kF6sP0HVRnZ9+LF/e9ut4rwD5/wobkWAAvKxOT/UVf3QqPiebDk4XkVVqhVRil0Y3WKWoJP/jwLJTrmVWJflgFOxNrgVSHY03Gj80wjAqfDs5cEvGzEoxdYnjIQAA6L dinomite@Caracalla
- ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAACAQDgNqNygJ1Koh1sGGXFCuTTLdxPrPIf9Zp2vDk0ptX8JTX57FQxmP7NzR1kDOqO7ZBQkpWfo40ehsHir1BOo5knTeiuqNbpAWS/ipN/JfjVSYE18G6I14/AMAQM5EpPuWwibGO9Q4e7P7aSnuGFvZPzAD1tyyZPQdvy7LrRlrfwvRguW7tH9934RxjQghwWn2L9sYzjhJV1jKM3QFQ0vDNAOYHD+etn5LU+MqIivrCoK9W2frh4ef8ZMLmGQII5C0ClBnVHuVSZWNbwfPJHpaIWXxW0CuTLIEYh6LLjIq7ZSuq13usBTW+j/69X1EL7e/4BgeqX1e6xvkaYCIvtLtueKV+MqYOpv8yi70xATey7HmUExqvHygcs6pKgcLV7y+JVnceu+3ipaFcpuujFePKmGXmGuYbM4zh4mqrnS37lZWMZFve7r9IYjryTdLpkFGL4ax0t9wF9d+T+ZOX6w8B5+JaP1Fah143Xci1uoSh0e65sX1BV1ALNPON45oJkebMHU0pbAnJmi7bBkDq1FZ4EL1joY

Keybase proof

I hereby claim:

  • I am dinomite on github.
  • I am dinomite (https://keybase.io/dinomite) on keybase.
  • I have a public key whose fingerprint is AD54 E78E BBF8 1792 430A D86E 2F11 EEF0 935F CCA5

To claim this, I am signing this object:

@dinomite
dinomite / scrape.rb
Created October 12, 2015 20:16
495/95 express lanes pricing scraper
#!/usr/bin/env ruby
require 'open-uri'
require 'json'
direction = 'Southbound';
origin = '180SO';
destination = '220SD';
date = '10/09/2015';
@curl_cmd = "curl 'https://www.expresslanes.com/historic-rate-data' -H 'Cookie: data=%7B%7D; digest=b9a6341bf276298b85e14530344aeb95a29b39bb; expire=1445866842; __utmt=1; __utma=269898021.1470859880.1444574061.1444574061.1444657244.2; __utmb=269898021.1.10.1444657244; __utmc=269898021; __utmz=269898021.1444574061.1.1.utmcsr=(direct)|utmccn=(direct)|utmcmd=(none)' -H 'Origin: https://www.expresslanes.com' -H 'Accept-Encoding: gzip, deflate' -H 'Accept-Language: en-US,en;q=0.8' -H 'User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/45.0.2454.101 Safari/537.36' -H 'Content-Type: application/x-www-form-urlencoded; charset=UTF-8' -H 'Accept: application/json, text/javascript, */*; q=0.01' -H 'Referer: https://www.expresslanes.com/historic-rates' -H 'X-curl_cmded-With: XMLHttpcurl_cmd' -H 'Connection: keep-alive' --data
@dinomite
dinomite / gist:79ce99a9124d207ab01d
Last active August 29, 2015 14:01
Size of Tesla Model S and BMW models
inches width length
BMW 3er
E30 65 176
E36 67 175
E46 69 170
E90 70 182
BMW 5er
E39 71 188
E60 73 190
F10 73 193
trajan:~$ brew install pdf2svg
==> Downloading http://www.cityinthesky.co.uk/_media/opensource/pdf2svg-0.2.1.tar.gz
File already downloaded and cached to /Users/drew/Library/Caches/Homebrew
==> ./configure --prefix=/usr/local/Cellar/pdf2svg/0.2.1 --disable-debug --disable-dependency-tracking
==> make install
/usr/bin/cc -DPACKAGE_NAME=\"pdf2svg\" -DPACKAGE_TARNAME=\"pdf2svg\" -DPACKAGE_VERSION=\"0.2.1\" -DPACKAGE_STRING=\"pdf2svg\ 0.2.1\" -DPACKAGE_BUGREPORT=\"David\ Barton\ \<davebarton@cityinthesky.co.uk\>\" -DPACKAGE=\"pdf2svg\" -DVERSION=\"0.2.1\" -I. -I/usr/X11R6/include -I/usr/local/Cellar/pixman/0.20.2/include/pixman-1 -I/usr/X11/include/cairo -I/usr/X11/include/freetype2 -I/usr/X11/include -I/usr/X11/include/libpng12 -D_REENTRANT -I/usr/local/Cellar/gtk+/2.24.4/include/gtk-2.0 -I/usr/local/Cellar/gtk+/2.24.4/lib/gtk-2.0/include -I/usr/local/Cellar/atk/2.0.0/include/atk-1.0 -I/usr/local/Cellar/gdk-pixbuf/2.22.1/include/gdk-pixbuf-2.0 -I/usr/local/Cellar/pango/1.28.4/include/pango-1.0 -I/usr/local/C