This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var es = require("event-stream"); | |
module.exports = function() { | |
return es.map(function(file, callback) { | |
file.contents = new Buffer("(function() {\n" + String(file.contents) + "\n})();"); | |
callback(null, file); | |
}); | |
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var fs = require("fs"), | |
readline = require("readline"); | |
var reader = readline.createInterface({ | |
input: fs.createReadStream("large-file.txt"), | |
output: fs.createWriteStream("/dev/null"), | |
terminal: false | |
}); | |
reader.on("line", function(line) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
angular.module("autoscroll", []) | |
.service("scroller", function() { | |
this.defaultTime = 500; | |
this.scroll = function(element, height, time) { | |
element.animate({ | |
scrollTop: height | |
}, time || this.defaultTime); | |
} | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function debounce(fn, time) { | |
var time = time || 300, | |
scope = this, | |
delay; | |
return function() { | |
var args = arguments; | |
if (delay) clearTimeout(delay); | |
delay = setTimeout(function() { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Function.prototype.addMethod = function(name, method) { | |
var existingMethod = this.prototype[name]; | |
this.prototype[name] = function() { | |
if (method.length == arguments.length) { | |
return method.apply(this, arguments); | |
} else if (typeof existingMethod == "function") { | |
return existingMethod.apply(this, arguments); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function inherit(child, parent) { | |
child.prototype = Object.create(parent.prototype); | |
child.prototype.constructor = child; | |
} | |
var Person = function Person(firstName, lastName) { | |
if (!firstName || !lastName) throw "Primeiro e último nome requerido!"; | |
this.firstName = firstName; | |
this.lastName = lastName; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'rubygems' | |
require 'pcaprub' | |
capture = PCAPRUB::Pcap.open_live('lo0', 65535, true, 0) | |
capture.setfilter('icmp') | |
while 1==1 | |
puts(capture.stats()) | |
pkt = capture.next() | |
if pkt | |
puts "captured packet" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var redis = require("redis") | |
, subscriber = redis.createClient() | |
, publisher = redis.createClient(); | |
subscriber.on("message", function(channel, message) { | |
console.log("Message '" + message + "' on channel '" + channel + "' arrived!") | |
}); | |
subscriber.subscribe("test"); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var async = function(url, callback) { | |
var script = document.createElement("script"); | |
script.src = url; | |
if (callback != null) { | |
callback.done = false; | |
script.onreadystatechange = s.onload = function() { | |
var state = script.readyState; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def password_prompt(message = "Inform your password: ") | |
puts message | |
begin | |
system "stty -echo -icanon" | |
gets.rstrip | |
ensure | |
system "stty echo icanon" | |
end | |
end |