Skip to content

Instantly share code, notes, and snippets.

Avatar
🎯
Focusing

Tom Medema tommedema

🎯
Focusing
View GitHub Profile
View gist:2622837
test :
@NODE_ENV=test
folders = $('find test -type d')
for folder in $folders
do
mocha --ignore-leaks folder
done
View gist:2621673

All application logic is defined using routines. Routines are loaded on runtime and are passed a global event emitter instance, called the mediator.

##Example The following describes an application example structure.

Application objective: create a http server and serve a RESTful API (serves current music stations and the current songs for each station).

###File tree

  • src/ (contains source files)
  • bootstrap.js (initializes the application and loads routines)
View gist:2603686
require('should');
var EventEmitter2 = require('eventemitter2').EventEmitter2
bootutil = require('../src/boot/util');
describe('boot util', function() {
it('should load existing test routines without mediator', function() {
bootutil.loadRoutines(__dirname + '/testroutines-nomediator', function(err, routines) {
err.should.not.exist();
View gist:2601189
require('should');
var bootutil = require('/src/boot/util'),
EventEmitter2 = require('eventemitter2').EventEmitter2;
describe('boot util', function() {
it('should load existing test routines without mediator', function() {
bootutil.loadRoutines('./testroutines-nomediator', function(err, routines) {
err.should.not.exist();
View boot-util-test.js
var vows = require('vows'),
assert = require('assert'),
EventEmitter2 = require('eventemitter2').EventEmitter2,
bootutil = require(__dirname + '/../src/boot/util');
vows.describe('Boot util').addBatch({
'when loading some existing test routines without mediator': {
topic: function() {
bootutil.loadRoutines(__dirname + '/testroutines-nomediator', this.callback);
},
View gist:2008348
//opens the stats collection
var openStats = function(err, stats) {
if (err) return console.log('error opening stats %o', err);
//when a new request occurs
stats.update({name: 'reqcount'}, {'$inc': {value: 1}}, {safe: true}, function() { });
};
//opens the database
var db = new Db('musictv', replSet);
View gist:1522539
{
"ns1:AmplifyResponse": {
"AmplifyReturn": {
"Topics": {
"Domains": [{
"Domain": {
"Name": "Business",
"Value": 10.00
},
"Subdomains": [{
View gist:1521693
net.js:425
this.bytesWritten += data.length;
^
TypeError: Cannot read property 'length' of undefined
at Socket.write (net.js:425:28)
at EventEmitter.<anonymous> (E:\Workspaces\Node.js\stockwiz\src\routines\boi
lerpipe\executor.js:32:26)
at EventEmitter.emit (E:\Workspaces\Node.js\stockwiz\node_modules\mediator\n
ode_modules\eventemitter2\lib\eventemitter2.js:246:22)
at EventEmitter.<anonymous> (E:\Workspaces\Node.js\stockwiz\src\routines\sca
View BoilerpipeCLI.java
import java.net.URL;
import java.util.Scanner;
import de.l3s.boilerpipe.extractors.ArticleExtractor;
public class BoilerpipeCLI {
public static void main(String[] args) throws Exception {
String inputText = "";
Scanner scanner = new Scanner(System.in);
View gist:1362160
2011-11-12 19:21:26,480 DEBUG: updating <jockey.detection.LocalKernelModulesDriverDB instance at 0x175eef0>
2011-11-12 19:21:28,845 DEBUG: reading modalias file /lib/modules/3.0.0-12-generic/modules.alias
2011-11-12 19:21:28,951 DEBUG: reading modalias file /usr/share/jockey/modaliases/b43
2011-11-12 19:21:28,965 DEBUG: reading modalias file /usr/share/jockey/modaliases/disable-upstream-nvidia
2011-11-12 19:21:29,018 WARNING: Could not open DriverDB cache /var/cache/jockey/driverdb-OpenPrintingDriverDB.cache: [Errno 2] No such file or directory: '/var/cache/jockey/driverdb-OpenPrintingDriverDB.cache'
2011-11-12 19:21:29,043 DEBUG: loading custom handler /usr/share/jockey/handlers/sl_modem.py
2011-11-12 19:21:29,072 DEBUG: Instantiated Handler subclass __builtin__.SlModem from name SlModem
2011-11-12 19:21:29,095 DEBUG: Software modem not available
2011-11-12 19:21:29,095 DEBUG: loading custom handler /usr/share/jockey/handlers/fglrx.py
2011-11-12 19:21:29,161 WARNING: modinfo for module fglrx_updates failed: