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 / 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 / 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 [email protected]
@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 / 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 / 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 / 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 / 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 / mac_os_tips.md
Last active January 30, 2017 07:34
Mac OS

SSH Broken Pipe fix

Source

To fix it, on your mac do:

emacs (or vim/vi/nano/etc) ~/.ssh/config

And then, write this:

@TheRatG
TheRatG / cors.nginx.md
Last active August 3, 2020 13:13
How to enable Cross-Origin Requests (CORS) on nginx

Open nginx CORS configuration

Wide open nginx CORS configuration CORS is a W3C working standard that currently has decent (but inconsistent) implementions in Firefox, Chrome and Safari. I use it primarily to test PhoneGap apps in regular browsers instead of testing the code in simulators. PhoneGap apps can skip the usual origin checks via configuration, but running a PhoneGap app takes more setup - which make it harder for designers to work with the app. Running apps in simulators or on actual devices also takes al lot more time that just reloading a browser and this annoys me.

Read up on CORS

@TheRatG
TheRatG / symfony_flash.md
Created June 14, 2017 08:53
Render all flash messages in Twig
{% for label, flashes in app.session.flashbag.all %}
    {% for flash in flashes %}
        <div class="alert alert-{{ label }}">
            {{ flash }}
        </div>
    {% endfor %}
{% endfor %}