Steps with explanations to set up a server using:
- virtualenv
- Django
- nginx
- uwsgi
#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]) { |
#!/usr/bin/python | |
""" | |
Binary Search | |
""" | |
def bsearch(array, min, max, target): | |
if max < min: | |
return -1 |
#include <stdio.h> | |
#define MIN(X,Y) ((X) < (Y) ? (X) : (Y)) | |
#define min(a, b) \ | |
({ __typeof__ (a) _a = (a); \ | |
__typeof__ (b) _b = (b); \ | |
_a > _b ? _b : _a; }) | |
#define max(a, b) \ |
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)): |
#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; |
# Slideshare link: http://www.slideshare.net/ChaoGao1/write-a-redis-client | |
import socket | |
tcp_host = '127.0.0.1' | |
tcp_port = 6379 | |
tcp_timeout = 10000 | |
buffer_size = 1024 | |
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) |
# use C-a, since it's on the home row and easier to hit than C-b | |
set-option -g prefix C-a | |
unbind-key C-a | |
bind-key C-a send-prefix | |
set -g base-index 1 | |
# vi is good | |
setw -g mode-keys vi | |
# mouse behavior |
pkg install python | |
pkg install git | |
pkg install wget | |
wget https://bitbucket.org/pypa/setuptools/raw/bootstrap/ez_setup.py -O - | python | |
easy_install pip | |
pip install ipython |
#include <stdio.h> | |
#include <stdlib.h> | |
#include <string.h> | |
#include <sys/types.h> | |
#include <sys/socket.h> | |
#include <netdb.h> | |
#include <unistd.h> | |
#include <fcntl.h> | |
#include <sys/epoll.h> | |
#include <errno.h> |