Skip to content

Instantly share code, notes, and snippets.

View NickHeiner's full-sized avatar
💭
Wubba lubba dub dub!!

Nick Heiner NickHeiner

💭
Wubba lubba dub dub!!
View GitHub Profile
@NickHeiner
NickHeiner / functions-in-functions.js
Created November 15, 2015 18:39
Examples of functions returning functions
// One classic purpose of a function returning a function is to do partial application.
// Let's say we have a function that adds two numbers:
function add(x, y) {
return x + y;
}
// Then, we want to make a function that adds 9000 to the argument:
function itsOver9000(x) {
return add(9000, x);
}
@NickHeiner
NickHeiner / Lessons Learned from Corpionage.md
Created October 17, 2015 14:00
Lessons Learned from Corpionage

** Originally written in Fall 2011. **

Lessons Learned from Corpionage

This semester, I worked on Corpionage, a Facebook game for people who like to mess with their friends. I thought it turned out pretty well, but there are a few key take-aways.

Our general architecture:

Server, UI, and Engine

@NickHeiner
NickHeiner / weka.md
Created October 17, 2015 13:58
Weka's API is Cumbersome

Weka's API is Cumbersome

I've only used Weka a bit, and it appears to be an impressive machine learning toolkit. However, its API is quite a pain to deal with.

Consider the following code that I wrote, which translates from one representation of an example to Instance, used by Weka:

public static Instance getInstance(WeatherLabeledFeatureVector featureVector, Instances instances) {
  Instance inst = new DenseInstance(instances.numAttributes());
  for (int i = 0; i  attInfo, int capacity) {

// ...

> Install-Package NUnit
> Install-Package NUnitTestAdapter
module MainTest
open NUnit.Framework
[<Test>]
let ``When 2 is added to 2 expect 4``() =
Assert.AreEqual(4, 2+2)
[<Test>]
let ``When 2 is added to 2 expect 5``() =
t.test('returns the correct value', function(t) {
t.plan(1);
doAsyncWork().then(function(actualResult) {
t.equal(actualResult, expectedResult);
});
})
it('returns the correct value', function() {
makeServerRequest().then(function(response) {
expect(response.statusCode).to.equal(200);
});
});
it('returns the correct value', function() {
return doAsyncWork().then(function(actualResult) {
expect(actualResult).to.equal(expectedResult);
});
});
it('returns the correct value', function(done) {
doAsyncWork().then(function(actualResult) {
expect(actualResult).to.equal(expectedResult);
}).finally(done);
});
// Some setup code omitted for brevity
nock('https://our-backend-service.opower.it')
.post('/endpoint/we/depend/on')
// Make your test more interesting by declaring which headers you care about
// Nock lets you declare matchers on many aspects of the request
.matchHeader('Content-type', 'application/json')
.reply(200, function(uri, requestBody) {
t.deepEqual(
requestBody,
expectedRequestBody,