Skip to content

Instantly share code, notes, and snippets.

View rpheath's full-sized avatar

Ryan Heath rpheath

View GitHub Profile
// Why is this not working in IE!?!?
// (using jQuery 1.4.2 and Rails 2.3.5)
// The issue is that it either: 1) posts as a regular form, ignoring the ajax
// or 2) asks me to download a file
// Yes, I've tried config.action_controller.use_accept_header = false
// in environment.rb and that has no effect on the outcome
// force accept headers
@rpheath
rpheath / jquery.infinitescroll.js
Created November 2, 2010 01:46
A jQuery plugin for bi-directional infinite scrolling
(function($) {
$.scroller = {
// default settings
settings: {
url: null,
reversed: true,
triggerAt: 250,
page: 2,
container: $(document),
update: '#scroller'
@rpheath
rpheath / jquery.infinitescroll.js
Created November 2, 2010 01:48
A jQuery plugin for bi-directional infinite scrolling
// A bi-directional infinite scrolling jQuery plugin
//
// Usage Example:
// $(window).infiniteScroll({ url: window.location.href })
(function($) {
$.scroller = {
// default settings
settings: {
url: null,
development:
subdomain: development-subdomain
api_key: XXX
site_key: XXX
production:
subdomain: production-subdomain
api_key: XXX
site_key: XXX
@rpheath
rpheath / validator.coffee
Created February 7, 2012 05:36
Client-Side Password Validator
# Playing around with CoffeeScript...
#####################################################################################
# Validator needs to inherit from Module class so we can support mixins
class Module
@include: (obj) ->
for key, value of obj
@::[key] = value
# -----------------------------------------------------------------------------------
@rpheath
rpheath / gemspec-usage.md
Created February 29, 2012 03:10 — forked from scharfie/gemspec-usage.md
test/spec/mini

Just install this in your apps like so:

gem 'test-spec-mini', :git => 'git://gist.github.com/1806986.git', :require => 'mini'

@rpheath
rpheath / template.js
Created April 24, 2012 17:16
Template Caching
// handles caching and rendering templates
var Template = (function() {
// initialize private method container
var TemplateHandler = function() {};
// private methods
TemplateHandler.prototype = {
// used to hold the collection of
// key/value cached templates
templates: {},
@rpheath
rpheath / article.rb
Created August 6, 2012 18:30
Link Validation
class Article < ActiveRecord::Base
# ...
def embedded_links
self.body_html.scan(/<a.+?href="(.+?)".+?/) if body_html
end
def has_links?
self.embedded_links.flatten.present?
end
@rpheath
rpheath / autosave.js
Created August 22, 2012 01:34
Auto-saving
// Usage:
// $(function() { $(document).autosave(); });
(function($) {
// initialize the namespace with an empty timer
$.autosave = { timer: null };
// NOTE: all actionable methods below provide hooks that you can
// bind to as needed (both before/after hooks are triggered)