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
-- This function generates ordered, base36 alpha-numeric ids similar to Slack's ID scheme. | |
-- | |
-- I wanted a primary key scheme that had the following features: | |
-- 1) Lexical order, so that `ORDER BY` works as expected. | |
-- 2) Prevents sampling an auto-incrementing primary key to determine growth over time. | |
-- 3) Shorter and more human-friendly than BIGINT and UUID keys. | |
-- 4) Has a prefix such that table can be inferred from any record's primary or foreign key. | |
-- | |
-- It is suitable for use as primary key, provided a few assumptions are true: | |
-- 1) You do not attempt to genereate more than 10M hids per second (system-time). |
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
-- 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%' |
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
function stackTrace() { | |
$stack = debug_backtrace(); | |
$output = 'Stack trace:' . PHP_EOL; | |
$stackLen = count($stack); | |
for ($i = 1; $i < $stackLen; $i++) { | |
$entry = $stack[$i]; | |
$func = $entry['function'] . '('; | |
$argsLen = count($entry['args']); |