Skip to content

Instantly share code, notes, and snippets.

View reterVision's full-sized avatar
🍙

Chao Gao reterVision

🍙
View GitHub Profile
@reterVision
reterVision / lnsym.py
Created February 4, 2013 09:34
A Python Script doing auto symbolic link for you.
#!/usr/bin/env python
import subprocess
import argparse
parser = argparse.ArgumentParser(description='Do the symbolic for you.')
parser.add_argument('--source', dest='folder',
help='Your code directory')
parser.add_argument('--virtual', dest='vfolder',
@reterVision
reterVision / check_python.sh
Created January 22, 2013 03:41
Do pyflakes & pep8 to modified files dicovered by git.
#!/bin/sh
git status | grep 'modified\|added' | awk '{system("pyflakes "$3)}'
git status | grep 'modified\|added' | awk '{system("pep8 "$3)}'
# Sometimes we could mistakenly commit something without pull first, so
# here is how we revert this process and keep our master branch clean.
# Reset back to the commit before you last commit.
# git reset --mixed will keep your changes and revert other files back
# to that commit.
git pull
git reset --mixed HEAD-before-your-last-commit
# Commit your changes again.
# How to merge other branch to master.
# First fetch the changes from your branch, could be made by others
git fetch
# Then commit your changes.
git commit -m "some"
git push origin my-branch
# Switch to master branch and pull the latest code to your local.
@reterVision
reterVision / create_and_grant.sql
Last active December 10, 2015 04:08
How to create a role and grant a view to him with the read only privilege in postgres.
CREATE ROLE <newuser> WITH LOGIN ENCRYPTED PASSWORD <password>;
CREATE VIEW <viewname> AS SELECT * FROM <yourtable> LIMIT 20;
GRANT CONNECT ON DATABASE "<databasename>" TO <newuser>;
GRANT SELECT ON schemaname.viewname TO <newuser>;
REVOKE ALL PRIVILEGES ON <schemaname> FROM <newuser>;
@reterVision
reterVision / brew_install_postgres.sh
Last active December 10, 2015 02:28
Show you the steps of upgrading postgres to 9.2 on Mac OS X using homebrew
# Update brew & install the latest postgres first
brew update
brew install postgres
# Shut down the old running postgres
# Assume you previously installed postgres using homebrew
pg_ctl -D /usr/local/Cellar/posgres/9.1.1 stop
# If postgres won't stop, you have to do the following step to unload it from LaunchAgents
launchctl unload -w ~/Library/LaunchAgents/org.postgresql.postgres.plist