Skip to content

Instantly share code, notes, and snippets.

Keybase proof

I hereby claim:

  • I am cgbystrom on github.
  • I am cgbystrom (https://keybase.io/cgbystrom) on keybase.
  • I have a public key whose fingerprint is DB53 8B7D E338 2CC6 2464 A30C 39BE BCB1 2F5B EF1A

To claim this, I am signing this object:

@cgbystrom
cgbystrom / StarWarsSchema.scala
Created July 16, 2015 17:31
Testing ways of mapping a GraphQL schema on to Scala's type system. See https://github.com/hrosenhorn/graphql-scala for more details.
// An example for how to map a GraphQL schema on to Scala's type system.
// Work in progress and still lots of unknowns but the great benefit we are after is true type safety at compile time.
// Tries to mimic the original Star Wars schema found in graphql-js reference impl.
// The schema below does not deal with Futures at all but it something we definitively need to support.
import scala.annotation.StaticAnnotation
// Test fixture data
object Data {
import java.net.InetSocketAddress;
import java.util.concurrent.Executors;
import java.util.concurrent.atomic.AtomicInteger;
import org.jboss.netty.bootstrap.ServerBootstrap;
import org.jboss.netty.channel.socket.nio.NioServerSocketChannelFactory;
import org.jboss.netty.channel.*;
import static org.jboss.netty.channel.Channels.pipeline;
import org.jboss.netty.handler.execution.OrderedMemoryAwareThreadPoolExecutor;
import org.jboss.netty.handler.execution.ExecutionHandler;
import java.net.InetSocketAddress;
import java.net.URI;
import java.util.concurrent.Executors;
import org.jboss.netty.bootstrap.ClientBootstrap;
import org.jboss.netty.channel.ChannelFactory;
import org.jboss.netty.channel.socket.nio.NioClientSocketChannelFactory;
import org.jboss.netty.handler.codec.http.DefaultHttpRequest;
import org.jboss.netty.handler.codec.http.HttpHeaders;
import org.jboss.netty.handler.codec.http.HttpMethod;
# A simple script to test memory allocation/deallocation in Python
#
# When run under Win32 with Python 2.6.2 (r262:71605, Apr 14 2009, 22:40:02)
# [MSC v.1500 32 bit (Intel)]
# it will after each allocation release all memory back the OS.
#
# However, when run under Linux/RHEL5 with
# Python 2.6 (r26:66714, Jun 15 2009, 17:33:43)
# [GCC 4.1.2 20071124 (Red Hat 4.1.2-42)]
# it never releases the memory again, thus eating more and more memory.
import time
time.sleep(123)
import locust
import gevent
from clients import HTTPClient
from gevent import wsgi
# Defines the behaviour of a locust (aka a website user :)
def website_user(name):
c = HTTPClient('http://localhost:8088')
for i in range(0, 10):
c.get('/fast', name='Fast page') # Request the fast page
/**
* Small patch by Carl Byström to make the readLine non-greedy.
*
* The MIT License
*
* Copyright (c) 2009 Adam MacBeth
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
public function generateUri(protocol:String = "ws"):String {
var uri:String = protocol + "://" + host + "/spheres/" + apiKey + "/users/" + user;
var params:Array = ['authToken=t'];
if (sequenceId > 0) { params.push("sequenceId=" + sequenceId); }
if (channels && channels.length > 0) { params.push("channels=" + channels.join(',')); }
if (params.length > 0) {
uri += "?";
uri += params.join('&');
}
Ludwig Bell - Silvertejp
http://open.spotify.com/track/1yuUvo5DA0QqmKGPPpZlFF
Capo 5
(Ackord relativt capo)
F/C x33210
C x32013
G 11 32301x
G 320013