Skip to content

Instantly share code, notes, and snippets.

@niallo
niallo / gist:5288738
Last active Dec 15, 2015
docker shell interaction oddity
View gist:5288738
Hangs:
$ cat > builder.sh
apt-get update
apt-get install -y wget
wget --help
$ docker run -i -t base /bin/bash < builder.sh
Doesn't hang:
@niallo
niallo / strider-custom.json
Created Mar 21, 2013
Example of a strider-custom.json for a Go project
View strider-custom.json
{
"prepare":"GOROOT=/opt/node/go GOBIN=/opt/node/bin/go make",
"test":"GOROOT=/opt/node/go GOBIN=/opt/node/bin/go make test",
"deploy":"echo a custom deploy command executed on test success"
}
@niallo
niallo / app.js
Created Mar 2, 2013
Quick and dirty landing page & contact form server in node.js, uses hapi.js, swig and nodemailer.
View app.js
var mailer = require('nodemailer')
var Hapi = require('hapi')
var util = require('util')
var template = require('swig')
var path = require('path')
var PORT = process.env.PORT || 8080
var server = new Hapi.Server(PORT)
template.init({
View mongolab-rest-api.php
<?php
// Get this at your MongoLab.com user page
$MONGOLAB_API_KEY = 'XXXXXXXXXXXXXX';
$DB = 'mydb';
$COLLECTION = 'mycollection';
$name = $_POST['fullName'];
$email = $_POST['email'];
$phone = $_POST['phoneNumber'];
$src = $_POST['src'];
View gist:3868709
//
// Node Child Process Spawn() race bug
//
// Triggerable on:
// Node 0.8.11 / OS X 10.8.2 / MBP 13" 2011 (4 cores)
// Doesn't seem to happen on:
// Node 0.8.11 / Ubuntu 10.04 LTS / EC2 Medium (1 core)
var assert = require('assert')
@niallo
niallo / gist:3863486
Created Oct 10, 2012
node 0.8.11 stdout/stderr setEncoding('utf8') strangeness
View gist:3863486
var assert = require('assert')
var spawn = require('child_process').spawn
function runTest(cb) {
var proc = spawn("/usr/bin/env", [], {env:{foo:"bar"}})
proc.stdoutBuf = ""
proc.stderrBuf = ""
proc.stdmergedBuf = ""
@niallo
niallo / gist:3484450
Created Aug 26, 2012
project type detection heuristic predicate
View gist:3484450
// Detection predicate for Python language & known frameworks
{
// "exists" property can be a glob as supported by node-glob
// https://github.com/isaacs/node-glob
//
// "grep" property is a JavaScript regular expression as described at
// https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/RegExp
// grep looks for the regular expression inside of the
// Array predicates have an implicit OR
@niallo
niallo / gist:3109252
Created Jul 14, 2012
Parse Github `Links` header in JavaScript
View gist:3109252
/*
* parse_link_header()
*
* Parse the Github Link HTTP header used for pageination
* http://developer.github.com/v3/#pagination
*/
function parse_link_header(header) {
if (header.length == 0) {
throw new Error("input must not be of zero length");
}
@niallo
niallo / cal.c
Created Jul 10, 2012
"cal" program from V6 AT&T UNIX (release May 1975)
View cal.c
char dayw[]
{
" S M Tu W Th F S"
};
char *smon[]
{
"Jan", "Feb", "Mar", "Apr",
"May", "Jun", "Jul", "Aug",
"Sep", "Oct", "Nov", "Dec",
};
@niallo
niallo / gist:3029840
Last active Oct 1, 2017
Sample Strider Webhook Payload
View gist:3029840
{ "test_results":
{ "deploy_exitcode": null,
"finish_time": "2012-06-29T00:19:26.622Z",
"repo_url": "https://github.com/niallo/gh-markdown-cli",
"start_time": "2012-06-29T00:19:04.538Z",
"github_commit_id": "f84bda271dc884fd6b2c0badc001f8fefcacdc9f",
"test_exitcode": 0
}
}