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 / gist:44c31fa6c51ed15b06ad
Created August 2, 2014 03:50
observable array
var mutators = [
'fill', 'pop', 'push', 'reverse', 'shift', 'sort', 'splice', 'unshift'
]
function ObservableArray(onChange){
var array = []
array.set = set
array.onchange = onChange
@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
@mmckegg
mmckegg / raf.js
Created December 9, 2013 00:27
cross browser requestAnimationFrame that works like setInterval (returns a function that will stop loop if called)
module.exports = animate
var requestAnimationFrame =
global.requestAnimationFrame ||
global.webkitRequestAnimationFrame ||
global.mozRequestAnimationFrame ||
global.msRequestAnimationFrame ||
global.oRequestAnimationFrame ||
function(fn, el) {
setTimeout(fn, 1000/60)
@mmckegg
mmckegg / bouce.sh
Created November 15, 2013 02:45
bounce local port off ssh server
ssh -R *:1234:localhost:9966 user@server.com
# http://server.com:1234