My First Post      My Facebook Profile      My MeOnShow Profile      W3LC Facebook Page      Learners Consortium Group      Job Portal      Shopping @Yeyhi.com

Pages










Saturday, November 24, 2012

'How To Tame Python' - Guidebook To Python Language by Anwar Jamal

Hi All,
I am glad to announce that 'How To Tame Python' guidebook is now complete and is available for all to view and download. It has been uploaded to Slideshare and Scribd web portals.

'How To Tame Python' is a Guidebook to programming Language Python. In a very simple and funny language, the author, Anwar Jamal Faiz, has tried to cover topics on Learning Identifiers, Data types, Decisions, Looping, Functions, Modules, and File Handling in Python.

How To Tame Python

Or view it on Slideshare Portal on :

Python - Tuple Vs List - Difference/ Comparison


Tuples and Lists have always attracted the learners of Python. And, to the most of employers, the difference between them still maintains favoritism. Searching over the Internet gives you the distinction between them, but to many the language used all over seems to not help much. And worse part is that, not all the differences have ever been published at one place. And the worst of all, sometimes technical slangs have been used, with no direct meaning or examples to make it clear.

Let me start with a very brief introduction to what these Datatypes are about. Following description of List and Tuple is an excerpt from my "How To Tame Python" guidebook.

List is one of the most helpful and versatile data type available in Python. A list contains several items separated by commas. The items are enclosed within square brackets ([]). The list comes with built in functions which can be used to add, delete, edit contents in a list. Any subset of a list returned is also a list. Also note that like strings here also the Index starts from 0 and goes to the Length of the list minus 1.
A typical list can be as simple as :
list=[2,4,8,16,32], or
list2=['how','to','tame','python'], 
Or it can be a mix of datatypes for eg.
list3=[1,'january',2.23,-3]

Tuple again is a data type that is similar to the list. However, elements of a tuple are enclosed within parentheses. [Remember elements in a list were enclosed in square paranthesis]. It is important to mention that a Tuple is a read-only list. Any subset of a tuple returned is also a tuple. Also note that like strings, and list, here also the Index starts from 0 and goes to the Length of the tuple minus 1.
Eg. tup1=(12,'leo',23.45)


After completing my "How To Tame Python" guidebook, addressing this issue was the most immediate task. I am thankful to the memories of my sweetheart, while she was away, that kept me awake till night and motivate me in finding out the real differences. I actually programmed and validated each statement I said below. There are differences in Tuples and a List. I have discussed them in following classes of distinctions. So, here comes the difference between Tuples and List in Python.

Class A:  Usage difference due to Runtime difference 
Tuples are Immutable. 'tuple' object does not support item assignment
Because they are immutable, a Tuple can be used as a Key in a Dictionary.
There may be a slight performance improvement in Tuple.
For eg.
Allocation in a book can be a combination of a page number and line number, eg (x,y)
Similarly, your gps coordinates can be (x,y)
It is a tuple because these things are immutable. As soon as either x or y changes, the meaning itself changes.
And now, some short notes can be added to these locations using a dictionary.

Class B:  Difference in what they mean due to Semantic difference
Tuples are hetrogenous data structure, while lists are homogenous. There is a semantic difference too. Tuples have structure, while lists have order. Tuples (generally) are sequences of different kinds of stuff, and you deal with the tuple as a coherent unit. But, Lists (generally) are sequences of the same kind of stuff, and you deal with the items individually.
Eg 1.
Consider the following two data structures:
>>> time.localtime()
(2012, 3, 7, 11, 45, 38, 2, 33, 0)
>>> range(10)
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
The first one, a tuple, is a sequence in which position has semantic value. The first position is always a year. This tuple functions as a lightweight record or struct. The second one, a list, is a sequence where we may care about order, but where the individual values are functionally equivalent.
Eg. 2
Consider example of the simultaneous use of both types. If you look the Python Database API fetchmany() method, you will see that it returns the result of any query as a "List of Tuples". The result set as a whole is a list, because rows are functionally equivalent (homogeneous). There is only a order, and no importance which row is what. But the individual rows are tuples, because rows are coherent, record-like groupings of (heterogeneous) column data. We know that first element means what and second elements mean what, and so on.


Class 3:  Usage as Enum or Stuct because of namedtuple() method

This difference becomes more visible as soon as you read about namedtuple in Python
Named tuples assign meaning to each position in a tuple and allow for more readable, self-documenting code. They can be used wherever regular tuples are used, and they add the ability to access fields by name instead of position index. Named tuples are especially useful for assigning field names to result tuples.
Syntax:
collections.namedtuple(typename, field_names, verbose=False, rename=False)
It Returns a new tuple subclass named typename. The new subclass is used to create tuple-like objects that have fields accessible by attribute lookup as well as being indexable and iterable.
Eg.
EmployeeDetail = namedtuple('EmployeeDetail', 'id, name, age, job, department, paygrade,address')


I have realized these differences after years of coding and using Python. Many of the differences, were always in sub-conscious mind and never came out. It was only when I was completing my "How To Tame Python" guidebook, that the idea of documenting the differences came to my mind. And, after this has been done, I was more than glad to find out that this is the best article over this subject. I have been informed by my friends and readers across the globe that they have found this article very helpful in their projects, understanding the Python, and their Job interviews.

You can also send me your feedbacks on this blog, or to my personal email id: Toughjamy@Yahoo.com
--Mohd Anwar Jamal Faiz

Tuesday, October 9, 2012

Image/Photo Editor for Samsung Bada OS


Bada, meaning "ocean" or "sea" in Korean, an operating system for mobile devices such as smartphones and tablet computers. Owned and developed by Samsung Electronics. Samsung is possibly considering releasing the source code under an open-source license. This may increase its usage.

Till now all Bada-powered devices are branded under the Wave name. Readers please do make a note of another fact also that Samsung's Android-powered devices are branded under the name Galaxy. ( Worth to mention, I use Samsung Galaxy Note and I just love it!! I have used Nokia E Series and Blackberry, but this Galaxy note is just superb. )

It has been found that Image editors are a big problem with Bada OS phones. Seems like it is not actually bundled with the package. There is actually a project called "IMAGEEDITOR" in Samsung Bada developers forum. See Samsung Image Editor Project. But it is not yet complete.

So, here comes the list of some softwares you can use at this time:

A. Franklin's Instant Photo Effects 2.0
Size:82.2 MB | License:Trial version
This software is  the fastest and easiest way to apply some nice effects to your photos.

B. Amazing Photo Editor 7.9.2
Size:2.7 MB | License:Trial version
A powerful and easy-to-use image editor used for image processing. Offers 33 different effects.

C. Photo Editor Software 3.32
Size:983.46Kb | License:Freeware

D. ColorTorch 
Great editing with ColorTorch. It is not a full photo-editing app: it only provides a partial colorizing effect. But even so it does its job so well. UI is very easy. Size is just 0.8 MB

E. Splendid Editor http://www.splendideffects.com/
The most common and efficient image editor for Bada OS 2.0. Has over 30 photo filters and edits image upto 3.2 mega pixels.
Watch http://www.youtube.com/watch?v=6VxSZUnzauE
Watch http://www.youtube.com/user/SplendidEffects

F. You can also download free image editor from:
http://badahub.com/2012/02/splendid-effects-free-from-today.html


Please notice that I have seen the usage of these softwares. But I am not the maker of these softwares nor the quality analyst. Please download from genuine internet websites and use with your risk. Cheers!! And do write your feedback of these softwares. And hope Samsung comes with its own editor soon.

Mohd Anwar Jamal Faiz

Wednesday, September 12, 2012

Color Coding Scheme in Remote Distibuted Systems


I always have to work hard to remember which server is live, which is for production, which is for development, etc. It’s also difficult to tell at a glance which remote server I’m connected to over remote desktop. Typically I change the wallpaper color to red for production servers, green for development servers and yellow for staging servers. But that doesn’t solve the second problem of immediately knowing which server I’m connected to. I needed my other teammates to know that this is a crucial machine and they should not use it.

The typical Color Codes I use:
Red:    Crucial Machine. Presently in Use, no one should Touch it.
Green: Free to go. Idle machine. Anyone can use.
Blue:    Free. But requires permission before last user, in case there are some logs he or she may need to take backup

Method 1: graphical UI method at time of connection
Though this seems to be a good approach, but I still recommend doing the colored background with the wallpaper since not all connecting clients will have desktop wallpaper enabled.  Since if background color enabled, it will be shown to user connecting to machine. Image how to chage….
There is no special need for rdb client to have certain option while making a connection. Also since it slows: Refer this small post:- Disable the remote host desktop wallpaper
http://new-it-discussions.blogspot.in/2012/09/disable-remote-host-desktop-wallpaper.html



Method 2: Setting using Default.rdp file to control parameters and behavior in remote desktop rdp/mstsc connections
When you use the Remote Desktop Protocol (RDP) to connect to a remote computer, the Default.rdp file is created on the client computer. This article discusses the connection settings that are stored in the Default.rdp file. For details view [Anwar Jamal Faiz Web Post] What is default.rdp file in remote desktop


Method 3: Using Group policy editor in Remote Desktop Connections [gpedit.exe]
First off, your RDP client (Remote Desktop Connection client in the case of Windows XP) has to have remote wallpaper enabled. On XP, open the saved Remote Desktop Connection file to the server you are connecting and click the Experience tab. Place a check in the option “Desktop background”. This allows the client to see enabled desktop wallpapers.
Second, connect to the remote Win2k3 server and from a Run box, type “mmc” and go to to open group policy editor
If you don’t know just simply type on run “gpedit.msc”
Start->Run->gpedit.msc [then press Enter]
Now browse to Local Computer Policy -> Computer Configuration -> Administrative Templates -> Windows Components -> Terminal Services. From the list, modify “Always show desktop on connection” to “Enabled” and “Enforce Removal of Remote Desktop Wallpaper” to “Disabled”. Now close the MMC clicking “No” about saving the settings.
Log out of your remote desktop connection and login again, making sure your RDP client has desktop wallpaper enabled. Now you should be able to rt-click the desktop and apply wallpaper normally. I still recommend doing the colored background with the wallpaper since not all connecting clients will have desktop wallpaper enabled.


This policy setting determines whether the desktop is always displayed after a client connects to a remote computer or an initial program can run. It can be used to require that the desktop be displayed after a client connects to a remote computer, even if an initial program is already specified in the default user profile, Remote Desktop Connection, Terminal Services Client, or through Group Policy.

If you enable this policy setting, the desktop is always displayed when a client connects to a remote computer. This policy setting overrides any initial program policy settings. If you disable or do not configure this policy setting, an initial program can be specified that runs on the remote computer after the client connects to the remote computer. If an initial program is not specified, the desktop is always displayed on the remote computer after the client connects to the remote computer.
Note: If this policy setting is enabled, then the "Start a program on connection" policy setting is ignored.

I guess this was my final  post on the topic. I wont write more on the topic. :) There is no need, its complete :)

Related posts:

--Mohd Anwar Jamal Faiz
Toughjamy@yahoo.com

Disable the remote host desktop wallpaper using Group Policy Settings *

A desktop wallpaper is an image or photograph that is displayed as the background on a computer desktop. It is typically used to personalize the appearance of a computer, and can be changed to reflect a user's preferences or interests. Desktop wallpapers can be found in many different styles and themes, including landscapes, nature scenes, abstract designs, and photographs of famous people, or famous quotes and slogans. They can be set as a static image or as a slideshow that changes images at regular intervals.

Users can speed up the rendering of the remote PC desktop display, particularly over slow data links, by disabling the display of the remote PC desktop wallpaper on the client PC's. This can be configured on the Remote Desktop host PC using the Group Policy Editor.

Windows Group Policy Settings is a feature in the Windows operating system that allows administrators to centrally manage and configure settings for multiple computers in a network. It allows administrators to apply policies and settings to specific groups of users or computers, such as disabling certain features, controlling access to certain applications, and setting security and privacy settings. These policies can be applied to both local and domain-joined computers. It is a powerful tool for managing and securing a network of Windows computers.



Also see the Using Group Policy with Remote Desktop section of the Resource Kit. Run gpedit.msc and navigate to the Local Computer Policy | Computer Configuration | Administrative Templates | Windows Components | Terminal Services policies. Double click on the Enforce Removal of Remote Desktop Wallpaper policy and select Enable. Click OK to save the new configuration. Click on File | Exit to exit the Group Policy Editor.


This post can be used in conjunction with my other post:
http://new-it-discussions.blogspot.in/2012/09/color-coding-scheme-in-remote.html



--Mohd Anwar jamal Faiz