Skip to content

Instantly share code, notes, and snippets.

Avatar
🍙

Stephen Wan stephen

🍙
View GitHub Profile
View backend-architectures.md
@stephen
stephen / gist:8488120
Last active Jan 3, 2016
Log of AirPlay send/received via AirSonos using Spotify (47 seconds of playback) from iPad Air (iOS 7) using AirSonos commit 6f8dd2086b
View gist:8488120
BEGIN BONJOUR ADVERTISING
INSPECTING HEADER @ 1390036591413
`--: OPTIONS * RTSP/1.0
`--: CSeq: 0
`--: X-Apple-Device-ID: 0xaccf5c73af4b
`--: Apple-Challenge: JWkfiX/5gzeKemPDHyBwww==
`--: DACP-ID: 21A3D7C25BB62248
`--: Active-Remote: 1588769825
`--: User-Agent: AirPlay/190.9
END HEADER
@stephen
stephen / gist:8487772
Last active Jan 3, 2016
txt for airplay working with os x
View gist:8487772
var mdns = require('mdns2');
var net = require('net');
var rtsp = require('./rtsp');
var txtSetup = {
txtvers: '1', // txt record version?
tx: '1', // ?
ch: '2', // # channels
cn: '0,2', // codec; 0=pcm, 1=alac, 2=aac, 3=aac elc
et: '0,1', // encryption; 0=none, 1=rsa, 3=fairplay, 4=mfisap, 5=fairplay2.5; need rsa for os x
@stephen
stephen / gist:8203356
Created Dec 31, 2013
playing with BLE + Misfit Shine
View gist:8203356
//
// sandboxAppDelegate.m
// Sandbox
//
// Created by Stephen Wan on 12/31/13.
// Copyright (c) 2013 Stephen Wan. All rights reserved.
//
#import "sandboxAppDelegate.h"
#import <IOBluetooth/IOBluetooth.h>
View gist:5996673
var _creditMerchantBankAccount = function() {
var amount = 5000;
var description = 'test';
var bankAccount = '/v1/customers/CU3Fxp3A2qYIJz5XrutOxthu/bank_accounts/BA4R9ts8OYE9ZaLrOUIklvW6';
balanced.Credits.add(bankAccount, 10000, description, function(err, result) {
console.log(err);
console.log(result);
});
};
@stephen
stephen / eventTester.js
Created May 11, 2014
node-sonos eventing framework
View eventTester.js
var Sonos = require('../index').Sonos;
var Listener = require('../lib/events/listener');
var x = new Listener(new Sonos(process.env.SONOS_HOST || '192.168.2.11'));
x.listen('/ZoneGroupTopology/Event', function(err, sid) {
console.log(sid);
});
View sessionBoodleModel.js
class Session extends BaseModel {
get definition() {
return {
user: 'string',
expirationTime: 'date'
};
}
// "instance methods"
View proxyGetSet.js
static createProxyFromModel(model) {
return new Proxy(model, {
get: function(target, name) {
if (name in model.definition) {
return model.get(name);
} else {
return target[name];
}
},
set: function(target, name, value) {
View baseModelLoad.js
static load(token) {
return new Promise((resolve, reject) => {
this._createQuery().get(token).then((data) => {
resolve(new this(data));
}, (err) => {
if (err.code === 101) {
resolve(null); // model with token does not exist.
} else {
reject(new Error(err));
}
View sessionMongooseModell.js
var Session = mongoose.model('Session', {
user: String,
expirationTime: Date
});
// "instance methods"
Session.methods.expire = function() { ... };
Session.methods.renew = function(date) { ... };
// "class methods"