Skip to content

Instantly share code, notes, and snippets.

View tian-im's full-sized avatar
🌅
WFH

Tianwen (Tian) Chen tian-im

🌅
WFH
View GitHub Profile
@tian-im
tian-im / utf8.sql
Last active April 2, 2020 14:28
UTF8 template1 for Postgres db create
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';
@tian-im
tian-im / readme.md
Created March 5, 2020 05:21
How to start using git version control

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
@tian-im
tian-im / vagrant_export_reload.sh
Created December 3, 2019 13:26
Vagrant reload export
sudo rm /etc/exports
sudo touch /etc/exports
vagrant reload
@tian-im
tian-im / reset.md
Created November 28, 2019 02:11
Correct Postgres Encoding
pg_createcluster --start -e UTF-8 8.4 main
@tian-im
tian-im / reset.md
Last active October 24, 2018 01:27
Reset Mysql root password in Ubuntu
# 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
@tian-im
tian-im / install.sh
Created October 23, 2017 04:16
Install chrome in ubuntu
#!/bin/sh
set -e
if [ -e /.installed ]; then
echo 'Already installed.'
else
echo ''
echo 'INSTALLING'
echo '----------'
@tian-im
tian-im / non-ascii_detector.rb
Created September 18, 2017 06:20
Detect non-ASCII charaters
"‐a".each_codepoint do |c|
if c & 0xff80 != 0
puts "#{c} is non-ASCII char"
end
end
@tian-im
tian-im / port_forwarding.exe
Created July 26, 2017 23:56
Port forwarding in Windows
# 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
@tian-im
tian-im / install-ruby.sh
Created July 23, 2017 01:01
Vagrant setup
#!/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 $@
@tian-im
tian-im / resume.rb
Last active January 2, 2024 07:10
Resume written in Ruby which can be run as RSpec test.
# Execute the following commands in terminal to see its output:
# $ curl -L -o resume.rb https://gist.github.com/tian-im/510644be3c5453f81bc86c8515d2d48b/raw && gem install rspec -N
# $ rspec resume.rb --format documentation --color
module Resume
puts <<~CONTACT
name: Tianwen "Tian" Chen
email: me at tian.im
github: https://github.com/tian-im
linkedin: http://www.linkedin.com/in/tian-im