Skip to content

Instantly share code, notes, and snippets.

View reterVision's full-sized avatar
🍔

Chao Gao reterVision

🍔
View GitHub Profile
@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)}'
@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 / perm.py
Last active December 12, 2015 04:39
All permulation algorithm written in Python.
"""
Permulation algorithm implemented in Python.
"""
array = range(1, 4)
def perm(array, lower, upper):
if lower >= upper:
print array
else:
@reterVision
reterVision / file_options.c
Last active December 15, 2015 08:19
Linux C Programming -- Create Process and File Read & Write
#include <stdio.h>
#include <unistd.h>
#include <fcntl.h>
int main(int argc, char *argv[])
{
int fd, fdw;
int pid;
pid = fork();
@reterVision
reterVision / mount.sh
Created March 24, 2013 09:31
Add new hard disk you Linux.
# 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
@reterVision
reterVision / bsearch.c
Last active December 15, 2015 09:29
Binary Search with C
#include <stdio.h>
#include <stdlib.h>
int binary_search(int a[], int min, int max, int value)
{
if (max < min) {
return -1;
}
int mid = (max + min) / 2;
if (value == a[mid]) {
@reterVision
reterVision / bsearch.py
Created March 26, 2013 00:51
Binary Search in Python
#!/usr/bin/python
"""
Binary Search
"""
def bsearch(array, min, max, target):
if max < min:
return -1
@reterVision
reterVision / anagram.py
Created May 5, 2013 07:56
Anagram solution in Python.
def get_anagram(big_phrase, phrase):
"""
Get a sub-string from a big phrase which is the anagram
with the other string.
"""
print 'Problem: ', big_phrase, phrase
big_phrase = big_phrase.lower()
phrase = phrase.lower().replace(' ', '')
for i in range(len(big_phrase)):

Set up Django, nginx and uwsgi

Steps with explanations to set up a server using:

  • virtualenv
  • Django
  • nginx
  • uwsgi
#include <unistd.h>
#include <stdio.h>
#include <dirent.h>
#include <string.h>
#include <sys/stat.h>
#include <stdlib.h>
void printdir(char *dir, int depth)
{
DIR *dp;