Skip to content

Instantly share code, notes, and snippets.

View ak47's full-sized avatar

Andrew Koch ak47

  • Sunnyvale, Caleeefourniah
View GitHub Profile
@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
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:b440e04d4e8beedc9ac4
Last active August 29, 2015 14:08
docker mongo shared replica set for dev
# https://sebastianvoss.com/docker-mongodb-sharded-cluster.html
# rs1_srv1 172.17.0.20:49170
# rs1_srv2 172.17.0.21:49171
# rs1_srv3 172.17.0.22:49172
# rs2_srv1 172.17.0.23:49173
# rs2_srv2 172.17.0.24:49174
# rs2_srv3 172.17.0.25:49175
# cfg1 172.17.0.26:49176
# mongos1 172.17.0.27:49177
@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
Resque::Failure.all(Resque::Failure.count-5,5).each { |job| puts "#{job["exception"]} #{job["backtrace"]}" }
fail_counts = {}
Resque::Failure.all(0,Resque::Failure.count).each do |job|
if fail_counts[job['queue']]
fail_counts[job['queue']] += 1
else
fail_counts[job['queue']] = 1
end
end
@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