Skip to content

Instantly share code, notes, and snippets.

@pghalliday
pghalliday / Main.c
Created June 16, 2012 10:00
Object Oriented OCode Boiler Plate
#include "opentv.h"
#include "assert.h"
#include "MyClass.h"
/* This method just waits for a quit message and then exits the application */
static void Main_waitToExit(void)
{
while (TRUE)
{
#define MY_MACRO(FUNCTION_NAME, FORMAT, ARGS...) FUNCTION_NAME(FORMAT , ##ARGS)
@pghalliday
pghalliday / FailsToExpand.c
Created June 23, 2012 11:20
Macro Pasting Hell
#define CALLONE(FUNCTION, ARGS...) FUNCTION(1 , ##ARGS)
CALLONE(add, CALLONE(addOne));
/* expands to */
add(1, CALLONE(addOne));
@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
@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);
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');
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: {
@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: {
@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 / 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);
});