Wednesday, September 22, 2010

Python : Create path or directories, if not exist

I came across to this question very often, that how to create a directory structure, if I know the exact path of file or directory hierarchy. That is not difficult but very time consuming if you don't know where to find the resources. Let go to code we need,

def assure_path_exists(path):
        dir = os.path.dirname(path)
        if not os.path.exists(dir):
                os.makedirs(dir)
first line define python function/module assure_path_exists, which take one argument "path" of file or directory.
second line, ensure path contain directory only. it strips filename, if there is any.
third line, checks for whether this path (pointed by dir), exists or not
forth line, if path pointed by dir not exists, we create that path through os.makedirs

Done!!!

Saturday, September 11, 2010

Within instant Google forgot basics of its embraced AJAX

I love Google, that is most of the developers says. Their day starts with Googling. Google defined standards of search engine industry. They embraced AJAX technology with Gmail, Google Docs etc.  They define standards of how to use AJAX effectively and efficiently. But, unfortunately today I found a usage of improper usage of AJAX in their webpage and that webpage is nothing but their Home page. Firstly, I didn't believe my eyes, I redo it 4-5 times with different browsers then I believed it. They missed handling back button. They didn't clear the result if back button reaches to their home page.

Here are the steps to reproduce it ( if after this post, they still didn't correct it).

1. Go to Google.com, and type whatever query you have and press enter. In my case, I typed "Blender" as I am learning 3D now a days



2. You reach result page, everything remain normal

3. Press back button of your browser. OOPS!!! I reached google home page with background contains previous result.

After this, I thought might be this is problem with Chromium alone as it is nightly build of Chromium. So, I tried it in Firefox also. Thats test is also turn positive thats why I writing this ;)

1.


2.


3.


Note: It is big because it is Google's Home page. Otherwise, who cares.
I feel sorry for Google guys as they have to come and fix this and its weekend already. sorry guys.

Thursday, January 14, 2010

The speech by Steve Jobs at Standford's in 2005 : Highly Motivational

This speech is highly motivational to me, when I first watched it in 2007. May be this could help you also. May be you need some information about Steve Jobs to understand this video.
Some takes for me from the speech,
  • Never stop on hurdles, it leads us to match dots when we look back to our life.
  • Love your work, and
  • Send positive energy to others and it also returned back to you.



Wednesday, January 13, 2010

Planned Security attack on Google and other companies, May lead to cease Google's China operation

Yesterday, Google on its blog mentioned that it faced security attack in mid-December. And, some other organizations from different fields were targeted. Google tracked these attackers from China seeking gmail account information of some Human Right Activists of China. As blog mentioned These attacks were not as successful as it is intended to be. Google thinks that further restrict free speech on web for Chinese people. So, Now they will talk to Chinese officials to see how Google.cn can provide uncensored content to the people of China without violating Chinese laws. If there is no way out then Google may cease its Chinese operation Google.cn .

Some comments on Techcrunch says that Google is very far behind some Chinese search site Baidu.com. on Alexa's Top sites, Baidu.com comes 8th and Google.cn comes 15th in the list. Baidu.com comes above Twitter and Myspace and many more. So, that lead to one another conclusion that Google may be tricking readers to get some extra market in China.

Whatever, may be the cause now Google cannot take a back from what they had done. If they
not backed what they write then it will definitely tarnish its image of good boy. But, if they not backed out and stop china operations that will hurt because China is very large market to any of the company and specially for Google.

Only, time will tell what is the behind the scene story.