-
Query table size:
SELECT relname AS table_name, pg_size_pretty(pg_total_relation_size(relid)) AS total_size, pg_size_pretty(pg_relation_size(relid)) AS data_size, pg_size_pretty(pg_total_relation_size(relid) - pg_relation_size(relid)) AS index_size FROM pg_stat_user_tables
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
update pg_database set datistemplate=false where datname='template1'; | |
drop database Template1; | |
-- if it complains the locale name -- run `locale -a` to list all locale names in terminal | |
create database template1 with owner=postgres encoding='UTF-8' lc_collate='en_US.utf8' lc_ctype='en_US.utf8' template template0; | |
update pg_database set datistemplate=true where datname='template1'; |
cd to target directory, run the following commands to start using git version control:
# start a local repository
git init
# add all files under directory to git repository
git add .
# commit the current version
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
sudo rm /etc/exports | |
sudo touch /etc/exports | |
vagrant reload |
pg_createcluster --start -e UTF-8 8.4 main
# 1. stop mysqld service
# after this command, remember to double check if /var/run/mysqld folder exists and its owner is mysql:mysql
sudo /etc/init.d/mysql stop
# might have to do this
sudo mkdir -p /var/run/mysqld
sudo chown mysql:mysql /var/run/mysqld
# 2. start mysql without password
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
#!/bin/sh | |
set -e | |
if [ -e /.installed ]; then | |
echo 'Already installed.' | |
else | |
echo '' | |
echo 'INSTALLING' | |
echo '----------' |
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
"‐a".each_codepoint do |c| | |
if c & 0xff80 != 0 | |
puts "#{c} is non-ASCII char" | |
end | |
end |
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
# to add | |
netsh interface portproxy add v4tov4 listenport=3000 listenaddress=127.0.0.1 connectport=3000 connectaddress=10.0.2.2 | |
# to remove | |
netsh interface portproxy delete v4tov4 listenport=3000 listenaddress=127.0.0.1 |
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
#!/usr/bin/env bash | |
source $HOME/.rvm/scripts/rvm || source /etc/profile.d/rvm.sh | |
rvm use --default --install $1 | |
shift | |
if (( $# )) | |
then gem install $@ |
NewerOlder