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
WITH table_scans as ( | |
SELECT relid, | |
tables.idx_scan + tables.seq_scan as all_scans, | |
( tables.n_tup_ins + tables.n_tup_upd + tables.n_tup_del ) as writes, | |
pg_relation_size(relid) as table_size | |
FROM pg_stat_user_tables as tables | |
), | |
all_writes as ( | |
SELECT sum(writes) as total_writes | |
FROM table_scans |
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 tablename AS TABLE_NAME, | |
ROUND(CASE | |
WHEN otta=0 THEN 0.0 | |
ELSE sml.relpages/otta::numeric | |
END,1) AS table_bloat, | |
CASE | |
WHEN relpages < otta THEN '0' | |
ELSE pg_size_pretty((bs*(sml.relpages-otta)::bigint)::bigint) | |
END AS table_waste, | |
iname AS index_name, |
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
(defun dotspacemacs/layers () | |
"Configuration Layers declaration. | |
You should not put any user code in this function besides modifying the variable | |
values." | |
(setq-default | |
;; Base distribution to use. This is a layer contained in the directory | |
;; `+distribution'. For now available distributions are `spacemacs-base' | |
;; or `spacemacs'. (default 'spacemacs) | |
dotspacemacs-distribution 'spacemacs | |
;; Lazy installation of layers (i.e. layers are installed only when a file |
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
1. Знание основ Ruby, фреймворка Ruby on Rails | |
- http://guides.rubyonrails.org/ | |
- http://rusrails.ru/ | |
Вопросы: | |
1. Чем отличается статическая и динамическая типизации в языках программирования? | |
2. Какие виды наследования поддерживаются в Ruby? | |
3. Что такое модуль? Какая разница между классом и модулем? | |
4. Какие есть уровни контроля доступа к методам для классов и модулей? | |
5. Какие есть способы вызова методов в Ruby? | |
6. Что означает ключевое слово self? |
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
$ brew install libmagic | |
$ brew link libmagic (if the link is already created is going to fail, don't worry about that) | |
$ env ARCHFLAGS="-arch x86_64" gem install ruby-filemagic -- --with-magic-include=/usr/local/include --with-magic-lib=/usr/local/lib/ |
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
-- WARNING: executed with a non-superuser role, the query inspect only index on tables you are granted to read. | |
-- WARNING: rows with is_na = 't' are known to have bad statistics ("name" type is not supported). | |
-- This query is compatible with PostgreSQL 8.2 and after | |
SELECT current_database(), nspname AS schemaname, tblname, idxname, bs*(relpages)::bigint AS real_size, | |
bs*(relpages-est_pages)::bigint AS extra_size, | |
100 * (relpages-est_pages)::float / relpages AS extra_ratio, | |
fillfactor, bs*(relpages-est_pages_ff) AS bloat_size, | |
100 * (relpages-est_pages_ff)::float / relpages AS bloat_ratio, | |
is_na | |
-- , 100-(sub.pst).avg_leaf_density, est_pages, index_tuple_hdr_bm, maxalign, pagehdr, nulldatawidth, nulldatahdrwidth, sub.reltuples, sub.relpages -- (DEBUG 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
SELECT | |
current_database(), schemaname, tablename, /*reltuples::bigint, relpages::bigint, otta,*/ | |
ROUND((CASE WHEN otta=0 THEN 0.0 ELSE sml.relpages::FLOAT/otta END)::NUMERIC,1) AS tbloat, | |
CASE WHEN relpages < otta THEN 0 ELSE bs*(sml.relpages-otta)::BIGINT END AS wastedbytes, | |
iname, /*ituples::bigint, ipages::bigint, iotta,*/ | |
ROUND((CASE WHEN iotta=0 OR ipages=0 THEN 0.0 ELSE ipages::FLOAT/iotta END)::NUMERIC,1) AS ibloat, | |
CASE WHEN ipages < iotta THEN 0 ELSE bs*(ipages-iotta) END AS wastedibytes | |
FROM ( | |
SELECT | |
schemaname, tablename, cc.reltuples, cc.relpages, bs, |
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 pg_size_pretty(SUM(pg_relation_size(idx))::BIGINT) AS SIZE, | |
(array_agg(idx))[1] AS idx1, (array_agg(idx))[2] AS idx2, | |
(array_agg(idx))[3] AS idx3, (array_agg(idx))[4] AS idx4 | |
FROM ( | |
SELECT indexrelid::regclass AS idx, (indrelid::text ||E'\n'|| indclass::text ||E'\n'|| indkey::text ||E'\n'|| | |
COALESCE(indexprs::text,'')||E'\n' || COALESCE(indpred::text,'')) AS KEY | |
FROM pg_index) sub | |
GROUP BY KEY HAVING COUNT(*)>1 | |
ORDER BY SUM(pg_relation_size(idx)) DESC; |
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 | |
pg_class.relname, | |
pg_size_pretty(pg_class.reltuples::BIGINT) AS rows_in_bytes, | |
pg_class.reltuples AS num_rows, | |
COUNT(indexname) AS number_of_indexes, | |
CASE WHEN x.is_unique = 1 THEN 'Y' | |
ELSE 'N' | |
END AS UNIQUE, | |
SUM(CASE WHEN number_of_columns = 1 THEN 1 | |
ELSE 0 |
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
# frozen_string_literal: true | |
require 'i18n/tasks' | |
RSpec.describe 'I18nEnsurance' do | |
let(:i18n) { I18n::Tasks::BaseTask.new } | |
let(:missing_keys) { i18n.missing_keys } | |
let(:unused_keys) { i18n.unused_keys } | |
it 'does not have missing keys' do |