Sunday, September 05, 2010

Removing recurring events from Google calendar.

I have added remember the milk calendar into my google calender then the mistake was happened. All events in remember the milk calendar were copied to google calendar. After sometime I got tired with remember the milk and I deleted it. Unfortunately, remember the milk has done the damage for me. It has created an event for everyday, yes for everyday. I assumed that RTM might create an event for the days I had event on their calender, but it has created huge amount of events. So now I want to go through everyday to delete them.

Deleting all of events manually is impossible, and for some reason I did not have the ease of using "delete all events of this type" option, therefore only option I am left with using google calendar api for this task. I have not use calendar api before therefore I have to study before using it. While I am doing that thought to document the process so that I can publish it as a blog post.

http://code.google.com/apis/calendar/data/1.0/developers_guide_python.html


I used Google Calendar API from above link and checked out source from mercurial. All I used is calendarExample.py and modified it to do my task.


What I wanted to do is search for “Tasks” (the events RTM has created called tasks) in whole calendar and delete all of those items, thus I created a search query which search “Tasks” and then delete all items in that query.


Please note that following code is only a modification of


http://code.google.com/p/gdata-python-client/source/browse/samples/calendar/calendarExample.py



Since google is returning only 24 events at a time, I had to use infinite loop to delete all events. Date range from 2009-09-05 to 2050-09-10 were used for the search and all events in this range were deleted in few minutes. Code shown in red is important whereas code shown in blue is mainly for informative purposes only.

Python Code Snippet.


def FullTextQuery(email, password, text_query='Tennis'):

cal = gdata.calendar.service.CalendarService()

cal.email = email

cal.password = password

cal.source = 'Google-Calendar_Python_Sample-1.0'

cal.ProgrammaticLogin()


print 'Full text query for events on Primary Calendar: \'%s\'' % ( text_query,)

query = gdata.calendar.service.CalendarEventQuery('default', 'private', 'full', text_query)


# This is the range that we search.

query.start_min = '2009-09-05'

query.start_max = '2050-09-10'


feed = cal.CalendarQuery(query)

for i, an_event in enumerate(feed.entry):

print '\t%s. %s' % (i, an_event.title.text,)

print '\t\t%s. %s' % (i, an_event.content.text,)

for a_when in an_event.when:

print '\t\tStart time: %s' % (a_when.start_time,)

print '\t\tEnd time: %s' % (a_when.end_time,)

if an_event:

cal.DeleteEvent(an_event.GetEditLink().href)



def main():

while(1):

print "deleteing events"


# Give your email and password here.

FullTextQuery(email, password, "Tasks")

time.sleep(5)


if __name__ == '__main__':

main()

Wednesday, August 18, 2010

Monday, August 02, 2010

Placing Ubuntu Close Button Right Side of the Window.

1. Alt + F2

       This will brings up "run" window

2. gconf-editor

       Configuration Editor will be showed up. 

3. apps -> metacity -> general
      Expand "apps" menu and then expand "metacity" menu after that select "general" directory.

4. button_layout

      Find "button_layout" under "general" directory.

5. menu:minimize,maximize,close

      Replace current string of "button_layout" with menu:minimize,maximize,close" (without quotes).