A (more) complete cheatsheet for Arel, including NamedFunction functions, raw SQL and window functions.
posts = Arel::Table.new(:posts)
posts = Post.arel_table # ActiveRecord| explain (analyze, buffers) | |
| SELECT | |
| pg_get_userbyid(userid) as user, | |
| pg_database.datname, | |
| pg_stat_statements.queryid, | |
| pg_stat_statements.calls as calls_total, | |
| pg_stat_statements.total_exec_time / 1000.0 as seconds_total, | |
| pg_stat_statements.rows as rows_total, | |
| pg_stat_statements.blk_read_time / 1000.0 as block_read_seconds_total, | |
| pg_stat_statements.blk_write_time / 1000.0 as block_write_seconds_total |
| SELECT | |
| pg_stat_statements.query as query, | |
| round(pg_stat_statements.total_exec_time::numeric, 2) AS total_time, | |
| pg_stat_statements.calls, | |
| round(pg_stat_statements.mean_exec_time::numeric, 2) AS mean, | |
| round((100 * pg_stat_statements.total_exec_time / | |
| sum(pg_stat_statements.total_exec_time::numeric) OVER ())::numeric, 2) AS percentage_cpu, | |
| round((100 * pg_stat_statements.calls / | |
| sum(pg_stat_statements.calls::numeric) OVER ())::numeric, 2) AS percentage_calls, | |
| pg_user.usename as username, |
| -- table + index sizes | |
| SELECT | |
| table_name, | |
| pg_size_pretty(table_size) AS table_size, | |
| pg_size_pretty(indexes_size) AS indexes_size, | |
| pg_size_pretty(total_size) AS total_size | |
| FROM ( | |
| SELECT | |
| table_name, | |
| pg_table_size(table_name) AS table_size, |
| psql -h <host> -U <user> -W -d postgres | |
| SELECT * from pg_stat_activity; | |
| SELECT * from pg_stat_database; | |
| # Queries running during >5 minutes | |
| SELECT | |
| pid, | |
| datname, | |
| query, |
| sudo yum update | |
| sudo amazon-linux-extras enable postgresql11 | |
| sudo yum install postgresql postgresql-devel |
| # Makefile for PlantUML | |
| # Author: Devin Weaver (@sukima) <[email protected]> | |
| # GistID: 52eacde54bf7861b19ee66a07b864583 | |
| # | |
| # This handles SVGs PNGs and ASCII outputs. | |
| # It handles included files with the .iuml extension: !include foo.iuml | |
| # All diagrams have the .uml extension and reside in the diagrams directory | |
| # All output is saved to the output directory | |
| # | |
| # make svg - (default) build all diagrams as SVGs |
Here I wanted to share my own configuration of Visual Studio Code that I currently use when programming in Elixir. The section about Tasks and Shortcut is taken from this post: Running Elixir Tests in Visual Studio Code/ElixirLS.
| #cloud-config | |
| package_upgrade: true | |
| packages: | |
| - docker | |
| - python2-pip | |
| write_files: | |
| - path: /etc/systemd/system/docker.service.d/aws-credentials.conf | |
| content: | | |
| [Service] | |
| Environment="AWS_ACCESS_KEY_ID=<key>" |