Skip to content

Instantly share code, notes, and snippets.

// Ajax File upload with jQuery and XHR2
// Sean Clark http://square-bracket.com
$.fn.upload = function(remote,data,successFn,progressFn) {
// if we dont have post data, move it along
if(typeof data != "object") {
progressFn = successFn;
successFn = data;
}
return this.each(function() {
if($(this)[0].files[0]) {
<style>.gist{color:#000;}.gist div{padding:0;margin:0;}.gist .gist-file{border:1px solid #dedede;font-family:Monaco,'Courier New','DejaVu Sans Mono','Bitstream Vera Sans Mono',monospace;margin-bottom:1em;}.gist .gist-file .gist-meta{overflow:hidden;font-size:85%;padding:.5em;color:#666;background-color:#eaeaea;}.gist .gist-file .gist-meta a{color:#369;}.gist .gist-file .gist-meta a:visited{color:#737;}.gist .gist-file .gist-data{overflow:auto;word-wrap:normal;background-color:#f8f8ff;border-bottom:1px solid #ddd;font-size:100%;}.gist .gist-file .gist-data pre{font-family:'Bitstream Vera Sans Mono','Courier',monospace;background:transparent !important;margin:0 !important;border:none !important;padding:.25em .5em .5em .5em !important;}.gist .gist-file .gist-data .gist-highlight{background:transparent !important;}.gist .gist-file .gist-data .gist-line-numbers{background-color:#ececec;color:#aaa;border-right:1px solid #ddd;text-align:right;}.gist .gist-file .gist-data .gist-line-numbers span{clear:right;display:b
@40
40 / gist:3240881
Created August 2, 2012 21:38 — forked from tracycodes/gist:3233358
Answer to a random interview question
function add1(array, val, n) {
var iter = 0,
end = array.length,
count = (n) ? n : -1,
multiple = 1;
if(n < 0) {
iter = array.length - 1;
end = 0;
multiple = -1;
@40
40 / boilerplate.coffee
Created February 27, 2012 18:14 — forked from bytespider/boilerplate.coffee
jsOAuth boilerplate for PIN based authentication in javascript
openAuthoriseWindow = (url) ->
waitForPin = ->
if wnd.closed
pin = prompt("Please enter your PIN", "")
oauth.setVerifier pin
oauth.fetchAccessToken getSomeData, failureHandler
else
setTimeout waitForPin, 100
wnd = window.open(url, "authorise")
setTimeout waitForPin, 100