Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@pghalliday
pghalliday / cascade_chef_attributes.rb
Last active August 29, 2015 14:09
Opcode Chef cascade attribute overrides
#
# What user gets created when `cookbook_c` is applied?
#
# cookbook_a/attributes/default.rb
node[cookbook_a][user] = 'a'
# cookbook_a/recipes/default.rb
user node[cookbook_a][user]
@pghalliday
pghalliday / auto-build-and-deploy-github-pages-with-travis-ci.sh
Last active October 7, 2019 05:54
Auto build and deploy GitHub pages with Travis-CI
#!/bin/bash
set -e
# Deploy built site to this branch
TARGET_BRANCH=master
# Sync the contents of this directory where the site should have been built
SOURCE_DIR=_site
if [ ! -d "$SOURCE_DIR" ]; then
echo "SOURCE_DIR ($SOURCE_DIR) does not exist, build the source directory before deploying"
@pghalliday
pghalliday / 1 test.js
Created November 20, 2012 10:30
node.js windows spawn with cmd /s /c
var http = require('http');
var spawn = require('child_process').spawn;
var child = spawn(
'CMD', [
'/S',
'/C',
'node',
'./child.js'
]
);
@pghalliday
pghalliday / child.js
Created November 18, 2012 19:16
Killing process trees
var http = require('http');
var PORT = 8080;
var server = http.createServer(function(request, response) {
response.end();
});
server.listen(PORT, function() {
console.log('Listening on port ' + PORT);
});
@pghalliday
pghalliday / http-upgrade.js
Created October 26, 2012 15:06
HTTP upgrade to tls
var http = require('http'),
tls = require('tls'),
fs = require('fs'),
crypto = require('crypto');
var PORT = 8080,
SERVER_KEY = fs.readFileSync('./test/keys/server-key.pem'),
SERVER_CERT = fs.readFileSync('./test/keys/server-cert.pem'),
CLIENT_KEY = fs.readFileSync('./test/keys/client-key.pem'),
CLIENT_CERT = fs.readFileSync('./test/keys/client-cert.pem');
@pghalliday
pghalliday / grunt.js
Created October 17, 2012 22:11
grunt-contrib-watch not detecting added files issue
module.exports = function(grunt) {
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.initConfig({
lint: {
files: ['grunt.js', 'src/**/*.js']
},
watch: {
scripts: {
module.exports = function(grunt) {
// Add our custom tasks.
// These include:
// test - Run unit tests with Mocha (overrides the nodeunit test task)
grunt.loadTasks('grunt/tasks');
// Project configuration.
grunt.initConfig({
lint: {
var mongoose = require('./testUtils/mongooseTestWrapper.js'),
Greetee;
exports.setUp = function(callback) {
// reset the schemas to ensure that any changes are picked up by the mongoose singleton
mongoose.resetSchemas();
// add the schemas back again
Greetee = require('./greetee.js');
@pghalliday
pghalliday / MyClass.Test.c
Created June 27, 2012 16:14
Blog - OOOCode - Part 2 - Gist 2
#include "OOOUnitTestDefines.h"
#include "MyClass.h"
OOOTest(MyClass)
{
MyClass * pMyClass = OOOConstruct(MyClass, 5);
MyClass * pMyClassCopy = OOOCall(pMyClass, copy);
/* Check stuff here */
OOOCheck(OOOCall(pMyClass, getMyField) == 5);
@pghalliday
pghalliday / IMyInterface.h
Created June 27, 2012 13:24
Blog - OOOCode - Part 2
#ifndef IMYINTERFACE_H_
#define IMYINTERFACE_H_
#include "OOOCode.h"
#define OOOInterface IMyInterface
OOOVirtuals
OOOVirtual(int, getData);
OOOVirtualsEnd
#undef OOOInterface