Skip to content

Instantly share code, notes, and snippets.

View gist:2818228
var @priv = {};
function Animal() {
priv[this] = {};
priv[this].walked = false;
}
Animal.prototype.walk = function walk() {
console.log('walking...')
priv[this].walked = true
View gist:3374570
int partial_match(char *word_a, char *word_b, int len) {
int res, idx;
res = 0;
for(idx = 0; idx < len; ++idx)
if (word_a[idx] == word_b[idx])
++res;
return res;
}
@soarez
soarez / gist:3481961
Created Aug 26, 2012
EC2 Amazon Linux AMI port prerouting with NAT iptables
View gist:3481961
# List rules
sudo iptables -t nat -L
# Add rule to forward 80 to 3080
sudo iptables -t nat -A PREROUTING -p tcp --dport 80 -j REDIRECT --to-ports 3080
# Will delete all rules from nat table
sudo iptables -F -t nat
@soarez
soarez / gist:3513190
Created Aug 29, 2012
.NET async method
View gist:3513190
public async Task<string> UsersLoginAsync(string login, string password)
{
var url = "login.xml";
var template = @"
<?xml version=""1.0"" encoding=""UTF-8""?>
<credentials>
<login>{0}</login>
<password>{1}</password>
</credentials>
@soarez
soarez / gist:3673845
Created Sep 8, 2012
Old rulio smooth speak module
View gist:3673845
var util = require('util');
var _ = require('lodash');
var liveconf = require('liveconf');
var conf = liveconf('smootSpeak.json');
module.exports = exports = function(client) {
var queues = [
{ regex: /\bsanchez\b/i, text: 'btw I hear that mr Sanchez is an awesome fella' },
View gist:3852067
function randomizeLetters(string) {
var letters = string.split('');
var result = '';
while(letters.length)
result += letters.splice(Math.floor(Math.random() * letters.length), 1)[0];
return result;
}
function jumbleWord(word) {
View 4b238b4c2ae8f5cf409cea5ca214b480b00e1a86_test_results.txt
make -C out BUILDTYPE=Release V=1
LD_LIBRARY_PATH=/Users/Soarez/src/joyent/node/out/Release/lib.host:/Users/Soarez/src/joyent/node/out/Release/lib.target:$LD_LIBRARY_PATH; export LD_LIBRARY_PATH; cd ../.; mkdir -p /Users/Soarez/src/joyent/node/out/Release/obj/gen; python tools/js2c.py "/Users/Soarez/src/joyent/node/out/Release/obj/gen/node_natives.h" src/node.js lib/_debugger.js lib/_linklist.js lib/assert.js lib/buffer.js lib/buffer_ieee754.js lib/child_process.js lib/console.js lib/constants.js lib/crypto.js lib/cluster.js lib/dgram.js lib/dns.js lib/domain.js lib/events.js lib/freelist.js lib/fs.js lib/http.js lib/https.js lib/module.js lib/net.js lib/os.js lib/path.js lib/punycode.js lib/querystring.js lib/readline.js lib/repl.js lib/stream.js lib/string_decoder.js lib/sys.js lib/timers.js lib/tls.js lib/tty.js lib/url.js lib/util.js lib/vm.js lib/zlib.js ./config.gypi src/macros.py
c++ '-D_LARGEFILE_SOURCE' '-D_FILE_OFFSET_BITS=64' '-D_DARWIN_USE_64_BIT_INODE=1' '-DNODE_WANT_INTERNALS=1' '-DARCH="x64
View 4d74a874da3e4fbcb8ac9dc4da56abb9bcd16935_test_results.txt
make -C out BUILDTYPE=Release V=1
LD_LIBRARY_PATH=/Users/Soarez/src/joyent/node/out/Release/lib.host:/Users/Soarez/src/joyent/node/out/Release/lib.target:$LD_LIBRARY_PATH; export LD_LIBRARY_PATH; cd ../.; mkdir -p /Users/Soarez/src/joyent/node/out/Release/obj/gen; python tools/js2c.py "/Users/Soarez/src/joyent/node/out/Release/obj/gen/node_natives.h" src/node.js lib/_debugger.js lib/_linklist.js lib/assert.js lib/buffer.js lib/buffer_ieee754.js lib/child_process.js lib/console.js lib/constants.js lib/crypto.js lib/cluster.js lib/dgram.js lib/dns.js lib/domain.js lib/events.js lib/freelist.js lib/fs.js lib/http.js lib/https.js lib/module.js lib/net.js lib/os.js lib/path.js lib/punycode.js lib/querystring.js lib/readline.js lib/repl.js lib/stream.js lib/string_decoder.js lib/sys.js lib/timers.js lib/tls.js lib/tty.js lib/url.js lib/util.js lib/vm.js lib/zlib.js ./config.gypi src/macros.py
c++ '-D_LARGEFILE_SOURCE' '-D_FILE_OFFSET_BITS=64' '-D_DARWIN_USE_64_BIT_INODE=1' '-DNODE_WANT_INTERNALS=1' '-DARCH="x64
View cb6d084d356da501bbdcfb6d0ac90180e011a9e2_test_results.txt
This file has been truncated, but you can view the full file.
python tools/gyp_node -f make
make -C out BUILDTYPE=Release V=1
cc '-D_DARWIN_USE_64_BIT_INODE=1' '-D_LARGEFILE_SOURCE' '-D_FILE_OFFSET_BITS=64' '-D_GNU_SOURCE' '-DHAVE_CONFIG_H' '-DCARES_STATICLIB' -I../deps/cares/include -I../deps/cares/src -I../deps/cares/config/darwin -Os -gdwarf-2 -mmacosx-version-min=10.5 -arch x86_64 -Wall -Wendif-labels -W -Wno-unused-parameter -fno-strict-aliasing -MMD -MF /Users/Soarez/src/joyent/node/out/Release/.deps//Users/Soarez/src/joyent/node/out/Release/obj.target/cares/deps/cares/src/ares_cancel.o.d.raw -c -o /Users/Soarez/src/joyent/node/out/Release/obj.target/cares/deps/cares/src/ares_cancel.o ../deps/cares/src/ares_cancel.c
@soarez
soarez / answer.js
Created Oct 28, 2012 — forked from tdantas/question.js
programming async trick.
View answer.js
//Question:
// Environment: NodeJS
// Lets suppose that you have a collection of items, and your function must persist all items using the
//database.insert(item, callback ) function. When you finish the task, you should call the callback function.
// If one item raise a error, the callback(err) must be called and never call the callback anymore.
function noop() {}
You can’t perform that action at this time.