Skip to content

Instantly share code, notes, and snippets.

@chriha
chriha / table_size.sql
Last active December 10, 2019 12:33
Query MySQL table size informations
/* size of a specific table */
SELECT table_name AS "Table", round( ( ( data_length + index_length ) / 1024 / 1024 ), 2 ) "Size in MB"
FROM information_schema.TABLES
WHERE table_schema = "YOUR_DB_NAME" AND table_name = "YOUR_TBL_NAME";
/* size of every table in every database */
SELECT table_schema as `Database`,
table_name AS `Table`,
round(((data_length + index_length) / 1024 / 1024), 2) `Size in MB`
FROM information_schema.TABLES
@chriha
chriha / move_git_repo.sh
Last active December 10, 2016 01:14
Moving a repo from one service to another
git remote rename origin bitbucket
git remote add origin https://github.com/USER/PROJECT.git
git push origin master
git remote rm bitbucket
@chriha
chriha / get_images.sh
Created March 4, 2014 07:53
Download all images from a websites directory
wget -A.png,.jpg,.gif,.jpeg -e robots=off -m -k -nv -np -p \ --user-agent="Mozilla/5.0 (compatible; Konqueror/3.0.0/10; Linux)" \ http://site.url/
# -A comma-separated list of accepted extensions.
# -e execute a `.wgetrc'-style command.
# -m shortcut for -N -r -l inf --no-remove-listing.
# -k make links in downloaded HTML or CSS point to local files.
# -nv turn off verboseness, without being quiet.
# -np don't ascend to the parent directory.
# -p get all images, etc. needed to display HTML page.
@chriha
chriha / change_git_author.sh
Last active January 12, 2017 10:01
Changing the author from previous commits
#!/bin/sh
git filter-branch --env-filter '
OLD_EMAIL="your-old-email@example.com"
CORRECT_NAME="Your Correct Name"
CORRECT_EMAIL="your-correct-email@example.com"
if [ "$GIT_COMMITTER_EMAIL" = "$OLD_EMAIL" ]
then
export GIT_COMMITTER_NAME="$CORRECT_NAME"
@chriha
chriha / split_file.sh
Created March 6, 2014 08:16
Splitting a file into multiple pieces by filesize or length.
# Split file "bigfile.sql" by SIZE
split -b 10[k|m] bigfile.sql bigfile.spl.
# or LENGTH
split -l 10 bigfile.sql bigfile.spl.
# bigfile.spl.aa
# bigfile.spl.ab
# bigfile.spl.ac
@chriha
chriha / .gitignore
Last active August 29, 2015 13:57
Default .gitignore
# Compiled source
# ---------------------------
*.com
*.class
*.dll
*.exe
*.o
*.so
*.map
@chriha
chriha / change_osx_screenshot_dir.sh
Created March 17, 2014 13:39
Changing the location of created screenshots with OS X
defaults write com.apple.screencapture location /Users/USER/Bilder/Screenshots
killall SystemUIServer
@chriha
chriha / create_bootable_usb.sh
Created March 24, 2014 23:10
Create a bootable USB stick on OS X
# Convert .iso to .img. OS X will create a ".img.dmg", don't rename it
hdiutil convert -format UDRW -o ~/path/to/target.img ~/path/to/os.iso
# Remove your USB device and run
diskutil list
# Insert USB device and run diskutil again
diskutil list
# Determine the device node assigned to your flash media (e.g. /dev/disk2)
@chriha
chriha / install.sh
Last active March 10, 2016 19:51
Provision file for Vagrant (kw: install, nginx, server)
#!/usr/bin/env bash
# update
echo ">>> Updating packages list"
sudo apt-get update && apt-get upgrade
# install base packages
echo ">>> Installing base packages"
sudo apt-get install -y python-software-properties build-essential wget curl vim nano zip