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
const {fork} = require('child_process'); | |
const child = fork('./foo.js', { | |
stdio: [ | |
0, // Use parent's stdin for child | |
'pipe', // Pipe child's stdout to parent | |
process.stdout // send it to the parents stdout? do whatever really. | |
] | |
}); |
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() { | |
function getChatStats(userid) { | |
return fetch(`http://chat.stackoverflow.com/users/${userid}`) | |
.then(res => res.text()) | |
} | |
function chatStat(msg, cb) { | |
const args = msg.parse(); | |
let [id = msg.get('user_id')] = args; | |
if (!/^\d+$/.test(id)) { | |
id = msg.findUserId(args.length > 1 ? id : args.join(' ')); |
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
const canvas = document.getElementById('canvas'); | |
const context = canvas.getContext('2d'); | |
const width = document.body.offsetWidth; | |
const height = document.body.offsetHeight; | |
canvas.width = width; | |
canvas.height = height; | |
const nodes = []; |
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 getMostOccurancesInArray(array) { | |
const sums = array.reduce((obj, item) => { | |
const key = String(item); | |
obj[key] = key in obj ? obj[key] + 1 : 1; | |
return obj; | |
}, {}); | |
return Object.keys(sums).reduce((array, value, index) => { | |
if (!index) return [value]; | |
if (sums[value] >= sums[array[0]]) { | |
if (sums[value] > sums[array[0]]) { |
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
.robogist-spin { | |
transition: all 500ms linear; | |
} | |
.robogist-spin:hover { | |
transform: rotate(360deg); | |
} |
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
// TODO :: remove dupe triggers | |
const emojiData = [{ | |
"emoji": "😀", | |
"triggers": [":grinning:", ":smile:", ":happy:", ":)"] | |
}, { | |
"emoji": "😬", | |
"triggers": [":grimacing:", ":("] | |
}, { | |
"emoji": "😁", |
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 checkIgnore(id) { | |
return $.post(`/users/thumbs/${id}`, fkey({showUsage:true})); | |
} | |
function ignoreParser(node) { | |
if( !node.classList || !node.classList.contains('user-container') ) return; | |
let id = node.className.match(/user-([0-9]+)/); | |
if( !id ) return; // cases where we match the node but has no user class | |
id = id.pop(); // just want the id. this is very ugly. | |
if( !id ) return console.log('error'); | |
checkIgnore(id).then( ret => { |
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 getColorWeight(clr1, clr2) { | |
return Math.sqrt(Math.pow((clr2.r - clr1.r), 2) + | |
Math.pow((clr2.g - clr1.g), 2) + | |
Math.pow((clr2.b - clr1.b), 2)) | |
} | |
function getClosestColor(clr) { | |
const chosen = { | |
code: null, | |
value: 1e9, |
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
class Terrain { | |
constructor(d) { | |
this.size = Math.pow(2,d) + 1; | |
this.max = this.size - 1; | |
this.map = new Float32Array(this.size * this.size); | |
} | |
get(x,y) { | |
if( x < 0 || x > this.max || y < 0 || y > this.max ) return -1; | |
return this.map[x + this.size * y]; | |
} |
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
import RPi.GPIO as GPIO | |
import time | |
GPIO.setmode(GPIO.BCM) | |
pins = [17,22,23,24] | |
for pin in pins: | |
GPIO.setup(pin, GPIO.OUT) | |
GPIO.output(pin, False) |