Skip to content

Instantly share code, notes, and snippets.

@jcoveney
jcoveney / type_proj_imp
Created June 16, 2014 20:46
Type projection and implicit resolution not playing nice
trait Plat[P <: Plat[P]] {
type Keyed[_, _]
}
class MPlat extends Plat[MPlat] {
type Keyed[K, V] = (K, TraversableOnce[V])
}
trait Prod[P <: Plat[P], T, This <: Prod[P, T, This]] {
http://www.infoq.com/presentations/scala-idris
http://www.cs.nott.ac.uk/~txa/publ/ydtm.pdf
http://coq.inria.fr/stdlib/Coq.Sorting.Mergesort.html
http://mazzo.li/posts/AgdaSort.html#fnref7
http://eb.host.cs.st-andrews.ac.uk/writings/idris-tutorial.pdf
https://gist.github.com/timjb/9043255
http://wiki.portal.chalmers.se/agda/pmwiki.php?n=Main.InductiveFamilies
http://www.cse.chalmers.se/~ulfn/darcs/AFP08/LectureNotes/AgdaIntro.pdf
http://eb.host.cs.st-andrews.ac.uk/drafts/pe-edsl.pdf
@jcoveney
jcoveney / gist:651fef547b8e9087547f
Created September 17, 2014 13:08
Not sure why this is diverging...
// in bijection branch jco/macro_case_class_plus
// ./sbt "bijection-macros/console"
// paste the following
import com.twitter.bijection._
import com.twitter.bijection.macros.common.TypesNotEqual
import com.twitter.bijection.macros.common.MacroImplicits._
trait Semigroup[T] {
@jcoveney
jcoveney / gist:4e609e6318a5f8037bda
Created October 2, 2014 23:58
Endofunctor attempt
// The following are just some useful category theoretic type classes
// Note that this IS an endofunctor -- it has to be. Our category is all possible types,
// so the type A and T[A] are both in our Category, so it's an endofunctor
trait Functor[T[_]] {
def map[A, B](fn: A => B): T[A] => T[B]
}
trait Monad[T[_]] extends Functor[T] {
// we go with the less common join approach because THIS is where the "monoid"-ness of
@jcoveney
jcoveney / avro_issue_1
Created April 4, 2013 16:18
Avro that works in python but not in java
a = """{
"fields": [
{
"type": "int",
"name": "first"
},
{
"type": "string",
"name": "second"
},
@jcoveney
jcoveney / avro_issue_2
Last active December 15, 2015 20:19
Avro version: 1.7.4 This doesn't work.
import java.io.FileOutputStream;
import org.apache.avro.Schema;
import org.apache.avro.file.CodecFactory;
import org.apache.avro.file.DataFileWriter;
import org.apache.avro.generic.GenericDatumReader;
import org.apache.avro.generic.GenericDatumWriter;
import org.apache.avro.io.DecoderFactory;
public class Hrm {
public static void main(String[] args) {
import avro.schema
from avro.datafile import DataFileReader, DataFileWriter
from avro.io import DatumReader, DatumWriter
import simplejson as json
a = avro.schema.parse(json.dumps({"name": "hey", "type": "record", "fields": [{"name":"n", "type":"double"}]}))
b = avro.schema.parse(json.dumps({"name": "hey", "type": "record", "fields": [{"name":"n", "type":"int"}]}))
c = avro.schema.parse(json.dumps({"name": "hey", "type": "record", "fields": [{"name":"n", "type":["int","double"]}]}))
writer = DataFileWriter(open("a.avro", "w"), DatumWriter(), a)
writer.append({"n": 1.0})
@jcoveney
jcoveney / gist:5459644
Created April 25, 2013 13:23
This seems to show a bug with the DataFileReader
import java.io.File;
import java.io.FileOutputStream;
import java.io.OutputStream;
import org.apache.avro.Schema;
import org.apache.avro.file.DataFileReader;
import org.apache.avro.file.DataFileWriter;
import org.apache.avro.file.FileReader;
import org.apache.avro.generic.GenericDatumReader;
import org.apache.avro.generic.GenericDatumWriter;
@jcoveney
jcoveney / gist:6094240
Last active December 20, 2015 07:38
An apology to @brucel for an offensive tweet
Bruce,
I do not know you, but I am told by people who care about you that you're a really nice guy. I was also told that a picture I tweeted recently was offensive[1]. I'm not going to try and justify this tweet: it was offensive, and it was wrong. Being a person who has been very fortunately untouched by sexual violence against children, I inconsiderately saw it as a funny subversion of a common sign, and not what it is: graffiti which trivializes the the issue of sexualizing children and sexual harassment or violence. I see that I was wrong, and in the future I will try to be much more sensitive to images which make light of a serious issue: when those who have power over children abuse that power in the worst possible way.
[1] The tweet in question: https://twitter.com/jco/status/360755209632362497
PS I made this apology public because the tweet was public, and others saw it. I'd like for them to know that it is offensive, and that I apologize.
I have a file at: scrooge_sbt/src/main/thrift/com/example/thrift/AStruct.thrift
namespace java com.example.thrift
include "thrift2/BStruct.thrift"
struct AStruct {
1: BStruct a_field
}