Skip to content

Instantly share code, notes, and snippets.

View mmckegg's full-sized avatar

Matt McKegg mmckegg

  • Wellington, New Zealand
View GitHub Profile
@mmckegg
mmckegg / bookmarks.obs.all.js
Last active December 12, 2017 17:32
example bookmark flumeview-reduce with realtime updating
var nest = require('depnest')
var MutantPullReduce = require('mutant-pull-reduce')
exports.needs = nest({
'sbot.pull.stream': 'first'
})
exports.gives = nest('bookmarks.obs.all', true)
exports.create = function (api) {
@mmckegg
mmckegg / to-mp3.sh
Created April 21, 2017 09:43
High quality VBR mp3 convert with ffmpeg
ffmpeg -i input.wav -vn -codec:a libmp3lame -qscale:a 2 output.mp3
@mmckegg
mmckegg / elementary-macbookpro11,5.sh
Last active September 20, 2016 10:09
Get Elementary OS working properly on MacbookPro11,5
# remove broken wifi drivers (makes wifi work after reboot)
sudo apt purge bcmwl-kernel-source
reboot
# to get backlight working, install rEFInd and enable "spoof_osx_version"
var execFile = require('child_process').execFile
module.exports = function (context, path, start, duration, cb) {
var child = execFile('ffmpeg', [
'-i', path,
'-ss', start,
'-t', duration,
'-f', 'wav',
'-acodec', 'pcm_s32le',
'pipe:1'
], { encoding: 'buffer', maxBuffer: 10 * 1024 * 1024 }, function (err, result, stderr) {
var watch = require('observ/watch')
module.exports = function (tempo, listener) {
var pos = null
var length = 25
var destroyed = false
var releases = []
if (typeof tempo === 'function') {
releases.push(watch(tempo, setTempo))
var SerialPort = require('serialport').SerialPort
var bl = require('bl')
module.exports = connect
function connect (device, cb) {
var port = new SerialPort(device, { baudrate: 115200, highWaterMark: 1 })
var timer = null
var initialized = false
var queue = []
var bl = require('bl')
var controlFrame = new Buffer([0x00, 0x00, 0x00, 0x00])
module.exports = function (pixels, cb) {
var frame = bl()
// start frame
frame.append(controlFrame)
// body frames
module.exports = bindWatch
function bindWatch (obs, handler) {
if (typeof handler === 'function') {
return obs(handler.bind(obs))
} else if (handler instanceof Object) {
var removeListeners = Object.keys(handler).map(watchKey, {
obs: obs,
handlers: handler
})
@mmckegg
mmckegg / create-loop.js
Last active November 12, 2015 09:41
experiment with another form of grid looping
var ArrayGrid = require('array-grid')
var deepEqual = require('deep-equal')
var unwrap = require('./unwrap')
module.exports = createLoop
function createLoop (frames, startTime, loopLength) {
if (frames.length) {
var shape = frames[frames.length - 1].value.shape
var length = shape[0] * shape[1]