Skip to content

Instantly share code, notes, and snippets.

🎯
Focusing

Aleksei Slaikovskii slaykovsky

🎯
Focusing
Block or report user

Report or block slaykovsky

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@slaykovsky
slaykovsky / 0_reuse_code.js
Last active Aug 29, 2015
Here are some things you can do with Gists in GistBox.
View 0_reuse_code.js
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@slaykovsky
slaykovsky / app.js
Created Nov 11, 2014
Almost working
View app.js
var fs = require('fs');
var data = function(dataFile, mapFile, done) {
fs.readFile(dataFile, function(err, dataString) {
if(err) return done(err);
var evaluated = eval(dataString+";data");
var data = evaluated.reduce(function(data, item) {
data[item.key] = item.val;
View app.js
var transformAsync = function(objects, map, data) {
console.log('-----------------------------------');
console.log('Function transformAsync is started.');
var keys = Object.keys(map);
async.each(objects, function(object, done) {
console.log('------------------------------------------------------------');
console.log('Processing object: %s', util.inspect(object, { depth: null }));
console.log('------------------------------------------------------------');
async.each(keys, function(key) {
if(typeof map[key] === 'object') {
View app.js
'use strict';
var util = require('util');
var Combo = function (finalCallback) {
this.finalCallback = finalCallback;
this.map = {};
this.counter = 0;
};
View new_gist_file_0
node app.js
Function transformAsync is started.
-----------------------------------
Start getVal "0:0:0:1", delay 329ms
End getVal "0:0:0:1", delay 329ms
Start getVal "0:0:0:2", delay 1442ms
End getVal "0:0:0:2", delay 1442ms
Start getVal "0:0:0:3:0", delay 977ms
End getVal "0:0:0:3:0", delay 977ms
Start getVal "0:0:0:3:1", delay 478ms
View app.js
'use strict';
var util = require('util');
var randomInt = function (low, high) {
return Math.floor(Math.random() * (high - low) + low);
};
var find = function (key, object, callback) {
object.forEach(function (element) {
View log
Function transformAsync is started.
-----------------------------------
Start getVal "0:0:0:1", delay 854ms
End getVal "0:0:0:1", delay 854ms
Start getVal "0:0:0:2", delay 483ms
End getVal "0:0:0:2", delay 483ms
Start getVal "0:0:0:3:0", delay 428ms
End getVal "0:0:0:3:0", delay 428ms
Start getVal "0:0:0:3:1", delay 1458ms
End getVal "0:0:0:3:1", delay 1458ms
View callback_hell.js
'use strict';
var util = require('util');
var randomInt = function (low, high) {
return Math.floor(Math.random() * (high - low) + low);
};
var find = function (key, object, callback) {
console.log('----------------');
View test.json
{
"display": {
"mainPage": {
"group": [
{
"_ind": null,
"name":"0.1.2.2.0.200.0.*.0",
"element": [
{
"_ind": null,
@slaykovsky
slaykovsky / new_test.json
Created Nov 20, 2014
Another testing map
View new_test.json
{
"_internal": {
"id": "0:0:0:1",
"type": "0:0:0:2"
},
"geo": {
"latitude": "0:0:0:3:0",
"longitude": "0:0:0:3:1"
},
"system": {
You can’t perform that action at this time.