Skip to content

Instantly share code, notes, and snippets.

@timblair
timblair / git-merge-point
Created February 19, 2014 19:42
Show the point where a given commit was merged into master
#!/bin/bash
# Displays the point at which a given commit SHA was merged
#
# Usage: git merge-point SHA <TARGET>
TARGET=${2-master}
git rev-list --ancestry-path $1..$TARGET |
grep -f <(git rev-list --first-parent $1..$TARGET) |
@timblair
timblair / markdown.css
Created August 25, 2011 15:57
Simple Markdown CSS
/* Based on http://kevinburke.bitbucket.org/markdowncss/ */
body{
margin: 0 auto;
font-family: Georgia, Palatino, serif;
color: #444444;
line-height: 1;
max-width: 960px;
padding: 30px;
}
@timblair
timblair / headers-with-ids.rb
Created November 10, 2021 17:45
Generating headers with IDs using CommonMarker
require "commonmarker"
class HeaderWithIdRender < CommonMarker::HtmlRenderer
def header(node)
block do
old_stream = @stream
@stream = StringIO.new(String.new.force_encoding("utf-8"))
out(:children)
content = @stream.string
@stream = old_stream
@timblair
timblair / strava.js
Last active April 12, 2021 19:31 — forked from scottpdawson/strava.js
Bulk download Strava activities
var maxPage = 1; // calculate this using (activities/20 + 1)
var activityType = "Run"; // change to the workout type you want, or blank for all
var p = 1;
var done = 0;
var url;
var nw = window.open("workouts.html");
nw.document.write("[");
while (p <= maxPage) {
url = "https://www.strava.com/athlete/training_activities" +
"?keywords=&activity_type=" + activityType + "&workout_type=&commute=&private_activities=" +
@timblair
timblair / 20150820-go-workshop-notes.md
Created August 21, 2015 09:22
2015-08-20: Go Workshop Notes

2015-08-20: Go Workshop Notes

Variables and Types

  • Type gives the compiler two things: size + representation. The compiler guarantees these types
@timblair
timblair / grid-join.go
Created December 22, 2017 10:10
AoC 2017 Day 21: Grid Joining
func join(gs []grid) grid {
n := int(math.Sqrt(float64(len(gs)))) // Number of subgrids across/down the new grid
sgn := len(gs[0]) // Number of values on one side of a subgrid
cg := newGridBySize(n * sgn) // The new, combined grid to populate
// Add each subgrid to the new, combined grid.
for i, g := range gs {
// Calculate the position of the top-left of the subgrid once placed in
// the new, combined grid. We use this plus the offset within the subgrid
// to place the values in the combined grid.
require "gviz"
require "optparse"
# Usage: $0 PINFILE [OPTIONS]
#
# -i, --highlight APPS Highlight apps that depend on these
# -x, --exclude APPS Exclude these apps
# -o, --only APPS Only show dependencies and dependants of these
# -s, --hide-solitary Hide apps with no dependecies or dependants
# -f, --out-file FILE The filename to write output to (default: out.png)
@timblair
timblair / gds-go-workshop-01-cheatsheet.md
Last active November 24, 2016 15:43
GDS Go Workshop #1: Cheatsheet

GDS Go Workshop #1: Cheatsheet

Value assignment

var s1 string         // a new string identifer with its zero value ("")
var s2 string = "foo" // an identifer with a non-zero value
var i1 int            // an int identifer with its zero value (0)
var i2 int = 42       // an int identifer with a non-zero value
@timblair
timblair / ayb12.md
Created November 23, 2012 12:56
Notes from All Your Base 2012, 2012-11-23

AYB12

Alvin Richards: MongoDB

  • Trade-off: scale vs. functionality. MongoDB tries to have good functionality and good scalability.
  • Auto-sharding to maintain equilibrium between shards
  • Scalable datastore != scalable application: use of datastore may still be non-scalable (e.g. many queries across all shards)
  • Get low latency by ensuring shard data is always in memory: datastore
@timblair
timblair / CHANGELOG.json
Created November 1, 2016 08:46
A quick stab at a machine-readable CHANGELOG format
{
"project": "some-project",
"url": "https://github.com/someorg/some-project",
"description": "Some project or other for SomeOrg",
"releases": [
{
"version": "1.0.0",
"date": "2014-12-05",
"items": [