Skip to content

Instantly share code, notes, and snippets.

View lardawge's full-sized avatar

Larry Sprock lardawge

  • Los Angeles, CA
View GitHub Profile
module Devise
module Strategies
class Token < Base
attr_reader :email, :token
def initialize(env, scope = nil)
super
return unless auth = ActionController::HttpAuthentication::Token.token_and_options(request)
@lardawge
lardawge / .bash_profile
Last active July 26, 2019 22:44
Shortcuts and scripts for Git
# Run brew install git bash-completion
# Add bash-completion to your ~/.bash_profile:
[ -f /usr/local/etc/bash_completion ] && . /usr/local/etc/bash_completion || {
# if not found in /usr/local/etc, try the brew --prefix location
[ -f "$(brew --prefix)/etc/bash_completion.d/git-completion.bash" ] && \
. $(brew --prefix)/etc/bash_completion.d/git-completion.bash
}
DULL=0
BRIGHT=1
@lardawge
lardawge / deploy.rb
Last active December 18, 2015 18:19
Restart resque workers on capistrano deploy
desc "Kill resque workers"
task :kill_processes, :roles => :god, :on_no_matching_servers => :continue do
run "cd #{deploy_to}/current && rake resque:restart_workers RAILS_ENV=#{rails_env}" do |ch, stream, data|
puts data
end
end
end
@lardawge
lardawge / server_security_setup.md
Last active December 16, 2015 08:39
Initial setup for Linux

Server setup

Add

Adding initial software and deploy user

ssh root@<ip_address>
apt-get -y update
apt-get -y install curl git-core python-software-properties
apt-get -y install software-properties-common # ubuntu >= 12.10
@lardawge
lardawge / gist:5026455
Created February 25, 2013 00:27
Cleaner way to check for partial in rails 3.2
<% if lookup_context.template_exists?("custom_header/#{@object.key}", 'parent_path', true) %>
<%= render "custom_header/#{@object.key}" %>
<% else %>
Stock header
<% end %>
@lardawge
lardawge / custom.js
Created October 9, 2012 08:17 — forked from drewjoh/custom.js
Dynamic (AJAX) loaded Bootstrap Modal (Bootstrap 2.1)
$(document).ready(function() {
// Support for AJAX loaded modal window.
// Focuses on first input textbox after it loads the window.
$('[data-toggle="modal"]').click(function(e) {
e.preventDefault();
var url = $(this).attr('href');
if (url.indexOf('#') == 0) {
$(url).modal('open');
} else {
@lardawge
lardawge / STYLEGUIDE.md
Created June 22, 2012 19:42
Myfdb Style Guide

Git

Write a good commit message.

[#123] Summary of changes under 50 characters

* More information about commit (under 72 characters)
* More information about commit (under 72 characters)
@lardawge
lardawge / sunspot_kaminari_support.rb
Created June 24, 2011 16:58
Override to allow sunspot to return an array that can be used by Kaminari
module Sunspot
module Search
class AbstractSearch
private
def maybe_will_paginate(collection)
collection.instance_eval <<-RUBY, __FILE__, __LINE__ + 1
def current_page
#{@query.page}
@lardawge
lardawge / gist:711050
Created November 23, 2010 01:00
Formtastic 1.9.2 failures
(in /Users/lar/Sites/formtastic)
.............................................................................................................................................................................................................FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF........................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................FF.FFFF..FF..............FF.........................
Failures:
1) check_boxes input for a has_many association should have input wrapper with class 'check_boxes'
@lardawge
lardawge / gist:703988
Created November 17, 2010 20:12
Failing specs with rails 3.0.3 commit f1c13b0 example
class Joins < ActiveRecord::Base
belongs_to :parent
belongs_to :child
validates_presence_of :parent_id, :child_id
end
class Parent < ActiveRecord::Base
has_many :joins
has_many :children,