Skip to main content


Showing posts from April, 2011

Python Server Pages Example of GET POST Form Input

Previously, I've talked about mod_python.publisher method of creating a simple website using Python. And this time, I will talk about mod_python.psp where PSP stands for Python Server Pages.

What good about Python Server Pages for former PHP or JSP programmer is the way you can write your code where you can use the <% # your code here %> tag as you always do. But before that, you have to configure your server to enable mod_python.psp.

In order to run your site with PSP, you have to install and enable mod_python. Here is the steps if you are using Ubuntu:
Install apache2 and libapache2-mod-python and enable mod-python
$ sudo apt-get install apache2 $ sudo apt-get install libapache2-mod-python $ sudo a2enmod pythonEdit /etc/apache2/sites-enabled/000-default. Search for this lines:
<Directory /var/www/> Options Indexes FollowSymLinks MultiViews AllowOverride None Order allow,deny allow from all …

Python Code to Get IP Address From Interface Name

From my previous code on How To Print Active Network Interface List in Linux using Python, I got this question.

Question from jimchris:
Nice work, now how do we get ip address from ifacedata?

My Answer:
Here's how... Add this function to your python code:
def getifip(ifn):import socket, fcntl, structsck = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)return socket.inet_ntoa(fcntl.ioctl(sck.fileno(),0x8915,struct.pack('256s', ifn[:15]))[20:24])
Then use it in your previous code like this:
print getifip(ifacedata[0])
Update: you can also download the python source code here

Wish you luck and Happy Coding!

VBScript Get File Extension

Before anything else, you may love to read this book too!...

Actually, I got this question from the reader of my previous blog post about VBScript to Replace Underscores in Filename with Spaces for All Files in a Folder, and I decided to answer it here.

Question from Justin:
I tried something simular..but modified your VBS..
'======================================================== ' VBScript to replace underscore in file name with space ' for each files in a folder ' Written by ApOgEE of '======================================================== Dim sName Dim fso Dim fol ' create the filesystem object Set fso = WScript.CreateObject("Scripting.FileSystemObject") ' get current folder Set fol = fso.GetFolder(".") ' go thru each files in the folder For Each fil In fol.Files ' check if the file name contains underscore If InStr(1, fil.Name, "The ") <> 0 Then ' replace underscore with…

HitungHari - PHP Countdown Banner Application

The ideas developed since my previous Countdown Banner for MOSC2011. I have made some modification on the source code and then it spark me an idea to share the source code as open source too. Therefore, I clean up my messy code, make some documentation and comments so people can reuse the code. And I name it as HitungHari.

The word HitungHari actually come from Malay words for counting days. Where 'Hitung' means 'Count', and 'Hari' means 'Days'. I have more ideas to develop from this piece. Perhaps, you may also have ideas too. I would be glad to hear your comments. Checkout the Google Code site for HitungHari and feel free to download, try, hack, and comment it.

MOSC 2011 Countdown Banner

I'm just having fun with PHP GD and Inkscape. So, to make my toy useful, I would like to dedicate this Countdown banner for the upcoming MOSC 2011 event. You are free to put it on your blog or website. Here is the code to put on your site:

<!-- MOSC2011 Countdown Banner By ApOgEE - code start --><div style="width:100%; text-align:center;"><a href="" target="_blank"><img src="" target="_blank"></a></div><!-- MOSC2011 Countdown Banner By ApOgEE - code end -->
And here is the result:

I hope you enjoy it! Feel free to Follow this blog if you like it.

I heard request on MOSC2011 mailing list where some of them want this banner in different sizes. So, I've modified my php code and add this sizes:

MOSC Countdown Banner 300x250
<!-- MOSC2011 Countdown Banner By ApOgEE - code start 300x250 --><div style="widt…

Safe Way To Learn Chemical Reaction Without Using Actual Chemicals

I played with hydrochloric acid during my school's chemistry lab session. Drop a little amount of it to my text book while my teacher is teaching something else, and see the pages being eaten by those acids. Just because I'm getting bored in class. That was one case of myself. How about you? Have you ever misuse your science lab chemicals? Today, I found other way for student to learn about chemical reaction without ever use the actual chemical.

At Museum of Science and Industry in Chicago, you can experiment and create a chemical reaction using their interactive exhibit in the Science Storms wing. This interactive exhibit is called Create a Chemical Reaction. Using specially-tagged pucks, visitors can grab atoms from the periodic table and combine them to cause chemical reactions.

The "Create a Chemical Reaction" interactive exhibit is powered by Sensetable platform from Patten Studio. The Sensetable concept and initial prototypes were developed by the Tangible Medi…