Skip to content

Instantly share code, notes, and snippets.

View distributedlife's full-sized avatar

Ryan Boucher distributedlife

View GitHub Profile
@distributedlife
distributedlife / imported.es6
Last active June 1, 2016 01:15
Imports are hoisted in es6
import sinon from 'sinon';
let config = require('./path/to/config');
sinon.stub(config, 'get').returns({ port: 1234 });
import * as database from './path/to/database'
//The port is whatever the default is from config.
@distributedlife
distributedlife / Dockerfile
Last active August 29, 2015 14:23
ensemblejs docker spike
FROM node:latest
MAINTAINER Ryan Boucher [email protected]
RUN npm i ensemblejs -g
ADD game /app/game
ADD gulpfile.js /app/gulpfile.js
ADD package.json /app/package.json
ADD supporting-libs /app/supporting-libs
@distributedlife
distributedlife / immutable_copy.js
Last active August 29, 2015 14:13
Functional, with imperative boundary in js.
var state = {
value: 0
};
var f = function(currentState) {
var newState = copy(currentState); ///copy is magic deep-copy function
newState.value += 1;
return newState;
};
@distributedlife
distributedlife / convert.rb
Created October 13, 2014 15:05
polyline_to_geojson
require 'polylines'
points = Polylines::Decoder.decode_polyline(File.read("data"))
reversed = points.map { |point| [point.last, point.first] }
puts "{\"type\":\"LineString\", \"coordinates\": #{reversed}}"
@distributedlife
distributedlife / code.cc
Created November 30, 2013 09:12
P2 December issue - code
if (collection->getCatalogue()->isMatch((*objectItr)->m_element), true)
{
// we have a match and our catalogue is not updated
}
if (collection->getCatalogue()->isMatch((*objectItr)->m_element, true))
{
// we have a match and our catalogue is updated
}
@distributedlife
distributedlife / folder.text
Last active December 28, 2015 20:48
distributedlife.com blog post snippets
-The test team branch
|-The Name of the System
| |-quick-test
@distributedlife
distributedlife / BatchCatalogue.cpp
Created November 15, 2013 02:31
P2 Magazine - Improve This - December Issue
#include "BatchCatalogue.h"
using namespace icnh::gf ;
const bool BatchCatalogue::isMatch (const BatchableObject* object, const bool checkOnly)
{
if (!object)
{
return false ;
}
@distributedlife
distributedlife / 1.c
Created November 13, 2013 11:26
distributedlife.com blog code samples
void Trim (const char* Bloated, const char* Parameter)
{
long BloatedLength = strlen (Bloated) ;
char* Trimmed = 0 ;
long TrimmedLength = 0 ;
long TrimFromStart = strspn (Bloated, " \t") ;
long TrimFromEnd = 0 ;
@distributedlife
distributedlife / 1.c
Last active December 28, 2015 05:09
distributedlife.com blog code samples
NoDataChanges () ;
@distributedlife
distributedlife / 1.c
Last active December 28, 2015 05:09
distributedlife.com blog code samples
void ConfigureMethod (const char* const Method)
{
lr_save_string (Method, "Method") ;
lr_save_string(lr_eval_string ("{Method}Response"), "Response");
lr_save_string(lr_eval_string ("{Method}Result"), "Result");
}