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; |
| 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 <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) \ |
| #!/usr/bin/python | |
| """ | |
| Binary Search | |
| """ | |
| def bsearch(array, min, max, target): | |
| if max < min: | |
| return -1 |
| #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]) { |
| # 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 |
| #include <stdio.h> | |
| #include <unistd.h> | |
| #include <fcntl.h> | |
| int main(int argc, char *argv[]) | |
| { | |
| int fd, fdw; | |
| int pid; | |
| pid = fork(); |
| 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() |
| """ | |
| Permulation algorithm implemented in Python. | |
| """ | |
| array = range(1, 4) | |
| def perm(array, lower, upper): | |
| if lower >= upper: | |
| print array | |
| else: |