Skip to content

Instantly share code, notes, and snippets.


Darius I. Karel dikarel

View GitHub Profile
dikarel / how-to-pipe.js
Created Oct 17, 2019
How to pipe shell commands in NodeJS
View how-to-pipe.js
// In this example, we use ChildProcess and piping to perform the NodeJS
// version of `find ~/Documents | egrep '\.ts$'`
const ChildProcess = require(“child_process”);
// 1. Start both "find" and "egrep"
// "shell" has to be true, so that we have access to "~"
const find = ChildProcess.spawn("find", ["~/Documents"], { shell: true });
const egrep = ChildProcess.spawn("egrep", ["\\.ts$"], {
shell: true
dikarel / ml5.d.ts
Last active Oct 31, 2020
ml5.js TypeScript definitions draft
View ml5.d.ts
// Not quite there yet, but better than nothing
// TODO: JSDoc, based on website documentation
// TODO: Interface/class types for each of these ML algorithm instances
// TODO: Break this apart into multiple files for readability
// TODO: Test autocomplete in a vanilla JS project
// TODO: Test autocomplete in a TypeScript project
import { MediaElement } from "p5";
export as namespace ml5;
dikarel /
Created Dec 10, 2016
Setting up a Docker machine for corporate environments

Create default Docker machine on VirtualBox with custom settings

You might want to do this to allocate extra RAM and disk size for Docker (esp. when dealing with large container images)

  1. Ensure that there's not yet been a Docker machine called 'default' (docker-machine ls). If so, you should remove it (docker-machine rm default).
    In theory, you can just create a second machine with a different name. This is not recommended since VirtualBox assigns IP addresses to each machine non-deterministically every time you restart your computer, causing docker-machine to choke on TLS cert-related issues
dikarel / hackerrank-util.js
Created Oct 2, 2016
HackerRank utilities
View hackerrank-util.js
// Minified one-liner
var main=d=>{var l=[];return require('readline').createInterface({input:process.stdin}).on('line',i=>l.push(i)).on('close',()=>d(l))}
// Example
main(lines => {
console.log('My lines are', lines)
dikarel /
Last active Oct 2, 2016
Helper classes for HackerRank
# Reads lines from stdin and run specified function
main = (done) ->
lines = []
readline = require 'readline'
readline.createInterface input: process.stdin
.on 'line', (line) -> lines.push line
.on 'close', -> done lines
# Minified one-liner
main=(d)->l=[];require('readline').createInterface(input:process.stdin).on('line',(i)->l.push i).on('close',->d l)
You can’t perform that action at this time.