Skip to content

Instantly share code, notes, and snippets.

View generatorSession.js
var session = yield Session.generate({ user: 'stephen' });
var token = session.token;
session.expirationTime = Date.now();
yield session.save();
// re-fetch
var fetchedSession = yield Session.load(token);
View promiseSession.js
var token = null;
Session.generate({ user: 'stephen' }).then(function(result) {
session.set('expirationTime', Date.now());
token = result.token;
return session.save();
}).then(function() {
View callbackSession.js
Session.generate({ user: 'stephen' }, function(err, result) {
var token = result.token;
session.set('expirationTime', Date.now());
session.save(function(err, result) {
// re-fetch
Session.load(token, function(err, fetchedSession) {
@stephen
stephen / data.log
Created Nov 13, 2014
airport express airplay log (soundcloud teardown)
View data.log
OPTIONS * RTSP/1.0
CSeq: 138
X-Apple-Device-ID: 0x80e650104f9c
Apple-Challenge: CY8Exs+7FfjQ9n17/3m0qg==
DACP-ID: 95482F9B7AEACEB
Active-Remote: 2783123138
User-Agent: AirPlay/215.10
RTSP/1.0 200 OK
Public: ANNOUNCE, SETUP, RECORD, PAUSE, FLUSH, TEARDOWN, OPTIONS, GET_PARAMETER, SET_PARAMETER, POST, GET
@stephen
stephen / gist:9f75655c87c00ae02e94
Created Nov 10, 2014
failed "could not connect to airsonos" log
View gist:9f75655c87c00ae02e94
OPTIONS * RTSP/1.0
CSeq: 0
X-Apple-Device-ID: 0x80e650104f9c
Apple-Challenge: b0m+LEonvoFTnJYrVo5Y1g==
DACP-ID: 95482F9B7AEACEB
Active-Remote: 67316247
User-Agent: AirPlay/215.10
RTSP/1.0 200 OK
CSeq:0
View buffer.log
<Buffer 20 00 00 04 00 13 08 09 2d f4 da 0a 0b fa b6 13 af 07 d2 d2 9e f7 ac 52 41 66 52 6b 42 c4 c3 86 87 c6 30 f0 d5 b2 6d 29 7a 7d 07 68 26 9e 3d f1 65 d0 f1 ...>
<Buffer 20 00 00 04 02 13 08 09 01 f4 7a 09 b3 fa a4 13 59 d5 0f 89 90 f2 84 15 ec a3 f8 c9 52 8c 21 37 bb 2d 6b ef 29 7f 53 ef c8 61 d3 14 f3 f3 b2 6d 53 cb 5e ...>
<Buffer 20 00 00 04 06 13 08 09 65 f4 b4 09 bb fa e6 13 c4 ad f8 18 c0 42 94 c6 e7 61 be e0 cb 74 08 cf a5 c1 b8 9e 30 f7 40 fd 6f 1a 1f 24 ca c4 e9 65 f9 11 86 ...>
<Buffer 20 00 00 04 04 13 08 09 35 f4 a2 09 dd fa d4 13 17 f0 75 68 09 3e f7 64 dc 60 28 f2 e4 de fb 2d 5d 0f 61 8c f7 db ff c2 d2 85 c6 31 dc de 9e 51 35 13 fb ...>
<Buffer 20 00 00 04 08 13 08 09 3d f4 9c 09 af fa 64 13 de 9e 55 ea 31 4f 04 1c 15 6c f8 3c 18 aa b4 84 98 92 b9 0a 91 8f ef 7c b3 88 ce 98 56 6f ce 11 a8 86 37 ...>
<Buffer 20 00 00 04 06 13 08 09 5d f4 b2 09 dd fa 32 13 34 93 b1 87 68 7b 70 ac 7a 8b 4d 3f 43 85 0e 57 96 8e 21 d2 06 93 b9 0d 51 d9 c7 14 ef 36 43 45 ba 5d c6 ...>
<Buffer 20 00 00 04 06 13 08
View rtp.js
this.baseServer.on('message', function(msg) {
var meta = msg.slice(0, 12);
var sequenceNumber = meta.slice(2, 4).readUInt16BE(0);
var encryptedAudio = msg.slice(12);
var decryptedAudio = new Buffer(0);
for (var i = 0; i < encryptedAudio.length; i += 16) {
View airsonos.log
GET /listen HTTP/1.1
Host: 172.17.106.64:8000
Accept-Language: en-us
X-Playback-Session-Id: 2E989289-87D5-4609-9DA1-7F7BEDC37D92
icy-metadata: 1
Accept: */*
User-Agent: AppleCoreMedia/1.0.0.14A389 (Macintosh; U; Intel Mac OS X 10_10; en_us)
Referer: http://localhost:8000/listen.m3u
Accept-Encoding: identity
Connection: keep-alive
View alac.log
00000000 47 45 54 20 2f 6c 69 73 74 65 6e 20 48 54 54 50 GET /lis ten HTTP
00000010 2f 31 2e 31 0d 0a 48 6f 73 74 3a 20 31 37 32 2e /1.1..Ho st: 172.
00000020 31 37 2e 31 30 36 2e 36 34 3a 38 30 30 30 0d 0a 17.106.6 4:8000..
00000030 41 63 63 65 70 74 2d 4c 61 6e 67 75 61 67 65 3a Accept-L anguage:
00000040 20 65 6e 2d 75 73 0d 0a 58 2d 50 6c 61 79 62 61 en-us.. X-Playba
00000050 63 6b 2d 53 65 73 73 69 6f 6e 2d 49 64 3a 20 41 ck-Sessi on-Id: A
00000060 36 33 41 37 36 31 44 2d 37 33 38 45 2d 34 42 38 63A761D- 738E-4B8
00000070 37 2d 41 44 30 33 2d 33 32 42 35 36 44 31 34 43 7-AD03-3 2B56D14C
00000080 45 36 39 0d 0a 69 63 79 2d 6d 65 74 61 64 61 74 E69..icy -metadat
00000090 61 3a 20 31 0d 0a 41 63 63 65 70 74 3a 20 2a 2f a: 1..Ac cept: */
@stephen
stephen / unwrapUrl.js
Last active Aug 29, 2015
unwraps a url from shorteners. assumes request is available.
View unwrapUrl.js
var unwrapUrl = function(input, callback) {
var options = {};
if (typeof(input) === 'string') {
options.url = input;
} else if (typeof(input) === 'object') {
options = input;
}
options._attempts = options._attempts || 0;
options.maxAttempts = options.maxAttempts || 5;