Skip to content

Instantly share code, notes, and snippets.

View TheRatG's full-sized avatar
🐭
be balanced

Vladimir Pak TheRatG

🐭
be balanced
View GitHub Profile
@TheRatG
TheRatG / mysqldump_exclude.sh
Last active June 4, 2018 17:42
mysqldump excluded tables
#!/usr/bin/env bash
PASSWORD=password
USER=user
DATABASE=database
DB_FILE=/tmp/${DATABASE}.sql.gz
EXCLUDED_TABLES=(
table_1
table_2
table_3
@TheRatG
TheRatG / prepare_prod.markdown
Last active January 24, 2023 05:08
Prepare platform

bash

Add into begining of file ~/.bashrc

[ -d ~/bin ] && PATH=~/bin:$PATH

mysql

A mysql and a mysqldump without user:passwod

@TheRatG
TheRatG / Replace in big file
Created June 20, 2016 06:43
Replace in big file
perl -e 'BEGIN{$/=\32768}' -pe "s/a/b/g" < one-line-250-mb.txt
@TheRatG
TheRatG / extract_phar.sh
Last active November 15, 2016 07:18
Extract phar
#!/usr/bin/env bash
#extract phar
phar extract -f php_util.phar extracted
#how to check is in phar
#if (strpos(__DIR__, 'phar://') === 0) {}
@TheRatG
TheRatG / mysqldump_gzip.sh
Last active March 8, 2017 08:38
mysqldump help
#!/usr/bin/env bash
USER=homestead
PASSWORD=secret
DATABASE=database
DB_FILE=/tmp/${DATABASE}.sql.gz
#dump specific table data
mysqldump --extended-insert --skip-lock-tables -u${USER} -p${PASSWORD} ${DATABASE} | gzip > ${DB_FILE}
@TheRatG
TheRatG / homestead.md
Last active April 21, 2018 09:35
Homestead Enhancement

Enhancement

  • usefull vagrant plugins
vagrant plugin install vagrant-vbguest vagrant-bindfs vagrant-hostsupdater
  • update after.sh
# after.sh
git config --global user.email your@email.com
@TheRatG
TheRatG / mysql_table_size.md
Last active August 23, 2017 07:10
mysql table size.md
SELECT 
    table_name AS `Table`, 
    round(((data_length + index_length) / 1024 / 1024), 2) `Size in MB` 
FROM information_schema.TABLES 
WHERE table_schema = "$DB_NAME"
    AND table_name = "$TABLE_NAME"
ORDER BY ROUND(((data_length + index_length) / 1024 / 1024), 2) DESC;

-- or this query to list the size of every table in every database, largest first:
@TheRatG
TheRatG / copy.php
Created February 2, 2016 09:50
symfony copy dir
$fileSystem = new Filesystem();
$fileSystem->mkdir($target);
$directoryIterator = new \RecursiveDirectoryIterator($source, \RecursiveDirectoryIterator::SKIP_DOTS);
$iterator = new \RecursiveIteratorIterator($directoryIterator, \RecursiveIteratorIterator::SELF_FIRST);
foreach ($iterator as $item) {
if ($item->isDir()) {
$targetDir = $target.DIRECTORY_SEPARATOR.$iterator->getSubPathName();
$fileSystem->mkdir($targetDir);
} else {
@TheRatG
TheRatG / find and size
Last active January 27, 2016 07:38
find and size
# find old files and calculate their size in Mb
find ./logs/* -type f -mtime +180 -exec du -ks {} \; | cut -f1 | awk '{total=total+$1}END{print total/1024}'
@TheRatG
TheRatG / chmod
Last active August 29, 2015 14:08
Uni read privileges
find <folder> -type d -exec chmod 755 {} \;
find <folder> -type f -exec chmod 644 {} \;