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
module.exports = (function(){ | |
const MS = | |
{ seconds: 1000 | |
, minutes: 60 * 1000 | |
, hours: 60 * 60 * 1000 | |
, days: 24 * 60 * 60 * 1000 | |
, weeks: 7 * 24 * 60 * 60 * 1000 | |
, months: 30 * 7 * 24 * 60 * 60 * 1000 | |
, years: 365 * 24 * 60 * 60 * 1000 } |
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
au BufRead,BufNewFile jquery.*.js set ft=javascript syntax=jquery | |
set nocompatible | |
set autoindent | |
set tabstop=2 | |
set showmatch | |
set vb t_vb= | |
set ruler | |
set nohls | |
set incsearch | |
syntax on |
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
// arrEach and objEach plugins | |
// code under MIT license by Marc Grabanski http://marcgrabanski.com | |
// jsperf tests: http://jsperf.com/each-vs-fn-arreach-and-objeach | |
$.arrEach = function(arr, cb){ | |
for (var i = 0, item; item = arr[i]; ++i) { | |
cb.apply(item, [i, item]); | |
} | |
return arr; | |
} |
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
<!doctype html> | |
<html> | |
<head> | |
<script src="http://popcornjs.org/code/dist/popcorn-complete.min.js"></script> | |
<script> | |
// ensure the web page (DOM) has loaded | |
document.addEventListener("DOMContentLoaded", function () { | |
// Create a popcorn instance by calling the Youtube player plugin |
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
Conditionals | |
( false :) | |
console.log "if" | |
:( true ) | |
console.log "else if" | |
:() | |
console.log "else" | |
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 ArrayExtender = function (a) { | |
var counter = 0; | |
for (var i in a) { | |
if (a.hasOwnProperty(i)) { | |
this[i] = a[i]; | |
++counter; | |
} | |
} | |
this.length = counter; |
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 fs = require('fs'), | |
sys = require('sys'), | |
http = require('http'); | |
http.createServer(function (req, res) { | |
checkBalanceFile(req, res); | |
}).listen(8000); | |
function checkBalanceFile(req, res) { | |
fs.stat("balance", function(err) { |
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
// Popcorn Instance Methods | |
var p = Popcorn( "#video" ) | |
p.play() | |
// Play the video (Native "pass through" method) | |
// Returns the Popcorn instance object | |
p.load() | |
// Load the video (Native "pass through" method) | |
// Returns the Popcorn instance object |
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
// Create an EventSource object, | |
// passing it the URL of the server sccript | |
var evtSrc = new EventSource( "server.php" ), | |
// Setup event types, provide explicit values if nec. | |
eventTypes = { | |
message: "status", | |
checkin: 1, | |
forward: 1, | |
direct: 1 | |
}; |
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 obj = {}, ordered = []; | |
$.get("jquery.min.js", function( src ) { | |
src.replace(/[^\w]|\d/gi, '').split('').forEach(function( c ) { | |
obj[ c ] ? ++obj[ c ] : ( obj[ c ] = 1 ) | |
}); |