Skip to content

Instantly share code, notes, and snippets.

View .gitignore
.DS_Store
*.log
tmp/
@Marak
Marak / imageResize.js
Last active Aug 29, 2015
Resize a remote image
View imageResize.js
var gm = require('gm');
module['exports'] = function resizeImage (hook, callback) {
hook.debug('Opening image stream');
var readStream = hook.open(hook.params.image);
hook.debug('Sending image/png header');
hook.res.writeHead(200, { 'Content-Type': 'image/png' });
@Marak
Marak / mergeHooks.js
Last active Aug 29, 2015
Merge multiple Hooks into a single Hook
View mergeHooks.js
var http = require('http');
module['exports'] = function recieveHttp (hook) {
var hook2 = hook.open('http://hook.io/Marak/echo?foo=bar');
var hook3 = hook.open('http://hook.io/Marak/echo');
var hooks = 2;
function complete() {
@Marak
Marak / pipeHook.js
Last active Aug 29, 2015
Pipe Hooks into each other
View pipeHook.js
module['exports'] = function pipeHook (hook) {
hook.debug('Opening echo hook with some data');
var hook2 = hook.open('http://hook.io/Marak/echo?foo=bar');
hook2.write('hello!');
hook2.pipe(hook.res);
};
@Marak
Marak / gist:39bb1d9dfb84d8b1074e
Created Nov 5, 2014
cat image to hook.io, rotate, pipe to new file locally
View gist:39bb1d9dfb84d8b1074e
cat cat.jpg | curl --header "content-type: application/octet-stream" --data-binary @- http://hook.io/Marak/image/rotate > upsidedowncat.jpg
View hookio-geocoder.js
/**
* Geocoder
*
* You pass it an address and it returns a geocoded response. You will need
* a Geocodio API Key.
*
* @param {string} api_key Your geocodio API Key
* @param {string} address An address.
*
* curl--data 'api_key=XXXXX&address=123 Maple Lane, Everywhere USA' http://hook.io/desmondmorris/geocoder
View hookio-geocoder.js
/**
* Geocoder
*
* You pass it an address and it returns a geocoded response. You will need
* a Geocodio API Key.
*
* @param {string} api_key Your geocodio API Key
* @param {string} address An address.
*
* curl--data 'api_key=XXXXX&address=123 Maple Lane, Everywhere USA' http://hook.io/desmondmorris/geocoder
@Marak
Marak / simpleHook.js
Last active Aug 29, 2015
setting an Theme View for a hook.io hook
View simpleHook.js
module['exports'] = function simpleHook (hook) {
hook.res.end('Request ended');
};
module['exports'].theme = "http://hook.io/themes/simple/index.html";
View hookio-geocoder.js
/**
* Geocoder
*
* You pass it an address and it returns a geocoded response. You will need
* a Geocodio API Key.
*
* @param {string} api_key Your geocodio API Key
* @param {string} address An address.
*
* curl--data 'api_key=XXXXX&address=123 Maple Lane, Everywhere USA' http://hook.io/desmondmorris/geocoder
View hookio-geocoder.js
/**
* Geocoder
*
* You pass it an address and it returns a geocoded response. You will need
* a Geocodio API Key.
*
* @param {string} api_key Your geocodio API Key
* @param {string} address An address.
*
* curl--data 'api_key=XXXXX&address=123 Maple Lane, Everywhere USA' http://hook.io/desmondmorris/geocoder