This file contains 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
#!/bin/bash | |
# | |
# Program: MySQL bash template with logging and etc <mysql_bash_template.sh> | |
# | |
# Author: Mikhail Grigorev <sleuthhound at gmail dot com> | |
# | |
# Current Version: 1.0 | |
# | |
# Revision History: |
This file contains 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
DO $$ | |
DECLARE | |
tab RECORD; | |
schemaName VARCHAR := 'public'; | |
BEGIN | |
for tab in (SELECT t.relname::varchar AS table_name | |
FROM pg_class t | |
JOIN pg_namespace n ON n.oid = t.relnamespace | |
WHERE t.relkind = 'r' and n.nspname::varchar = schemaName | |
ORDER BY 1) |
This file contains 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
# native using psql | |
SELECT 'CREATE DATABASE mydb' WHERE NOT EXISTS (SELECT FROM pg_database WHERE datname = 'mydb')\gexec | |
# native using shell + psql | |
echo "SELECT 'CREATE DATABASE mydb' WHERE NOT EXISTS (SELECT FROM pg_database WHERE datname = 'mydb')\gexec" | psql |
This file contains 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
SET GROUP_CONCAT_MAX_LEN=131072; | |
SET @selects = NULL; | |
SELECT CONCAT('SELECT * FROM (\n', GROUP_CONCAT(single_select SEPARATOR ' UNION\n'), '\n ) Q ORDER BY Q.TABLE_ROWS DESC') AS sql_query | |
FROM ( | |
SELECT CONCAT( | |
'SELECT "', | |
table_name, | |
'" AS TABLE_NAME, COUNT(1) AS TABLE_ROWS | |
FROM `', | |
table_schema, |
This file contains 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 tbl AS ( | |
SELECT table_schema, table_name | |
FROM information_schema.tables | |
WHERE table_name NOT LIKE 'pg_%' AND table_schema NOT IN ('information_schema') | |
) | |
SELECT table_schema, table_name, | |
(xpath('/row/c/text()', query_to_xml(format('SELECT count(1) AS c FROM "%I"."%I"', table_schema, table_name), FALSE, TRUE, '')))[1]::text::bigint AS table_count | |
FROM tbl; |
This file contains 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
git config --global core.excludesfile ~/.gitignore_global | |
cat <<EOF > ~/.gitignore_global | |
.DS_Store | |
.DS_Store? | |
._* | |
.Spotlight-V100 | |
.Trashes | |
ehthumbs.db | |
Thumbs.db | |
EOF |
This file contains 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
vnoremap :w !xsel -b | |
" Make backspace delete lots of things | |
" set backspace=indent,eol,start | |
" Enable syntax highlighting | |
syntax on | |
" Enable line highlight | |
set cursorline | |
" Try to show at least three lines and two columns of context when | |
" scrolling | |
set scrolloff=3 |
This file contains 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
# If not running interactively, don't do anything | |
case $- in | |
*i*) ;; | |
*) return;; | |
esac | |
# Default editor | |
export EDITOR=vim | |
# Enable programmable completion features (you don't need to enable |
This file contains 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
#!/bin/ash | |
help="Usage: zabbix_sender.sh <-z zabbix server> [-p server port] [-s host name] <-k key name> <-o key value>" | |
while getopts "z:p:s:k:o:h" c; do | |
case $c in | |
z)z=${OPTARG};; | |
p)p=${OPTARG};; | |
s)s=${OPTARG};; | |
k)k=${OPTARG};; | |
o)o=${OPTARG};; | |
h)echo $help;exit 0;; |
This file contains 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
# For Zabbix < 5.0 (password: zabbix) | |
update users set passwd='5fce1b3e34b520afeffb37ce08c7cd66' where alias='Admin'; | |
# For Zabbix >= 5.0 (password: zabbix) | |
update users set passwd='$2y$10$92nDno4n0Zm7Ej7Jfsz8WukBfgSS/U0QkIuu8WkJPihXBb2A1UrEK' where alias='Admin'; |
NewerOlder