Skip to content

Instantly share code, notes, and snippets.

View lscott3's full-sized avatar

Larry Scott lscott3

View GitHub Profile
@lscott3
lscott3 / alias
Last active December 11, 2015 21:58
alias project='cd ~/path/to/project/; rm log/test.log && rm log/development.log; touch log/test.log && touch log/development.log && git branch'
@lscott3
lscott3 / deploy.rb
Created January 18, 2013 03:28
Run rake task from capistrano
desc 'Run the sqlite dump after deploy'
task :sqlite_dump_dev do
rake = fetch(:rake, 'rake')
rails_env = fetch(:rails_env, 'development')
run "cd '#{current_path}' && #{rake} sqlite_dump RAILS_ENV=#{rails_env}"
end
@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 / 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
<%-- 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: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
@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
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