Skip to content

Instantly share code, notes, and snippets.

@williamho
williamho / jenkins_console.css
Last active September 14, 2021 13:16
User style for Jenkins console output to make it look like travis
.console-output {
background: #2a2a2a;
color: #f1f1f1;
padding: 1em;
line-height: 19px;
font-size: 14px;
font-weight: 400;
word-wrap: break-word;
}
@williamho
williamho / twitter.css
Created December 20, 2015 04:52
custom styles for twitter
li.js-moments-tab {
display: none;
}
ol.expanded-conversation div.AdaptiveMedia.is-square {
max-height: none !important;
overflow: auto;
}
ol.expanded-conversation div.AdaptiveMedia-singlePhoto img {
# In Gemfile:
# gem 'google-api-client', '0.9.pre3'
require 'google/apis/customsearch_v1'
Customsearch = Google::Apis::CustomsearchV1
search = Customsearch::CustomsearchService.new
# https://cse.google.com/cse/all
# Click name of CSE to edit
(function() {
var d = document;
var img = d.createElement('img');
img.style.cssText = 'right:0; top:0; position:fixed;';
d.body.appendChild(img);
var elems = d.querySelectorAll('a[href^="./"]');
Array.prototype.forEach.call(elems, function(elem) {
elem.addEventListener('mouseover', function() {
@williamho
williamho / index.js
Created November 17, 2015 20:34
convert marineregions geojson to mongodb 2.4 mongoimport compatible file
/*
Convert marineregions json (converted from shapefile) to mongodb 2.4 compatible format (for mongoimport)
Mongo 2.4 doesn't support `MultiPolygon` type, so split `MultiPolygon` into multiple individual `Polygon`s.
Also convert ISO alpha 3 to alpha 2.
Usage:
Convert the marineregions shapefile (EEZ_land_v2_201410.shp) to a geojson file:
ogr2ogr -f GeoJSON -t_srs crs:84 -clipsrc -180 -90 180 90 countries.geojson *.shp
@williamho
williamho / index.js
Last active November 17, 2015 18:27
db-ip to mongoimport
// From a db-ip csv file, generate a mongoimport-compatible file, converting IPs to Longs.
// Ignores IPv6 because byte arrays are annoying to work with. Sorry.
// Usage: node index.js <input.csv >output.txt
var ipModule = require('ip')
, parse = require('csv-parse')
, transform = require('stream-transform')
;
var parser = parse({ columns: ['startIp', 'endIp', 'countryCode'] });
@williamho
williamho / FicusSpec.scala
Last active November 5, 2015 18:22
ficus
import org.specs2.mutable._
import com.typesafe.config._
import net.ceedubs.ficus.Ficus._
import net.ceedubs.ficus.readers.ArbitraryTypeReader._
class HelloSpec extends Specification {
case class MyConfig(
key1: String,
key2: String,
@williamho
williamho / mapValues.scala
Created November 5, 2015 17:01
mapValues doesn't map the values until the object is evaluated
// See https://issues.scala-lang.org/browse/SI-7005
scala> val m = Map(1 -> 2, 3 -> 4)
m: scala.collection.immutable.Map[Int,Int] = Map(1 -> 2, 3 -> 4)
scala> val m1 = m.mapValues { x => println("mapValues is being evaluated"); x + 2 }
mapValues is being evaluated
mapValues is being evaluated
m1: scala.collection.immutable.Map[Int,Int] = Map(1 -> 4, 3 -> 6)
@williamho
williamho / README.md
Last active October 23, 2015 17:15
work pipeline statsd

Work pipeline dashboard example

work-pipeline-grafana.json:

  • example grafana dashboard json (assumes the metrics will be prefixed in the format someNamespace.somePipelineName)

WorkPipelineSample.scala

  • scala example code for using the workpipeline and generating some metrics

you can use this to set up grafana/graphite/statsd locally: https://github.com/kamon-io/docker-grafana-graphite

@williamho
williamho / .vimiumrc
Created September 13, 2015 02:59
vimium mappings
map <c-u> scrollPageUp
map <c-d> scrollPageDown
unmap u
unmap d
unmap r
unmap p
unmap P
unmap t
unmap x