Skip to content

Instantly share code, notes, and snippets.

var array = ["one", "two", "three", "four", "five"];
document.writeln(array + "<br />");
var newArray = shuffle(array);
document.writeln(newArray);
function shuffle (arr) {
var copy = arr.concat(),
sample gist
<!DOCTYPE html>
<html>
<head>
<title>jQuery Templating Demo</title>
<style type="text/css">
html {
background:#f3f3f3;
font: 13px/1.5 helvetica, arial, san-serif;
}
ul {
(function ($) {
$.fn.chromeFade = function (opts) {
var defs = { msTilFade : 2000, fadeSpeed : 500, fadeTo : 0.01 },
sets = $.extend({}, defs, opts),
elems = this,
fadeFunc = function () {
elems.fadeTo(sets.fadeSpeed, sets.fadeTo);
},
fadeTimer = setTimeout(fadeFunc, sets.msTilFade);
@andrew8088
andrew8088 / jquery_mobile.html
Created October 17, 2010 01:42
playing with jQuery Mobile
<!DOCTYPE html>
<html>
<head>
<title>Page Title some change </title>
<link rel="stylesheet" href="http://code.jquery.com/mobile/1.0a1/jquery.mobile-1.0a1.min.css" />
<script src="http://code.jquery.com/jquery-1.4.3.min.js"></script>
<script src="http://code.jquery.com/mobile/1.0a1/jquery.mobile-1.0a1.min.js"></script>
</head>
<body>
@andrew8088
andrew8088 / __noSuchMethod__.js
Created October 22, 2010 15:31
Playing around with FireFox's __noSuchMethod__ property; all browsers should have this!
var myObj = (function () {
var data = {
products : ["foobar", "bazquirk", "gizmo"],
services : ["widgets", "other", "last"]
};
return {
__noSuchMethod__ : function (id, args) {
if (id === 'all_products') return data.products;
if (id === 'all_services') return data.services;
@andrew8088
andrew8088 / tumblr2opml.js
Created November 25, 2010 21:27
You can run this script on tumblr.com/following and you'll get an OPML file for tumblogs on that page print out to the console, ready for you to copy+paste into a file and import into Google Reader.
clear();
var feeds = Array.prototype.slice.call(document.querySelectorAll("div.name a")),
i = 0, p, f, doc = "";
while (feeds[i]) {
f = feeds[i];
feeds[i++] = {
htmlUrl : f.href,
xmlUrl : f.href + 'rss',
title : f.innerHTML,
@andrew8088
andrew8088 / oop.js
Created December 12, 2010 02:15
OOP in JS
var tooltip_button = {
show : function () {
this.panel.show();
},
hide : function () {
this.panel.hide();
},
bind_events : function () {
var that = this;
this.button.bind("mouseover.Tooltip_Button", function () { that.show.call(that); });
@andrew8088
andrew8088 / yui_exercise_1.html
Created January 21, 2011 18:35
For some reason, the handler on "#groupA li" works for lis in groupB
<div id="exercise" class="yui3-g">
<div class="yui3-u-1-2">
<h3>Group A</h3>
<ul id="groupA">
<li>Steven Tyler</li>
<li>Joe Perry</li>
<li>Brad Whitford</li>
<li>Tom Hamilton</li>
</ul>
</div>
@andrew8088
andrew8088 / twitter-scrolling.js
Created February 16, 2011 14:07
This code is an alternate version of the code found in my tutorial on Nettuts+: http://net.tutsplus.com/tutorials/javascript-ajax/implement-twitter-scrolling-without-jquery-2
$(document).bind("scroll", function (e) {
scrolling = true;
});
setInterval(function () {
if (scrolling) {
//console.profile("scroll");
scrolling = false;
var temp_top = win.scrollTop(),
down = scroll_top - temp_top < 0 ? true : false,