Skip to content

Instantly share code, notes, and snippets.

Carl Byström cgbystrom

Block or report user

Report or block cgbystrom

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@cgbystrom
cgbystrom / BUILD
Created Nov 9, 2017
Minimal Go app built with Bazel
View BUILD
package(default_visibility = ["//visibility:public"])
load("@io_bazel_rules_go//go:def.bzl", "go_prefix", "go_binary")
go_prefix("helloworld")
go_binary(
name = "helloworld",
srcs = ["helloworld.go"],
)
@cgbystrom
cgbystrom / StarWarsSchema.scala
Created Jul 16, 2015
Testing ways of mapping a GraphQL schema on to Scala's type system. See https://github.com/hrosenhorn/graphql-scala for more details.
View StarWarsSchema.scala
// 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 {
View keybase.md

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 / canvas-logger.js
Created Feb 16, 2015
Log calls made to HTML Canvas context (only works with 2D)
View canvas-logger.js
function hookCanvasGetContext () {
var ctxFns = [
'fillRect',
'save',
'restore',
'scale',
'rotate',
'translate',
'transform',
'setTransform',
@cgbystrom
cgbystrom / npm-linked-pkgs.js
Created Oct 15, 2014
Get a list of all NPM linked packages
View npm-linked-pkgs.js
var util = require('util');
var exec = require('child_process').exec;
function getNpmLinkedPackages (callback) {
exec('npm list --global', function (error, stdout, stderr) {
if (error) return callback(error);
if (stderr.length > 0) return callback(stderr);
var pkgs = stdout
.split('\n')
@cgbystrom
cgbystrom / cors_middleware.py
Created Jun 27, 2012
WSGI middleware for serving CORS compatible requests
View cors_middleware.py
class CORSMiddleware(object):
"""Enable serving of CORS requests (http://en.wikipedia.org/wiki/Cross-origin_resource_sharing)"""
ALLOW_ORIGIN = "*"
ALLOW_HEADERS = "Origin, X-Requested-With, Content-Type"
def __init__(self, app):
self.app = app
def __call__(self, environ, start_response):
@cgbystrom
cgbystrom / parse_route53_usage.py
Created Mar 5, 2012
Prints usage for Amazon Route 53 zones for a given time period
View parse_route53_usage.py
"""
Prints usage for Route 53 for a given time period
(exported from the Amazon Route 53 usage console).
"""
import csv
route53_reader = csv.reader(open('route_53_usage_february_2012.csv', 'rb'), delimiter=',', quotechar='|')
route53_reader.next() # Skip header
zone_lookup = dict('INSERT_ZONE_ID'='mydomain.com')
@cgbystrom
cgbystrom / LatencySimulatorHandler.java
Created Oct 31, 2011
Netty event latency simulator
View LatencySimulatorHandler.java
import org.jboss.netty.channel.*;
import org.jboss.netty.util.HashedWheelTimer;
import org.jboss.netty.util.Timeout;
import org.jboss.netty.util.Timer;
import org.jboss.netty.util.TimerTask;
import java.util.concurrent.TimeUnit;
/**
* Simulates latency of Netty events
@cgbystrom
cgbystrom / actstream.py
Created Oct 12, 2011
Simple proof-of-concept implementing an activity stream on top of Cassandra
View actstream.py
# Naive implementation of an activity stream service using Cassandra.
# Just a proof of concept and not anything that is for production use.
# Probably flawed in many ways like proper key usage, writing and features.
import pycassa
import datetime
import uuid
pool = pycassa.connect('Actstream')
@cgbystrom
cgbystrom / beaconpush-toolbar.js
Created Jul 12, 2011
Bookmarklet toolbar for Beaconpush Client
View beaconpush-toolbar.js
(function (){
/*!
* jQuery JavaScript Library v1.6.2
* http://jquery.com/
*
* Copyright 2011, John Resig
* Dual licensed under the MIT or GPL Version 2 licenses.
* http://jquery.org/license
*
* Includes Sizzle.js
You can’t perform that action at this time.