Skip to content

Instantly share code, notes, and snippets.

@johndavid400
johndavid400 / status.rb
Created January 26, 2022 02:50
what I used before finding enum in Rails
# This module contains creates getter, setter, and scopes for each provided status.
# You must have a 'status:string' column on whatever table you are including this module on.
#
# Use in any model:
# include Status
#
# Then you must add a list of status names you wish to use for the model.
# statuses :open, :closed, :archived
#
deployer@grow:~/resources/current$ rake data_migrations:add_file_extensions RAILS_ENV=production
/home/deployer/resources/shared/bundle/ruby/2.4.0/gems/rake-12.0.0/lib/rake/file_utils.rb:9: warning: already initialized constant FileUtils::RUBY
/home/deployer/.rvm/gems/ruby-2.4.1@global/gems/rake-12.0.0/lib/rake/file_utils.rb:9: warning: previous definition of RUBY was here
/home/deployer/resources/shared/bundle/ruby/2.4.0/gems/rake-12.0.0/lib/rake/file_utils.rb:108: warning: already initialized constant FileUtils::LN_SUPPORTED
/home/deployer/.rvm/gems/ruby-2.4.1@global/gems/rake-12.0.0/lib/rake/file_utils.rb:108: warning: previous definition of LN_SUPPORTED was here
/home/deployer/resources/shared/bundle/ruby/2.4.0/gems/rake-12.0.0/lib/rake/file_utils_ext.rb:16: warning: already initialized constant Rake::FileUtilsExt::DEFAULT
/home/deployer/.rvm/gems/ruby-2.4.1@global/gems/rake-12.0.0/lib/rake/file_utils_ext.rb:16: warning: previous definition of DEFAULT was here
WARNING: Possible conflict with Rake extensio
# SQLite version 3.x
development:
adapter: sqlite3
database: db/your_app_development.sql
pool: 5
timeout: 5000
test:
adapter: sqlite3
@johndavid400
johndavid400 / gist:10340969
Created April 10, 2014 03:45
cron job - rsync remote, every night at 11pm
* 23 * * * rsync -av --delete -e 'ssh -p22' /home/user/source_directory user@hostname:~/home/user/remote_directory
@johndavid400
johndavid400 / gist:9915660
Last active August 29, 2015 13:57
sql query table where ID is contained in an array of IDs
ids = users.pluck(:id)
ids_string = "(" + ids.join(",") + ")"
query = "SELECT id, name FROM table WHERE id_column IN #{ids_string};"
@johndavid400
johndavid400 / gist:8419786
Created January 14, 2014 15:09
unicorn error
E, [2014-01-14T08:42:03.178021 #32084] ERROR -- : Operation not permitted - /tmp/unicorn.stderr.log (Errno::EPERM)
/home/deployer/.rvm/gems/ruby-2.0.0-p353@network_churches/gems/unicorn-4.8.0/lib/unicorn/util.rb:19:in `chown'
/home/deployer/.rvm/gems/ruby-2.0.0-p353@network_churches/gems/unicorn-4.8.0/lib/unicorn/util.rb:19:in `block in chown_logs'
/home/deployer/.rvm/gems/ruby-2.0.0-p353@network_churches/gems/unicorn-4.8.0/lib/unicorn/util.rb:18:in `each_object'
/home/deployer/.rvm/gems/ruby-2.0.0-p353@network_churches/gems/unicorn-4.8.0/lib/unicorn/util.rb:18:in `chown_logs'
/home/deployer/.rvm/gems/ruby-2.0.0-p353@network_churches/gems/unicorn-4.8.0/lib/unicorn/worker.rb:143:in `user'
/home/deployer/.rvm/gems/ruby-2.0.0-p353@network_churches/gems/unicorn-4.8.0/lib/unicorn/http_server.rb:613:in `init_worker_process'
/home/deployer/.rvm/gems/ruby-2.0.0-p353@network_churches/gems/unicorn-4.8.0/lib/unicorn/http_server.rb:639:in `worker_loop'
/home/deployer/.rvm/gems/ruby-2.0.0-p353@network_churches/gems/unicor
upstream network_churches {
# for UNIX domain socket setups:
server unix:/tmp/network_churches.socket fail_timeout=0;
}
server {
# if you're running multiple servers, instead of "default" you should
# put your main domain name here
listen 80 default;
#include <Servo.h>
Servo myservo;
void setup()
{
myservo.attach(8);
}
void loop()
User-agent: Googlebot
User-Agent: bingbot
User-Agent: MSNbot
User-Agent: Yahoo!
User-Agent: FacebookExternalHit
User-Agent: Ezooms
User-Agent: teoma
User-Agent: Butterfly
User-Agent: ShowyouBot
User-Agent: magpie-crawler
$HTTP["host"] =~ ".*" {
# Live Site Configuration
proxy.balance = "hash"
proxy.server = ( "/blog" => ( ( "host" => "50.56.206.231" ) )
)
fastcgi.server = ( "" => ( "foo-rap" => ( "allow-x-send-file" => "enable", "check-local" => "disable", "disable-time" => 1, "host" => "127.0.0.1", "idle-timeout" => 20, "port" => 1028 ) ) )
}