Skip to content

Instantly share code, notes, and snippets.

@joshgillies
joshgillies / bespin-bookmarklet-4-mysource-matrix.js
Created January 11, 2011 01:07
WIP: Enable the Bespin Bookmarklet to enable fancy editing of MySource Matrix design parse files
javascript:(function(){var%20elem=document.createElement('script');elem.setAttribute('src','https://bespin.mozillalabs.com/bookmarklet/bookmarklet.js');document.getElementById('main_frameset').getElementsByTagName('frame')[2].contentWindow.document.body.appendChild(elem);})()
@joshgillies
joshgillies / sonofspam.txt
Created September 26, 2011 06:31
Comprehensive list of rules for #sonofspam
first rule of #sonofspam, don't talk about #sonofspam
second rule of #sonofspam, don't spam #sonofspam, unless you're dave
third rule of #sonofspam, matt, you're banned, get over it :)
fourth rule of #sonofspam, the direction is always ------------>
fifth rule of #sonofspam, you can only complain about your irc client if it isn't irssi
@joshgillies
joshgillies / gist:1708729
Created January 31, 2012 04:11
Print Preview Shizz
(function(url, search) {
var printButton = $("#nav").find(".printer");
var searchString = (search) ? search + "&SQ_DESIGN_NAME=printer_friendly" : false;
var printButtonHref = (searchString) ? printButton.attr("href") + searchString : false;
(printButtonHref) ? printButton.attr("href", printButtonHref) : printButton.attr("href");
})("<MySource_PRINT id="__global__" var="asset_url" />", window.location.search);
gist + sublimetext 2 = hawtness! needs mo hax
@joshgillies
joshgillies / gist:1990873
Created March 7, 2012 04:04
WCAG AA document.write()
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
<script>window.jQuery || document.write('<script src="js/libs/jquery-1.7.1.min.js"><\/script>')</script>
@joshgillies
joshgillies / callback.js
Created July 20, 2012 04:07
Fun with JS callbacks!
// getting my head around callbacks, would like to take this further. Maybe another time.
// See this code live: http://jsconsole.com/?function%20testMe(%20a%2C%20b%2C%20c%2C%20callback%20)%20%7B%0A%20%20var%20test%20%3D%20a%2C%0A%20%20%20%20%20%20test2%20%3D%20b%2C%0A%20%20%20%20%20%20test3%20%3D%20c%3B%0A%20%20console.log(test%20%2B%20%22%20%22%20%2B%20test2%20%2B%20%22%20%22%20%2B%20test3)%3B%0A%20%20test2%20%3D%20b%20%2B%207%3B%0A%20%20return%20callback(%20test%2C%20test2%2C%20test3%20)%3B%0A%7D%0A%0Afunction%20testThis(%20callback%20)%20%7B%0A%20%20console.log(%22helloworld%22)%3B%0A%20%20console.log(typeof%20callback)%3B%0A%20%20(typeof%20callback%20%3D%3D%3D%20'number'%20%3F%20%20callback%20%3D%20callback%20%2B%207%20%3A%20callback)%3B%0A%20%20return%20callback%3B%0A%7D%0A%0AtestThis(%20testMe(%20%22string%22%2C%2020%2C%20false%2C%20function%20()%20%7B%0A%20%20return%20test2%3B%0A%7D))%3B
function testMe( a, b, c, callback ) {
var test = a,
test2 = b,
test3 = c;
console.log(test + " "
@joshgillies
joshgillies / id-v-class.md
Created November 22, 2012 00:00
In defence of... I dunno, smart CSS?

Some notes around the article I've just read from JZ; http://www.zeldman.com/2012/11/21/in-defense-of-descendant-selectors-and-id-elements/

Whilst OOCSS is the new hotness (or at least was a few years ago), I can faithfully agree with the notion of every element in your mark-up DOES NOT require a class... In fact use classes as a way to describe your mark-up where a descriptive/semantic tag ins't available.

By the same token, the use of an ID where appropriate is totally fine, as JZ

for instance with ID's seeing something like this in CSS is completely wrong:

#paraInsideAside {
@joshgillies
joshgillies / hax.js
Created November 30, 2012 05:21
Link bait hax0r. Pulled from a compromised FTP server recently.
ww = window;
try {
ww.document.body = ww.document.body
} catch(dgsgsdg) {
zxc = 1;
}
try {
if(ww.document) window["doc" + "ument"]["body"] = ww.document
} catch(bawetawe) {
if(ww.document) {
@joshgillies
joshgillies / .vimrc
Created June 13, 2013 07:05
dat vim
" Use Vim settings, rather then Vi settings (much better!).
" This must be first, because it changes other options as a side effect.
set nocompatible
" TODO: this may not be in the correct place. It is intended to allow
" overriding <Leader>.
" source ~/.vimrc.before if it exists.
if filereadable(expand("~/.vimrc.before"))
source ~/.vimrc.before
endif " ================ General Config ====================
@joshgillies
joshgillies / pw-hax.js
Created February 27, 2014 04:18
some things for things
var json = {
data: ['a','bunch','of','things']
};
var otherData = {
things: [],
madness: {}
};
json.data.forEach(function(data,index,array){