Skip to content

Instantly share code, notes, and snippets.

View azasypkin's full-sized avatar

Aleh Zasypkin azasypkin

View GitHub Profile
@azasypkin
azasypkin / map-reduce.js
Last active March 17, 2017 14:08
Javascript MapReduce example
const map = new Map([[1, true], [2, true], [3, false], [4, false], [5, true]]);
const processedMap = Array.from(map.entries())
.map(([key, value]) => [value, key])
.reduce((acc, [key, value]) => acc.set(key, value + (acc.get(key) || 0)), new Map());
console.log('---------- Original Map ----------');
for (const [key, value] of map.entries()) {
console.log(`key: ${key}, value: ${value}`);
}
Setup RaspberryPi:
mkdir -p /etc/ppp/scripts
cat > /etc/ppp/scripts/ppplogin <<EOF
#!/bin/sh
# ppplogin - script to fire up pppd on login
# Disable other users to write to the tty.
mesg n
@azasypkin
azasypkin / WebSocketServer.js
Last active August 29, 2015 14:11
FxOS WebSocketServer draft
/* exported WebSocketUtils */
(function(exports) {
'use strict';
exports.WebSocketUtils = {
/**
* Mask every data element with the mask (WebSocket specific algorithm).
* @param {Array} mask Mask array.
* @param {Array} array Data array to mask.