Skip to content

Instantly share code, notes, and snippets.

View Lokua's full-sized avatar
🐐
 

Joshua Kleckner Lokua

🐐
 
View GitHub Profile
export function listNodeMidiPorts(portType) {
const io = new require('midi')[portType]()
return Array(io.getPortCount())
.fill(null)
.map((_, index) => io.getPortName(index))
}
export function getNodeMidiPortNumberByName(portType, name) {
const io = new require('midi')[portType]()
@Lokua
Lokua / .babelrc
Created November 7, 2017 04:35
babel-plugin-module-resolver snippet
{
"plugins": [
[
"module-resolver",
{
"root": ["./src"],
"alias": {
"^\\$(.+)": "./src/\\1"
}
}
@Lokua
Lokua / recess.txt
Created September 25, 2017 14:04
CSS Orders
position
top
right
bottom
left
z-index
display
float
width
height
@Lokua
Lokua / aws-cli-snippets.md
Last active September 24, 2017 22:31
aws cli snippets
@Lokua
Lokua / .editorconfig
Created September 9, 2017 17:23
editorconfig
root = true
[*]
indent_style = space
indent_size = 2
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
max_line_length = 100
@Lokua
Lokua / 5to6.js
Created July 18, 2017 21:05
convert es5 js to es2015 using lebab and prettier
// requires node > 8
const lebab = require('lebab')
const prettier = require('prettier')
const util = require('util')
const readFile = util.promisify(require('fs').readFile)
;(async () => {
try {
const input = process.argv.slice(2)[0]
const body = await readFile(input, 'utf8')
@Lokua
Lokua / omit.js
Created May 20, 2017 23:26
shallow copy of object without provided keys
function omit(keys, obj) {
return keys.reduce((o, k) => {
o[k] = obj[k]
return o
}, {})
}
@Lokua
Lokua / chunk.js
Created April 20, 2017 05:33
chunk
function chunk(array, chunkSize) {
if (!chunkSize) throw new Error('chunkSize must be greater than 0')
return array.reduce((chunked, value, i) => {
if (!(i % chunkSize)) chunked.push([])
chunked[chunked.length - 1].push(value)
return chunked
}, [])
}
@Lokua
Lokua / quick-benchmark.js
Created April 19, 2017 02:32
quick benchmark.js
const { Suite } = require('benchmark')
const test = (specs = {/*name:fn*/}) => {
const suite = new Suite()
Object.keys(specs).forEach(name => suite.add(name, specs[name]))
suite.on('cycle', e => console.info(String(e.target)))
suite.on('complete', () => console.info(`Fastest is ${suite.filter('fastest').map('name')}`))
suite.run({ async: false })
}
// // EXAMPLE:
@Lokua
Lokua / .hyper.js
Created March 11, 2017 05:34
my hyperterm config
const md = mdColors()
const LIGHT = false
module.exports = {
config: {
fontSize: 12,
fontFamily: `"Fira Code", "Droid Sans Mono", "DejaVu Sans Mono", "Lucida Console", monospace`,
// `BEAM` for |, `UNDERLINE` for _, `BLOCK` for █
cursorShape: `BEAM`,