Skip to content

Instantly share code, notes, and snippets.

@ak47
ak47 / .vimrc
Last active October 7, 2020 21:20
syntax on
colo murphy
set nu
set tabstop=8 softtabstop=0 expandtab shiftwidth=2 smarttab
set ignorecase
set backspace=indent,eol,start
" Set utf8 as standard encoding and en_US as the standard language
set encoding=utf8
@ak47
ak47 / unicorn.rb
Created April 3, 2014 23:54
force figaro ENV vars to reload on unicorn USR2 restarts
root = "/var/www/cake/current"
working_directory root
pid "#{root}/tmp/pids/unicorn.pid"
stderr_path "#{root}/log/unicorn.stderr.log"
stdout_path "#{root}/log/unicorn.log"
listen "/tmp/unicorn.cake.sock"
worker_processes 2
timeout 15
irb(main):002:0> a.password = 'Qa123456'
=> "Qa123456"
irb(main):003:0> a.password_confirmation = 'Qa123456'
=> "Qa123456"
irb(main):004:0> a.save
@ak47
ak47 / gist:5906514
Last active December 19, 2015 05:49
module Devise
module Strategies
class MyAuthenticatable < Authenticatable
def authenticate!
begin
if resp = authenticate_local
else
fail!('Invalid username or password')
[vagrant@localhost ~]$ yum list freetds
Loaded plugins: fastestmirror, security
Determining fastest mirrors
* base: mirrors.seas.harvard.edu
* epel: linux.mirrors.es.net
* extras: centos.mirror.netriplex.com
* updates: mirror.pac-12.org
Installed Packages
freetds.x86_64 0.91-2.el6 @epel
Available Packages
module B
def self.included(base)
class << base
attr_accessor :catch
def acts_as_catchall(hsh)
@catch = hsh
end
def inherited(subclass)
subclass.catch = subclass.superclass.catch
module B
def self.included(base)
class << base
attr_accessor :catch
def acts_as_catchall(hsh)
self.catch = hsh
end
end
end
module ActsAsCatchall
def self.included(base)
base.extend ClassMethods
end
module ClassMethods
class << self; attr_accessor :catchall end
def acts_as_catchall(options = {})
# db_field, klass, use_method_missing = false
@ak47
ak47 / gist:1469862
Created December 13, 2011 00:45
cap-mailer error
/my_gems/gems/actionpack-3.1.3/lib/abstract_controller/rendering.rb:65:in `protected_instance_variables': undefined method `protected_instance_variables' for #<Hash:0x00000102286768> (NoMethodError)
from /my_gems/gems/actionpack-3.1.3/lib/abstract_controller/rendering.rb:134:in `view_assigns'
from /my_gems/gems/actionpack-3.1.3/lib/abstract_controller/rendering.rb:87:in `view_context'
from /my_gems/gems/actionpack-3.1.3/lib/abstract_controller/rendering.rb:120:in `_render_template'
from /my_gems/gems/actionpack-3.1.3/lib/abstract_controller/rendering.rb:114:in `render_to_body'
from /my_gems/gems/actionpack-3.1.3/lib/abstract_controller/rendering.rb:99:in `render'
from /my_gems/gems/actionmailer-3.1.3/lib/action_mailer/base.rb:718:in `block in collect_responses_and_parts_order'
from /my_gems/gems/actionmailer-3.1.3/lib/action_mailer/base.rb:729:in `each'
from /my_gems/gems/actionmailer-3.1.3/lib/action_mailer/base.rb:729:in `each_template'
from /my_gems/gems/actionmailer-3.1.3/lib/action_mailer/base.r
@ak47
ak47 / gist:1278823
Created October 11, 2011 17:46
How to load RVM in Ruby Net::SSH session
Net::SSH.start('<server>','<user_name>',:password => '<secret>') do |ssh|
ssh.exec!(". $HOME/.rvm/scripts/rvm; ruby -v")
end