Skip to content

Instantly share code, notes, and snippets.

-----BEGIN PGP PUBLIC KEY BLOCK-----
Version: Mailvelope v1.5.1
Comment: https://www.mailvelope.com
xsFNBFe98WgBEAClcLt6EUSxeD/tOptUMo0WTSaXPsKcMh+lbDoURi3MzIEw
hGbOMurD11FG8Hcr039MgvUpP8P+WFTb+vrz4lMz/sRJ/bHlB3+NptU7fZIt
vjL+LS7v6eMw0o6aSOZ2S19+PE7ri7Q8PQjXZk4aZk7YucW+x/ANtwFNDvfI
sCJrho0bHQXs5vbv/P1768WTXHO/kL528SKNFylt4eHaUBgmftZjutpPu0bP
ulxplmmQryjOkohHWHJKn1sUnOAVteK3vzYkXyQy9tkyQP4wG6ga+5nI33W8
P6YlVkBODj8CKOGyrh9yEmyyENltqnOsBeZr6vbju/u112/iJdqwhfe27MLy
@adparadise
adparadise / growl.sh
Created January 7, 2016 15:32
Display a growl notification on OSX from command line.
#!/bin/bash
title=$1
shift
if [ "$title" == "" ]; then
title="Finished"
fi
body=$1
@adparadise
adparadise / grunt.js
Created November 2, 2012 23:21
Grunt watch task configuration
watch: {
scripts: {
files: "src/**/*.js",
tasks: "concat"
}
}
@adparadise
adparadise / grunt.js
Created November 2, 2012 23:19
Grunt custom task
module.exports = function(grunt) {
function custom () {
console.log(this.data.variable);
};
grunt.initConfig({
custom: {
dist: {
variable: 'value'
}
@adparadise
adparadise / grunt.js
Created November 2, 2012 23:17
Grunt concatenation
module.exports = function(grunt) {
grunt.initConfig({
concat: {
dist: {
src: ['src/util.js',
'src/project.js',
'src/execute.js'],
dest: 'dist/project.js'
}
}
@adparadise
adparadise / index.js
Created November 2, 2012 23:16
Node proxy, cache busting
chunkString = chunkString.replace(/src="(.*\.js)"/,
'src="$1?cb=' + Math.random() + '"');
chunkString = chunkString.replace(/href="(.*\.css)"/,
'href="$1?cb=' + Math.random() + '"');
@adparadise
adparadise / index.js
Created November 2, 2012 23:04
Proxy server, serve transformed HTML
var Transform = require('readable-stream/transform.js');
function serveTransformedHTML (httpRequest, httpResponse) {
var remoteRequest, transform, remoteURL;
console.log("transforming: " + httpRequest.url);
transform = new Transform();
transform._transform = function (chunk,
outputFunction,
callback) {
@adparadise
adparadise / index.js
Created November 2, 2012 22:56
Proxy server, transform html refactoring
function serveViaProxy (httpRequest, httpResponse) {
if (/\.html/.test(httpRequest.url)) {
serveTransformedHTML(httpRequest, httpResponse);
} else {
serveUnalteredViaProxy(httpRequest, httpResponse);
}
}
@adparadise
adparadise / index.js
Created November 2, 2012 22:55
Proxy server, serving a local file
var mime = require('mime');
function serveLocalFile (httpRequest, httpResponse, filename) {
console.log("local: " + httpRequest.url);
var send404 = function () {
httpResponse.setHeader('Content-Type', 'text/html');
httpResponse.write("NOT FOUND: " + httpRequest.url);
httpResponse.end();
};
@adparadise
adparadise / index.js
Created November 2, 2012 22:53
Proxy server, local fileserve refactoring
var localFiles = {
"/js/working.js": "local/working.js"
};
function server (httpRequest, httpResponse) {
var filename = localFiles[httpRequest.url];
if (filename) {
serveLocalFile(httpRequest, httpResponse, filename);
} else {
serveViaProxy(httpRequest, httpResponse);