Sunday, 28 March 2010

Attacked ‘b Terminator

So living aboard we’ve a Thetford Loo. These come with cassettes that need emptying, in our case bi-weekly. In the meantime they get fuller and fuller and smellier and smellier so ‘er-in-doors has tried any number of ways of making the boat smell nice, this has ranged from Potpourri to scented candles. So far so smelly... until this week when she got some electronic thing that sets off when it notices movement. A motion sensitive Glade thing or something.

It's not actually all that bad except that the smell just masks the other smells so it's a bit like putting perfume on a turd, that and it sets itself off every time I enter the loo (being motion activated) - sounding like some sort of piston on a mad Steampunk bio-mechanical creation dreamed up by China MiĆ©ville, or on a clunky Terminator (not like the nice one played by Summer Glau). Actually that does sound sort of bad really. It leaves me smelling perfumed turds and terrified… I think that this is one of those things that might find its way into the bin when she’s not watching!

terminatortv

Wednesday, 17 March 2010

removeParent

Nah, this isn’t about how your parents mess you up, it’s about JavaScript (or ECMAScript if you prefer). You know how GMail has that groovy thing where you can add a number of email addresses to a contact? There’s this cool bit where you can click on a [add] and another field appears below the email field. Besides the new email field there is a [remove] link which gets rid of it if’n you don’t need it. I spent ages trying to figure out how this was done and discovered that the way to do it is:

onclick="this.parentNode.parentNode.removeChild(this.parentNode);"

How cool is that?

Thursday, 11 March 2010

Beards and mapping

In regards to the previous posting about the mapping between Google and Outlook csv files I actually think that Google general approach is to clump First, Middle and Last names into one Name. I think that this is a nicer way to do it TBH but I'm open to argument one way or another...?

I found the following at some god-awful time this morning when I couldn't sleep:

Can't work out where I am yet as I often get too itchy to make it past Sea Captain, actually I'm happy with that!

The Blogger blog Google Data API Tips is tops! As is this discussion forum.

Tuesday, 9 March 2010

outlook and google csv files

google outlook
Name,
Given Name,
Additional Name,
Family Name,
Yomi Name,
Given Name Yomi,
Additional Name Yomi,
Family Name Yomi,
Name Prefix,
Name Suffix,
Initials,
Nickname,
Short Name,
Maiden Name,
Birthday,
Gender,
Location,
Billing Information,
Directory Server,
Mileage,
Occupation,
Hobby,
Sensitivity,
Priority,
Subject,
Notes,
Group Membership,
E-mail 1 - Type,
E-mail 1 - Value,
E-mail 2 - Type,
E-mail 2 - Value,
E-mail 3 - Type,
E-mail 3 - Value,
E-mail 4 - Type,
E-mail 4 - Value,
IM 1 - Type,
IM 1 - Service,
IM 1 - Value,
Phone 1 - Type,
Phone 1 - Value,
Phone 2 - Type,
Phone 2 - Value,
Phone 3 - Type,
Phone 3 - Value,
Address 1 - Type,
Address 1 - Formatted,
Address 1 - Street,
Address 1 - City,
Address 1 - PO Box,
Address 1 - Region,
Address 1 - Postal Code,
Address 1 - Country,
Address 1 - Extended Address,
Address 2 - Type,
Address 2 - Formatted,
Address 2 - Street,
Address 2 - City,
Address 2 - PO Box,
Address 2 - Region,
Address 2 - Postal Code,
Address 2 - Country,
Address 2 - Extended Address,
Organization 1 - Type,
Organization 1 - Name,
Organization 1 - Yomi Name,
Organization 1 - Title,
Organization 1 - Department,
Organization 1 - Symbol,
Organization 1 - Location,
Organization 1 - Job Description,
Website 1 - Type,
Website 1 - Value,
Website 2 - Type,
Website 2 - Value
First Name,
Middle Name,
Last Name,
Title,
Suffix,
Initials,
Web Page,
Gender,
Birthday,
Anniversary,
Location,
Language,
Internet Free Busy,
Notes,
E-mail Address,
E-mail 2 Address,
E-mail 3 Address,
Primary Phone,
Home Phone,
Home Phone 2,
Mobile Phone,
Pager,
Home Fax,
Home Address,
Home Street,
Home Street 2,
Home Street 3,
Home Address PO Box,
Home City,
Home State,
Home Postal Code,
Home Country,
Spouse,
Children,
Manager's Name,
Assistant's Name,
Referred By,
Company Main Phone,
Business Phone,
Business Phone 2,
Business Fax,
Assistant's Phone,
Company,
Job Title,
Department,
Office Location,
Organizational ID Number,
Profession,
Account,
Business Address,
Business Street,
Business Street 2,
Business Street 3,
Business Address PO Box,
Business City,
Business State,
Business Postal Code,
Business Country,
Other Phone,
Other Fax,
Other Address,
Other Street,
Other Street 2,
Other Street 3,
Other Address PO Box,
Other City,
Other State,
Other Postal Code,
Other Country,
Callback,
Car Phone,
ISDN,
Radio Phone,
TTY/TDD Phone,
Telex,
User 1,
User 2,
User 3,
User 4,
Keywords,
Mileage,
Hobby,
Billing Information,
Directory Server,
Sensitivity,
Priority,
Private,
Categories

Or:

outlook csv

First Name,
Middle Name,
Last Name,
Title,
Suffix,
Initials,
Web Page,
Gender,
Birthday,
Anniversary,
Location,
Language,
Internet Free Busy,
Notes,
E-mail Address,
E-mail 2 Address,
E-mail 3 Address,
Primary Phone,
Home Phone,
Home Phone 2,
Mobile Phone,
Pager,
Home Fax,
Home Address,
Home Street,
Home Street 2,
Home Street 3,
Home Address PO Box,
Home City,
Home State,
Home Postal Code,
Home Country,
Spouse,
Children,
Manager's Name,
Assistant's Name,
Referred By,
Company Main Phone,
Business Phone,
Business Phone 2,
Business Fax,
Assistant's Phone,
Company,
Job Title,
Department,
Office Location,
Organizational ID Number,
Profession,
Account,
Business Address,
Business Street,
Business Street 2,
Business Street 3,
Business Address PO Box,
Business City,
Business State,
Business Postal Code,
Business Country,
Other Phone,
Other Fax,
Other Address,
Other Street,
Other Street 2,
Other Street 3,
Other Address PO Box,
Other City,
Other State,
Other Postal Code,
Other Country,
Callback,
Car Phone,
ISDN,
Radio Phone,
TTY/TDD Phone,
Telex,
User 1,
User 2,
User 3,
User 4,
Keywords,
Mileage,
Hobby,
Billing Information,
Directory Server,
Sensitivity,
Priority,
Private,
Categories

google csv

Organisation of google.csv file (as of 09/03/2010):

Name,
Given Name,
Additional Name,
Family Name,
Yomi Name,
Given Name Yomi,
Additional Name Yomi,
Family Name Yomi,
Name Prefix,
Name Suffix,
Initials,
Nickname,
Short Name,
Maiden Name,
Birthday,
Gender,
Location,
Billing Information,
Directory Server,
Mileage,
Occupation,
Hobby,
Sensitivity,
Priority,
Subject,
Notes,
Group Membership,
E-mail 1 - Type,
E-mail 1 - Value,
E-mail 2 - Type,
E-mail 2 - Value,
E-mail 3 - Type,
E-mail 3 - Value,
E-mail 4 - Type,
E-mail 4 - Value,
IM 1 - Type,
IM 1 - Service,
IM 1 - Value,
Phone 1 - Type,
Phone 1 - Value,
Phone 2 - Type,
Phone 2 - Value,
Phone 3 - Type,
Phone 3 - Value,
Address 1 - Type,
Address 1 - Formatted,
Address 1 - Street,
Address 1 - City,
Address 1 - PO Box,
Address 1 - Region,
Address 1 - Postal Code,
Address 1 - Country,
Address 1 - Extended Address,
Address 2 - Type,
Address 2 - Formatted,
Address 2 - Street,
Address 2 - City,
Address 2 - PO Box,
Address 2 - Region,
Address 2 - Postal Code,
Address 2 - Country,
Address 2 - Extended Address,
Organization 1 - Type,
Organization 1 - Name,
Organization 1 - Yomi Name,
Organization 1 - Title,
Organization 1 - Department,
Organization 1 - Symbol,
Organization 1 - Location,
Organization 1 - Job Description,
Website 1 - Type,
Website 1 - Value,
Website 2 - Type,
Website 2 - Value

In case you were wondering (I surely was) what "Yomi" meant: It's not a name but a reading of the name.

I originally did a search for it and found that it was something to do with the underworld and got all excited that my friends were in the mafia or something!

array_combine

This nigh on killed me except I solved it last night while I was asleep. Now to turn it into a loop!

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>CSV12</title>
    </head>
    <body>
        <?php
          // file names.csv:
          /*
Name,Email Address,Phone Number
Bob Smith,bob@smith.com,01234567890
Martha Jones,martha@jones.com,0987643210
Joe Bloggs,joe.bloggs@gmail.com,01484522869
           */
          // get the file into an array
          $file = "names.csv";
          $fileHandle = fopen("names.csv", "r");
          // check that the array is a csv file
          if (substr(strrchr($file, '.'), 1) == "csv") {
            // count the number of lines in the file
            $lines = count(file($file));
            // display the result of the count
            echo "<p>There are $lines lines in $file</p>";
            // if there are more than 2 continue
            if ($lines > 1){
              // this is the first line as an array, we'll be using this as the
              // key to our key value array
              $firstLine = fgetcsv($fileHandle);
              // print the 1st line
              print_r($firstLine);
              // this is the second line, we'll be using this as the value to
              // out key value array
              $secondLine = fgetcsv($fileHandle);
              // print the 2nd line
              print_r($secondLine);
              // use array_combine to use values from the 1st line as keys and
              // values form out 2nd line as values to out key value array
              $firstSecond = array_combine($firstLine, $secondLine);
              // print it all out nice to check
              print_r($firstSecond);
              /*
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>CSV12</title>
    </head>
    <body>
        <p>There are 4 lines in names.csv</p>Array
(
    [0] => Name
    [1] => Email Address
    [2] => Phone Number
)
Array
(
    [0] => Bob Smith
    [1] => bob@smith.com
    [2] => 01234567890
)
Array
(
    [Name] => Bob Smith
    [Email Address] => bob@smith.com
    [Phone Number] => 01234567890
)
    </body>
</html>            
                */
            }
            // if less than 2 it's not a valid file
            else {
              echo "There are not enough lines to work with.";
            }
          }
        ?>
    </body>
</html>