Skip to content

Instantly share code, notes, and snippets.

View aroberts's full-sized avatar

Andrew Roberts aroberts

View GitHub Profile
@aroberts
aroberts / Example.scala
Created May 2, 2017 14:44
Intellij Scala plugin: Failure to infer class type parameters from parameter list when an implicit parameter list is present
package com.fuze.perseus.flink
class FailingExample[T](s: Concrete[T])(implicit tc: Typeclass[T])
class WorkingExample[T](s: Concrete[T])
trait Typeclass[T]
trait Concrete[T]
object Concrete {
val instance = new Concrete[Int] {}
}
import java.time.{Instant, ZoneId, LocalDateTime}
import io.circe.{Encoder, Decoder}
import io.circe.syntax._
trait LocalDateTimeCodec {
val UTC = ZoneId.of("UTC")
implicit val dateTimeEncoder: Encoder[LocalDateTime] = Encoder.instance(
@aroberts
aroberts / router.js
Created December 2, 2014 13:56
Ember nested resources
// first example
App.Router.map(function () {
this.resource('address', { path: '/:address_id' }, function() {
this.resource('thread', { path: '/:thread_id' });
});
this.resource('tag', { path: '/tag/:tag' }, function() {
this.resource('thread', { path: '/:thread_id' });
});
});
@aroberts
aroberts / shell_output
Created February 28, 2014 19:23
Underscored positional argument bug in invoke 0.7
$ inv working
'working' did not receive all required positional arguments!
$ inv nonworking
should error
$
@aroberts
aroberts / git-patch-from
Created November 22, 2013 16:09
Git command for moving dirty changes from machine to machine. Takes remote host as the first argument, and remote path as optional second argument (defaults to inferring from current path).
#!/bin/bash
port=22
while getopts "p:" opt; do
case "$opt" in
\?)
echo "bad opt"
exit 1
;;
@aroberts
aroberts / example.py
Created May 14, 2013 19:36
BeautifulSoup4 bug illustration. HTML fragment taken from github.com
BeautifulSoup(open('fragment.html'), 'html5lib').select('div.secondary strong')
@aroberts
aroberts / client.py
Last active December 16, 2015 17:19
Example code snips highlight an issue with requests posting to a url
########################################
# client.py
import requests
url = 'http://localhost:5000/'
requests.post(url)
@aroberts
aroberts / git-report.rb
Created November 19, 2012 16:17
git command to show information about a week's worth of commits
#!/usr/bin/env ruby
require 'optparse'
require 'date'
def date_of_last(day)
date = Date.parse(day)
delta = date > Date.today ? 7 : 0
(date - delta)
@aroberts
aroberts / git-multi-status.sh
Created June 29, 2012 13:58 — forked from jcordasc/rec_git_status.sh
Script for checking git status of many git repositories
#!/bin/bash
# usage: $0 source_dir [source_dir] ...
# where source_dir args are directories containing git repositories
red="\033[00;31m"
green="\033[00;32m"
yellow="\033[00;33m"
blue="\033[00;34m"
purple="\033[00;35m"
@aroberts
aroberts / d3.phylogram.js
Created September 16, 2011 18:42 — forked from kueda/d3.phylogram.js
Right-angle phylograms and circular dendrograms with d3. Forked to add some options and minor formatting changes.
/*
d3.phylogram.js
Wrapper around a d3-based phylogram (tree where branch lengths are scaled)
Also includes a radial dendrogram visualization (branch lengths not scaled)
along with some helper methods for building angled-branch trees.
d3.phylogram.build(selector, nodes, options)
Creates a phylogram.
Arguments:
selector: selector of an element that will contain the SVG