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
| { | |
| "_id": "_design/CQS/test10", | |
| "_rev": "1-b906ada82e09f7dd1f85f4f8ee0e1b7b", | |
| "name": "test10", | |
| "ApproximateNumberOfMessages": 0, | |
| "ApproximateNumberOfMessagesNotVisible": 0, | |
| "VisibilityTimeout": 30, | |
| "CreatedTimestamp": "2011-09-12T14:37:35.981Z", | |
| "LastModifiedTimestamp": "2011-09-12T14:37:35.981Z", | |
| "Policy": null, |
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
| pipeline = new Pipeline('test pipeline 2', { | |
| load: loadFunction | |
| , save: saveFunction | |
| }); | |
| pipeline | |
| .on('initial', initialHandler, { | |
| success: 'a' | |
| , condition: function(doc) { | |
| conditionCalled = true; | |
| return true; |
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
| 1.upto 1000 do |exp| | |
| frequencies = {} | |
| 1.upto 5000 do |i| | |
| number = rand(16); | |
| frequency = (frequencies[number] || 0) + 1 | |
| frequencies[number] = frequency | |
| end | |
| squared_sum = (0..15).map {|number| frequencies[number] * frequencies[number] }.reduce(0) {|mem, freq| mem + freq } |
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 child_process = require('child_process'); | |
| function spawn() { | |
| var child = child_process.spawn(...); | |
| child.on('exit', spawn); | |
| } |
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 net = require('net'); | |
| var connectTimes = []; | |
| function connect() { | |
| var socket = new net.Socket({type: 'tcp4'}); | |
| var time = Date.now(); | |
| socket.setTimeout(30000); | |
| //socket.connect(5015, '66.228.62.138'); | |
| socket.connect(5012, 'fragola.sfarm1.com'); |
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 async(i, callback) { | |
| timeout = Math.round(Math.random() * 3000); | |
| setTimeout(function() { | |
| console.log(i + ' is done'); | |
| callback(); | |
| }, timeout); | |
| } |
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
| // NOTE: Fugue *almost* works great. But it doesn't seem to responsd to the USR2 signal correctly | |
| // Try it one more time. | |
| var fugue = require('fugue') | |
| var path = require("path") | |
| var sys = require('sys') | |
| // https://github.com/pgte/fugue | |
| // Send kill -USR2 <PID> to hot reload! 0 downtime. |
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 insertCollection(collection, callback) { | |
| for(var i = 0; i < collection.length; i++) { | |
| (function(i) { | |
| db.insert(collection[i], function(err) { | |
| if (err) { | |
| callback(err); | |
| return; | |
| } | |
| if (i == (collection.length - 1)) { | |
| callback(); |
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 setup(how_many, callback) { | |
| var successful_ones = 0; | |
| for (var i=0; i < how_many; i++) { | |
| db.some_call('name', 'value', function(err) { | |
| if (err) { callback (err); return; }; | |
| successful_ones ++; | |
| if (successful_ones == how_many) { | |
| callback(); | |
| } | |
| }); |
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 USERS = { | |
| 1: {name: 'Pedro', age: 35, sex: 'm'} | |
| , 2: {name: 'John', age: 32, sex: 'm'} | |
| , 3: {name: 'Bruno', age: 28, sex: 'm'} | |
| , 4: {name: 'Sandra', age: 35, sex: 'f'} | |
| , 5: {name: 'Patricia', age: 42, sex: 'f'} | |
| , 6: {name: 'Joana', age: 29, sex: 'f'} | |
| , 7: {name: 'Susana', age: 30, sex: 'f'} | |
| }; |