Skip to content

Instantly share code, notes, and snippets.

View send2moran's full-sized avatar
🎯
Focusing

Moran Helman send2moran

🎯
Focusing
  • Tel Aviv, Israel
View GitHub Profile
@send2moran
send2moran / transcodeVideo.js
Last active August 29, 2015 14:15 — forked from Marak/transcodeVideo.js
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"
});
function qs(name) {
name = name.replace(/[\[]/, "\\[").replace(/[\]]/, "\\]");
var regex = new RegExp("[\\?&]" + name + "=([^&#]*)"),
results = regex.exec(location.search);
return results === null ? "" : decodeURIComponent(results[1].replace(/\+/g, " "));
}
@send2moran
send2moran / gist:6b1660ec83310e8ec94b
Created August 12, 2014 08:12
We need to make sure that the new operator is always used.
function User(first, last){
if ( !(this instanceof User) )
return new User(first, last);
this.name = first + " " + last;
}
var name = "Resig";
var user = User("John", name);
@send2moran
send2moran / gist:9fcdde24645c6ef1e5b1
Created July 12, 2014 09:33
Generic arguments swapValues function
var arr = [1,2,3,4];
function swapValues(){
return [].slice.call(arguments).reduce(function(a, b) {return a.concat(b);}).reverse();
}
arr = swapValues(arr,5);
console.log(arr)
@send2moran
send2moran / gist:d95f91cc4213817d4442
Created July 9, 2014 19:18
JS OOP Layer 4 , super const and sub const
function Person(name){
this.name = name;
}
Person.prototype.say = function(){
console.log("hi");
}
function CTO(){
Person.call(this,"dd")
var globals = {
isUndefined: function (o) {
return (o === undefined);
},
isNull: function (o) {
return (o === null);
},