Skip to content

Instantly share code, notes, and snippets.

Browse:
https://oauth.twitter.com/2/authorize?oauth_callback_url=http://www.skyrock.com/&oauth_mode=flow_web_client&oauth_client_identifier=7ynojZQ3uVE2DifWftbS3w
After authentication, user gets redirected to:
http://www.skyrock.com/#oauth_access_token=RnEJAQAAAABpYH8NAAAAAGKSBQAAAAAAr9G2hLrnXaznri8LlSIaR0HuNBI=HLx1r47oqpobPncAm9DNeRCdySaMqoTKJcCLwnhIP&oauth_bridge_code=2wxWDd3IIZ0UW1y4oFpioWfbzTeaAlSGoJk5L6qMpGQ
...Use the API:
@jimfleming
jimfleming / server.js
Created January 7, 2011 07:27
Listens for events from emission...
var sys = require('sys'),
Emission = require('./emission');
var emission = new Emission();
emission.cycle();
emission.on('recycle', function(cycles) {
if (cycles < 10) {
sys.puts(cycles);
}
@jimfleming
jimfleming / Emission.js
Created January 7, 2011 07:25
Should emit events.
var sys = require('sys'),
events = require('events');
var Emission = module.exports = function () {
events.EventEmitter.call(this);
this.cycles = 0;
};
sys.inherits(Emission, events.EventEmitter);
@jimfleming
jimfleming / Array.js
Created November 10, 2010 16:19
Some useful array extensions (dependent on javascript 1.6)
Array.prototype.intersect = function(b) {
return this.filter(function(n) {
return (b.indexOf(n) != -1);
});
}
Array.prototype.diff = function(a) {
return this.filter(function(n) {
return !(a.indexOf(n) > -1);
});
String.prototype.replaceAt = function(index, char) {
return this.substr(0, index) + char + this.substr(index + char.length);
}
var Timespan = function(milliseconds) {
this.milliseconds = milliseconds;
this.seconds = this.milliseconds / 1000;
this.minutes = this.seconds / 60;
this.hours = this.minutes / 60;
this.days = this.hours / 24;
this.weeks = this.days / 7;
this.months = this.days / 30;
this.years = this.months / 12;
this.centuries = this.years / 100;
var zero_pad = function(value, length) {
value = value.toString();
while (value.length < length)
value = '0' + value;
return value;
};
@jimfleming
jimfleming / String.prototype.repeat.js
Created August 25, 2010 15:47
repeats a given string x times (source: stackoverflow)
String.prototype.repeat = function(times) {
return new Array(isNaN(times) ? 1 : ++times).join(this);
}
var json_escape = function(value) {
if (value.replace)
return value.replace(/\//g, '\\/')
else
return value
}
var json_to_html = function(json, level) {
level = level || 0
var head = document.getElementsByTagName('head')[0];
var meta = document.createElement('meta');
meta.setAttribute('http-equiv', 'X-UA-Compatible');
meta.setAttribute('content', 'IE=EmulateIE7');
head.appendChild(meta);