Skip to content

Instantly share code, notes, and snippets.

View lscott3's full-sized avatar

Larry Scott lscott3

View GitHub Profile
@lscott3
lscott3 / ajax.js
Created January 4, 2013 01:55
Ajax Success
$("form#new_note").bind("ajax:success", function(xhr, data, status){
// this is where the success stuff goes
});
@lscott3
lscott3 / .gitignore
Created January 3, 2013 19:36
Gitignore file
# See http://help.github.com/ignore-files/ for more about ignoring files.
#
# If you find yourself ignoring temporary files generated by your text editor
# or operating system, you probably want to add a global ignore instead:
# git config --global core.excludesfile ~/.gitignore_global
# Ignore bundler config
/.bundle
# Ignore the default SQLite database.
@lscott3
lscott3 / maxlength.js
Created October 4, 2012 19:02
maxlength.js
jQuery.fn.limitMaxlength = function(options){
var settings = jQuery.extend({
attribute: "maxlength",
onLimit: function(){},
onEdit: function(){}
}, options);
// Event handler to limit the textarea
var onEdit = function(){
@lscott3
lscott3 / blank_migration.rb
Created August 1, 2012 15:08
Removing migration data
class CreateAttributes < ActiveRecord::Migration
def change
end
end
@lscott3
lscott3 / heroku-db-config.txt
Created July 30, 2012 18:44
Configure heroku app to use a mysql db.
heroku config:add DATABASE_URL=mysql2://username:password@ip.goes.here/data_base_name --app heroku-app-name
<%-- This block checks the number of items in a contentloop
---------------------------------------------------------------------------------- --%>
<cms:contentaccess var="content" scope="page" />
<c:set var="count" value="${fn:length(content.valueList['Bottom'])}" />
<%-- End the check
----------------------------------------------------------------------------------- --%>
@lscott3
lscott3 / application_controller.rb
Created May 17, 2012 02:38
Full Authentication, Authlogic
class ApplicationController < ActionController::Base
helper_method :current_account, :current_user # you may have others that go here too
private
# I added this so that way I can just use current_account just like current_user
def current_account
@current_account = Account.find_by_subdomain(request.subdomain)
return @current_account
@lscott3
lscott3 / application_controller.rb
Created May 17, 2012 02:06
Authlogic application controller
class ApplicationController < ActionController::Base
helper_method :current_account, :current_user # you may have others that go here too
private
# I added this so that way I can just use current_account just like current_user
def current_account
@current_account = Account.find_by_subdomain(request.subdomain)
return @current_account
class UserSessionsController < ApplicationController
def new
@user_session = current_account.user_sessions.build
end
end
class Account < ActiveRecord::Base
has_many :users
authenticates_many :user_sessions, :scope_cookies => true
# Other code by you
end