Skip to content

Instantly share code, notes, and snippets.

View pantlesswonder's full-sized avatar

pantless wonder pantlesswonder

View GitHub Profile
@pantlesswonder
pantlesswonder / throttle.js
Created February 13, 2013 00:59
Workaround for plug.dj rate limiting and bots being easily banned
//ok so this is pretty neat, you can just burst two messages every just over 3.33 seconds,
//and you never hit the rate limiter to cause the banning. Very groovy.
//constants
var delay = 3400, //ms to wait per burst
burst = 2; //burst the first 2 messages
//state
var messages = [],
timer = null;
//send just calls JSON.stringify and then client.write using that string
//respond to a ping
state.client.send({
type: 'rpc', id: 2,
name: 'user.pong', args: []});
//join a room
state.client.send({
type: 'rpc', id: 1,
@pantlesswonder
pantlesswonder / gist:4053451
Created November 11, 2012 02:38
socket.io code
//code
c.prototype.emit = function(a) {
var b = Array.prototype.slice.call(arguments, 1), c = b[b.length - 1], d = {type: "event",name: a};
return "function" == typeof c && (d.id = ++this.ackPackets, d.ack = "data", this.acks[d.id] = c, b = b.slice(0, b.length - 1)), d.args = b, this.packet(d)
}
//approximate state on the return line
a: "chat"
arguments: Arguments[2]
0: "chat"
@pantlesswonder
pantlesswonder / plug.dj2.js
Created October 18, 2012 00:20
plug.dj chat goes red when rate limit in effect
(function(){
if (Models.chat._sendChat) { return; }
Models.chat._sendChat = Models.chat.sendChat;
Models.chat.sendChat = function(value){
var sent = this._sendChat(value);
if (sent)
{
$('#chat-input-field').css({color: '#CC4141'});
setTimeout(function(){$('#chat-input-field').css({color: '#fff'});}, this.rateLimit * 1000);
}
@pantlesswonder
pantlesswonder / plug.dj.js
Created October 16, 2012 23:51
plug.dj hide video and widen the chat
(function(){
var btn = document.createElement('div');
//rotate an element
function rotate(el, angle)
{
$(el).css({
'-webkit-transform': 'rotate(' + angle + 'deg)',
'-moz-transform': 'rotate(' + angle + 'deg)',
'-ms-transform': 'rotate(' + angle + 'deg)',
@pantlesswonder
pantlesswonder / plug.fm.js
Created October 16, 2012 00:50
plug.fm phantomjs
// Get twitter status for given account (or for the default one, "PhantomJS")
var page = require('webpage').create(),
twitterUsername = '',
twitterPassword = ''; //< default value
// Route "console.log()" calls from within the Page context to the main Phantom context (i.e. current "this")
page.onConsoleMessage = function(msg) {
console.log(msg);
};