🎭 Jester gist stars for rwaldron
A♦
jquery.ba-tinypubsub.js49 stars

/*!
 * jQuery Tiny Pub/Sub - v0.X - 11/18/2010
 * http://benalman.com/
 * 
 * Original Copyright (c) 2010 "Cowboy" Ben Alman
 * Dual licensed under the MIT and GPL licenses.
 * http://benalman.com/about/license/
 *
 * Made awesome by Rick Waldron
 *
 */
A♦
K♣
style-guide.js32 stars

Writing Idiomatic JavaScript

1. Two space soft indents (fake tabs) OR tabs... BUT NEVER BOTH - DO NOT MIX

2. Whitespace, Parens, Braces, Linebreaks

  
  
  if/else/for/while/try always have spaces, braces and multiple lines.
  --------------------------------------------------------------------

  
  
  //  Bad
K♣
Q♥
jquery-patching-tips.sh15 stars

# Tips for jQuery Bug Patching

# There are some assumptions made here, one being that you're 
# set up with some form of "localhost" http server and that it's running.
#  - http://www.mamp.info/en/mamp/
#  - sudo apt-get install apache2

# Get it running: 
# On Mac: 
  
  $ python -m SimpleHTTPServer
Q♥
J♠
jquery.viewport-original.js4 stars

/*
 * Viewport - jQuery selectors for finding elements in viewport
 *
 * Copyright (c) 2008-2009 Mika Tuupola
 *
 * Licensed under the MIT license:
 *   http://www.opensource.org/licenses/mit-license.php
 *
 * Project home:
 *  http://www.appelsiini.net/projects/viewport
 *
 */
J♠
十♦
sharedworker.multi-connect-inner.html3 stars

<!DOCTYPE HTML>
<html>
  <head>
    <script src="sharedworker.multi-connect.renderer.js"></script>
  </head>
  <body>
    <pre id="shared-worker-log"></pre>
  </body>
</html>
十♦
9♣
always-an-object.js3 stars

console.log(blanky); // `object definition`
console.log(typeof blanky); // object

console.log(blanky.__proto__); // object
console.log(typeof blanky.__proto__); // object

console.log(blanky.constructor); // SafetyBlanket()
console.log(typeof blanky.constructor); // function

console.log(blanky.constructor.prototype); // object{}
console.log(typeof blanky.constructor.prototype); // object
9♣
8♥
sharedworker.multi-connect-inner.html2 stars

<!DOCTYPE HTML>
<html>
  <head>
    <script src="sharedworker.multi-connect.renderer.js"></script>
  </head>
  <body>
    <pre id="shared-worker-log"></pre>
    <pre id="shared-worker-connection-log"></pre>
  </body>
</html>
8♥
7♠
idb.html2 stars

Working through the indexedDB API that was released in Chromium 8.0.552.5 dev

<!doctype html>
<html> 
  <head>
    <title>IDB* API</title>
    <script src="idb.js"></script>   
  </head>
  <body> 
    <input type="button" id="button" value="message" />
  </body> 
</html> 
7♠
6♦
microsoft.h264.contentscript.js2 stars

var supportedMimeTypes = ['video/mp4', 'video/x-ms-wmv'];
var supportedVideoExtensions = ['.mp4', '.wmv', '.mp4v', '.m4v'];

var getSupportedMediaSource = function(videoElement)
{
    // If the video element source is supported, then we replace the tag.

    if (videoElement.src
        && isWMPSupported(videoElement))
    {
        return videoElement.src;
    }
6♦
5♣
5♣
4♥
4♥
3♠
event.php1 stars

<?php
header("Content-Type: text/event-stream\n\n");

echo 'data: ' . json_encode(
                  array(
                    0 => array(
                      'time' => time(),
                      'message' => 'Some kind of foo'
                    ),
                    1 => array(
                      'time' => time(),
                      'message' => 'Some kind of quux'
3♠
2♦
results.txt1 stars

Array
  + concat
  + every
  + filter
  + forEach
  + indexOf
  + join
  + lastIndexOf
  + length
  + map
  + pop
  + push
2♦
A♦
error.php1 stars

<?php header('HTTP/1.0 500 Internal Server Error'); exit; ?>
A♦
K♣
worker-via-blob-import.js1 stars

//  Declare an object literal as a namespace        
var Utils = {};



// Define an sort of ES5 forEach (this is demo only, so it's fast and loose)
Utils.forEach = function(arr, callback) {

                  var iter  = 0,
                      len   = arr.length;

                  for ( ; iter < len; iter++ ) {
K♣
Q♥
array-comprehension.html1 stars

Various pre-Harmony bits and pieces

<script type="application/javascript;version=1.8">

var toString = Object.prototype.toString;

console.log(

  [ i for each ( i in [ 1,2,3,4,5 ] ) ]

);


function $r( floor, ceil ) {
Q♥
J♠
h264.html1 stars

H264 Support Revision

<!DOCTYPE html>
<html>
<head>
  <title>H264</title>


  <script src="h264.js"></script>
</head>
<body>

  <video id='video' style="display:" 
    controls> 
J♠
十♦
cons.html1 stars

Exercise to understand Lisp cons/car/cdr, by implementing in JS

<script src="cons.js"></script>
十♦
9♣
def.js1 stars

/*
 *    def.js: Simple Ruby-style inheritance for JavaScript
 *
 *    Copyright (c) 2010 Tobias Schneider
 *    This script is freely distributable under the terms of the MIT license.
 */
(function(global) {

  __super__ = function(){
    var caller = __super__.caller;
    if(caller !== caller._super){ return caller._super.apply(caller, arguments); }
  }
9♣
8♥
type.js0 stars

(function($){

	var toString = Object.prototype.toString;
	
	
	var class2type = {
		"[object Boolean]": "boolean",
		"[object Number]": "number",
		"[object String]": "string",
		"[object Function]": "function",
		"[object Array]": "array",
		"[object Date]": "date",
8♥
7♠
Comma-First Code Writing Is Bad0 stars

Test:

var foo = { bar : 'barberic'
          , baz : 'bazterd' 
          , duck : 'punch'
          };

JSLint Results:

Error:
Problem at line 1 character 19: Bad line breaking before ','.
7♠
6♦
gistfile1.js0 stars

The example given on Ajaxian:


// See comments below.

// standard style
var a = "ape",
  b = "bat",
  c = "cat",
  d = "dog",
  e = "elf",
  f = "fly",
6♦
5♣
html5-data.js0 stars

(function (undefined) {  
  function detectMutation() {
    mutationSupported = true;
    this.removeEventListener('DOMAttrModified', detectMutation, false);
  }

  var forEach = [].forEach, 
      regex = /^data-(.+)/,
      el = document.createElement('div'),
      mutationSupported = false,
      match
  ;
5♣
4♥
jquery.pollute.js0 stars

(function ($) {
  $.fn.pollute = function (pollution) {
    
    // first we extend the pollution object to the window, nice!
    $.extend(window, pollution);
    
    // make sure we're really nasty, and pollute all the elements as well.
    return this.each(function () {
      
      for ( var junk in pollution ) {
        if ( typeof pollution[junk] === 'object' ) {
          $(this).pollute(pollution[junk]);
4♥
3♠
jquery.pollute.js0 stars

(function ($) {
  $.fn.pollute = function (pollution) {
    
    pollutants = {
      air:"SMOAK",
      water:"OIL",
      noise:"BLAH"
    }

    window.emit = function(type) {
      var i = Math.round(Math.random()*1000);
      while(--i) {
3♠
2♦
index.html0 stars

<!DOCTYPE html>
<html>
  <head>
    <title>Workers: Basic Demo</title>
    <script>

    document.addEventListener('DOMContentLoaded', function () {

	var worker  = new Worker('worker-javascript-file.js');

	worker.postMessage('Hello Worker!');
2♦
A♦
compatible-filtering-worker.html0 stars

<!DOCTYPE html>
<html>
  <head>
    <title>Workers: Compatibility</title>
    <script>

//  This script is executed in the main window

/*
  we'll use a worker to filter a huge data set
  for all entries that match our filter string "foo"
*/
A♦
K♣
jquery.detonate.html0 stars

<!DOCTYPE html>
<html>
  <head>
    <title>$.detonate()</title>
    <script src="http://code.jquery.com/jquery.js"></script>
    <script src="jquery.detonate.js"></script>
    <script>
    $(function () {


      $.charge(
        '/fuse',
K♣
Q♥
client.html0 stars

<script src="event-source.js"></script>
Q♥
J♠
J♠
十♦
motormouth-worker.js0 stars

importScripts('jquery.hive.pollen.js');

$(function (data) {
  // message received from rendering process

  $.ajax.get({ 
    url:      'proxy.php',
    data:     $.param(data),
    dataType: 'json', 
    success: function(jsonObj) {

      $.each(jsonObj.results, function (i, result) {
十♦
9♣
jquery.detonate.js0 stars

/*  
  jQuery.Mines.Charge/Detonate/Disarm()
*/  
;(function($){
  var _payloadCache = {};
  
  function blast(fuses, args) {
    $.each(_payloadCache[fuses], function(){
      this.apply($, args || []);
    });  
  }
  
9♣
8♥
sharedworker.html0 stars

<!DOCTYPE html>
<html>
	<head>
		<title>Shared Workers</title>
		<script>


			var worker = new SharedWorker('sharedworker.js');

			console.log(worker);

			worker.port.addEventListener('message', function(event) {
8♥
7♠
minified.html0 stars

<!DOCTYPE html>
<html>
  <head>
    <title>Um. Duh?</title>
    <script src="http://github.com/DmitryBaranovskiy/raphael/raw/master/raphael-min.js"></script> 
    <script>
    
    //  WORKS FINE.
    console.log(Raphael);
      
    </script>
  </head>
7♠
6♦
animeiosis.js0 stars

(function($canvas) {
  var 
  //  STORE DEFAULT CELL ATTRS
  cellAttrs = {
    fill: "#E0E4CD", 
    stroke: "#000", 
    "stroke-width": 2
  },
  //  SET UP CELL ARRAY 
  $cells    = [],
  //  DRAW INITIAL CELL
  $cell     = $canvas.circle(  /* coordX, coordY, radius */
6♦
5♣
jQuery.classList.js0 stars

/*
Usages: 
$(selector).classList() //returns an array of classnames
$(selector).classList('newclass') //replaces the current element's classes
$(selector).classList(['new', 'class', 'names']) //replaces the current element's classes
*/

jQuery.fn.extend({
  classList: function( value ) {
    if( value ){
      if( jQuery.isArray(value)){
        this.attr('class', '')
5♣
4♥
jquery.classes.html0 stars

<!DOCTYPE html>
<html>
  <head>
    <title>jquery.classes.js</title>
    <script src="jquery-1.4.2.js"></script> 
    <script src="jquery.classes.js"></script>
  </head>
<body>
  
  <p class="foo bar baz">classes: foo, bar, baz</p>
  
  <p class="foo">classes: foo</p>
4♥
3♠
nit_twit.py0 stars

import urllib
import optparse
import os.path
import pickle


def truncate(message,limit):
    if len(message) > limit:
        # break off at 137 chars and concat elipsis
        return message[:(limit-3)] + "..."
    else:
        # not too long
3♠
2♦
mice.css0 stars

.mouse{
  position: absolute;
  background-image: url('../images/cursor.png');
  width: 15px;
  height: 22px;
  z-index: 100;
}
2♦
A♦
burst-syntax.js0 stars

  Burst({
    
    'arbitrary-timeline-name' : {
      start:  0,
      frames: 100,
      ratio:  1, 
      loop:   false,
      finish: function () {}, 
      tracks: {
        
        'arbitrary-red-square'  : {
          ref:  redBox.style,
A♦
K♣
badge.html0 stars

<!DOCTYPE html>
<html>
  <head>
    <title>Badges</title>
  </head>
  <body>
    
    <script src="badge.js?type=jedi"></script>
    <script src="badge.js?type=ninja"></script>    
    
    
    <script>
K♣
Q♥
caret.html0 stars

<script src="caret.js"></script>
Q♥
J♠
detonate-usage.js0 stars

$.mines.detonate('/fuse/c', ['message']);

$.mines.detonate([

  {
    key: '/fuse/a',
    args: ['message from fuse a', { foo: 'bar' }]
  },
  {
    key: '/fuse/b',
    args: ['message from fuse b', ['an', 'array'] ]
  },
J♠
十♦
pictocalypse.js0 stars

$(function () {
  var Pict = {
    api: {
      url:'http://ajax.googleapis.com/ajax/services/search/images'
    },
    atCache:  0,
    cache:    [], 
    clear:    function ( fn ) {
      this.cache.length  = 0;
      if ( fn && $.isFunction(fn) ) {
        fn();
      }
十♦
9♣
index.html0 stars

<!DOCTYPE html> 
<html>
  <head> 
    <title>Dead Simple Twitter Search API jQuery Feed</title> 
    <script src="http://code.jquery.com/jquery.js"></script>
    <script src="jQuery.twitterFeed.js"></script>
    <script src="jquery.twitter-usage-ex.js"></script>
    <link href="jQuery.twitterFeed.css" media="screen" rel="stylesheet" type="text/css"> 
  </head> 
  <body> 
    <h1>Twitter:</h1>
    <div class="twitter-posts"><h3>Loading Tweets From The Cloud With AJAX HTML5...</h3><hr class="space"/></div>
9♣
8♥
auto-run-concat-test.js0 stars

$LAB.script("http://code.jquery.com/jquery.js").wait(function () {
  var tally = 0;

  jQuery(function () {
    function loopClickEmToRunEm() {
      setTimeout(function () {
        jQuery('#button_1').trigger('click');
      }, 0);
      setTimeout(function () {
        jQuery('#button_2').trigger('click');
      }, 3000);
      setTimeout(function () {
8♥
7♠
7♠
6♦
workers-1.js0 stars

/*

  The constructor
  
  It takes the worker file name as an argument
  
*/
var worker = new Worker('worker-javascript-file.js')

/* 
  
  The postMessage() function sends a message to the worker
6♦
5♣
event-source.php0 stars

<?php
header("Content-Type: text/event-stream\n\n");

echo 'data: ' . json_encode(
                  array(
                    'from' => 'event-source'
                  )
                ) . "\n";
?>
5♣
4♥
close.js0 stars

// close stream: label-a
$.eventsource('close', 'label-a');

// close stream: label-b
$.eventsource('close', 'label-b');

// close all open streams
$.eventsource('close');
4♥
3♠
10m-results.js0 stars

// Results at 10,000,000 iterations

// $([]) omitted/not tested - caused chrome to crash
// $('null') omitted/not tested - caused chrome to crash

$(""):        1274ms
$(""):        1270ms
$(""):        1278ms
$(""):        1265ms

$(undefined): 1199ms
$(undefined): 1167ms
3♠
2♦
hide-show-perf.html0 stars

<!DOCTYPE html>
<html>
  <head>
    <title>jQuery hide/show speed</title>
    <script src="http://code.jquery.com/jquery.js"></script>
    <script>
      $(function () {
        var iter  = 100000, 
            $p    = $("p"); 
        
        
        
2♦
A♦
proper-collections.js0 stars

// FROM:
// http://www.quora.com/Is-there-a-way-for-jQuery-to-return-a-single-object-instead-of-an-array-of-objects-For-example-if-I-use-an-id-selector#ans94625

//  This is actually a good thing
var foo = $("#foo")

//  but it's important to indicate that
//  this var is a collection, and should
//  be declared as:
//
//  var $foo = $('#foo')
A♦
K♣
google-particles.js0 stars

(function(){try{if(!google.doodle)google.doodle={};var a=200,g=-200,j=-200,k,l,m,n=0,o=0,p=0,q=35,r,s=[],t,u,v;google.doodle.init=function(){if(!v&&window.location.href.indexOf("#")==-1){v=true;if(t=document.getElementById("hplogo")){google.j&&google.j.en&&w(100,x,function(){return google.rein&&google.dstr});w(100,y,function(){return google.listen});w(100,z,function(){return google.browser})}}};var w=function(b,c,d){if(d())c();else b< 200&&window.setTimeout(function(){w(b+1,c,d)},b)},x=function(){if(!google.doodle.n){google.doodle.n= true;google.rein.push(google.doodle.init);google.dstr.push(A)}},y=function(){google.listen(document,"mousemove",B)},B=function(b){a=200;g=b.clientX-t.offsetLeft;j=b.clientY-t.offsetTop},C=function(){return[u?window.screenLeft:window.screenX,u?window.screenTop:window.screenY,document.body.clientWidth]},z=function(){u=google.browser.engine.IE&&google.browser.engine.version!="9.0";s=[D(202,78,9,"ed9d33"),D(348,83,9,"d44d61"),D(256,69,9,"4f7af2"),D(214,59,9,"e
K♣
Q♥
foo.html0 stars

<!DOCTYPE html>
<html>
<head>
<script src="foo.js">
{
  "foo" : "bar"
}
</script>
</head>
<body>
</body>
</html>
Q♥
J♠
screening.js0 stars

// 1: how could you rewrite the following to make it shorter?
if (foo) {
  bar.doSomething(el);
} else {
  bar.doSomethingElse(el);
}




// 2: what is the faulty logic in the following code?
var foo = 'hello';
J♠
十♦
screening.js0 stars

// 1: how could you rewrite the following to make it shorter?
if (foo) {
  bar.doSomething(el);
} else {
  bar.doSomethingElse(el);
}


//  Rick says: There is more then one way to optimize this
foo ? bar.doSomething(el) : bar.doSomethingElse(el);

//  Peter Higgins' solution was neat.
十♦
9♣
zany-ternary.js0 stars


// Given
var a = true, b='b', c='c';

(a?b:c)


// via @cowboy
[c,b][1-!a]


// via @rwaldron
9♣
8♥
ba-postMessage-detect.js0 stars

/*!
 * postMessage detector - v0.1pre - 9/15/2010
 * http://benalman.com/
 * 
 * Copyright (c) 2010 "Cowboy" Ben Alman
 * Dual licensed under the MIT and GPL licenses.
 * http://benalman.com/about/license/
 */

// If `window.postMessage.complex` is true, postMessage can pass complex non-string
// values like objects and arrays. If it's false, it can only pass strings (TODO: test)
// 
8♥
7♠
protopattern.js0 stars

var X = function () {
  return new X.prototype.init() ;
};

X.prototype = {
  init: function () {
    this.y = 0;

    return this;
  }, 
  y: 1
}; 
7♠
6♦
index.html0 stars

<html>
<head>
<script>
var worker = new Worker('worker.js');

worker.addEventListener('message', function (event) {
  console.log(event.data);
});



</script>
6♦
5♣
throbbing.js0 stars

$(document)
  .ajaxSend(function (event, xhr, aOpts) {

    $('<div/>', {
      id:   'loading-indicator',
      text: 'Working...',
      css: {
        position: 'fixed',
        top: '0',
        left: '0'
      }
    }).prependTo('body');    
5♣
4♥
LOLheritence.js0 stars

/* ------------------------------ Main Class ------------------------------ */
// Returns "instances" of itself which are actually functions.
function Ben ( greeting ) { var Parent, scope
  function Scope () {
    // Here is where you put your normal constructor junk
    this.greeting = greeting
    this.colours = [ 'yellow', 0xFFFFFF ]
  }

  // Magic
  function Proxy() {
    Scope.prototype.init.apply( scope, arguments )
4♥
3♠
magic-properties.js0 stars

/**
 * This library defines magic properties and methods
 * for objects. Generic hooks are: __get__, __set__,
 * __delete__, __count__ and __noSuchProperty__.
 *
 * Used features: Harmony (ES6) proxies.
 *
 * Tested in FF4 beta.
 *
 * @author Dmitry A. Soshnikov <dmitry.soshnikov@gmail.com>
 * (C) 2010 Mit Style License
 */
3♠
2♦
index.html0 stars

<!DOCTYPE html>
<html>
  <head>
    <title>List navigation</title>
    
    <style>
      .selected {
        background: yellow;
      }
    </style>
    <script src="http://code.jquery.com/jquery.js"></script> 
    <script src="linav.js"></script>
2♦
A♦
index.html0 stars

<!doctype html>
<html>
 <head>
  <script src="http://code.jquery.com/jquery.js"></script>
  <script src="script.js"></script>
 </head>
 <body>
 
 <textarea id="whatever">foo bar #hash</textarea>
 
 Proof Of Concept: If you arrow right until just before the #hash and type shift-@, a "faked" autocomplete will trigger and insert @user - but will retain the string following. Currently, if you try this in #newTwitter, it will blow away any text following the autocompleted @user.
 
A♦
K♣
function.prototype.call.js0 stars

Per wycats suggestion to overwrite function.prototype.call

var originalCall = (function () {
                      return Function.prototype.call;
                   })();

Function.prototype.call = function () {
  
  console.log(arguments);
  
  return originalCall;
}

function testFn(arg) {
K♣
Q♥
jquery.ba-logselector.js0 stars

/*!
 * jQuery log selector - v0.1pre - 10/22/2010
 * http://benalman.com/
 * 
 * Copyright (c) 2010 "Cowboy" Ben Alman
 * Dual licensed under the MIT and GPL licenses.
 * http://benalman.com/about/license/
 */

// Log the selector used to select elements to each selected element,
// otherwise to the body. Hover over logged selectors to highlight
// stuff all fancy-like (note: don't select SPAN elements because this
Q♥
J♠
function.prototype.call-2.js0 stars

overwrites function.prototype.call with enforced scope. (the closure seems unnec. but is, when running in FF)

var originalCall = (function () {
                      return Function.prototype.call;
                   })();

Function.prototype.call = function () {
  
  console.log('Logging:', arguments);
  
  return originalCall;
}

J♠
十♦
prepdeploy.php0 stars

<?php

echo "Prepping CSS and JS for deploy...\n";

$css_files['app'] = array('reset', '960', 'screen', 'jquery.tagsinput', 'jquery.autocomplete', 'tipsy', 'prettify');
//$css_files['splash'] = array('reset', 'splash');
//$css_files['iphone'] = array('reset', 'screen', 'iphone');

$js_files['app'] = array('jquery.autocomplete.min', 'jquery.tagsinput', 'jquery.scrollTo-1.4.2-min', 'forrst',
                         'jquery.tipsy', 'jquery.autoresize.min', 'prettify',
                         'lang-apollo',
                         'lang-css',
十♦
9♣
9♣
8♥
fiddle.css0 stars

jsfiddle html panel contents

#foo {
  height:100px;
  width:100px;
  padding:20px;
  border:1px solid;
}
8♥
7♠
makefile.sh0 stars

will build a special version of jquery that allows for iframe context's to inherit jquery from window.top

V ?= 0

SRC_DIR = src
TEST_DIR = test
BUILD_DIR = build

PREFIX = .
DIST_DIR = ${PREFIX}/dist

RHINO ?= java -jar ${BUILD_DIR}/js.jar

CLOSURE_COMPILER = ${BUILD_DIR}/google-compiler-20100917.jar
7♠
6♦
6♦
5♣
array.prototype.unique.js0 stars

var states = ["Alabama", "Alaska", "Arizona", "Arkansas", "California", "Colorado", "Connecticut", "Delaware", "Florida", "Georgia", "Hawaii", "Idaho", "Illinois", "Indiana", "Iowa", "Kansas", "Kentucky", "Louisiana", "Maine", "Maryland", "Massachusetts", "Michigan", "Minnesota", "Mississippi", "Missouri", "Montana", "Nebraska", "Nevada", "New Hampshire", "New Jersey", "New Mexico", "New York", "North Dakota", "North Carolina", "Ohio", "Oklahoma", "Oregon", "Pennsylvania", "Rhode Island", "South Carolina", "South Dakota", "Tennessee", "Texas", "Utah", "Vermont", "Virginia", "Washington", "West Virginia", "Wisconsin", "Wyoming", "Alabama", "Alaska", "Arizona", "Arkansas", "California", "Colorado", "Connecticut", "Delaware", "Florida", "Georgia", "Hawaii", "Idaho", "Illinois", "Indiana", "Iowa", "Kansas", "Kentucky", "Louisiana", "Maine", "Maryland", "Massachusetts", "Michigan", "Minnesota", "Mississippi", "Missouri", "Montana", "Nebraska", "Nevada", "New Hampshire", "New Jersey", "New M
5♣
4♥
code-smells.js0 stars

// SMELLY: HTML in your JavaScript
$('#showMessage').click(function() {
  $('<div>' +
    '<h1>' + $('#messageTitle').val() + '</h1>' +
    '<p>' + $('#messageText').val() + '</p>' +
    '</div>')
    .appendTo('#messageContainer')
});

// MINTY FRESH: Use templates instead
<script type="text/x-jquery-tmpl" id="messageTemplate">
  <div>
4♥
3♠
DetectCreditCardType0 stars

<!doctype html>
<html>

<head>
  <meta charset="utf-8">
  <title>Detect Credit Card Type</title>
</head>

<body>

  <form>
    <label for="card_number">Enter Card Number:</label>
3♠
2♦
DetectCreditCardType.html0 stars

<!doctype html>
<html>

<head>
  <meta charset="utf-8">
  <title>Detect Credit Card Type</title>
</head>

<body>

  <form>
    <label for="card_number">Enter Card Number:</label>
2♦
A♦
usage-revised.js0 stars

An example from the JSDoc #usage page.

// Usage example revised

/**
 * Shape is an abstract base class. It is defined simply
 * to have something to inherit from for geometric 
 * subclasses
 * @constructor
 */
function Shape( color ) {
  this.color = color;
}
A♦
K♣
jquery.ba-htmldoc.js0 stars

/*!
 * jQuery htmlDoc "fixer" - v0.2pre - 12/15/2010
 * http://benalman.com/projects/jquery-misc-plugins/
 * 
 * Copyright (c) 2010 "Cowboy" Ben Alman
 * Dual licensed under the MIT and GPL licenses.
 * http://benalman.com/about/license/
 */

(function($){
  
  var // RegExp that matches opening and closing HTML, HEAD, BODY tags.
K♣
Q♥
jsonp.html0 stars

<!DOCTYPE html>
<html>
<head>
  <script src="jsonp.js"></script>
  <script>
  document.addEventListener("DOMContentLoaded", function() {
    
    var requestUrl  = "http://en.wikipedia.org/w/api.php?action=parse&page=Dog&format=json";


    getJsonp({
      url: requestUrl,
Q♥
J♠
iife-variations.js0 stars

// Want to learn more about Immediately Invoked Function Expressions? Read
// this article first:
// 
// http://benalman.com/news/2010/11/immediately-invoked-function-expression/

// Parens are used to tell the parser that it's a function expression,
// not a function declaration. If you don't explicitly tell the parser to
// expect an expression, it will throw a SyntaxError exception because it
// sees a function declaration without a name specified.

(function(){ /* code */ })() // I've been using this one
(function(){ /* code */ }()) // Crockford recommends this one
J♠
十♦
ba-whatevcache.js0 stars

/*!
 * JavaScript whatevCache - v0.2pre - 12/30/2010
 * http://benalman.com/
 *
 * Copyright (c) 2010 "Cowboy" Ben Alman
 * Dual licensed under the MIT and GPL licenses.
 * http://benalman.com/about/license/
 */

// whatevCache.set( key, value [, ttl ] );
// (returns undefined on success, error object otherwise)
//
十♦
9♣
gistfile1.js0 stars

function Human(){
  var that = this;
  var name="John Doe";
  that.getName=function(){return name;}
  that.setName=function(value){name=value;}
  return that;
}

function Man(){
	
  var that = this.prototype = new Human();
  this.prototype.constructor = Man;
9♣
8♥
simpledomready.js0 stars

function domReady(callback) {
    var domLoaded;
    var called;

    var onReadyStateChange = function () {
      if (document.readyState == 'complete') {
        domLoaded();
      }
    };

    var interval;
8♥
7♠
inherited.html0 stars

<!DOCTYPE html>
<html>
<head>
    <title>Dojo x-domain Skeleton</title>
    <script src="http://ajax.googleapis.com/ajax/libs/dojo/1.5/dojo/dojo.xd.js"></script>
    <script>

		// the superclass
		dojo.declare("Foo", null, {
			bar:function(){
				console.warn("Foo's bar");
			},
7♠
6♦
jquery.ba-htmldoc.js0 stars

/*!
 * jQuery htmlDoc "fixer" - v0.2pre - 12/15/2010
 * http://benalman.com/projects/jquery-misc-plugins/
 * 
 * Copyright (c) 2010 "Cowboy" Ben Alman
 * Dual licensed under the MIT and GPL licenses.
 * http://benalman.com/about/license/
 */

(function($){
  
  var // RegExp that matches opening and closing HTML, HEAD, BODY tags.
6♦
5♣
microsoft.h264.contentscript.js0 stars

var supportedMimeTypes = ['video/mp4', 'video/x-ms-wmv'];
var supportedVideoExtensions = ['.mp4', '.wmv', '.mp4v', '.m4v'];

var getSupportedMediaSource = function(videoElement)
{
    // If the video element source is supported, then we replace the tag.

    if (videoElement.src
        && isWMPSupported(videoElement))
    {
        return videoElement.src;
    }
5♣
4♥
self-demo.js0 stars

self calling worker

document.addEventListener( "DOMContentLoaded", function() {
  
  var selfy = selfish();
  
  
  
  selfy.worker.addEventListener( "message", function( event ) {
    
    var data = event.data;
    
    console.log( data );
  
4♥
3♠
demo.html0 stars

<!DOCTYPE html>
<html>
<head>


  <script src="renderer.js"></script>
  
</head>
<body>

</body>
</html>
3♠
2♦
prepdeploy.php0 stars

<?php

echo "Prepping CSS and JS for deploy...\n";

$css_files['app'] = array('reset', '960', 'screen', 'jquery.tagsinput', 'jquery.autocomplete', 'tipsy', 'prettify');
//$css_files['splash'] = array('reset', 'splash');
//$css_files['iphone'] = array('reset', 'screen', 'iphone');

$js_files['app'] = array('jquery.autocomplete.min', 'jquery.tagsinput', 'jquery.scrollTo-1.4.2-min', 'forrst',
                         'jquery.tipsy', 'jquery.autoresize.min', 'prettify',
                         'lang-apollo',
                         'lang-css',
2♦
A♦
couch-node.ini0 stars


; Just drop this in /etc/couchdb/local.d/ and then
; start CouchDB normally.


; Here couch_node can be anything as long as it's uniq.
[os_daemons]
couch_node = /Users/davisp/tmp/couch-node.js


; This section can be named anything but you should
; probably make it follow the os_daemon name we
A♦
K♣
gistfile1.js0 stars

// get the average color of two hex colors.
function avgcolor(color1,color2){
    var avg  = function(a,b){ return (a+b)/2; },
        t16  = function(c){ return parseInt((''+c).replace('#',''),16) },
        hex  = function(c){ return (c>>0).toString(16) },
        hex1 = t16(color1),
        hex2 = t16(color2),
        r    = function(hex){ return hex >> 16 & 0xFF},
        g    = function(hex){ return hex >> 8 & 0xFF},
        b    = function(hex){ return hex & 0xFF},
        res  = '#' + hex(avg(r(hex1),r(hex2))) 
                   + hex(avg(g(hex1),g(hex2))) 
K♣
Q♥
phpinfo-mine.sh0 stars

#!/bin/sh
# phpinfo-mine
# Finds and retrieves phpinfo() pages from Google results.
#
# Requires WhatWeb and gggooglescan in the current working directory.
#
# It is highly recommended that you change your passwords if your servers'
# passwords appears in this list.
##
# Google Results as at 2011-01-21 #
# 52 results for intitle:"phpinfo()" "mysql.default_password" "Zend Scripting Language Engine"
# 33 results for inurl:"phpinfo.php" intitle:"phpinfo()" "mysql.default_password"
Q♥
J♠
irc-counter.rb0 stars

#!/usr/local/bin/ruby

require "socket"

irc = TCPSocket.open('irc.freenode.net', 6667)
irc.send("USER blah blah blah :blah blah\n", 0)
irc.send("NICK ChanScanBot\n", 0)
irc.send("JOIN #sproutcore\n", 0)

names = []
until irc.eof?
  data = irc.gets
J♠
十♦
js-text-editor.html0 stars

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"
   "http://www.w3.org/TR/html4/strict.dtd">

<html lang="en">
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
	<title>Text Editor</title>
	<meta name="generator" content="TextMate http://macromates.com/">
	<meta name="author" content="Peter Wagenet">
	<!-- Date: 2010-05-12 -->
	<script type="text/javascript" charset="utf-8" src="jquery-1.4.2.js"></script>
十♦
9♣
here.js0 stars

v8 = V8::Context.new

v8["foo"] = proc do |hello|
  # can I get the JS callstack here?
  puts hello
end

v8.eval("function bar() { baz('sven' )}; function baz(name) { foo(name) }")
9♣
8♥
pp.js0 stars

function pp (t) {
  if (typeof console == "object" && typeof console.log == "function") 
    console.log(t);
  else
    print(t);
}
8♥
7♠
serial.js0 stars

var SerialPort = require("./serialport")
var sp = new SerialPort("/dev/ttyUSB0")
sp.write("OMG USB");
// Reading is not perfect yet
sp.on('data', function(data) {
  sys.puts("data");
});             
sp.close();
7♠
6♦
6♦