Skip to content

Instantly share code, notes, and snippets.

View kyledecot's full-sized avatar
🤘

Kyle Decot kyledecot

🤘
View GitHub Profile
@kyledecot
kyledecot / gist:2782141
Created May 24, 2012 15:11
Alias for opening current directory in Coda 2
alias coda='open -a /Applications/Coda\ 2.app .'
@kyledecot
kyledecot / string_additions.rb
Created May 21, 2012 19:12
Ruby String#to_md5
require 'digest/md5'
class String
def to_md5
Digest::MD5.hexdigest(self)
end
end
# "Hello World!".to_md5
@kyledecot
kyledecot / each_slice.js
Created May 11, 2012 17:57
jQuery.each_slice inspired by Ruby's each_slice
(function($) {
$.each_slice = function(num, things, iterator) {
var tmp = [];
$.each(things, function(index, thing) {
tmp.push(thing);
if (tmp.length >= num || (index + 1) >= things.length) {
iterator(tmp);
tmp = [];
}
});
@kyledecot
kyledecot / gist:2159149
Created March 22, 2012 15:52
Unobtrusive JS for submitting a delete link
jQuery('body').on('click', '[data-method="delete"]', function(event) {
event.preventDefault();
var confirm_msg = jQuery(this).data('confirm');
var form = jQuery('<form />').attr({
method : 'POST',
action : jQuery(this).attr('href')
});