Skip to content

Instantly share code, notes, and snippets.

View dberesford's full-sized avatar

Damian Beresford dberesford

View GitHub Profile
@dberesford
dberesford / gist:28876b39d26b02b7683a
Last active March 27, 2023 13:31
Sample node.js leak detection using memwatch and heapdump
var http = require('http');
var util = require('util');
var heapdump = require('heapdump');
var memwatch = require('memwatch');
var server = http.createServer(function (req, res) {
res.writeHead(200, {'Content-Type': 'text/plain'});
for (var i=0; i<1000; i++) {
server.on('request', function leakyfunc() {
@dberesford
dberesford / gist:4081066
Created November 15, 2012 20:30
How to add a new markdown HTML element to your AngularJS App

First install [https://github.com/coreyti/showdown](showdown js) component:

yeoman install showdown

This adds the showdown component to your App.

Create a new 'markdown' AngularJS Directive:

yeoman init angular:directive markdown
@dberesford
dberesford / gist:968881
Created May 12, 2011 16:32
Sample Node.js code for connecting to Redis Service in CloudFoundry
require.paths.unshift('./node_modules')
var http = require('http');
var fs = require('fs');
var redis = require("redis");
var util = require('util');
var server = http.createServer(function (request, response) {
// Redis local settings, overridden below if we're running in CloudFoundry
var redisPort = 6379;
@dberesford
dberesford / OddsConverter.mobl
Created March 22, 2011 20:59
.mobl file for simple Fractional to Decimal Odds converter
application OddsConverter
import mobl::ui::generic
entity Odds {
traditional: String (searchable)
decimal: String
function toString():String{
return this.traditional + " -> " + this.decimal + " -> " +