Skip to content

Instantly share code, notes, and snippets.

@lukemartin
lukemartin / gist:1070357
Created July 7, 2011 19:40
Git: cheat sheet
# Remove deleted files from repo
$ git add -u
# Delete untracked files from local disk
$ git clean -f
# Amend previous commit (only unpushed commits)
$ git commit --amend
@lukemartin
lukemartin / gist:1071270
Created July 8, 2011 06:49
JavaScript: jQuery plugin template
(function ($) {
$.fn.droppie = function (options) {
// override options
var opts = $.extend({}, $.fn.plugin.defaults, options);
return this.each(function() {
$.fn.plugin.something();
});
};
@lukemartin
lukemartin / gist:1071273
Created July 8, 2011 06:52
JavaScript: Method comments
/**
* Description of the method
* @param {Object} param1 description of object
* @param {String} param2 description of string
* @param {Int} param3 description of integer
*/
var something = function(param1, param2, param3) {
return;
};
@lukemartin
lukemartin / gist:1071281
Created July 8, 2011 06:59
JavaScript: Loose augmentation pattern
// Global UI object
var UI = UI || {};
UI.Generic = (function($) {
var my = {};
// Public
my.foo = "Something";
my.bar = function() {
return "Something else";
@lukemartin
lukemartin / gist:1071283
Created July 8, 2011 06:59
JavaScript: Generic.js
// Global UI object
var UI = UI || {};
// Generic methods
UI.Generic = (function ($) {
var my = {};
// init methods
my.init = function () {
@lukemartin
lukemartin / gist:1094564
Created July 20, 2011 08:16
Facebook: Auto-resize height of iframe
<div id="fb-root"></div>
<script type="text/javascript">
window.fbAsyncInit = function() {
FB.init({
appId: 'APP_ID_HERE',
status: true,
cookie: true,
xfbml: true
});
@lukemartin
lukemartin / gist:1094751
Created July 20, 2011 10:43
CSS: Horizontally centre list items
ul {
float: left;
left: 50%;
margin: 0;
padding: 0;
position: relative;
}
ul li {
float: left;
left: -50%;
@lukemartin
lukemartin / gist:1096955
Created July 21, 2011 10:53
JavaScript: JSHint parameters
/*jshint asi: false, curly: true, debug: false, eqeqeq: true, onevar: true, undef: true */
/*global jQuery: true, setTimeout: true */
@lukemartin
lukemartin / gist:1162843
Created August 22, 2011 16:34
RegEx - Add spaces to Zen Coding's replacements
Find:
("[\S]+": ")([a-z\-]+:)([a-z\-|]+)
Replace:
$1$2 $3
@lukemartin
lukemartin / gist:1292433
Created October 17, 2011 11:27
Regex: Remove comma from last object property
Find: (\S+:\s*[\S]+),(\s+})
Replace: $1$2