-
Show active connections
SELECT * FROM pg_stat_activity;
ps aux | grep postgres | wc -l
(roughly, when you cannot connect to it)
-
Show @max_connections@
- In psql:
SHOW max_connections;
(SHOW ALL;
)
- In psql:
-
SQL:
SELECT * FROM pg_settings WHERE name = 'max_connections';
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def template_digest | |
tmpl = lookup_context.find(action_name, _prefixes) | |
ActionView::Digestor.digest(name: tmpl.virtual_path, finder: lookup_context) | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
server { | |
listen 80; | |
server_name [domain name]; | |
root [Rails root]/public; | |
location @passenger { | |
passenger_enabled on; | |
passenger_app_env production; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
if [ -n "$1" ]; | |
then | |
ssh_config=$(mktemp -t ssh_config) | |
vagrant ssh-config > "$ssh_config" | |
scp -F "$ssh_config" $@ | |
else |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Sidekiq | |
module Middleware | |
module Server | |
class TaggedLogger | |
def call(worker, item, queue) | |
tag = "#{worker.class.to_s} #{SecureRandom.hex(12)}" | |
::Rails.logger.tagged(tag) do | |
job_info = "Start at #{Time.now.to_default_s}: #{item.inspect}" | |
::Rails.logger.info(job_info) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Concerns | |
module Transactions | |
extend ActiveSupport::Concern | |
def transaction_begin | |
ActiveRecord::Base.connection.begin_db_transaction | |
ActiveRecord::Base.connection.increment_open_transactions | |
render nothing: true | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# main logic | |
def hi | |
'hi' | |
end | |
# rspec tests | |
require 'rspec' | |
describe "hi" do | |
it "says 'hi'" do |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
*/2 * * * * if [[ `pmset -g batt | awk -F'[^0-9]*' '{ print $3 }'` -lt 20 ]];then say "Battery low";fi |