Skip to content

Instantly share code, notes, and snippets.

<snippet>
<content><![CDATA[{
"name": "${1:Project}",
"version": "${2:0.0.1}",
"private": ${3:true},
"dependencies": {
}
}]]></content>
<tabTrigger>bower</tabTrigger>
<scope></scope>
@lukemartin
lukemartin / app.coffee
Last active August 29, 2015 14:04
Bluebird Promise Example
Promise = require 'bluebird'
getName = ->
return new Promise((resolve) -> resolve('Luke'))
getAge = (name) ->
data =
'Luke': 27
@lukemartin
lukemartin / git-tagssorted
Created August 12, 2014 13:24
Git: Sort tags
#!/bin/sh
# put in ~/bin
# make executable
# git tagssorted
git for-each-ref --format="%(taggerdate): %(refname)" --sort=-taggerdate --count=10 refs/tags
@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: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: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: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%;