Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

'use strict';
var globalFoo;
function Foo(name) {
this.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
george-hawkins / hcidump.out
Last active November 25, 2015 17:00
Noble #269
@george-hawkins
george-hawkins / SpringPropertiesTest.java
Last active June 9, 2016 10:07
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;
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
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
george-hawkins / StreamCost.java
Created August 27, 2016 10:44
Do streams involve upfront calculation in Java?
package net.betaengine;
import java.util.stream.IntStream;
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);
}
package week2
import java.util.Arrays
import common.ParallelConstructs._
import scala.util.Random
import org.scalameter._
object ParallelMergeSortLecture extends App {
package week2
object Lecture6 extends App {
def reduceSeg1[A](inp: Array[A], left: Int, right: Int, a0: A, f: (A, A) => A): A = {
var a = a0
var i = left
while (i < right) {
a = f(a, inp(i))
i += 1
}