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
// Inspired from: | |
// https://ben.akrin.com/driving-a-28byj-48-stepper-motor-uln2003-driver-with-a-raspberry-pi/ | |
// https://gist.github.com/wolli2710/9ae48c9f39737896c1f6 | |
const { Gpio } = require("onoff"); | |
const in1ToGpio = 17; // IN1 | |
const in2ToGpio = 18; // IN2 | |
const in3ToGpio = 27; // IN3 | |
const in4ToGpio = 22; // IN4 | |
const timeout = 1; // milliseconds |
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
/** | |
* Serialize a POJO while preserving `undefined` values. | |
*/ | |
function serializePOJO(value, undefinedPlaceholder = "[undefined]") { | |
const replacer = (key, value) => (value === undefined ? undefinedPlaceholder : value); | |
return JSON.stringify(value, replacer); | |
} | |
/** | |
* Deserialize a POJO while preserving `undefined` values. |
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 SVGO from "svgo"; | |
import deasync from "deasync"; | |
function svgoOptimizeSync(svgo, content) { | |
let res; | |
svgo.optimize(content, result => res = result); | |
deasync.loopWhile(() => !res); | |
return res; | |
} |
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
var Rx = require('rx'); | |
var readline = require('readline'); | |
var fs = require('fs'); | |
var rl = readline.createInterface({ | |
input: fs.createReadStream('lines.txt') | |
}); | |
var lines = Rx.Observable.fromEvent(rl, 'line') | |
.takeUntil(Rx.Observable.fromEvent(rl, 'close')) |
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
sudo fsck_exfat -d disk0sXXX | |
diskutil repairvolume /Volumes/XXX/ |
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
# Version key/value should be on his own line | |
PACKAGE_VERSION=$(cat package.json \ | |
| grep version \ | |
| head -1 \ | |
| awk -F: '{ print $2 }' \ | |
| sed 's/[",]//g' \ | |
| tr -d '[[:space:]]') | |
echo $PACKAGE_VERSION |