Skip to content

Instantly share code, notes, and snippets.

@tirams
tirams / jqueryize.js
Created December 20, 2011 00:29
function to include latest jquery
function(){
if (typeof jQuery != 'undefined')
{
console.log('jquery version ' + $.fn.jquery);
return;
}
var s=document.createElement('script');
s.setAttribute('src','http://code.jquery.com/jquery.min.js');
document.body.appendChild(s);
void(s);
@tirams
tirams / BradleyAudio.css
Created December 22, 2011 04:12
Audio troubleshooting for Bradley
/* globals */
html {
font:62.5%/1 "Droid Sans", "Lucida Sans Unicode", "Lucida Grande", Verdana, Arial, Helvetica, sans-serif;
background: url('background.png');
background-repeat: no-repeat
}
body {
margin: 0 auto;
}
@tirams
tirams / htmlForLoadJQuery.txt
Created December 22, 2011 04:56
How to add html tag to include jquery
_ ____
(_)/ __ \
_| | | |_ _ ___ _ __ _ _
| | | | | | | |/ _ \ '__| | | |
| | |__| | |_| | __/ | | |_| |
| |\___\_\\__,_|\___|_| \__, |
_/ | __/ |
|__/ |___/
//get latest minified
$(function () { // this line makes sure this code runs on page load
$('.checkall').click(function () {
$(this).parents('fieldset:eq(0)').find(':checkbox').attr('checked', this.checked);
});
});
@tirams
tirams / getRallyStories.js
Created January 19, 2012 19:29
extract data from Rally views
// extract the stories from rally list
//jQuerieze the page first to use it
var stories=""; rows = jQuery('#storycard_tps tr').each(function(ind, e) {
var vals={}; $(e).find('td').each(function(indt,f) {
if (f.className.indexOf('idstring') != -1)
stories += f.innerText + ",";
else if (f.className.indexOf('name0') !=-1)
stories += f.innerText + ",";
else if (f.className.indexOf('owner') !=-1)
stories += f.innerText + "\n";
@tirams
tirams / preloadImages
Created February 15, 2012 07:04
jQuery plugin to preload images
// Usage: $(['img1.jpg','img2.jpg']).preloadImages(function(){ ... });
// Callback function gets called after all images are preloaded
$.fn.preloadImages = function (callback)
{
// Helper function, used below.
// Usage: ['img1.jpg','img2.jpg'].remove('img1.jpg');
var checklist = this.toArray();
var removeImg = function (element)
{
@tirams
tirams / twipsy-view.js
Created February 15, 2012 07:16 — forked from oroce/twipsy-view.js
Twitter Bootstrap Backbone.View
var TwipsyView = Backbone.View.extend({
tagName: "div",
className: "twipsy fade",
events: {
"mouseenter": "show",
"mouseleave": "hide"
},
options: {
enabled: true,
title: "twipsyView",
@tirams
tirams / gist:1834006
Created February 15, 2012 07:18 — forked from joneath/gist:1680082
Basic Backbone View Jasmine Test
describe("NotesView", function() {
beforeEach(function() {
var notes = new NotesCollection();
spyOn(notes, "fetch");
var view = new NotesView({collection: notes});
});
describe("#initialize", function() {
it("should fetch the notes", function() {
@tirams
tirams / profileJavascript.snippet
Created February 29, 2012 15:23
add timing to a js page to test performance
// with jQuery on the page do the nezt line in the debugger to include the timer scripts
jQuery.getScript("http://remysharp.com/time.packed.js")
time.func(funcname);
time.stop('nameforeport')
time.start('nameforreport')
//----------------------- DOC ----------------
// see http://remysharp.com/2007/04/20/performance-profiling-javascript/
Synxtax
@tirams
tirams / colorParents.js
Created July 13, 2012 13:50
jquery snippet to dump position info and outline with color borders an element and its parents
//*debug layout *//
function randomColor() {
return '#' + Math.floor(Math.random() * 16777215).toString(16);
}
//The .offset() the current position of an element relative to the document
function colorParents(startelt, on) {