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
NAME="ofn" | |
DISTRIBUTION="ubuntu" | |
RELEASE="xenial" | |
ARCH="amd64" | |
HOST="ofn.local" | |
DEVENV_USER="ofn-admin" | |
DEVENV_GROUP="openfoodnetwork" | |
PROJECT_NAME="openfoodnetwork" |
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
select spree_line_items.order_id, spree_products.supplier_id, sum(spree_line_items.price * spree_line_items.quantity) AS amount | |
from spree_line_items | |
inner | |
join spree_variants | |
on spree_variants.id = spree_line_items.variant_id | |
inner | |
join spree_products | |
on spree_products.id = spree_variants.product_id | |
inner | |
join enterprises |
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
On Wed, Oct 1, 2014 at 2:18 PM, Stuart Bishop <stuart(at)stuartbishop(dot)net> | |
wrote: | |
> It is unnecessary maintaining a list of parameters which require a | |
> restart, as you can tell by looking at pg_settings. | |
> | |
> The way I do it is by comparing the contents of pg_settings with a | |
> snapshot I made just after (or just before) the server was last |
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
Like most databases, Postgres has a built-in slow query log feature that automatically logs queries to the main Postgres log file if they take over a certain amount of time and it's really easy to set up. | |
In your main postgresql.conf file (which is often somewhere like /etc/postgresql/9.6/main/postgresql.conf), either edit or add a line like so: | |
log_min_duration_statement = 1000 | |
After restarting Postgres or reloading the config with SELECT pg_reload_conf();, this directive causes any queries that take over 1000 milliseconds (one second) to be logged. | |
(The location of the log file varies but is /var/log/postgresql/postgresql-9.6-main.log on my test setup, for instance.) | |
To deliberately run a long query for testing purposes: |
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
\watch | |
SELECT datname, usename, query FROM pg_stat_activity; \watch |
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
Bundler could not find compatible versions for gem "actionpack": | |
In Gemfile: | |
rails (~> 4.0.0) was resolved to 4.0.0, which depends on | |
actionpack (= 4.0.0) | |
simple_form was resolved to 2.0.2, which depends on | |
actionpack (~> 3.0) | |
Bundler could not find compatible versions for gem "activerecord": | |
In Gemfile: |
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
# At the bottom of add /etc/postgresql/9.5/main/postgresql.conf | |
shared_preload_libraries = 'pg_stat_statements' | |
pg_stat_statements.max = 10000 | |
pg_stat_statements.track = all | |
sudo systemctl restart postgresql | |
sudo su postgres | |
psql | |
CREATE extension pg_stat_statements; |
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
ActiveSupport::Deprecation.silenced = true |
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
# Failed | |
Delayed::Job.where('failed_at IS NOT NULL') | |
# Active | |
Delayed::Job.where('failed_at IS NULL AND locked_by IS NOT NULL') | |
# Queued | |
Delayed::Job.where('failed_at IS NULL AND locked_by IS NULL') | |
# Destroy |
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
Have you seen Matthew Inman's (The Oatmeal) comic about why he runs? It's | |
a classic. In it he talks about his inspiration for taking up long-distance | |
running. He imagines his tendency to slack off and sit on the couch as a little | |
creature he calls "The Blerch". It follows him around, tempting him to stop | |
moving and scarf down junk food. | |
I run too, though nothing close to the distances Inman runs. In my experience, | |
refactoring as a skill has a lot in common with running or any other athletic | |
sport. You can exercise your refactoring muscles, by deliberately working | |
through the steps with discipline, like we talked about in the last email. As |