This file contains 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
sudo yum install -y make | |
echo 'sleeping for 2 seconds now...' | |
sleep 2 | |
sudo yum install -y git | |
echo 'sleeping for 2 seconds now...' | |
sleep 2 | |
sudo yum install -y gcc-c++ | |
echo 'sleeping for 2 seconds now...' |
This file contains 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
'use strict' | |
const size = 130000 | |
let arr1 = new Array(size) | |
let arr2 = new Array(size) | |
for (let i = 0; i < size; i++) { | |
arr1[i] = i + '' | |
arr2[i] = i + '' |
This file contains 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
'use strict' | |
const size = 10000000 | |
let arr = new Array(size) | |
for (let i = 0; i < size; i++) { | |
arr[i] = i + '' | |
} |
This file contains 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
'use strict' | |
const _ = require('lodash') | |
function intersection(source, target) { | |
let result = [] | |
for (let i = source.length - 1; i >= 0; i--) { | |
let value = source[i] | |
if (target.indexOf(value) > - 1) { | |
result.push(value) |
This file contains 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 toBits(a, res) { | |
if (a === 0) return | |
let r = a % 2 | |
if (r === 0) { res.push(0) } else { res.push(1) } | |
toBits(Math.floor(a / 2), res) | |
} | |
function dec2bin(dec){ | |
return (dec >>> 0).toString(2); | |
} |
This file contains 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 el = {} | |
var props = Object.keys(el) | |
propes.forEach(function (p) { | |
el[p] = function(v) { | |
} | |
}) |
This file contains 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 endsWith(str, endsWith) { | |
return str.substr(str.length - endsWith.length) === endsWith | |
} | |
function startsWith(str, startsWith) { | |
return str.substr(0, startsWith.length) === startsWith | |
} |
This file contains 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 zmq = require('zmq') | |
var socket = zmq.socket('router'); | |
socket.identity = 'server' + process.pid; | |
for (var i = 2; i < process.argv.length; i++) | |
socket.connect('tcp://127.0.0.1:' + process.argv[i]); | |
console.log('connected!'); |
This file contains 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 zmq = require('zmq') | |
var socket = zmq.socket('dealer'); | |
socket.identity = 'client' + process.pid; | |
var value = 0; | |
socket.bind('tcp://127.0.0.1: ' + process.argv[2], function(err) { | |
if (err) throw err; |
This file contains 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
/* | |
* | |
* One requester two responders (round robin) | |
* | |
*/ | |
var cluster = require('cluster') | |
, zeromq = require('zmq') | |
, port = 'tcp://127.0.0.1:12345' | |
, port2 = 'tcp://127.0.0.1:12346'; |