Skip to content

Instantly share code, notes, and snippets.

@hughfdjackson
hughfdjackson / Compiled js.js
Created January 25, 2012 00:41
CoffeeScript trial.
(function() {
var Actor, Meta, flatten_world, flywheel, inner_loop, pure, render, _;
flywheel = require("./lib/flywheel");
_ = require("./lib/underscore");
pure = {};
Actor = function() {
@hughfdjackson
hughfdjackson / gist:1674220
Created January 25, 2012 02:22 — forked from anonymous/gist:1674197
kayseebee - pastebin.com/m8jye8Y0
<script type="text/javascript">
var counter = 0;
function execLot()
{
var grpNums1 = new Array(1,2,3,4,5,6,7,8,9,10);
var index1 = Math.floor(Math.random()*grpNums1.length);
@hughfdjackson
hughfdjackson / gist:1680645
Created January 26, 2012 02:47 — forked from anonymous/gist:1680643
Lordveda - pastebin.com/UDjr6Cxd
// initialize the counter and the array
var numnames = 0;
var names = new Array();
function SortNames(){
// Get the name from the text field and convert it to Upper Case
var thename = document.theform.newname.value;
thename=thename.toUpperCase();
// Add the name to the array
names[numnames] = thename;
// Increment the counter
@hughfdjackson
hughfdjackson / gist:1700353
Created January 29, 2012 19:51 — forked from anonymous/gist:1700314
joe972 - pastebin.com/9gBXuCUe
<html>
<head>
<script type="text/javascript">
function newTable(form)//begins function
{
var rows = Number(form.rows.value);//number function converts object values to their numbers
var cols = Number(form.columns.value);//number function converts object values to their numbers
@hughfdjackson
hughfdjackson / gist:1700354
Created January 29, 2012 19:51 — forked from anonymous/gist:1700322
sgflt - pastebin.com/drsKKm4n
What I want: Load a number of images and fire a callback once all are loaded. The image objects of all images need to be available, this is *not* just for caching.
Example use:
var loader = new ImageLoader();
var img1 = loader.addImage('someurl');
var img2 = loader.addImage('anotherurl');
loader.beginLoading(function() {
/* do something with the loaded images img1 and img2, which are Image objects
});
@hughfdjackson
hughfdjackson / gist:1703648
Created January 30, 2012 09:59 — forked from anonymous/gist:1703623
sendoushi - pastebin.com/JzGNVwCB
void function(){
var InstM=jQuery('#InstitutionalM');
var SolutM=jQuery('#SolutionsM');
var DevM=jQuery('#DevelopersM');
InstM.subname=jQuery('#InstitutionalSM');
SolutM.subname=jQuery('#SolutionsSM');
DevM.subname=jQuery('#DevelopersSM');
var AllSubMenu=jQuery('#InstitutionalM,#SolutionsM,#DevelopersM');
@hughfdjackson
hughfdjackson / gist:1775237
Created February 8, 2012 23:04 — forked from anonymous/gist:1775221
TheWarden - pastebin.com/3bv12LsW
function selectStoreValues(fromElementID,toElementID)
{
var fileToTableObj = document.getElementById('ImportexportFilesSelected');
var fileToTable = fileToTableObj.options[fileToTableObj.selectedIndex].value;
var txtSelectedValuesObj = document.getElementById(toElementID);
var selectedArray = new Array();
var selObj = document.getElementById(fromElementID);
var i;
var count = 0;
for (i=0; i<selObj.options.length; i++)
function foo(a){
return a == 1 ? "that was one!"
: a == 2 ? "and that one was twoooo"
: /* otherwise */ "I can't deal with bigger numbers"
}
@hughfdjackson
hughfdjackson / gist:1848933
Created February 16, 2012 23:56
fizzbuzz w/ nested ternaries
function fizzbuzz(len){
var res = []
for ( var i = 1; i <= len; i += 1 ) res.push(fizz_or_buzz(i))
return res
function fizz_or_buzz(num){
return num % 3 == 0 && num % 5 == 0 ? "fizzbuzz"
: num % 3 == 0 ? "fizz"
!function(){
var game = {
foo: function(){
return game
}
}
console.log(game.foo())
}()