Skip to content

Instantly share code, notes, and snippets.

@syshack
syshack / yesterday.py
Created January 16, 2012 04:58
get yesterday dete str
#!/usr/bin/env python
import string
import datetime
today = string.join(string.split(str(datetime.date.today()),"-"),"")
yesterday = str(int(today) - 1)
@syshack
syshack / yesterday2.py
Created January 16, 2012 04:59
yet another demo
#!/usr/bin/env python
import time
t =time
today = t.strftime("%Y%m%d",t.localtime())
yesterday = int(today) - 1
@syshack
syshack / crc.py
Created January 16, 2012 09:35
crc
#!/usr/bin/env python
import os, sys
import zlib
import base64
filename = sys.argv[1]
def crc(fileName):
fd = open(fileName,"rb")
content = fd.readlines()
fd.close()
prev = None
@syshack
syshack / cnfparse.py
Created January 17, 2012 03:21
config file parse
#!/usr/bin/env python
# -*- coding:utf-8 -*-
import os
import sys
########################################################################
class cnfparse:
"""config file parse
Usage:cnfparse [path_to_cnf-file]"""
#----------------------------------------------------------------------
@syshack
syshack / 99.py
Created January 18, 2012 02:44
99乘法表
#!/usr/bin/env python
#99表
for x in range(1, 10):
for y in range(1, x + 1):
print "%s*%s=%-2s"%(y, x, x *y),
print
@syshack
syshack / 99-2.py
Created January 18, 2012 02:55
另一个99表
#!/usr/bin/env python
#99表2
for i in range(1,10):
for j in range(1,i+1):
print str(j)+"*"+str(i)+"="+str(i*j),
print
@syshack
syshack / php5.spec
Created February 23, 2012 09:19
php5.spec
%define version 5.3.10
%define so_version 5
Name: php
Summary: PHP: Hypertext Preprocessor
Group: Development/Languages
Version: %{version}
Release: 2%{?dist}.centos
License: The PHP license (see "LICENSE" file included in distribution)
Source: http://www.php.net/get/php-%{version}.tar.gz
@syshack
syshack / php4.3.9.spec
Created February 28, 2012 02:40
php4.3.9.spec
%define contentdir /var/www
%define with_oci8 %{?_with_oci8:1}%{!?_with_oci8:0}
%define with_mssql %{?_with_mssql:1}%{!?_with_mssql:0}
%define with_mhash %{?_with_mhash:1}%{!?_with_mhash:0}
Summary: The PHP HTML-embedded scripting language. (PHP: Hypertext Preprocessor)
Name: php
Version: 4.3.9
Release: 3.9
License: The PHP License
@syshack
syshack / install-mongo.sh
Created April 13, 2012 03:29
mogodb auto-compile
#/bin/bash -e
#author:syshack
echo "Before all,u should download pcre,js,scons,boost,mongodb sourcecode"
echo -n "Pls enter ur *needed* package path:"
read prepath
cd ${prepath:=.}
echo -n "Where your bin want to install:"
read mongodir
echo "Install scons"
tar -xvf scons-*
@syshack
syshack / mongodb.conf
Created April 13, 2012 03:37
conf file of mongodb
#where to log
logpath=mongod.log
rest=true
logappend=true
# fork and run in background
fork = true
#port = 27017