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
// Good approach
'use strict';
const coRequest = require('co-request'),
tape = require('tape'),
coTape = require('co-tape'),
makeServer = require('../..');
tape('heartbeat', function(t) {
const app = makeServer();
// 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,
it('returns the correct value', function(done) {
doAsyncWork().then(function(actualResult) {
expect(actualResult).to.equal(expectedResult);
}).finally(done);
});
it('returns the correct value', function() {
return doAsyncWork().then(function(actualResult) {
expect(actualResult).to.equal(expectedResult);
});
});
it('returns the correct value', function() {
makeServerRequest().then(function(response) {
expect(response.statusCode).to.equal(200);
});
});
t.test('returns the correct value', function(t) {
t.plan(1);
doAsyncWork().then(function(actualResult) {
t.equal(actualResult, expectedResult);
});
})
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``() =
> Install-Package NUnit
> Install-Package NUnitTestAdapter
@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) {

// ...

@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