Skip to content

Instantly share code, notes, and snippets.

View kilink's full-sized avatar

Patrick Strawderman kilink

  • Netflix
  • San Francisco Bay Area
View GitHub Profile
import graphql.parser.InvalidSyntaxException
import graphql.parser.Parser
import graphql.schema.GraphQLSchema
import graphql.schema.idl.RuntimeWiring
import graphql.schema.idl.SchemaGenerator
import graphql.schema.idl.SchemaParser
import graphql.validation.ValidationError
import graphql.validation.Validator
import org.junit.jupiter.api.Test
import org.junit.jupiter.api.fail
import Ember from 'ember';
export default Ember.Controller.extend({
appName: 'Ember Twiddle',
objects: [{name: "foo"}, {name: "bar"}],
actions: {
add() {
this.get('objects').pushObject({name: "baz"});
},
remove() {
import Ember from 'ember';
export default Ember.Controller.extend({
appName: 'Ember Twiddle',
objects: [{name: "foo"}, {name: "bar"}],
actions: {
add() {
this.get('objects').pushObject({name: "baz"});
},
remove() {
@kilink
kilink / mergeDataClass.kt
Last active June 22, 2017 01:51
merge data class with ObjectNode
fun main(args: Array<String>) {
val mapper = ObjectMapper().registerKotlinModule()
val obj = Foo("foo", "bar", 3)
val obj2 = merge<Foo>(obj, mapper.readValue<ObjectNode>("""{"x": "baz", "z": 5}"""))
println("obj=${obj} obj2=${obj2}, obj === obj2 is ${obj === obj2}")
}
fun <T> merge(obj: Any, json: ObjectNode): T {
@kilink
kilink / KotlinDataDeserializer.kt
Created June 22, 2017 01:22
Kotlin data class deserializer
@JsonDeserialize(using = KotlinDataDeserializer::class)
data class Foo(val x: String, val y: String, val z: Int)
class KotlinDataDeserializer : StdDeserializer<Foo>(Foo::class.java) {
override fun deserialize(p: JsonParser, ctxt: DeserializationContext): Foo {
return p.readValueAs(Foo::class.java)
}
override fun deserialize(p: JsonParser, ctxt: DeserializationContext, intoValue: Foo): Foo {
val copy = intoValue::copy
import java.io.IOException
import okhttp3.Call
import okhttp3.Callback
import okhttp3.Response
import rx.Single
fun Call.toSingle(): Single<Response> =
Single.create { subscriber ->
enqueue(object : Callback {
override fun onResponse(call: Call, response: Response) {
@kilink
kilink / OkHttpCompletableFuture.kt
Created February 11, 2017 07:26
OkHttp Java 8 CompletableFuture extension method
import okhttp3.Call
import okhttp3.Callback
import okhttp3.Response
import java.io.IOException
import java.util.concurrent.CompletableFuture
fun Call.executeAsync(): CompletableFuture<Response> {
val future = CompletableFuture<Response>()
enqueue(object : Callback {
override fun onResponse(call: Call, response: Response) {
@kilink
kilink / t.py
Last active September 20, 2015 23:56
local variable string interpolation in Python
import inspect
import re
import sys
class T(object):
pattern = re.compile("#{(.+)}")
currentframe = inspect.currentframe
def __call__(self, template):

Keybase proof

I hereby claim:

  • I am kilink on github.
  • I am kilink (https://keybase.io/kilink) on keybase.
  • I have a public key whose fingerprint is F23F CF51 9040 9BC9 1DEA 0C26 8A40 3841 C80A 0CB5

To claim this, I am signing this object:

import collections
dictionary = """ab
ac
b
xe
e
df
dx
de