Tuesday, November 27, 2007

Weird Google Maps Route

Does someone want to explain the following route to me?



So we come from the bottom left, pass the ending point, make a scenic loop through Kristin Dr. (really nice Christmas lights?) then return to the ending point.

Tuesday, November 20, 2007

Peeve Promotion

I have a peeve that I'm considering for promotion to Pet Peeve. Picture this: I'm standing at the street corner, waiting to cross. I've pushed the button to turn on the walk signal. Someone walks up behind me, and pushes the button again.

You were three feet behind me! Did you not see me already push it? Even if you didn't, do you really think I'd stand two feet away from it and not push it? You REACHED AROUND ME TO PUSH IT.

Apparently I have a sleazy, non-button-pushing look about me that makes people glance at me and think to themselves, "He looks like the type of guy who would walk right by a button and not push it. Probably too incompetent to push a button even if he wanted to. Better push it myself. Geez, you want anything done around here..."

I'd promote it if it wasn't, in the long run, a pretty stupid peeve...

Monday, November 19, 2007

Munchkins!

At the animal shelter today we had a munchkin. This was a cat, not be confused with the card game.

Note the extremely short legs. It's like the basset hound of the cat world. It also has a shorter tail.



Saturday, November 17, 2007

Diamond Fork Hot Springs

On Child's day off (Wednesday), we took a hike to Diamond Fork Hot Springs, also known as Fifth Water, I believe. We tried once before, early this year when there was snow on the ground, but couldn't find the place. There were all sorts of conflicting directions online (on purpose, I think), and the snow made it even more difficult. As it turns out, the snow had actually been blocking the road we needed to go on, so we never even made it to the trailhead.

This time, the directions we had were spotty, but accurate. We found the place exactly 10 miles up Diamond Fork Canyon, and there was a nice, new parking lot. (We had heard rumors of no place to park, cars getting towed, etc.) The hike was a pleasant one, chilly at first, but we quickly warmed up. After we turned off the main river to a small stream that fed into it, the water started turning cloudy blue and we could smell sulphur in the air.


We were the only ones at the hot springs when we arrived, and we spent a few minutes exploring. There were several different pools that had been made, some hot, some cooler. Later, a nice man we named "Bob" came along and enjoyed the hot springs without the encumbrance of clothes, fortunately in a different pool.

Anyone else up for a trip?


Vacuum Bags

We recently got some vacuum bags. On the bags it says, "A cleaner, odor free home starts here." TM.

They trademarked that phrase. Honestly, who else would want to steal that?

Dust-Spray CEO: "Curses! They beat us to the phrase! What other motto could we possibly use?!"

Arm & Hammer Vacuum Bag CEO: "Bwahahahaha!"

Thursday, November 15, 2007

Hiking Y Mountain

Once again I summited Y Mountain, this time with two friends from work. It was a warm day, surprisingly, and I only ended up using the coat I brought for a few minutes on the peak. We were sweating most of the way up, but there was a intermittent breeze that cooled us on occasion.

The below picture is looking over Rock Canyon, at Squaw Peak.


A couple more pictures of nearby peaks, the names of which I do not know. I like how they contrast, though: one sunny and brown; the other snowy, cloudy, and gray.



The other two members of the expedition. For computer geeks, I think we did a good job. 2:15 to the summit, :15 on the peak, and 1:30 back down, for almost exactly a four hour round-trip.

Mountains, Valleys, and Hot Springs

The past half-week has been a lot of fun. Canyoneering, mountaineering, and hot-spring-eering.

We'll start with last weekend, and the canyoneering trip to Leprechaun Canyon. Leprechaun Canyon has three forks, and since we had three Taiwanese friends along who had never been canyoneering before, we decided to do the shorter, easier right fork. We went down Friday night and camped at Sandthrax campground; fortunately it was a lot dryer and less windy than the last time we had camped there. The next morning we started towards the canyon, stopping to talk to another guy who had camped nearby.

"Leprechaun Canyon, eh? Sounds fun. Just don't do the middle fork! It's pretty difficult."

"Um...we already have, last year."

"Oh."



The canyon comes out near the Sandthrax campgrounds, so you start by climbing up some sandstone hills to a plateau, then hiking across the plateau to get to the start of the canyon. We followed the same path that we had used to get to the middle fork previously, but since we were on the right side of the canyon and we were doing the right fork, we didn't have as far to hike. Not that it would have been too bad, since the weather was about perfect: cool, but sunny.



We soon dropped into the canyon. We were going a little slower than usual, since we had to show the Taiwanese students how to use a harness, how to rapell, etc. They really enjoyed it, though.





When I snapped this picture, Corin was at the front of the group while I was at the back. In between, our third friend was helping the three Taiwanese students negotiate a down-climb. I told Corin to climb in the alcove for the picture, which he did. He stayed up there while Randall and the other three passed beneath him. He was above their eye-level so they didn't see him, but they knew he had been ahead of them. Thinking he was still ahead, they started hurrying, trying to catch up to him. Finally one of them yelled his name. Now in last place behind me, Corin yelled back, "What?"

They were rather startled. It's a slot canyon, so there was no obvious way to get from the front of the group to the back. We told them it was "canyon-magic."



When Child saw the above picture, she told me it was a little weird. Looking at it, I can see how it might appear odd.



When they saw this shaft of sunlight, all three Taiwanese students instantly posed in it. It was a lot of fun having them along--even if they would instantly throw up a "V" sign every time they saw me aiming my camera at them. "No! I want a *candid* shot!"

Monday, November 12, 2007

Latest Animal Shelter Visit

I visited the animal shelter this morning, the first time in...about a month, I'd guess. At least, I saw some "Missing Animal" flyers on the bulletin board marked "10/11" in my handwriting.

It was good to see everyone again. Pat gave me some honeycomb. It's a little odd chewing a ball of wax with honey dripping from it, but it was more amusing watching one of the girls there eating it. She touched it with her tongue, then made a face and tried to pick a piece of wax from her tongue. I don't think she understood you were supposed to chew the whole thing at once, and the wax would ball together.

On the more unpleasant side, a lady called asking about a missing chihuahua. We didn't have one from her city, but the police had brought in a dead one that had gotten hit by a car in a neighboring city. She wanted to verify that it wasn't her dog, so it was my job to open the bags in the freezer to find the dog and transfer it to a bag of its own. Meh. I've had more fun.

Speaking of which, I went canyoneering over the weekend, so later this evening I'll post some pictures from that.

Monday, November 05, 2007

Favorite OCReMix Songs

  1. Super Metroid - Four Little Metroids - AmIEvil
  2. Fire Emblem - Etude for Piano in F# Minor - Kevin Stephens, trickwater
  3. Zelda 3 - Triforce Majeure - Disco Dan
  4. Xenogears - Chu Chu's Flight - Jared Hudson
  5. Mega Man 2 - Duck and Cover - Star Salzman
  6. Gunsmoke - Spaghetti Cowboy - Gux
  7. Street Fighter 2 - Ryu for Four Pianos - Reuben Kee
  8. Final Fantasy 5 - Cursed Pirates of the Sea - Protricity
  9. Donkey Kong Country 2 - Assembly Line Apparitions - Protricity
  10. Super Mario Bros. - Mario's Tropical Paradise - Dr. Fruitcake
  11. Final Fantasy 6 - Nightmare Before Kefka - zircon
  12. Ogre Battle - Zenobia's Grave - DJ K-Wix, Israfel
  13. Final Fantasy 6 - Battle Theme -Noir

Saturday, November 03, 2007

Google Analytics Google Gadget

With the NaNoWriMo gadget a success, I've been working on another gadget. This one displays your Google Analytics statistics.


So my blog doesn't really get that many hits, that's just the screenshot of the gadget in action that the Google Gadget Directory wanted.

Note how the gadget creates a new tab for each profile in your account. Also, that's what the previous couple posts about PGP and GnuPG/GPG encryption were all about--I'm encrypting the Analytics username/password.

I barely published it, so it won't show up in the Google Gadget directory for a few days, assuming Google doesn't have a problem with it.

Encrypting to PGP / GnuPG / GPG using Javascript

In a previous post I wrote about receiving PGP-encrypted data and using GnuPG (GPG) from a PHP script to decrypt it. In this post I'm going to show the client-side, a webpage (or in my case, a Google Gadget) that uses Javascript to PGP-encrypt sensitive information and send it to a server. Yes, you could use SSL, but the destination I was sending it to didn't have an SSL certificate.

To do the Javascript encryption, I modified some code from Herbert Hanewinkel, and I'll post the necessary Javascript include files, which he makes available.
<!--Create a holding variable that will be used later -->
<input type="hidden" name="keyid" id="keyid" value="">

<!-- Drop your public key into an invisible textarea. It's called public for a reason; there's no danger in letting people see it. -->

<textarea id="public_key" name="public_key" style="display:none;">
-----BEGIN PGP PUBLIC KEY BLOCK-----
Version: GnuPG v1.4.2 (GNU/Linux)

mQGiBEcrXY0RBACao9CBQL/BggPP5HcnWXLV/O5MEYhAAg3kl6l6Xu3CVKtGlw5d
P8CJSZuPZSrcQs+GI4PAkS1AH4f7Ex7phwUIMak6ufv5wX5iWU4JwxDCuvYOmlyz
l4iMsH5uJSI7QvQ7zl9QR3KC/qONZ5EWYiW7Gu/1yJ6JuykM2vumhi9CMwCg9KZy
vh5HDynAEf+8PbeD9z7aRcED/1x2muLD1gt5fSBSyyCjcvYtQ8od+UT/GwVpCMRu
Eq+t0uBrrecKmQ9GzkXhnP7KXLe7NDgTZwxAqTjMAkf+v/v5HOnBClOdzoS6EAFO
JotlB+SJiqXoClvhfHRJKhJwyMfKlmGUAWr9itaWQbdLXo5BGqDyaoXjw5jyQ4ch
yf5PA/wMjqDcUux8eOGivU63CGLHriHRMT2QtPSU73zDf3X8+X9EPZxLPZ7SCFTO
YCeyNBe5PvMsk0n8ZO/Gnezxh345NtJ9LXxk+65svGaxnTPQksdzOJAzE8KjlHDF
ZNGl52J6R/TPOxwBSt42ackTfn50IJJC/0kSvHRKck+Ll4MR4bQ7QmVuamFtaW4g
SGFyZGluIChHb29nbGUgQW5hbHl0aWNzKSA8ZXZpbG92ZXJsb3JkQGdtYWlsLmNv
bT6IYAQTEQIAIAUCRytdjQIbAwYLCQgHAwIEFQIIAwQWAgMBAh4BAheAAAoJEJ3f
PyIusymjPNcAnAqILzNRYnpk2xD0ruE0OJyGZ4OoAJoDSV9G/rVmNVVjTb2PMwMm
v49UgbkBDQRHK12NEAQAsZW2iev4FbLAaYZJ073DP1F+RuzNaa+KplQ4pHnoci2l
7JqTD+iVlODdpWbzEYQursq5L2v7xdKRN56aga0AV4j0JCXouc5atYsGCY6OY7PT
OGWMB21y8K8I9LM/9h/YZblc+7pChqeC9dJ1pL8G9dhNh02cMyEwp8BuTsx39IMA
AwUD/3+Ei+zt/rWFFtHMMByvqyRnqk8U3QWiTgN8DhY+9lol7w2OCgKjFaVZUqzt
pQnAXO665er49suqrx8riZ6Lan0YO6swxjQ8C7BUj9/fMDAlDBfpOspWDMzYu/9e
fOAqk3z8PJlPIUlMxIwy6a1wuoSt2ko3wmP2VH6Mv+0dltrriEkEGBECAAkFAkcr
XY0CGwwACgkQnd8/Ii6zKaNB5ACg33r2gxWkiZidQLZRXg5sidz7KAoAn3ajmkuL
vO273vANfSgRe9MrGJAI
=aiWr
-----END PGP PUBLIC KEY BLOCK-----

</textarea>

<!-- Include some required files. They are hyperlinked! Download them now! -->
<script language="Javascript" src="rsa.js" type="text/javascript"> </script>
<script language="Javascript" src="aes-enc.js" type="text/javascript"> </script>
<script language="Javascript" src="sha1.js" type="text/javascript"> </script>
<script language="Javascript" src="base64.js" type="text/javascript"> </script>
<script language="Javascript" src="mouse.js" type="text/javascript"> </script>
<script language="Javascript" src="PGencode.js" type="text/javascript"> </script>
<script language="Javascript" src="PGpubkey.js" type="text/javascript"> </script>

<script language="Javascript">

var keytyp = -1;
var keyid = '';
var pubkey = '';

function getkey()
{
    var pu = new getPublicKey( document.getElementById( "public_key" ).value );
    if(pu.vers == -1) return;

    document.getElementById("keyid").value = pu.keyid;

    /* I didn't end up needing this variable in the encrypt function, since I already knew the key type was Elgamal */
    /* document.getElementById( "pktype" ).value = pu.type; */

    pubkey = pu.pkey.replace(/\n/g,'');
}

/* Pass in the data to encrypt */
function encrypt(text)
{
    keyid='0000000000000000';
    if( document.getElementById( "keyid" ).value.length )
        keyid=document.getElementById( "keyid" ).value;

    if(keyid.length != 16)
    {
        alert('Invalid Key Id');
        return;
    }

    /* Since I already knew my key type was Elgamal, I didn't need this block of code. I just set "keytype=1" below. */
    /*
    keytyp = -1;
    if( document.getElementById( "pktype" ).value == 'ELGAMAL')
        keytyp = 1;
    else if( document.getElementById( "pktype" ).value == 'RSA')
        keytyp = 0;

    if(keytyp == -1)
    {
        alert('Unsupported Key Type');
        return;
    }
    */
    keytyp = 1;

    return doEncrypt(keyid, keytyp, pubkey, text);
}

var encrypted_data = encrypt("sensitive data here!");
alert(encrypted_data);

/*
Special Note: I was forced to send the data through a URL (i.e. a GET rather than a POST). This forced me to encode the data prior to attaching to URL. Contains "+", so we must use "encodeURIComponent()" instead of "escape()". (See below for how the server-side PHP script will handle the received data.) */
encrypted_data = encodeURIComponent(encrypted_data);

/* Do something with the data. */
window.location = "http://www.test.com/index.php?encrypted_data="+encrypted_data;
</script>

Here's what happens on the server side, in the PHP script that receives it. (In the previous blog post about the PHP side I just pulled the encrypted data from a file, but here's what I was really doing.)
<?php
/* Reverse the effects of the Javascript "encodeURIComponent" */
$encrypted_data = rawurldecode( $_GET['encrypted_data'] );

/* From here, jump right into the PHP script outlined in the previous post, commenting out the line where you're pulling the encrypted data from a file, since you just got it from the GET request. */
?>

High-Toned and Fancy To-Do

Last night Child and I received some last-minute invitations to an dinner event that featured the First Lady of Guatemala, Wendy de Berger, as a speaker and Michael Ballam playing the piano and singing as the entertainment. It was an event held by Enterprise Mentors International, which gives microloans to people in developing countries.

One of the other people at our table told a story about a trip he had gone on to Guatemala to help build an orphanage. The government had given them the land for the orphanage, a vacant lot that was strewn with broken and rusted-out cars. When they started clearing out the cars in preparation for building the orphanage, they found out that they ended up displacing thirty children who had been living in the cars! Those thirty kids were the first ones into the new orphanage when it was built, however, so I guess it turned out okay. Really makes you think, though.

Our poor waitress was having a difficult time. She was very pleasant when we first arrived, complimenting Child's grandma on her dress, but later that evening Child noticed that she looked like she had been crying. Child asked her what was wrong--apparently she had hit someone in the head with a pitcher of water. The people attending this weren't your average Joes (except Child and I), they were people like Michael Ballam, the Guatemalan First Lady's entourage, general authorities from the Church of Jesus Christ, the guy who does Music and the Spoken Word for the Mormon Tabernacle Choir, and high-powered businessmen from around the country who help with the third-world mentoring. I could picture the MC getting up, "Um, we regret to announce that Michael Ballam is no longer performing...he got hit in the head with a water pitcher..." The more lady was probably scared to death that she'd get fired or something.

At the end of the evening, one person at each table won the centerpiece, a beautiful vase of flowers. Good thing I've always dreamed of winning a vase of flowers, because I ended up getting ours! Anyway, I gave it to Child.

Friday, November 02, 2007

Setting up GnuPG (GPG) for use with PHP

Step 1 (failed):
$ pecl install gnupg

downloading gnupg-1.3.1.tar ...
Starting to download gnupg-1.3.1.tar (-1 bytes)
.............done: 124,416 bytes
5 source files, building
running: phpize
Configuring for:
PHP Api Version: 20020918
Zend Module Api No: 20020429
Zend Extension Api No: 20050606
`phpize' failed

Step 2 (success). Some information drawn from http://www.php.net/manual/en/install.pecl.php, a basic tutorial on how to install PECL extensions.
$ cd /usr/lib64/php/extensions

(This is where my PHP extensions [files with .so extension] are stored)
$ pecl download gnupg
$ tar -zxvf gnupg-1.3.1.tgz
$ cd gnupg-1.3.1/
$ phpize
$ ./configure
$ make
$ make install

"gnupg.so" now appears in /usr/lib64/php/extensions
Now I need to install the extension in the php.ini file
$ whereis php.ini

/etc/php.ini
$ vi /etc/php.ini

Find the list of extensions in php.ini, in my case headed by "[extension section]". Add "extension=gnupg.so" to the end of the list, save and exit.
Now I need to restart apache so the extension takes effect.
$ apache2ctl graceful

Now do some PHP coding. Assumes you have GnuPG (gpg) installed, and have set up your key pair ("gpg --gen-key"). Some of these steps might be unnecessary, but after hours of fiddling around, I'm not about to walk through it again and find the essential ones.
/* Change this to your own path */
putenv("GNUPGHOME=/home/bch36/.gnupg/");

$encrypted_data = file_get_contents("encrypted.gpg");

$res = gnupg_init();

gnupg_seterrormode($res,GNUPG_ERROR_WARNING);

/* Change this to your own fingerprint. Find your fingerprint by running "gpg --fingerprint" from the commandline. Comment this out when everything works. */
print_r(gnupg_keyinfo($res,"ASDF1234QWER5678ZXCV9012ASDF3456QWER7890"));

/* Put your own fingerprint and passphrase here. Also, this function will fail unless you see Important Note #1 below */
gnupg_adddecryptkey($res, "ASDF1234QWER5678ZXCV9012ASDF3456QWER7890", "put your secret passphrase here");

/* You'll want to comment this out when everything is working */
echo gnupg_geterror($res);

/* This function will fail unless you see Important Note #2 below */
$plain = gnupg_decrypt($res, $encrypted_data);

Important Notes:
1. To get gnupg_keyinfo() to work, you'll need to let your webserver have some access to your keyring. Do the following (replace "www" with the group that your own webserver runs under):
> cd /home/bch36/.gnupg
> chown :www pubring.gpg trustdb.gpg
> chmod 660 pubring.gpg trustdb.gpg

2. To get gnupg_decrypt() to work, you'll need to grant more access. Note that the webserver will now have access to your secret key! However, if you don't do the following, the gnupg_decrypt() function will fail and you'll get the following warning when printing out gnupg_geterror(): "Warning: gnupg_adddecryptkey() [function.gnupg-adddecryptkey]: get_key failed in ..."
> chown :www secring.gpg
> chmod 660 secring.gpg

As a possible point of interest, I'm only doing decryption because I want a remote webpage to use Javascript to PGP encrypt data and send it to my PHP file, which can then decrypt it. I guess it's a workaround for not having SSL. I'll try to post an entry about the client-side next (Javascript PGP).