RSS Feed

RSS

Comments RSS

ASCII Mandelbrot Fractal – as a Python CGI

Here is an example of a Python CGI that I have running on my SDF.org website.  It generates a ASCII Mandelbrot Fractal and allows for the user to change and zoom in the field of view.  Granted, it is very low resolution being ASCII, but the main purpose was to demonstrate the use of Python for CGI purposes on SDF.org.   (FOR FURTHER EXPLORATION):   Since the SDF.org server Python package (v 2.6.5) has the PIL (Python Image Library) available, I can see no reason that true binary images of Mandelbrot fractals might not be produced and displayed on as pictures on the web page.  UPDATE:  As suspected, creating true graphical Mandelbrot fractals did in fact work out well.   Here is a link to a Python CGI that uses PIL to create the images.  Graphical Mandelbrot CGI

Ubuntu+XAMPP+Python part 1

Do you have Ubuntu running on a system at home or work?  Have you ever wanted to run your own local web server or at least have one available for development work?   Have you ever wanted to craft your own web CGI scripts?  If you answer yes to these, then here is a serials of tutorials on how to get an Apache web server running quickly and easily on your Ubuntu system and how use Python to craft CGI scripts to run on it.

First, let’s get an Apache web server up and running.   Since this is targeted at people running Ubuntu desktop, rather than Ubuntu server, the very simplest way to install Apache is to do it via XAMPP.   XAMPP is a bundled, self-contained Apache web server distribution provided by Apache Friends that is complete and robust.  It includes  features here as listed from the website:

The distribution for Linux systems (tested for SuSE, RedHat, Mandrake and Debian) contains: Apache, MySQL, PHP & PEAR, Perl, ProFTPD, phpMyAdmin, OpenSSL, GD, Freetype2, libjpeg, libpng, gdbm, zlib, expat, Sablotron, libxml, Ming, Webalizer, pdf class, ncurses, mod_perl, FreeTDS, gettext, mcrypt, mhash, eAccelerator, SQLite and IMAP C-Client.

The XAMPP distribution is designed simply to be downloaded, unpacked, and run from a self-contained directory.   It does not modify your Ubuntu system at all and can be removed simply by deleting the folder that contains the installation.    Now, follow this link to the Apache Friends website and follow the directions for downloading and installing the XAMPP distribution, after reading the notes I provide here.  You will notice there are also instructions on securing the installation.  This is particularly important if you are using this for anything other than development purposes running on your personal system.  If this will be exposed to others, or the world, be sure to follow the instructions on making XAMPP secure.  Note:  Since this is being targeted for Ubuntu do not use the su command as stated in the XAMPP installations instructions.  Instead, you should install using this single line.

sudo  tar xvfz xampp-linux-1.7.3a.tar.gz -C /opt

XAMPP will be installed in the /opt/lampp folder.   To start it up, go to a shell prompt and type the following.  Again, sudo is required.

sudo /opt/lampp/lampp

Now, open you browser and give http://localhost as the address.  You will be presented with the default XAMPP webpage that is being served out by your local Apache web server.  I encourage you to play around with XAMPP for a while and explore your installation via the default page, then return here for the next installment of this series where we will look further at developing CGI scripts in Python.

Python – the new BASIC

I recently read a good blog on the subject of the Python programming language being the new BASIC, and that being a good thing. I very much agree, and it IS a good thing. I got my start in computing and programming just as the age of the home computer was coming to be, i.e. days of the Sinclair, Atari, TRS 80 type home systems. BASIC was the mainstay on these systems and usually came bundled in the system. In those days, home computer users were not looking to just surf the web (which did not exist yet as we know it) or other entirely enduser type activities that are so common today. Back in the day, late 70’s & early 80’s, home computer users were most difinately hobbyists and enthusiasts. Most folks were looking to discover just what they could do with this computer technology now that it was feasible to have it in the home without spending too much of a fortune. Part of this experience for most was learning the version of the BASIC programming language that was bundled, or built into, their computer. There was not much software available back then and the folks were willing and eager to write their own. I’ll never forget the very first computer that our family purchased and on which I first hacked out in BASIC a program. I was a Radio Shack TRS-80 Pocket Computer. It had a HUGE 8Kbytes of RAM! It plugged into and interface that let you print to adding machine roll paper and save programs to an external cassett tape. I learned BASIC and so did my Dad. Those were the days! BASIC was the gateway into programming because it had two fundamental features – it was simple and highly accessible. It came with nearly ALL home computing systems. BASIC spread like wildfire. Today, there is a great need for the same thing. A programming language that is both simple and accessible. While I have mastered several programming languages over the years, the only one that harkens me back to the good old days of BASIC is Python. This is a GOOD thing! Python is both totally free and available for most any computer system and it is simple to learn. It is interpreted and highly portable, just like BASIC was, yet is powerful. Any newbie programmer can pick it up and get it to spit out “Hello World” in just one simple line of code and then within mere days (maybe even hours) be creating useful Object Orientated code using the most modern programming paradigms (usually with even realizing it!). Also, it is not some toy programming language. There is a huge body of high end programs written in it which is growing everyday. Python is the NEW BASIC, without the design shortcomings of BASIC. It is what we have needed.

Linux games! (didn’t you know?)

Yes, Virginia, there are Linux games and good ones too!
You might not be much into gaming, but hey, you might get bored one evening. Here are some good Linux games of various sorts. All for FREE.

Cool list of 5 great Linux games in 2010 (various). BTW, Dedoimedo is a great blog!
http://www.dedoimedo.com/games/linux-games-best.html

For those who LOVE WWII and the battles! Computer version of the classic boardgame Axis & Allies.
http://triplea.sourceforge.net. For all platforms, extract zip into a folder and run the OS appropriate OS triplea file.

Battle for Wesnoth. Turn based fantasy strategy game. Play the computer or others online.
Install version wesnoth-1.8 from the Ubuntu repostiory. http://www.wesnoth.org

Ubuntu comes with some solitare type games already loaded, but if you want many more then install PySol from the repository.
Includes many, many types of games including Majong and others, really worth installing.
http://pysolfc.sourceforge.net/

The opensource version of one of the best games of all time, Civilization, as FreeCiv.
Install freeciv from the Ubuntu repository.
http://freeciv.wikia.com/wiki/Main_Page

Doug Hellmann – Code Interstices

I have come across a terrific Python resource in a blog. The blog Doug Hellmann – Code Interstices features a PyMOTW, Python Module Of The Week, that covers much of the Python Standard Library with discussion and examples. The discussion is cogent and the examples clear. Mr. Hellmann has put together an index of all his PyMOTW articles that in total is a very good Python reference. I highly recommend this resource and commend the author for sharing with the community.

Also, Doug Hellmann’s main website.

GIMP – a deskew plugin

GIMP (the GNU Image Manipulation Program) is a great product.  It provides many advanced image editing options and is available on both the Linux and Windows platforms.  Of course, it is FREE.  One capability that is noticed to be missing from its sizable suite of tools is a “deskew” function.   As the name suggests,  a deskew function straightens up a somewhat crooked picture.  This is often needed to straighten up a scanned image that did not pass through the scanner in a perfectly straight manner.   After quite a lot of searching on the web, I found that there is a plugin (an add-on) that provides this function for GIMP.   For the typical user, getting ones hands on the deskew plugin is not as easy nor is installing it intuitive, so I will provide links to both the Linux and Windows versions of the deskew plugin and instructions how to install each.

First download the plugin for your OS:

GIMP-deskew-plugin for Windows
GIMP-deskew-plugin for Linux

To install in the plugin into GIMP for Windows, unzip the plugin from the file you downloaded and place the deskew.exe file in the c:\program files\gimp\lib\2.0\lib\plug-ins\ folder.

To install the pluging into GIMP for Linux, simply place the pluging you downloaded, the deskew file, into the /usr/lib/gimp/2.0/plug-ins/ folder.

Now, either open GIMP or close and restart the program if you already had it open. You will now find a new entry in the Filters menu called Misc. The plugin is selected via the menu path Filters>Misc>Deskew.

NOTE: I did not write the GIMP deskew plugin, and thus cannot provide any support for it. I just want to make it easily available to other GIMP users since it took me some time to find both versions.