Load browser cookies from selenium

import pickle
import selenium.webdriver 

driver = selenium.webdriver.Firefox()
driver.get("http://www.google.com")
pickle.dump( driver.get_cookies() , open("cookies.pkl","wb"))

and later to add them back:

import pickle
import selenium.webdriver 

driver = selenium.webdriver.Firefox()
driver.get("http://www.google.com")
cookies = pickle.load(open("cookies.pkl", "rb"))
for cookie in cookies:
    driver.add_cookie(cookie)

Met a nice guy at bus stop. inspired with his positive attitude

Today I was waiting for my bus at bus stop with my colleague…i get irrerated after waiting for bus 15 minutes. we observed one guy was trying to catch 222A bus. he was handicaped and the bus moved fast . he did not catch the bus. just we went to colose to him and asked him where do you want to go? he said lingam palli. so i asked him from how much time ur waiting for bus. he said 40 minutes. next i asked do not you get angry on bus’s and drivers  and poor rtc service they are not stoping the bus na . he just smiled and it was common to me.. i am very much impressed of his positive attitude.

Basic photo uploading app – Django 1.4

django basic upload photo

Thai Tran

There are chances that you have to upload an image and perform some image processing within the admin side of Django. Here is a small example to do that

I. Create project and create app:

II. Configure resource folder in django project ‘s settings:


III. Models:
We need a field to upload image from your hard drive. ImageField of django requires a callable function for upload_to attribute. This image will be saved on the server, then, we will use PIL to resize this image into 3 other images (medium size, small size, and thumbnail). This can be achieved by overriding the save function of the model. We also need a function to show the thumbnail on the list page of the admin page, a clean-up function to delete all the images if we delete that record.

IV. Showing the small image on the admin update form:
Also, we need to…

View original post 128 more words

My post

This is a wonderful blog post about XML-RPC. xyz
This is a wonderful blog post about XML-RPC. xyz

Difference Between Dictionary items and iteritems

Now i want to print key,value of a dictionary

sample dictionary test_dictionary={1:’one’,2:’two’,3:’three’}

#Using items

for k,v in test_dictionary.items():

     print k,v

output:1,one

           2:two

 

#Using iteritems

for k,v in test_dictionary.iteritems():

     print k,v

output:1,one

           2:two

            3:three

 

both ways we can print the values but both functional-ties are different let me explain with example

if you print s.items() you will get [(1,’one’),(2,’two’),(3,’three’)]

so s.items will give in list of tuples

if you print s.iteritems() it will return dictionary object so if you want print the values

use s.iteritems().next() you will get only (1,’one’) next time (2,’two’)

iteritems is a iterator function