Skip to content

Instantly share code, notes, and snippets.

View Marak's full-sized avatar

Marak

View GitHub Profile
@Marak
Marak / transcodeVideo.js
Last active January 14, 2019 01:44
Hook for transcoding video streams using FFMpeg
var Transcoder = require('stream-transcoder');
module['exports'] = function transcodeVideoStream (hook) {
var readStream = hook.open(hook.params.video);
hook.debug('Opening read stream to video');
hook.res.writeHead(200, {
"Content-Type": "video/mp4"
});
@Marak
Marak / transform.js
Last active August 26, 2018 13:04
Transform incoming streams of HTTP data
module['exports'] = function logParser (hook) {
// If the hook is not currently streaming, req has already been fully buffered
if (!hook.streaming) {
//
// To test a streaming Hook you can use Curl:
//
// echo "foo" | curl --header "content-type: application/octet-stream" --data-binary @- http://hook.io/Marak/transform
//
return hook.res.end('No streaming request detected. \n\nTo test streaming data to this Hook try running this Curl command: \n\n echo "foo" | curl --header "content-type: application/octet-stream" --data-binary @- http://hook.io/Marak/transform');
@Marak
Marak / mockreadwritestream.js
Created May 20, 2011 06:29 — forked from indexzero/mockreadwritestream.js
A mock stream for node.js that is both Readable and Writeable.
var events = require('events'),
util = require('util');
var MockReadWriteStream = helpers.MockReadWriteStream = function () {
//
// No need to do anything here, it's just a mock.
//
};
util.inherits(MockReadWriteStream, events.EventEmitter);
@Marak
Marak / lol.js
Created August 6, 2012 11:43
A terrible solution for finding network gateway
//
// Since the code to actually figure this out doesn't exist in node yet
//
// see: https://groups.google.com/forum/?fromgroups#!topic/nodejs-dev/QbcnxS0_yyg
//
var guessGateway = function () {
var network = os.networkInterfaces(),
guess = '10.0.0.1';
Object.keys(network).forEach(function(interfaces){
module['exports'] = function (hook) {
var rest = require('restler'),
moment = require('moment');
var myGender = 'male',
myCountry = 'United States',
myDOB = '1986-05-01';
var currentDate = moment();
@Marak
Marak / datastoreExample.js
Last active June 18, 2016 04:17
hook.io example microservice for using hook.io's cloud datastore API
module['exports'] = function datastoreExample (hook) {
var res = hook.res,
req = hook.req,
store = hook.datastore;
store.set('mykey', { foo: "bar" }, function(err, result){
if (err) { return res.end(err.message); }
store.get('mykey', function(err, result){
if (err) { return res.end(err.message); }
res.end(JSON.stringify(result, true, 2));
});
https://frameio.geckoboard.com/dashboards/026BB9398258380D
@Marak
Marak / index.html
Created March 17, 2016 03:10
quick template
<h1>hello world</h1>
@Marak
Marak / chinese-lorem-translated.js
Last active February 8, 2016 03:12
translation from pull request to faker.js for adding chinese lorem ipsum
module [ "exports"] = [
'Abba', 'Achang', 'A big,' 'Adi', 'fools', 'hooligan', 'Afu', 'princes', 'donkey', 'Liza', 'Allah' 'Ali', 'Mom,' 'Oman', 'Mei', 'Niang'
'Lady', 'Auntie', 'flattery', 'Egypt', 'suffer side', 'one by one', 'beaten', 'wait until', 'hungry', 'one by one', 'survive', ' suffer shoulder, '' near to ',' scolded '' Punished ',' next '
'Beating', 'Damn,' 'Oh,' 'cancer', 'cancer', 'cancer', 'Airan', 'Wormwood', 'Fitch', 'Ai Peng', 'moxa', ' Artemisia ',' be too embarrassed to mention ',' find it difficult to ',' in the way ',' eyesore '
'Due', 'pet name', 'love', 'love', 'caress',' patriotism ',' loving ',' love ',' love ',' lovingly ',' love ',' Amy ',' loving ',' love ',' daughter ',' wife '
'Love', 'love', 'love that', 'hear', 'care', 'small love', 'love', 'love and hate', 're-love', 'love child', 'Pass' 'horse', 'saddle', 'amino' 'ammonia', 'ammonia'
'Placement', 'Anderson', 'Andhra', 'stable', 'settled', 'placed', 'law-abiding', 'appease', 'well', 'Anhui', 'settle down', 'quiet'
@Marak
Marak / gist:8062641
Created December 20, 2013 22:28
building dogecoin on ubuntu 12.04
sudo apt-get update
sudo apt-get install -y git-core build-essential libssl-dev libboost-all-dev libboost1.48-all-dev libdb5.1-dev libdb5.1++-dev libgtk2.0-dev
git clone https://github.com/dogecoin/dogecoin.git
cd dogecoin/src
make -f makefile.unix clean; make -f makefile.unix USE_UPNP= dogecoind