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 iframeProxy = new IFrameProxy({ | |
url: 'localhost:12007' | |
}); | |
Btapp.ajax = iframeProxy.ajax; | |
var btapp = new Btapp(); |
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
### Keybase proof | |
I hereby claim: | |
* I am pwmckenna on github. | |
* I am pwmckenna (https://keybase.io/pwmckenna) on keybase. | |
* I have a public key whose fingerprint is F6BE 52B8 CCBE 35DF F1A1 E089 709D 2816 47B4 0DDA | |
To claim this, I am signing this object: |
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
// | |
// Gyro.h | |
// CustomComponent | |
// | |
// Created by Patrick Williams on 4/7/15. | |
// | |
#import "RCTBridge.h" | |
#import <CoreMotion/CoreMotion.h> |
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
defer.makeNodeResolver = function () { | |
return function (err, res) { | |
if (err) { | |
this.reject(err); | |
} else { | |
this.resolve(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
/** | |
Usage: | |
var add = btapp.func('add', 'torrent'); | |
...or to provide a callback for dht activity, you might try the following: | |
var get_any_hash = btapp.func('dht', 'get_any_hash'); | |
// While the function won't be available immediately, it is abstracted away, | |
// allowing you to treat the future function as immedidately callable | |
get_any_hash(function(hash) { | |
//Just saw a hash in the dht! | |
}); |
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
/** | |
Usage: | |
scrape(hash).then(function(infos) { | |
//we have the scrape info for our favorite trackers | |
}); | |
**/ | |
var btapp = new Btapp; | |
var scrape = (function() { | |
// First off get a function wrapper that we can call at any time |
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
Btapp.prototype.resolve_torrent_metadata = function(magnet_link) { | |
var magnet_identifier = 'magnet:?xt=urn:btih:'; | |
if(magnet_link.indexOf(magnet_identifier) !== 0) | |
throw 'malformed magnet link'; | |
var hash = magnet_link.substring(magnet_identifier.length).substr(0, 40); | |
console.log(hash); | |
if(!hash.match(/[a-zA-Z0-9]/)) | |
throw 'only support hex encoded info hashes'; |
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 request = app.btapp.get('torrent').download({ | |
url: 'magnet:?xt=urn:btih:D075D45EA1DA3E20BA148A08D984EFFC439273A4', | |
callback: function() { | |
// torrent has been added to the torrent list of the client. | |
// this is called immediately on magnet links, | |
// but might take a bit for http://*.torrent file urls | |
} | |
}); | |
request.then(function(res) { | |
// the client has heard and acknowledged your request |
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
app.get('btapp').on('all', _.bind(console.log, console)); |
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
logger = function(ev) { | |
if(ev === 'client:connected') { | |
app.get('btapp').off('all', logger); | |
} | |
console.log(JSON.stringify(_.toArray(arguments), null, 4)); | |
}; | |
app.get('btapp').on('all', logger); |
OlderNewer