Skip to content

Instantly share code, notes, and snippets.

class DefaultXConnector {
// ...
@Override
rx.Observable<JsonObject> getSessionWithTimeout(JsonObject jsonObject, long timeout) {
log.debug('Getting session with timeout {} for query: {} ({}, {})', timeout, jsonObject, this, this.eventBus)
return eventBus.sendWithTimeout(ServiceLocation.BUS_SESSION_SERVICE_LOCATION, jsonObject, timeout).map(body(true))
}
public static <T> Func1<RxMessage<T>, T> body(boolean logMessage) {
return { RxMessage<T> message ->
@jgrgt
jgrgt / package.json
Created March 13, 2015 08:55
Locking up an npm connect proxy
{
"devDependencies": {
"connect": "~3.3.4",
"proxy-middleware": "~0.11.0",
"url": "~0.10.3",
"http": "0.0.0"
},
"scripts": {
"start": "node server.js"
}
@jgrgt
jgrgt / zip-vs-from.groovy
Created September 16, 2015 05:46
Experimenting with flatMap, concat and buffer in RxJava.
@Grab('com.netflix.rxjava:rxjava-joins:0.19.6')
import rx.Observable
import rx.functions.Func1
import rx.functions.Action1
import java.util.concurrent.TimeUnit
def range = new IntRange(5, 0)
range.each { println it}
@jgrgt
jgrgt / main.c
Created October 1, 2010 14:53 — forked from squaredisk/main.c
///////////////////////////////////////////////////////////////////////////////
//
// Simple game where the mission is the correctly estimate the passage of a
// small amount of time
//
// Gareth Williams // SquareDisk // All round, different
//
#include "msp430g2211.h"
# This script connects to an account in your Pidgin and sends an IM message
# to one of your contacts. You can pass the message as the first command
# line argument to the script. The default message is "Poke!". Change the
# NAME, PROTOCOL and TO variables at the beginning of the script to your
# liking. Make sure the account is enabled in your Pidgin or the script
# will fail.
import dbus
import sys
@jgrgt
jgrgt / Carvelang-10
Created November 23, 2010 14:37
10 line Carvelang file.
abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ[]{}()# abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ[]{}()# abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ[]{}()# abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ[]{}()# abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ[]{}()# abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ[]{}()# abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ[]{}()# abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ[]{}()# abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ[]{}()# abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ[]{}()# abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ[]{}()# abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ[]{}()# abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ[]{}()# abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ[]{}()# abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ[]{}()# abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ[]{}()# abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ[]{}()# abcd
[defaults]
# suppress noisy extdiff header message
#cdiff = -q
#import = --no-commit
#backup = --merge
[hooks]
pretxncommit.crlf = python:hgext.win32text.forbidcrlf
# Prevent "hg pull" if MQ patches are applied.
prechangegroup.mq-no-pull = ! hg qtop > /dev/null 2>&1
def i_am_wrong(d=dict()):
key = "results"
if key not in d:
d[key] = list()
d[key].append("Hi!")
return d
print "No problems:"
print i_am_wrong(dict())
print i_am_wrong(dict())
@jgrgt
jgrgt / logstash_pylabs.rb
Created September 14, 2012 09:43
A logstash configuration to track Pylabs 5.1 logs.
input {
stdin {
type => "stdin-type"
}
file {
type => "pylabs"
path => [ "/opt/qbase5/var/log/pylabslogs/*/*.log" ]
}
@jgrgt
jgrgt / pylogcapture.py
Created October 12, 2012 12:17
Pylabs logging Nosetests plugin. Still a WIP!
"""Save at /opt/qbase5/lib/python/site-packages/pylogcapture.py"""
from pylabs import q
from nose.plugins.base import Plugin
from nose.util import ln, safe_str
class PyLogTarget(object):
# TODO: memory management, filtering
enabled = True