Live Chat!

Does scons outperforms autoconf and makefiles?

* * * * * 1 votos

May 28th, 2009 mysurface

SCons is a software construction tool (build tool, or make tool) implemented in Python, that uses Python scripts as “configuration files” for software builds. Based on the design that won the Software Carpentry build tool competition, SCons solves a number of problems associated with other build tools, especially including the classic and ubiquitous Make itself.
In [...]

Posted in python | Hits: 15103 | No Comments »

python: simple http server for file sharing

* * *     2 votos

May 15th, 2009 mysurface

You do not need to setup apache server just to hosting your file for sharing. If you have python 2.5 and above, you can do this at the targeted directory to share.
python -m SimpleHTTPServer 9914
9914 is the port number I choose to host my web, assume my IP is 192.168.1.1, in firefox you can ask [...]

Posted in python | Hits: 23457 | 5 Comments »

Bit shifting can be done in python just like in c

* * * * * 1 votos

April 1st, 2009 mysurface

It was amazing to discover that I can do bit shifting in python just like in c, the syntax makes no different at all. Let us look at how easy I can do a bit shifting. I write an example loop by shifting the bit leftwards.

for i in range(0,10):
print “0×0001 << [...]

Posted in Developer, python | Hits: 36001 | No Comments »

How can I avoid running a python script multiple times? Implement file locking.

* * * ½   3 votos

March 13th, 2009 mysurface

Sometimes we just need a single instance of the python script to run at a time. Meaning, the python script itself should detects whether any instances of himself are still running and act accordingly.
Well, how to do it?
The idea is simple, the first instance of the python script will open a file, and lock it. [...]

Posted in Developer, python | Hits: 41966 | 3 Comments »

Plot your graphs with command line gnuplot

* * * ½   3 votos

February 12th, 2009 mysurface

gnuplot is a command line driven graph plotter tools for us to generate graphs. The common graphs that we are looking forward to present the resource performance per seconds, hours, days, weeks or months are usually plot graphs, which it consist of lines and dots. gnuplot allows us to read the data from text files [...]

Posted in Developer, gnuplot | Hits: 51653 | 3 Comments »

Python: Manipulate string or binary bytes with StringIO

* * *     2 votos

November 25th, 2008 mysurface

Sometimes it is not convenient to construct string using equal (=) like this:
str = “Hello, ”

str = str + “my name is ”

str = str + Name
print str
In python, we have string stream (StringIO) that will behave like file stream, you can construct your string like this:
str=StringIO()

str.write(”Hello, “)

str.write(”my name is “)

str.write(Name)
print str.getvalue()
The same way, you [...]

Posted in Developer, python | Hits: 70928 | 4 Comments »

python: writing binary file

* * *     2 votos

November 20th, 2008 mysurface

Python is the best scripting language which I found it out perform Bash script as well as Lua. I like python’s scripting syntax, which is make sense and very convenient in string manipulations. Its now come to binary format manipulation, how convenient is python?
I have carry out some research on python into writing binary files. [...]

Posted in python | Hits: 72136 | 1 Comment »

Python vs Lua, data structure

          0 votos

June 28th, 2008 mysurface

In python, we have various type of data structure, such as list, set, tuple, dictionary etc, but in Lua, we only have table. Table in Lua can be used as array, list, dictionary or object.
Let see how you we construct list from Lua table.
t = { ‘a’,'b’,'c’,'d’,'e’,'f’ }
To print out the whole list, we need [...]

Posted in Developer, Lua, python | Hits: 44556 | 2 Comments »

How to list shared library dependencies used by an application

          0 votos

June 15th, 2008 mysurface

Almost every application in Linux uses shared library, even the one compiled by yourself with gcc. You may have realized that application compiled with gcc 4.1 in Fedora or Ubuntu does not able to run under Red Hat ES3 or ES4. Or some other new applications does not able to run at legacy Linux, it [...]

Posted in Developer, ldd | Hits: 50918 | 8 Comments »

How to embed Lua 5.1 in C++

          0 votos

June 7th, 2008 mysurface

Lua, is a scripting language providing dynamic data structures, maths, io and string manipulations just like any interprete language such as Bash, Python, Ruby etc.
What is so special about Lua?
Lua is Fast, Light-weight and Embeddable.
Lua can be embedded into c and c++ programs and Lua core are statically complied with your c++ programs, [...]

Posted in Developer, Lua | Hits: 40934 | 1 Comment »