Skip to content

Instantly share code, notes, and snippets.

View BoyCook's full-sized avatar

Craig Cook BoyCook

View GitHub Profile
@BoyCook
BoyCook / node_session_redis.js
Created November 18, 2012 22:55
Node.js configuration for session with redis
var RedisStore = require('connect-redis')(express);
app.use(express.cookieParser('appsecret'));
app.use(express.bodyParser());
app.use(express.session({ secret:'appsecret', store:new RedisStore, cookie:{ maxAge:60000, expires: false } }));
app.use(express.cookieSession());
app.use(app.router);
@BoyCook
BoyCook / express_server.js
Last active December 11, 2015 10:29
Node.js express server.js defaults
/*
Server app
*/
var express = require('express');
var app = express();
var port = 3000;
app.configure(function () {
console.log('Doing [default] configure');
app.use(express.static(__dirname + '/public'));
@BoyCook
BoyCook / node_makefile
Last active December 11, 2015 13:18
Makefile for Node.js projects
TESTS = test/spec
REPORTER = spec
XML_FILE = reports/TEST-all.xml
HTML_FILE = reports/coverage.html
test: test-mocha
test-ci:
$(MAKE) test-mocha REPORTER=xUnit > $(XML_FILE)
@BoyCook
BoyCook / npm_tips.sh
Created January 23, 2013 15:17
NPM tips
# Install package to local repo
sudo npm install . -g
# Delete package from local repo
sudo rm -r /usr/local/lib/node_modules/{module}
# Install package from local repo
npm install /usr/local/lib/node_modules/{module}
@BoyCook
BoyCook / blog.js
Last active December 12, 2015 01:39
TiddlyWiki5 server side modules
/*\
title: $:/core/modules/blog.js
type: application/javascript
module-type: server-off
WordPress blog module
\*/
(function(){
@BoyCook
BoyCook / testSpawn.js
Last active December 14, 2015 10:18
Node.js wrapper for starting web app and spawning multiple subprocesses
var spawn = require('child_process').spawn;
var server = require('./server');
var spawns = {};
server.start({port: 8080}, function () {
createSpawn('jasmine-node', [ 'test/spec', '--junitreport', '--forceexit' ], logToConsole, logToConsole);
createSpawn('casperjs', [ 'test', 'test/ui' ], logToConsole, logToConsole);
});
function createSpawn(name, args, stdout, stderr) {
@BoyCook
BoyCook / MessageHelper
Created March 3, 2013 12:22
C# Helper file for using WM_DATACOPY in Win32 API
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.Serialization.Formatters.Binary;
using System.Runtime.InteropServices;
using System.Diagnostics;
public class MessageHelper
{
@BoyCook
BoyCook / ServerITSpec.js
Last active May 14, 2019 18:28
Integration testing a node.js web app with Mocha
var should = require('should');
var request = require('request');
var url = 'http://localhost:8080';
var HttpServer = require('./server').HttpServer;
var server;
describe('HttpServer', function () {
before(function (done) {
server = new HttpServer({port: 8080}).start(done);
@BoyCook
BoyCook / jinx.py
Created July 8, 2013 12:48
TiddlyWeb jinx plugin
def jinx(environ, start_response):
start_response('200', [])
return ['hello world']
def init(config):
config['selector'].add('/jinx', GET=jinx)
#export CATALINA_HOME=/usr/share/tomcat
export MAVEN_OPTS="-Xms512m -Xmx2048m -XX:MaxPermSize=512m"
# export MAVEN_OPTS="-Xms512m -Xmx2048m -XX:MaxPermSize=512m -Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=5005"
export LIQUIBASE_HOME=/usr/share/java/liquibase-2.0.3
export MULE_HOME=/usr/share/java/mule-standalone-3.2.1
export ANT_HOME=/usr/share/ant
export GRAILS_HOME=/usr/share/grails
export REDIS_HOME=/usr/share/redis
export JSCOVERAGE_HOME=/usr/share/jscoverage
export JMETER_HOME=/usr/share/jmeter