Skip to content

Instantly share code, notes, and snippets.

View global-local-capture.js
'use strict';
var globalFoo;
function Foo(name) { = name;
function captureGlobalFoo(name) {
globalFoo = new Foo(name);

Cable making service?

Hi all --

Does anyone know someone who can make high quality cables?

I need to make an adapter from a JST-PH 2-pin male connector to a two pin 0.1" female header connector.

To hack up something like this would be trivial, but I need them for a situation where they should look near perfect - for this I came up with:

package hello;
import com.stormpath.sdk.servlet.config.CookieConfig;
public class DelegatingCookieConfig implements CookieConfig {
private final CookieConfig delegate;
public DelegatingCookieConfig(CookieConfig config) {
this.delegate = config;
george-hawkins /
Last active Jun 9, 2016
Accessing Spring properties in a non-Spring application. This test demonstrates creating an application context that doesn't create beans but does setup the environment.
package com.example;
import java.util.Arrays;
import java.util.NavigableSet;
import java.util.Set;
import java.util.TreeSet;
import org.junit.Assert;
import org.junit.Test;
import org.springframework.boot.ApplicationArguments;
View union.scala
def union(that: TweetSet): TweetSet = {
(left union (right union that)) incl elem
// If we have two trees x={{{.a.}b.}c{.d{.e.}}} and y={{{.f.}g.}h{.i{.j.}}} the number of calls to union varies dramatically according to how we order things:
// (left union (right union that)) incl elem // calls=5
// (right union (left union that)) incl elem // calls=5
// (right union (that union left)) incl elem // calls=36
// (left union (that union right)) incl elem // calls=33
// (that union (left union right)) incl elem // calls=26
// (that union (right union left)) incl elem // calls=26
View MonadLawSuite.scala
package mytests
import org.scalatest.FunSuite
class MonadLawSuite extends FunSuite {
// 1. Remind ourselves about associativity.
test("addition is associative") {
val rtl = (1 + 2) + 3
val ltr = 1 + (2 + 3)
george-hawkins /
Created Aug 27, 2016
Do streams involve upfront calculation in Java?
package net.betaengine;
public class StreamCost {
private boolean isPrime(int n) {
System.out.println("Checking if " + n + " is a prime.");
return IntStream.range(2, n).allMatch(x -> n % x != 0);

BLE Nano and the nRF51822 SDK

If you've tried using the nRF51822 SDK with the BLE Nano (after following the RedBearLab guide) you may have come to a dead end.

Even the simplest examples didn't work for me. I assumed I had a dead Nano (despite the upload process seeming to work fine).

The reason turned out to be that the latest SDK versions assume you have a nRF51822 chip with 32KB of RAM rather than the 16KB that the nRF51822 on the Nano has.

James Willcox explains this in a post to the RedBearLab BLE Nano support forum.

View ParallelMergeSortLecture.scala
package week2
import java.util.Arrays
import common.ParallelConstructs._
import scala.util.Random
import org.scalameter._
object ParallelMergeSortLecture extends App {