It all sounds Geek to me! [Gautam Arora]

Saturday, August 27, 2005

# Firedrop2 micromini how-to-blog [for win-xp]

1.Open the firedrop2 gui by double-clicking 'C:\Python24\Lib\site-packages\firedrop2\wxfiredrop.pyw'

2.Make your blog by:
File->New site...->Choose a content type:Weblog->Choose/Create directory...->Make New Folder->C:\Weblog->Generating files->OK

3.Click the 'Open' button on the fd2 gui, and select 'C:\Weblog' from the browse-tree.
Note: Your Weblog has been loaded by the fd2.

4.Click the 'New' button on the fd2 gui.This will create an entry '*New*.
Example:
insert_date='2005-08-21 00:31:09'
modified_date='2005-08-21 00:31:09'
--
*New*

5.Edit the content to:
insert_date='2005-08-21 00:31:09'
modified_date='2005-08-21 00:31:09'
--
Hello World
%

Welcome to Firedrop2

6.Click the 'Save' button on the fd2 gui, to save your blog entry.

7.Click on 'Build', to build your blog.

8.Click on 'Preview'. This will open a browser window and display your blog.

You have successfully created a blog using 'firedrop2'.To create more entries, return to step 4.

Sunday, August 21, 2005

# Firedrop2 micromini how-to-install [for win-xp]

The purpose of this how-to is to get you started with the Firedrop2 on win-xp asap!

  • What is Firedrop2?
Firedrop2 is a client side weblog creation and web content management system.
It is open source and written in Python by Hans Nowak.
It is cross platform and runs on Windows,Linux, Mac OS X and most Unix like systems.
Fuzzyman has created a plugin creation tool and some nice plugins.

  • Downloads:
Python 2.4
wxPython 2.5xx (wxPython2.5-win32-ansi-2.5.5.1-py24.exe)
wax 2.xx (wax-0.2.68 )
firedrop2-2005.9

  • Installation:
>>>Python 2.4 - Install py2.4 at 'C:\Python24'

>>>wxPython 2.5xx (wxPython2.5-win32-ansi-2.5.5.1-py24.exe) -Install at 'C:\Python24\Lib\site-packages'

>>>wax 2.xx (wax-0.2.68 ) - Unzip the file(anywhere) and copy-paste the 'wax' folder to 'C:\Python24\Lib\site-packages'
Note: setup.py is provided for installation, but due to some incompatible changes,this might not work.Use the copy-paste technique as above.

>>>firedrop2-2005.9 - Unzip the file to 'C:\Python24\Lib\site-packages'

Note: 'C:\Python24\Lib\site-packages' should contain the following folders now: wx-2.5.5-msw-ansi, wax, firedrop2

  • Configuration:
>>>Edit 2 lines in the file 'C:\Python24\Lib\site-packages\firedrop2\wxfiredrop.py'

From:
import tools
tools.require_wax('0.2.57')

To:
import tools
tools.require_wax('0.2.68')

  • Testing:
Double click the file 'C:\Python24\Lib\site-packages\firedrop2\wxfiredrop.pyw'. This should start the firedrop2 gui as below.


You have successfully installed and configured the 'firedrop2'.

Note:
>>> This micromini how-to is based on the Mini How-To for Firedrop2 and Python411: Firedrop2 Podcast by Ron Stephens

Thursday, August 18, 2005

Lets be more Pythonic ... Part II

The comments in the previous post sure brought abt a miniature py vs ry code-snippet war:

1) List comprehensions
Python: ret=[do_something(elem) for elem in li]
Ruby: ret=li.each {|elem| elem.do_something}

2) return
In Python, all functions return a value; if you dont provide return, your function returns the None object automatically
In Ruby, everything(methods, prodecures, code blocks etc.) returns a value; usually of the last statement executed unless an explicit return statement
(More research required for this point....)

3) each
Python: [do_something(elem) for each in li]
Ruby: ret=li.each {|elem| elem.do_something}

4) yield (the 'round' wheels)

Ruby code for fibo series from Programming Ruby:The Pragmatic Programmer's Guide

def fibUpTo(max)
...i1, i2 = 1, 1
...while i1 <= max
......yield i1
......i1, i2 = i2, i1+i2
...end
end
fibUpTo(1000) { |f| print f, " " }

Python code for fibo series

def fibUpTo(max):
...i1,i2=1,1
...while i1<=max:
......yield i1
......i1,i2=i2,i1+i2
print [i for i in fibUpTo(1000)]

5) Syntax
Python: Indentation rules
Ruby: OO

6)Readability: --->depends on u

This (friendly???) war is certainly gonna continue, but its quite a learning experience and has made me more passionate about Py!

More issues will be discussed and more rants will be thrown around.....watchout!

Thursday, August 11, 2005

Lets be more Pythonic ...

This is C:

for (i=0; i < class="entryText">
   do_something(mylist[i]);
}
--------------------------------------
Is this being Pythonic:

i = 0
while i < mylist_length:
do_something(mylist[i])
i += 1
NO! certainly not!
--------------------------------------
Then this must be being Pythonic:
for i in range(mylist_length):
do_something(mylist[i])

Nopes!
--------------------------------------
This one ?
for element in mylist:
do_something(element)
Oh Yes! This is is more like it!
--------------------------------------

"To be Pythonic is to use the Python constructs and
datastructures with clean, readable idioms.
It is Pythonic is to exploit dynamic typingfor instance,
and it's definitely not Pythonic to introducestatic-type style
verbosity into the picture where not needed. To bePythonic is
to avoid surprising experienced Python programmers with unfamiliar
ways to accomplish a task."

--------------------------------------
This is a must-try for anyone with a python interpreter around.
Invoke the python interpreter and type 'import this'.

C:\>python
Python 2.4 (#60, Nov 30 2004, 11:49:19) [MSC v.1310 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.

>>> import this
The Zen of Python, by Tim Peters

Beautiful is better than ugly.
Explicit is better than implicit.
Simple is better than complex.
Complex is better than complicated.
Flat is better than nested.
Sparse is better than dense.
Readability counts.
Special cases aren't special enough to break the rules.
Although practicality beats purity.
Errors should never pass silently.
Unless explicitly silenced.
In the face of ambiguity, refuse the temptation to guess.
There should be one-- and preferably only one --obvious way to do it.
Although that way may not be obvious at first unless you're Dutch.
Now is better than never.
Although never is often better than *right* now.
If the implementation is hard to explain, it's a bad idea.
If the implementation is easy to explain, it may be a good idea.
Namespaces are one honking great idea -- let's do more of those!
>>>
--------------------------------------
The Pythonic way of getting the Python source code:

import ftplib

f=ftplib.FTP("ftp.python.org")
f.login()
f.cwd("pub/python/2.4/")
f.retrbinary("RETR Python-2.4.tar.bz2",open('Python-2.4.tar.bz2','wb').write)
f.quit()

This code works(try it if you have a python interpreter)!
--------------------------------------

Additional info at:
Python Secret Weblog - Martijn Faassen's musings
and Python Corner-Linux For You(LFY)

Wednesday, August 10, 2005

HOWTO: Installation & Configuration of WAMP - Part 1

->WAMP:Windows Apache MySQL PHP

  • Apache Web Server Installation:
1.Get Apache Win32 Binary (MSI Installer)

2.The only info you need to fill during the installation wizard is:
xyz.com
www.xyz.com
webmaster@xyz.com
For the rest of the screens, just click the next button.

3.Apache is installed at "C:\Program Files\Apache Group\Apache2"

  • Apache Web Server Configuration:
1.Stop Apache Server by double clicking the icon in the taskbar which displays the Apache Service Monitor and then clicking Stop.

2.Open "C:\Program Files\Apache Group\Apache2\conf\httpd.conf" using notepad.

#.Change DocumentRoot to DocumentRoot to DocumentRoot "C:\Program Files\Apache Group\Apache2\htdocs"

#.Change to

3.Change DirectoryIndex index.html index.html.var to DirectoryIndex index.html index.html.var index.php

4.Save the configuration file

5.Start Apache server using the Apache Service Monitor

  • Testing Apache Web Server:
Open your Internet Explorer/Mozilla Firefox and in the address bar type, 'http://localhost'

  • PHP Installation:
1.Get PHP 4.4.0 zip package

2.Unzip the file to 'C:\PHP\php-4.4.0-Win32'

3.Copy all 'dll' files from 'C:\PHP\php-4.4.0-Win32\dlls' to 'C:\PHP\php-4.4.0-Win32' i.e where file 'php4ts.dll' is located

4.Copy all 'dll' files from 'C:\PHP\php-4.4.0-Win32\extensions' to 'C:\PHP\php-4.4.0-Win32' i.e where file 'php4ts.dll' is located

5.Copy 'php.ini-dist' file from 'C:\PHP\php-4.4.0-Win32' file to 'C:\WINDOWS' and rename it to 'php.ini'

6.Edit 'php.ini file' and set 'doc_root' as doc_root = "C:\Program Files\Apache Group\Apache2\htdocs"

7.Edit 'php.ini file'and set 'user_dir' as user_dir = "C:\PHP\php-4.4.0-Win32"

8.Edit 'php.ini file'and set 'extension_dir'as extension_dir = "C:\PHP\php-4.4.0-Win32"

  • PHP Configuration with Apache:
1. To make PHP work with Apache, edit file 'C:\Program Files\Apache Group\Apache2\conf\httpd.conf' and set the following:

AddType application/x-tar .tgz
ScriptAlias /php/ "C:\PHP\php-4.4.0-Win32\"
AddType application/x-httpd-php .php
AddType application/x-httpd-php .php3
AddType application/x-httpd-php .php4
Action application/x-httpd-php "/php/php.exe"

2.Double click to start 'C:\PHP\php-4.4.0-Win32\php.exe' to make sure PHP starts.

3.Also restart Apache

4. To test if PHP works with Apache, make a file with the following content:

echo "Hello!";
php?>

and save it as 'test.php' under web document root directory which is at 'C:\Program Files\Apache Group\Apache2\htdocs'

  • Testing PHP on Apache Web Server:
Now go to Internet Explorer and open 'http://localhost/test.php'. You should see 'Hello!' on the page.

This concludes Part 1 of the WAMP HOWTO.
Part 2 will cover MySql installation and more ...

Note: This article is an updated version of the original WAMP article By NORBU (norbu@druknet.bt)
Please leave your comments if you faced any problems or tips to improve this howto.

Saturday, August 06, 2005

Experience at the Mumbai PHP Meetup August 2005

I attended my first Mumbai PHP Meetup today, organised at the People Cafe(the Shaadi.com people)
It started with a 4-hour workshop on MySQL by Mr.Shantanu Oak, covering the basics and advanced topics and giving a demo of phpAdmin(which i learnt can be used to power the backend of your website.Its a risky deal, but you would be safe if you take your backups and its worth the effort, coz its your free MySQL server!)

After the workshop, began the meetup where the group discussed topics about database migration and large forms.The solutions being provided by the members kept in mind the business logic and usability.

The PHP meetup group is a bunch of friendly motivated individuals(mostly working professionals), with the desire to share and learn.A great community building effort here, and an ideal place to open up your mind and put forward your business ideas.

Mr.Shantanu Oak also demonstrated a financial tool that he has developed using MS-Excel as frontend and MySQL as backend, to extract stock prices from websites.Another great find was Sarovar, the Indian equivalent to Sourceforge.

Many seemed to agree as to how M$'s ASP and ASP.NET starts cracking apart when the real money starts coming in(thats when a large number of users register, say a million or so) and the only way to keept it together to get in the M$ Business Logic Server etc to save the day.
This made me feel real good(no points for guessing why!)

LAMP, but of course, stands tall as the strongest platform for such database-intensive websites e.g Shaadi.com(Just an example!)

Such active groups are an ideal way to start off open source projects, and I believe that this group will have something coming up in a few months too.

Note: The views expressed in this post are solely mine, and not of the group as a whole! :)

Thursday, August 04, 2005

Knoppix and Kanotix



Knoppix is one of the most popular Linux Live CD, where you just need to pop a cd into your cdrom drive, change the bios settings to boot from cdrom, and the Knoppix OS unpacks itself on your RAM, and runs like a dream.

I downloaded the latest Knoppix 3.9 (approx 700 mb) using a torrent, and thanks to my broadband connection, its did not take me long

Knoppix 3.9 looked and worked even better than the previous 3.6, and the KDE desktop rendered itself beautifully, leaving me speechless.
Thats when i thought, that if such is the power that Knoppix delivers off a CD, what would be the results when i install it on my hard disk...!

I decided it was time to move on from my Fedora Core 3 (PC Quest White Hope), which is complete and stable distro for developers.

Installing Knoppix onto the hard disk is no different than any linux distro, and if you have ever installed linux, no need to think twice...

Installing Knoppix from CD to Hard Disk:
1.Boot from cdrom with the knoppix cd in the cdrom drive
2.Once on the desktop, click on the Knoppix penguin(next to the K Menu on the taskbar), and select Root Shell (you will have to provide the root password)
3.On the root prompt type:
#knoppix-installer
4.Configure your installation and set the partitions using QTParted
5.Start installation...



Kanotix (HD Installation) is fast, stable and packs in more punch than Knoppix (after all this time its on the hard disk!)

Knoppix 3.9 and Kanotix are both based on Debian with Linux-Kernel 2.6 and KDE v3 and the rest of the powerful features.

This was my first shot on a debian-based system, and i wondered if i was better of in the world of rpm's, but to my surprise, updating,upgrading,installing and removing packages on Debian distros is even simpler.
#apt-get update
#apt-get upgrade
#apt-get install package_name
#apt-get remove package_name

As with Knoppix, setting my broadband connection here on Kanotix required me to choose Knoppix Penguin(taskbar)->Network/Internet->ADSL/PPPOE configuration and i was up and surfing.

All tools required for chatting, IRC,mail clients,browsers,word processors etc are packed into this very compelete distro.

Get hold of a Knoppix3.9 cd asap, and then a copy of Knoppix Hacks.

Monday, August 01, 2005

Zipping away with Python...it's in the air!


When i last posted about Python, i was still learning the ropes, but a few days at the Python Challenge and my current position at Level 7, has really improved my Python skills.
I started Level 1 with a procedural code to break into Level 2, but soon realised that it wasnt in the pythonic spirit and i wouldnt reach far.
After a quick glance at the py tutorial again, set my gears in motion and i can feel 'python powered'.
The Python Challenge, i agree, is the best way to learn python.

My partner in crime is Swapneel (at level 7 too!), coding away the py challenege in Ruby!

If uou are heading towards the land of pythons, i would recommend the py tutorial, and keep a copy of Learning Python(2nd Ed) and Programming Python handy for any in-depth topic coverage (you will need it!)

#The Python Challenge Guide:Part 1...in Python and Ruby...Comin Soon!
any volunteers for the Python Challenege in any other languages e.g. php?

#Visit Open Puppets for open-source artwork (like my python above!)!