This file contains hidden or 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 maxThrottles = 10; | |
connectionManager[connection.id].lastMessage = +new Date(); | |
connectionManager[connection.id].timeOutUntil = connectionManager[connection.id].lastMessage + 1000; // one second, too long? | |
connectionManager[connection.id].throttledCount = 0; | |
connection.addListener("message", function( message ) { | |
var messageTime = +new Date(); | |
if (messageTime < connectionManager[connection.id].timeOutUntil) { | |
(throttleCount < maxThrottles) ? connectionManager[connection.id].throttledCount++ : kickMe(connection.id); | |
} |
This file contains hidden or 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
tests['backgroundsize'] = function() { | |
var bool = test_props_all( 'backgroundSize' ); | |
if (bool){ | |
bool = new Boolean(bool); | |
bool.contain = !!(function() { | |
set_css('background-size: contain'); | |
return contains(m_style['backgroundSize'], 'contain'); | |
}); | |
bool.cover = !!(function() { |
This file contains hidden or 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
function factorial( n ) { | |
if (n > 1) { | |
return factorial(n-1) * n; | |
} else { | |
return 1; | |
} | |
} | |
console.log( factorial( 1 ) 1 ); | |
console.log( factorial( 3 ), 6 ); |
This file contains hidden or 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
// 1: how could you rewrite the following to make it shorter? | |
if (foo) { | |
bar.doSomething(el); | |
} else { | |
bar.doSomethingElse(el); | |
} | |
This file contains hidden or 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
// From jQuery source | |
// Calculate pageX/Y if missing and clientX/Y available | |
if ( event.pageX == null && event.clientX != null ) { | |
var doc = document.documentElement, body = document.body; | |
event.pageX = event.clientX + (doc && doc.scrollLeft || body && body.scrollLeft || 0) - (doc && doc.clientLeft || body && body.clientLeft || 0); | |
event.pageY = event.clientY + (doc && doc.scrollTop || body && body.scrollTop || 0) - (doc && doc.clientTop || body && body.clientTop || 0); | |
} |
This file contains hidden or 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
# set temporary environment variable | |
export PORT=8888 | |
# Expresso test with code coverage | |
expresso -I lib-cov test/* |
This file contains hidden or 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
function doHash(str, seed) { | |
var m = 0x5bd1e995; | |
var r = 24; | |
var h = seed ^ str.length; | |
var length = str.length; | |
var currentIndex = 0; | |
while (length >= 4) { | |
var k = UInt32(str, currentIndex); | |
This file contains hidden or 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
// Optimize gamecast with ( http://github.com/LearnBoost/Socket.IO-node/blob/master/lib/socket.io/listener.js#L83-90 ): | |
Listener.prototype.broadcast = function(message, except){ | |
for (var i = 0, k = Object.keys(this.clients), l = k.length; i < l; i++){ | |
if (this.clients[k[i]] && (!except || [].concat(except).indexOf(this.clients[k[i]].sessionId) == -1)){ | |
this.clients[k[i]].send(message); | |
} | |
} | |
return this; | |
}; |
This file contains hidden or 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
function minVersion(version) { | |
var $vrs = window.jQuery.fn.jquery.split('.'), | |
min = version.split('.'); | |
for (var i=0, len=$vrs.length; i<len; i++) { | |
console.log($vrs[i], min[i]); | |
if (min[i] && $vrs[i] < min[i]) { | |
return false; | |
} | |
} | |
return true; |
This file contains hidden or 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
<div class="component"> | |
<div class="tweet-media"> | |
<div class="dailybooth"> | |
<a class="inline-media-image" data-inline-type="DailyBooth" href="http://dailybooth.com/pamelafox/9884843" target="_blank"><img src="http://cdn2.dailybooth.com/5/pictures/large/cd75a8852f0d648d2de6a28e9317a2e3_9884843.jpg"></a> | |
</div> | |
<div class="media-attribution"> | |
<span>via</span><img width="16px" height="16px" src="http://dailybooth.com/favicon.ico"><a target="_blank" data-media-type="DailyBooth" class="media-attribution-link" href="http://dailybooth.com">DailyBooth</a> | |
</div> | |
</div> | |
<hr class="component-spacer"> |