Skip to content

Instantly share code, notes, and snippets.

@kflorence
kflorence / git-tidy-alias
Created February 20, 2014 01:25
Git alias for removing stale branches that have already been merged into master
[alias]
tidy = !git branch --merged master | grep -v 'master$' | xargs git branch -d && git remote | xargs -n 1 git remote prune
@kflorence
kflorence / devtools.md
Created March 28, 2014 18:05
Handy development tools
@kflorence
kflorence / 1password
Created February 9, 2015 21:25
Serve 1Password Anywhere from Dropbox folder
# Serve 1Password anywhere from the Dropbox folder
server {
listen 80;
server_name 1password;
root /home/kflorence/Dropbox/1Password.agilekeychain;
location / {
index 1Password.html;
}
}
@kflorence
kflorence / ubuntu_setup.md
Last active August 29, 2015 14:15
Ubuntu setup

Use above instructions to install the Spotify Linux preview.

Git

sudo apt-get install git
@kflorence
kflorence / .bash_profile
Created April 8, 2015 19:00
.bash_profile Mac OS X
function parse_git_branch {
git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ (\1)/'
}
# Nicer looking prompt with git branch in it
# https://github.com/mbadolato/iTerm2-Color-Schemes
export PS1="\[\033[36m\]\u\[\033[m\]:\[\033[33;1m\]\w\[\033[m\]\[\033[35;1m\]\$(parse_git_branch)\[\033[m\]\$ "
# ls colors
export CLICOLOR=1
@kflorence
kflorence / jquery.plugin.js
Created November 17, 2010 01:43
jQuery plugin pattern
(function($) {
// $.widget-lite
$.plugin = function(name, base, prototype) {
if (!prototype) {
prototype = base;
base = function(options, element) {
if (arguments.length) {
$.data(element, name, this);
this.element = $(element);
this._init(options);
@kflorence
kflorence / ieChangeFix.js
Created January 8, 2011 02:11
Fix for IE not firing the change event for certain inputs (namely, checkboxes and multiple select lists).
/**
* Fixes binding the "change" event to checkboxes and select[type=multiple]
* for Internet Explorer.
*
* @param {jQuery|Element|Element[]} elements
* The DOM Element we wish to bind the event to.
*
* @param {String} eventType
* The name of the event we want to bind to.
*
// ----------------------------------------------------------
// A short snippet for detecting versions of IE in JavaScript
// without resorting to user-agent sniffing
// ----------------------------------------------------------
// If you're not in IE (or IE version is less than 5) then:
// ie === undefined
// If you're in IE (>=5) then you can determine which version:
// ie === 7; // IE7
// Thus, to detect IE:
// if (ie) {}
@kflorence
kflorence / jquery-attached-detatched.js
Created April 28, 2011 19:14
Convenience methods to determine whether or not an element is attached or detached from the DOM
(function( jQuery ) {
jQuery.extend({
attached: function( elem ) {
if ( elem instanceof jQuery ) {
elem = elem[ 0 ];
}
return jQuery.contains( elem.ownerDocument.documentElement, elem );
},
detached: function( elem ) {
@kflorence
kflorence / isArrayLike.js
Created April 29, 2011 00:24
isArrayLike
(function( jQuery ) {
// Determines if we can treat an object like an array.
var isArrayLike = function( obj ) {
var length;
// Supports arrays, jQuery objects, nodeLists and HTMLCollections
// Should also support function arguments, but there is no cross-browser way...
return obj && ( obj instanceof jQuery || ( typeof obj === "object" &&
!jQuery.isWindow( obj ) && ( typeof ( length = obj.length ) === "number" &&
( obj.item && ( obj.namedItem || jQuery.isFunction( obj.item ) ) ) ) || jQuery.isArray( obj ) ) );