Skip to content

Instantly share code, notes, and snippets.

# Install Dependencies
sudo apt-get install libmysqlclient-dev mysql-client libcurl4-openssl-dev libgd2-xpm-dev libjpeg-dev libpng3-dev libxpm-dev libfreetype6-dev libt1-dev libmcrypt-dev libxslt1-dev bzip2 libbz2-dev libxml2-dev libevent-dev libltdl-dev libmagickwand-dev libmagickcore-dev imagemagick libreadline-dev libc-client-dev libsnmp-dev snmpd snmp libvpx-dev libxpm-dev libgmp3-dev libicu-dev libpspell-dev libtidy-dev freetds-dev unixodbc-dev librecode-dev libglib2.0-dev libsasl2-dev libgeoip-dev imagemagick libmagickcore-dev libmagickwand-dev
# Stop Apache
sudo service apache2 stop
# Cleanup Packages
sudo apt-get autoremove
# Remove Ubuntu PHP Packages
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#define MAXLEN 32
#define printB(x) printf("len: %d\nones: %d\n", x->lenBin, x->onesNum)
#define print(x) printf("%.0f\n",x)
typedef struct binary_struct{
int *bin; /*the binary array*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#define MAXLEN 32
#define printB(x) printf("len: %d\nones: %d\n", x->lenBin, x->onesNum)
#define print(x) printf("%.0f\n",x)
typedef struct binary_struct{
int *bin; /*the binary array*/
#include <stdio.h>
#include <string.h>
#define sigma 26
#define print(x) printf("%ld\n",x);
long factorial(int k)
{
if(k==0)
return 1;
int i;
@liuyuuan
liuyuuan / cg.py
Created September 16, 2012 15:39
def cg(n,t): # according to taocp v4f3 chap. 7.2.1.3 algo l.
import pdb
pdb.set_trace()
# initializing...
result = []
comb=[-1]
for j in range(1, t+1):
comb.append(j-1)
comb.append(len(n))
comb.append(0)
@liuyuuan
liuyuuan / cnrmemo.py
Created September 12, 2012 13:49
cnrmemo.py
def randPermute(r, n ):
""" Compute C(n,r) and the corresponding combinations. r here is
a list.
@return list all combinations.(Including duplicates)
"""
import pdb
#pdb.set_trace()
d = [] # a result container
if len(r) == 0:
return d
@liuyuuan
liuyuuan / cnr.py
Created September 8, 2012 15:15
C(n,r) recursion version, final, but slow...
def randPermute(r, n ):
""" Compute C(n,r) and the corresponding combinations. r here is
a list.
@return list all combinations.(Including duplicates)
"""
import pdb
#pdb.set_trace()
d = [] # a result container
if len(r) == 0:
return d
@liuyuuan
liuyuuan / randPermute.py
Created September 5, 2012 12:43
c(n,r)
def randPermute(r, n ):
""" Compute C(n,r) and the corresponding combinations. r here is
a list.
@return list all combinations.(Including duplicates)
"""
import pdb
#pdb.set_trace()
d = [] # a result container
if len(r) == 0:
return d
@liuyuuan
liuyuuan / books1Dfs.py
Created September 5, 2012 08:02
version.
def evaluate(pages,border, avg):
D =0
for i in range(len(border)):
d = sum(pages[border[i-1][0]:border[i][0]]) - avg
D += d**2
return D
def DFS(k, m, pages,solutions, border,branch=-1,score = [float("inf"),0]):
if branch != 0:
if branch == -1:
def evaluate(pages,border, avg):
D =0
for i in range(len(border)):
d = sum(pages[border[i-1][0]:border[i][0]]) - avg
D += d**2
return D
def DFS(k, m, pages,solutions, border,branch=-1,score = [float("inf"),0]):
import pdb
pdb.set_trace()