Skip to content

Instantly share code, notes, and snippets.

View aaronmcadam's full-sized avatar
🎉
Having fun!

Aaron McAdam aaronmcadam

🎉
Having fun!
View GitHub Profile
@aaronmcadam
aaronmcadam / ee_disqus_exporter.rb
Created May 27, 2010 19:26 — forked from shapeshed/ee_disqus_exporter.rb
import ee comments to disqus
# Copyright 2009 Michael Ivey, released to public domain
# Disqus guts lifted from http://github.com/squeejee/disqus-sinatra-importer/tree/master
# I wanted it to run from MySQL and command line, instead of a Sinatra app
require 'rubygems'
require 'rest_client'
require 'json'
require 'sequel'
disqus_url = 'http://disqus.com/api'
@aaronmcadam
aaronmcadam / jquery.textchange.js
Created June 16, 2010 01:47 — forked from mkelly12/jquery.textchange.js
jQuery Text Change Event
(function ($) {
$.event.special.textchange = {
setup: function (data, namespaces) {
$(this).bind('keyup.textchange', $.event.special.textchange.handler);
$(this).bind('cut.textchange paste.textchange input.textchange', $.event.special.textchange.delayedHandler);
},
teardown: function (namespaces) {
@aaronmcadam
aaronmcadam / gist:440401
Created June 16, 2010 09:48 — forked from paulirish/gist:403386
jQuery( elem :any(el) ... )
// Idea from http://dbaron.org/log/20100424-any
jQuery.expr[':'].any = function(el, i, match) {
return jQuery.find.matches(match[3], [el]).length > 0;
};
jQuery('body :any(div, form) p'); // Same as jQuery('body div p, body form p')
jQuery('div:any(.foo,.bar)'); // Same as jQuery('div.foo, div.bar')
@aaronmcadam
aaronmcadam / pubsub.md
Created November 14, 2011 09:22 — forked from addyosmani/pubsub.md
Four ways to do Pub/Sub with jQuery 1.7 and jQuery UI (in the future)

#Four Ways To Do Pub/Sub With jQuery 1.7 and jQuery UI (in the future)

Between jQuery 1.7 and some of work going into future versions of jQuery UI, there are a ton of hot new ways for you to get your publish/subscribe on. Here are just four of them, three of which are new.

(PS: If you're unfamiliar with pub/sub, read the guide to it that Julian Aubourg and I wrote here http://msdn.microsoft.com/en-us/scriptjunkie/hh201955.aspx)

##Option 1: Using jQuery 1.7's $.Callbacks() feature:

$.Callbacks are a multi-purpose callbacks list object which can be used as a base layer to build new functionality including simple publish/subscribe systems. We haven't yet released the API documentation for this feature just yet, but for more information on it (including lots of examples), see my post on $.Callbacks() here:

@aaronmcadam
aaronmcadam / currycompose.coffee
Created February 27, 2012 23:42 — forked from twfarland/currycompose.coffee
Currying / Function composition in coffeescript
arr = Array::
arrSlice = arr.slice
curry = ->
args = arrSlice.call arguments
->
args2 = arrSlice.call arguments
args[0].apply @, args.slice(1).concat(args2)
sum = ->
@resetInputsForForm: (form_html, taskNumber, taskType) ->
form = $(form_html)
form.find('input').each (index, element) ->
taskNamePrefix = "#{taskType}_task"
currentName = $(element).attr('name')
multipleParamNamePrefix = "inputs_for_task['#{taskNumber}']"
newName = currentName.replace(taskNamePrefix, multipleParamNamePrefix)
$(element).attr('name', newName)
form
@aaronmcadam
aaronmcadam / svn.patch
Created May 8, 2012 22:26 — forked from ittayd/svn.patch
tweak for svn prompt in oh-my-zsh
---
plugins/svn/svn.plugin.zsh | 30 ++++++++++++++++++------------
1 files changed, 18 insertions(+), 12 deletions(-)
diff --git a/plugins/svn/svn.plugin.zsh b/plugins/svn/svn.plugin.zsh
index e2cf96c..b5b5265 100644
--- a/plugins/svn/svn.plugin.zsh
+++ b/plugins/svn/svn.plugin.zsh
@@ -1,5 +1,6 @@
function svn_prompt_info {
@aaronmcadam
aaronmcadam / cucumbertables.vim
Created July 4, 2012 14:11 — forked from MaienM/cucumbertables.vim
Auto-align on equal signs (=) using Tabularize.
inoremap <silent> = =<Esc>:call <SID>ealign()<CR>a
function! s:ealign()
let p = '^.*=\s.*$'
if exists(':Tabularize') && getline('.') =~# '^.*=' && (getline(line('.')-1) =~# p || getline(line('.')+1) =~# p)
let column = strlen(substitute(getline('.')[0:col('.')],'[^=]','','g'))
let position = strlen(matchstr(getline('.')[0:col('.')],'.*=\s*\zs.*'))
Tabularize/=/l1
normal! 0
call search(repeat('[^=]*=',column).'\s\{-\}'.repeat('.',position),'ce',line('.'))
endif
@aaronmcadam
aaronmcadam / filter_subdir.sh
Created August 7, 2012 20:50 — forked from cowboy/filter_subdir.sh
Make a new repo from a subdirectory of an original repo
# Please don't just RUN this. Do it step-by-step.
user=bocoup
orig_repo=training
new_repo=training-jquery
subdir=jquery-conference
# Pull down the original repo.
git clone [email protected]:$user/$orig_repo.git $new_repo
# Repo, I'm in you.
@aaronmcadam
aaronmcadam / Accommodation.rb
Created August 9, 2012 11:06 — forked from jeroenr/Accommodation.rb
Use ActiveResource with non-Rails REST API
class Accommodation < ActiveResource::Base
class << self
def element_path(id, prefix_options = {}, query_options = nil)
prefix_options, query_options = split_options(prefix_options) if query_options.nil?
"#{prefix(prefix_options)}#{collection_name}/#{id}#{query_string(query_options)}"
end
def collection_path(prefix_options = {}, query_options = nil)
prefix_options, query_options = split_options(prefix_options) if query_options.nil?
"#{prefix(prefix_options)}#{collection_name}#{query_string(query_options)}"