Python HOWTO Push a Dict on to a List (push a hash on to an array)

One of my more popular posts is How to Push a Hash on to an Array in PERL, but how do you push a dict on to a list in Python?

Lists are one-dimensional arrays and dicts are associative arrays or hash arrays.  This means we can do the same thing we do in other languages, with syntax to match Python’s object-oriented data structures.

import pprint

# Define the list
somelist = []

# Do add some elements to the list
somelist.append({'key1':'value1', 'key2': 'value2'})
somelist.append({'key1':'value1', 'key2': 'value2'})
somelist.append({'key1':'value1', 'key2': 'value2'})

# Print it out
pp = pprint.PrettyPrinter(indent=4)
pp.pprint(somelist)

Will give you:

[   {   'key1': 'value1', 'key2': 'value2'},
{   'key1': 'value1', 'key2': 'value2'},
{   'key1': 'value1', 'key2': 'value2'}]

Did you find this post useful or have questions or comments? Please let me know!

Posted in How Tos, Programming, python, Software | Leave a comment

Integrate Shared Google Calendars With Thunderbird

NOTICE:
This blog post is outdated and no longer contains factual data. Google and Thunderbird have updated their software since this post was written.

TIP:
Look at the Thunderbird Add-On called “Provider for Google Calendar”. It takes care of all this crap for you.

Before we get started, if you have a personal calendar, Google has a quick how-to here. The Google tutorial only covers basic calendars.  This tutorial will cover both personal and shared calendars.

Google Calendar is neat and pretty much every phone and app has some sync system that works with it… except Thunderbird with the Lightning Add-on.  Actually it does, it’s just not intuitive.

NOTE: If you use the Sunbird stand-alone calendar client, the steps are essentially the same, but some menu options may be different.

What you need:

Thunderbird (2.x works, but >= 3.01 is better)

Lightning Add-on (.9x for Thunderbird 2.x, >=1.0b1 for TB 3.0.x)

A Google Calendar or access to a shared Google Calendar.

What to do:

  1. Add the Lightning Add-on to Thunderbird and fire it up.
  2. In the left column your calendars are listed.  Below them right-click and click New Calendar
  3. Select On the Network, click Next
  4. Select CalDAV
  5. Put in your calendar URL
    The URL of your calendar takes this form:
    https://www.google.com/calendar/dav/[Google Calendar ID]/events

    In the case of  a personal calendar, the ID is simply your gmail.com address such as this:
    https://www.google.com/calendar/dav/BigTurnip@gmail.com/events

    In the case of a shared calendar the ID is fugly, like this:
    https://www.google.com/calendar/dav/utqisjt6b9hoot6i9o2jk1k9qg%40group.calendar.google.com/events

    To get that string, log in to your Google calendar and go to the calendar settings.  Down by the XML, iCAL and HTML links there is something like this:
    (Calendar ID: SomeBigNastyStringOfJunk@group.calendar.google.com)

    That’s your prize!

  6. Click Next
  7. Give your calendar and name, color and an email address.  Click Next.
  8. Click Finish.
  9. If it doesn’t seem to work, close and open Thunderbird.  There is a bug that may cause new network calendars to fail to display right away.  If it still fails, check the URL from step 5.

Happy calendaring.

Did you find this post useful or have questions or comments? Please let me know!

Posted in Calendaring, Google, How Tos, iCal, lightning, Sunbird, thunderbird, WebDav | 2 Comments

How to Survive ESX Snapshot Hell

You can’t.  Once you have fail, the power of fail has you.  There is no escape, but there is hope.

If you’ve fought the fail of corrupt ESX snapshots and missing -flat.vmdk files (once the -flat.vmdk file is gone, so is your data), you’ve experienced the joy of hoping you have a backup somewhere… anywhere.

Max has a nice collection of resources to monitor snapshot removal, check progress, recover from corruption, kill a hung VM and generally give you a better tomorrow.

While there is no easy way out, you may still survive.

Did you find this post useful or have questions or comments? Please let me know!

Posted in ESX | Leave a comment