This file contains 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 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 |
This file contains 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
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>; |
This file contains 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
# 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. |
This file contains 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
# 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. |
This file contains 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 | |
git status | grep 'modified\|added' | awk '{system("pyflakes "$3)}' | |
git status | grep 'modified\|added' | awk '{system("pep8 "$3)}' |
This file contains 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 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', |
This file contains 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
""" | |
Permulation algorithm implemented in Python. | |
""" | |
array = range(1, 4) | |
def perm(array, lower, upper): | |
if lower >= upper: | |
print array | |
else: |
This file contains 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
from datetime import datetime | |
class LRUCacheItem(object): | |
"""Data structure of items stored in cache""" | |
def __init__(self, key, item): | |
self.key = key | |
self.item = item | |
self.timestamp = datetime.now() |
This file contains 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
#include <stdio.h> | |
#include <unistd.h> | |
#include <fcntl.h> | |
int main(int argc, char *argv[]) | |
{ | |
int fd, fdw; | |
int pid; | |
pid = fork(); |
This file contains 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
# Extracted information from below | |
# http://rbgeek.wordpress.com/2012/05/11/how-to-add-2nd-hard-drive-to-ubuntu/ | |
# http://ubuntuforums.org/showthread.php?t=1659376 | |
# 1. List out all the disk you have in hand now. | |
sudo fdisk -l | |
# 2. Create partition on the secondary hard drive. | |
# Remember to create logical partition. | |
sudo fdisk /dev/sdb |
OlderNewer