Skip to content

Instantly share code, notes, and snippets.

Avatar

John Hunter johnhunter

View GitHub Profile
@johnhunter
johnhunter / table-cell-background.html
Created Aug 27, 2011
TextMate snippet: table cell background (html email)
View table-cell-background.html
<!--
Don't forget to add:
<html xmlns:v="urn:schemas-microsoft-com:vml">
-->
<!--[if gte mso 9]>
<v:image xmlns:v="urn:schemas-microsoft-com:vml" style='behavior: url(#default#VML);
display: inline-block;
position: absolute;
height: ${1:100}px;
width: ${2:100}px;
@johnhunter
johnhunter / gist:1176741
Created Aug 28, 2011
TextMate snippets for JS modules
View gist:1176741
/*
Module $1
${7:Description of $1.}
@author ${TM_FULLNAME}
created `date +%Y-%m-%d`
*/
var ${1:module} = (function (${2:\$}) {
var ${5:bar};
${4:function foo () { return bar; \}
@johnhunter
johnhunter / gist:1225265
Created Sep 18, 2011
Random color hex value
View gist:1225265
'#' + Math.floor(Math.random() * 0xffffff).toString(16);
@johnhunter
johnhunter / modules.html
Created Oct 10, 2011
Files that acompany the JavaScript workshop on 10th Oct 2011
View modules.html
<!DOCTYPE html>
<html><head>
<meta charset="utf-8">
<title>Modules</title>
</head><body><script>
@johnhunter
johnhunter / gist:1297920
Created Oct 19, 2011
Weinre mobile remote debug booklarklet
View gist:1297920
javascript:(function(e,h){h=prompt('Enter hostname (return for localhost)');h=h||'localhost';e.setAttribute("src","http://"+h+":8081/target/target-script-min.js#anonymous");document.getElementsByTagName("body")[0].appendChild(e);}(document.createElement("script")));
@johnhunter
johnhunter / jquery.minmax.js
Created Nov 3, 2011
Run min / max over a JQuery object to equalise heights etc.
View jquery.minmax.js
/*
min, max - jQuery plugins which set css properties to min/max value for the collection
@author John Hunter
created 2011-11-03
use: $('li.tabs').max('height');
*/
(function ($) {
$.fn.max = function (prop) { return foldProp(this, Math.max, prop); };
$.fn.min = function (prop) { return foldProp(this, Math.min, prop); };
@johnhunter
johnhunter / gist:1362075
Created Nov 13, 2011
Example JavaScript Pseudo-class
View gist:1362075
// Example Pseudo-class
var Animal = (function() {
function Animal(name) {
this.name = name;
}
Animal.prototype.getName = function () {
return this.name;
};
@johnhunter
johnhunter / gist:1438452
Created Dec 6, 2011
Have Alfed search the jquery API docs
View gist:1438452
alfredapp://customsearch/Search%20JQuery%20API/jquery/ascii/url=http://api.jquery.com/?s={query}
@johnhunter
johnhunter / app.js
Created Dec 10, 2011
Nodejs chat with socket.io
View app.js
/*
Websockets using http://socket.io/
Also with express web mvc framework http://expressjs.com/
*/
var app = require('express').createServer(),
io = require('socket.io').listen(app),
port = 88;
View useful-mixins.less
/*
Less mixins (http://css-tricks.com/snippets/css/useful-css3-less-mixins/)
*/
.text-shadow (@string: 0 1px 3px rgba(0, 0, 0, 0.25)) {
text-shadow: @string;
}
.box-shadow (@string) {
-webkit-box-shadow: @string;
-moz-box-shadow: @string;
box-shadow: @string;
You can’t perform that action at this time.