Skip to content

Instantly share code, notes, and snippets.

@todoubled
todoubled / IE: Fix 6 & 7 z-indexing
Created July 6, 2010 20:52
IE: Fix 6 & 7 z-indexing
$(function() {
var zIndexNumber = 1000;
$('div').each(function() {
$(this).css('zIndex', zIndexNumber);
zIndexNumber -= 10;
});
});
@todoubled
todoubled / Character Count
Created July 6, 2010 21:06
Character Count
$(function() {
$('#post_message').keyup(function() {
var content_length = $(this).val().length;
var remaining = 420 - content_length
$('.counter').html(remaining);
if (remaining < 0) {
$('input[type=submit]').attr("disabled", "disabled");
} else if (remaining < 21 && remaining > 9) {
$('input[type=submit]').removeAttr("disabled");
$('.counter').removeClass('red');
@todoubled
todoubled / bookmarklet.js
Created June 18, 2011 16:30 — forked from kn0ll/bookmarklet.js
advanced bookmarklet template
javascript:(function() {
if(!window.your_bookmarklet) {
var doc = document,
js = doc.createElement('script');
js.type = 'text/javascript';
js.src = 'loader.js';
js.async = true;
@todoubled
todoubled / latency.coffee
Created November 16, 2011 23:58
Latency Test
startTime = new Date().getTime()
onLoadEventHandler = () ->
latency = startTime - performance.timing.navigationStart
console.log 'Latency = ' + latency + 'ms'
onLoadEventHandler()
@todoubled
todoubled / randomize.coffee
Created November 23, 2011 22:23
Randomize the order of strings in an array
array = [
"dog"
"cat"
"fish"
]
randomize = -> return (Math.round(Math.random())-0.5)
random = array.sort randomize
@todoubled
todoubled / infinite-scroll.coffee
Created November 23, 2011 22:30
Infinitely scroll through an array of items in any direction.
# Shuffle items front and back to flow infinitely
infiniteFlow: () =>
last = $("#{@config.id} section.item:last-child")
first = $("#{@config.id} section.item:first-child")
outer = $('.items')
if last.hasClass('right') or last.hasClass('current')
oldLeft = outer.position().left
width = first.width()
newLeft = oldLeft + width
@todoubled
todoubled / deploy.coffee
Created November 23, 2011 23:06
Deployment script for Node.js
control = require 'control'
task = control.task
perform = control.perform
task 'staging', 'config got my server', ->
config = user: 'root'
addresses = ['socketchat.co.uk']
return control.hosts(config, addresses)
task 'deploy', 'deploy the latest version of the app', (host) ->
@todoubled
todoubled / Procfile
Created November 26, 2011 16:58 — forked from mojodna/Procfile
Getting Kue working on Heroku
web: node app.js
worker: node consumer.js
window = {} unless window?
global.$=require('jquery') unless jQuery?
global._=require('underscore') unless _?
global.Backbone=require('backbone') unless Backbone?
global.Mustache=require('../lib/mustache') unless Mustache?
global.localStorage=require('localStorage') unless localStorage?
global.Store=require('../lib/backbone.localStorage') unless Store?
global.jsdom = require("jsdom").jsdom
global.document = jsdom('<html><body></body></html>')
global.window = document.createWindow()
@todoubled
todoubled / sc-dl.js
Created March 7, 2012 15:58 — forked from pheuter/sc-dl.js
Bookmarklet that generates download link for a Soundcloud upload
(function(d) {
var dl = d.createElement('a');
dl.innerText = 'Download MP3';
dl.href = "http://media.soundcloud.com/stream/"+d.querySelector('#main-content-inner img[class=waveform]').src.match(/\.com\/(.+)\_/)[1];
dl.download = d.querySelector('em').innerText+".mp3";
d.querySelector('.primary').appendChild(dl);
dl.style.marginLeft = '10px';
dl.style.color = 'red';
dl.style.fontWeight = 700;
})(document);