Owner: selinap URL:http://www.selinap.com Join Date: Thu, 27 Mar 2008 10:56:11 -0500 Rating:0 Site Description: Computer programming: Python, PhP, LaTeX and anything about computer Site statistics:Click here
Python: Put comma(s) to numbers 2008-03-22 11:44:00 This script will put commas between each group of three digits number. For example, 1234567 will become 1,234,567.import reputComma = lambda x: (','.join(re.findall("\d{1,3}", str(x)[::-1])))[::-1]print putComma(1234567) # 1,234,567print putComma(12345678) # 12,345,678print putComma(123456789) # 123,456,789print putComma(1212) # 1,212 Read more:Python
How to publish python code in blogger 2008-03-16 13:18:00 To publish python code and preserve the tab, just enclose the code within the <pre> ... </pre> block.The pre element defines preformatted text. Usually spaces and line breaks will be preserved.Example:<pre>your python code goes here</pre>
Python: Prime Number 2008-03-16 12:47:00 def isPrime(x): for i in range(2, x): if x%i == 0: return false return truefor c in range(1,10): if isPrime(c): print c, output: 1 2 3 5 7 Read more:Python
, Number
Compiling LaTeX on Windows: An alternative method 2007-07-22 20:12:00 The usual method
to compile latex is by using "latex" command, and if the latex file contains bibliography, it will be a very tedious and repetitive job.To produce a dvi file:latex yourfile.texbibtex yourfile.texlatex yourfile.texlatex yourfile.texTo produce a pdf file:pdflatex yourfile.texbibtex yourfile.texpdflatex yourfile.texpdflatex yourfile.texHowever, for the windows user, with miktex, there is an alternative that could simplify all those tasks - the texify.To produce a dvi filetexify yourfile.texTo produce a dvi file and clean all the auxilary filestexify -c yourfile.texTo produce a pdf file (to clean all the auxilary files, just add -c as above)texify -p yourfile.texTo produce a dvi file and run the default viewer (add -p for pdf)texify yourfile.tex --run-viewer Read more:Windows
LaTeX example - creating a lecture note 2007-07-08 05:41:00 This LaTeX example will create an automatic exercises numbering as well as the problems in each exercise.\documentclass[a4paper,12pt]{book}\newcounter{exercisenum}[section]\renewcommand{\theexercisenum}{\arabic{exercisenum}}\newenvironment{exercise}{\stepcounter{exercisenum}\vspace{1pc}\par\noindent\textbf{Exercise \thesection.\theexercisenum}\par\begin{flushleft}}{\end{flushleft}}\newcounter{problemnum}[exercisenum]\renewcommand{\theproblemnum}{\arabic{problemnum}}\newcommand{\problem}{\stepcounter{problemnum}\theproblemnum. }\newcounter{secondproblemnum}[problemnum]\renewcommand{\thesecondproblemnum}{\alph{secondproblemnum}}\newcommand{\secondproblem}{\stepcounter{secondproblemnum}\thesecondproblemnum) }\begin{document}\chapter{Introduction}\section{Function}\begin{exercise}\begin{tabula Read more:lecture
Backup folders with 7-zip command line 2007-05-23 20:24:00 The 7-zip command
line can be used to do a multiple folders backup. The good thing with 7-zip is that it support many compression method such as bzip2, gzip, zip and of course 7z.Here are steps for doing a backup on multiple folders on Windows: Download the 7-zip Command Line Version from Extract the content of the zip file to a temporary folder. Copy 7za.exe to your system folder (for example C:\Windows\System32\ for Windows XP).Create a folder for your backup, for example C:\backup. Create a text file in the C:\backup folder and name it backup.txt. List the full path of the folders that will be backup, each on a new line. Create a batch file in C:\backup folder and name it backup.bat. In the backup.bat file, type 7za u backup -up1q3r2x1y2z1w2 @backup.txtTo back up, just double click t
Python: Make division always produce real numbers 2008-03-28 04:35:00 A division of 7/2 in Python
will gives a result of 2. However, this is not correct. Since Python always
assume that the numbers are whole numbers, the resultant will be truncated from 2.5 to 2.A work around is to write one of the numbers as a decimal:>>> print 7/3.02.5>>> print 7.0/32.5>>> print 7.0/3.02.5In order to change this behaviour of Python, throughout the program execution, so that Python will always produce
real numbers, a module division has to be imported.>>> from __future__ import division>>> print 7/32.5
Check your blog load time 2008-03-31 19:57:00 The form below could be used to determine a blog load time.Enter your domain name in the text box, for example selinap.blogspot.com:.
Read more:Check
Python: Initialize list and tuple values 2008-03-31 00:57:00 To initialize list myList values to 0, with 10 items:myList = (0,)*10If we need to have 5 item of list with the value 0 and the rest 5 with the value 1:myList = [0]*5 + [1]*5To initialize tuple myTuple values to 0, with 10 items:mytuple = (0,)*10If we need to have 5 item of tuple with the value 0 and the rest 5 with the value 1:myList = (0,)*5 + (1,)*5For tuple, don't forget the ','. It means one item.
Read more:Python
Ping your blog to Technorati 2008-03-30 20:03:00 Please use this form to ping Technorati
once you update your blog. Technorati will check your for blog new content.For blogger.com, ping could be done automatically by enabling "Add your blog to our listings?" in your blogger basic settings.If you are using blog software, please enter "" into your weblog tool's configuration for Pings and Notifications.
Python: Parse Apache log to sqlite database 2008-04-02 04:30:00 Apache server log like this23.13.171.152 - - [26/Sep/2007:21:20:36 +0800] "GET /forum/Themes/BlueStory/images/bbc/ftp://ftp.gif HTTP/1.1" 200 191 " "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.7) Gecko/20070914 Firefox/2.0.0.7"could be parse to an sqlite database, with the class below.class Parser: def __init__(self, serverLog, db): if db.strip() == "": db = "log.db" try: conn = sqlite3.connect(db) Read more:Python
, Apache
Links for 2008-04-05 [Digg] 2008-04-06 00:00:00
KL 1 April 2008
Apicture of KL sky on the first of April, 2008
Read more:Digg
Links for 2008-04-03 [Digg] 2008-04-04 00:00:00
Python: py2exe setup file example
A py2exe setup code sample
Python: Parse Apache log to sqlite database
This Python script could parse an apache server log to sqlite database
Read more:Digg
Python: Parse Apache log to sqlite database 2008-04-02 04:30:00 Apache server log like this23.13.171.152 - - [26/Sep/2007:21:20:36 +0800] "GET /forum/Themes/BlueStory/images/bbc/ftp://ftp.gif HTTP/1.1" 200 191 " "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.7) Gecko/20070914 Firefox/2.0.0.7"could be parse to an sqlite database, with the class below.class Parser: def __init__(self, serverLog, db): if db.strip() == "": db = "log.db" try: conn = sqlite3.connect(db) Read more:Python
, Apache
Links for 2008-03-31 [Digg] 2008-04-01 00:00:00
Python: Initialize list and tuple values
Initialize the value of list and tuple
Backup folders with 7-zip command line
How to do backup using 7-zip command line
Check your blog load time
Use this tool to determine the speed of your blog or website
Read more:Digg
Check your blog load time 2008-03-31 19:57:00 The form below could be used to determine a blog load time.Enter your domain name in the text box, for example selinap.blogspot.com:.
Read more:Check
Python: Initialize list and tuple values 2008-03-31 00:57:00 To initialize list myList values to 0, with 10 items:myList = (0,)*10If we need to have 5 item of list with the value 0 and the rest 5 with the value 1:myList = [0]*5 + [1]*5To initialize tuple myTuple values to 0, with 10 items:mytuple = (0,)*10If we need to have 5 item of tuple with the value 0 and the rest 5 with the value 1:myList = (0,)*5 + (1,)*5For tuple, don't forget the ','. It means one item.
Read more:Python
Links for 2008-03-30 [Digg] 2008-03-31 00:00:00
Ping your blog to Technorati
Inform Technorati that you have recently updating your blog contents.
Read more:Digg
Ping your blog to Technorati 2008-03-30 20:03:00 Please use this form to ping Technorati
once you update your blog. Technorati will check your for blog new content.For blogger.com, ping could be done automatically by enabling "Add your blog to our listings?" in your blogger basic settings.If you are using blog software, please enter "" into your weblog tool's configuration for Pings and Notifications.
Links for 2008-03-29 [Digg] 2008-03-30 00:00:00
Compiling LaTeX on Windows: An alternative method
How to compile LaTeX documents
LaTeX example - creating a lecture note
How to create a lecture note with LaTeX
BibTeX Entry Types
List of BibTeX entries
Python: Prime Number
Display list of prime numbers with Python
Read more:Digg
Links for 2008-03-28 [Digg] 2008-03-29 00:00:00
Python: Make division always produce real numbers
How to make division of two numbers in Python to always produce real numbers
Python: How to put comma(s) to numbers
How to make 123456 become 123,456 in Python
Backup folders with 7-zip command line
Tutorial on how to backup folders with 7-zip command line.
How to publish python code in blogger
How to preserve tab while publishing python code in blogger.
Read more:Digg
Python: Make division always produce real numbers 2008-03-28 04:35:00 A division of 7/3 in Python
will gives a result of 2. However, this is not correct. Since Python always
assume that the numbers are whole numbers, the result will be truncated from 2.5 to 2.A work around is to write one or both of the numbers as a decimal:>>> print 7/3.02.5>>> print 7.0/32.5>>> print 7.0/3.02.5In order to change this behaviour of Python, throughout the program execution, so that Python will always produce
real numbers, a module division has to be imported.>>> from __future__ import division>>> print 7/32.5
Python: Put comma(s) to numbers 2008-03-22 11:44:00 This script will put commas between each group of three digits number. For example, 1234567 will become 1,234,567.import reputComma = lambda x: (','.join(re.findall("\d{1,3}", str(x)[::-1])))[::-1]print putComma(1234567) # 1,234,567print putComma(12345678) # 12,345,678print putComma(123456789) # 123,456,789print putComma(1212) # 1,212
Read more:Python
How to publish python code in blogger 2008-03-16 13:18:00 To publish python code and preserve the tab, just enclose the code within the <pre> ... </pre> block.The pre element defines preformatted text. Usually spaces and line breaks will be preserved.Example:<pre>your python code goes here</pre>
Python: Prime Number 2008-03-16 12:47:00 def isPrime(x): for i in range(2, x): if x%i == 0: return false return truefor c in range(1,10): if isPrime(c): print c, output: 1 2 3 5 7
Read more:Python
, Number