I hereby claim:
- I am noma4i on github.
- I am noma4i (https://keybase.io/noma4i) on keybase.
- I have a public key ASCtcIlOl0oZfkDAz8sj_-f4j27Cn_3KcwAoxqgBpq_2IQo
To claim this, I am signing this object:
| 0.- Stop graphite-web | |
| /etc/init.d/apache2 stop | |
| 1.- Backup SQLite db | |
| export GRAPHITE_ROOT=/opt/graphite | |
| PYTHONPATH=$GRAPHITE_ROOT/webapp django-admin.py dumpdata --settings=graphite.settings -e contenttypes --natural > sqlite_graphite_dump.json | |
| require 'mina/bundler' | |
| require 'mina/git' | |
| require 'mina/rbenv' | |
| set :domain, 'your_domain.com' | |
| set :deploy_to, '/home/deployer/app_name' | |
| set :repository, 'git@github.com:user_name/app_name' | |
| set :branch, ENV["brunch"] || 'master' | |
| set :app_name, "app_name" |
| JS_PATH = "app/assets/javascripts/**/*.js"; | |
| Dir[JS_PATH].each do |file_name| | |
| puts "\n#{file_name}" | |
| puts Uglifier.compile(File.read(file_name)) | |
| end |
| -- Settings | |
| hs.window.animationDuration = 0 | |
| hs.hints.showTitleThresh = 0 | |
| -- | |
| -- Reload Config onChange | |
| function reloadConfig(files) | |
| doReload = false | |
| for _,file in pairs(files) do | |
| if file:sub(-4) == ".lua" then |
I hereby claim:
To claim this, I am signing this object:
| FROM rails:4.2.3 | |
| MAINTAINER Renato Filho <renatosousafilho@gmail.com> | |
| ENV HOME /home/app | |
| ENV RAILS_ENV development | |
| RUN useradd -m -s /bin/bash app | |
| RUN gem install -N bundler |
| # frozen_string_literal: true | |
| begin | |
| require 'bundler/inline' | |
| rescue LoadError => e | |
| warn 'Bundler version 1.10 or later is required. Please update your Bundler' | |
| raise e | |
| end | |
| gemfile(true) do |
| -- show running queries (pre 9.2) | |
| SELECT procpid, age(clock_timestamp(), query_start), usename, current_query | |
| FROM pg_stat_activity | |
| WHERE current_query != '<IDLE>' AND current_query NOT ILIKE '%pg_stat_activity%' | |
| ORDER BY query_start desc; | |
| -- show running queries (9.2) | |
| SELECT pid, age(clock_timestamp(), query_start), usename, query | |
| FROM pg_stat_activity | |
| WHERE query != '<IDLE>' AND query NOT ILIKE '%pg_stat_activity%' |
| -- | |
| -- Read only | |
| -- | |
| -- Create a group | |
| CREATE ROLE postgres_ro_group; | |
| -- Grant access to existing tables | |
| GRANT USAGE ON SCHEMA public TO postgres_ro_group; | |
| GRANT SELECT ON ALL TABLES IN SCHEMA public TO postgres_ro_group; |
The code here is a tech demo showing how to switch between databases in Rails 5, in a thread-safe manner.
The simple way to switch databases is:
ActiveRecord::Base.establish_connection :user_shard1
puts User.find(1) # this is executed on the database keyed on "user_shard1" in database.yml
ActiveRecord::Base.establish_connection :development