Skip to content

Instantly share code, notes, and snippets.

Avatar
🐐
 

Joshua Kleckner Lokua

🐐
 
View GitHub Profile
@Lokua
Lokua / package.json
Last active Feb 13, 2020
Barebones testing and test-runner for node >= 13
View package.json
{
"scripts": {
"test": "node ./path-to/test-runner.mjs"
}
}
@Lokua
Lokua / recursively-remove-node-modules.sh
Last active Sep 3, 2019
recursively removes node_modules folders
View recursively-remove-node-modules.sh
#! /bin/bash
find . -name 'node_modules' -type d -prune -exec rm -rf '{}' +
@Lokua
Lokua / wav2mp3.sh
Last active Jul 20, 2019
converts all wav files in cwd to highest quality lame mp3
View wav2mp3.sh
#!/bin/bash
function wav2mp3() {
for filename in *.wav; do
echo wav2mp3: converting $filename
mp3_filename="${filename[@]/%wav/mp3}"
lame --preset insane "$filename" "$mp3_filename"
echo wav2mp3: finished converting $filename
echo
done
@Lokua
Lokua / watch.js
Created Jan 3, 2019
starter script to restart electron on main process file change
View watch.js
const { spawn } = require('child_process')
const chokidar = require('chokidar')
const chalk = require('chalk')
const paths = ['./src/main.js']
let child
let wait = false
spawnElectron()
View rotate.js
const rotate = (array, n) => [
...array.slice(array.length - n),
...array.slice(0, array.length - n),
]
View isEventWithin.js
export function isEventWithin(e, element) {
const rect = element.getBoundingClientRect()
return (
rect.top <= e.clientY &&
e.clientY <= rect.top + rect.height &&
rect.left <= e.clientX &&
e.clientX <= rect.left + rect.width
)
}
View node-midi-helpers.js
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 Nov 7, 2017
babel-plugin-module-resolver snippet
View .babelrc
{
"plugins": [
[
"module-resolver",
{
"root": ["./src"],
"alias": {
"^\\$(.+)": "./src/\\1"
}
}
View recess.txt
position
top
right
bottom
left
z-index
display
float
width
height
@Lokua
Lokua / aws-cli-snippets.md
Last active Sep 24, 2017
aws cli snippets
View aws-cli-snippets.md
You can’t perform that action at this time.