Three till Seven

Archive for March, 2006

1 Mar 06 soup and heat

Poor Ashlee’s sick. Jess and I were going to go to dinner tonight and invited her along but she just shook her head, looking very morose. I thought maybe something had happened, but she apparently just feels like crap. Well, Jess and I cancelled our plans (we were just going to eat in the cafeteria anyway) and took a Kroger run to get soup, Vick’s, water, Sprite, sherbet, and a variety of other groceries both for Ashlee and ourselves. Upon getting back to the dorm, I was given soup duty (with a pan and a stove and evathang!–Ashlee dislikes microwave-made soup for some reason) while Jess washed a bowl and spoon.

After getting Ashlee started on her soup, Jess and I ate dinner in the room while I talked with Todd online. Since then, I’ve watched American Idol and talked online. Trin was on! I never see her anymore since she’s n hours ahead of me, over in Germany. I chatted with Tony for a bit, too; there’s another guy I don’t see anymore, though that’s mostly because I’m not taking any classes this semester so I don’t have any with him.

It’s freaking hot in this dorm. Today saw a sudden spike in temperature, enough so that I was a little warm in the skirt I wore to work. Of course the heat in the building is still on and they probably won’t switch the AC back for a while. Despite the discomfort while indoors, I would rather it stay warm so Jess and I can get to a park. We were going to go today after dinner, until Ashlee’s sickness was noticed, because Jess felt like swinging and it was such a pretty day. I went to the grocery in my new Portishead t-shirt, even.

2 Mar 06 scarves and murder

Note: This was a dream of mine. I have this warning here because some visitors have thought my life had just gone to pot, when really they were only reading one of my crazy dreams. :)

I was in an old barn with Jessica and some other people, though I don’t know who they were because I just paid attention to Jess. I had a scarf with me that was made of dried grass, but the grass had dried too much and so the scarf had shrunk. I was trying to stretch it back out but ended up just tearing it into pieces. There were bits of bamboo along with the grass.

I left the barn to get something to use to fix my scarf, but when I came back, everyone was gone and the place was dark. I had a bad feeling about it, and then I noticed a small, white fox with glowing white eyes in the back corner. He kept running up to attack me, but I kicked him back each time, kind of lazily. I looked around for something else to do.

The dream shifted and I was in someone’s house, standing at the top of a flight of stairs leading down into a hallway. It was late evening and light from the setting sun was coming in from a window behind me in a bedroom. There was an older man, maybe in his forties, that was standing behind me. He had sandy blond hair and looked similar to Robert Redford. I think I was his mistress, or maybe just the babysitter for his kids, but we had fooled around in the past and now I was a threat to his marriage. He shoved me down the stairs and I saw it from his perspective: I bounced down and finally ended in a heap at the bottom.

The dream shifted again and I was at a party in the same house, walking through the living room. I was dead and a ghost; no one could see me, but I didn’t walk through anybody–I still felt corporeal. I tried to interact with some people but no one took any notice of me. I went over to a card table where four teenagers were sitting. They had piles of paper, multi-colored glitter, and glitter pens; the setup was supposed to act like a Ouiji board. I leaned over between two of the teenagers and grabbed several of their pens, scattering some of their papers. They started to look scared because of the fluttering papers and pens floating in midair. However, they remained seated and continued writing and drawing. I wrote over top of whatever they did, writing, “He killed that girl,” and similar messages. Apparently the man who had killed me was on trial, but everyone figured he was innocent because he was such a respectable figure. The teenagers read what I had written and looked horrified, glancing over at the man, who was in the corner talking with some girl.

The dream shifted again and I was out in the country on a very rainy, gray day. I was climbing into a station wagon with my cousin Shannon, who was pregnant. For some reason, she was able to sense me and could communicate with me. We were arguing about something and I was getting annoyed because she was trying to convince me not to do something.

4 Mar 06 ad blocking through /etc/hosts

Note: If you enjoy this article, you might also check out the Geeky Stuff section.

There are several ad sites that you’ll see being used everywhere. They slow down page loading, even on fast connections, because sometimes there’ll be lag and they won’t load immediately and instead of being able to read that interesting news article, you’re stuck waiting for some Flash animation to show up so you can ignore it. A simple way to make those ads 1) not show up and 2) not cause delays in page loading is to edit /etc/hosts. Check out hostsfile.mine.nu for ways of doing this in Windows and Mac.

Here’s an example /etc/hosts file:

127.0.0.1       localhost

# The following lines are desirable for IPv6 capable hosts
# (added automatically by netbase upgrade)

::1     ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
ff02::3 ip6-allhosts

We’re not interested in anything after the first line, really, because that first line is the key to our trick. What it’s doing is associating a host name (e.g. localhost) with an IP address (e.g. 127.0.0.1). What we’re going to do is assign some common ad host names to IP addresses beginning with 127.0.0, and ending with some number. The idea here is to point the host name, in our case some ad site, to an IP address that goes right back to localhost. This will cause the ad to load immediately because it’ll be looking on your local system, but since you’re not going to have /adi/N3271.RealCities/B1808805.8;sz=300×250;click=… on your computer, the ad will just show up with a ‘Not Found’ message:

Example of blocked ad

So as root, edit /etc/hosts with your favorite editor and add the following lines:

127.0.0.2 ad.doubleclick.net
127.0.0.3 servedby.advertising.com
127.0.0.4 ad.uk.doubleclick.net
127.0.0.5 ad.au.doubleclick.net
127.0.0.6 z1.adserver.com
127.0.0.7 red.as-eu.falkag.net
127.0.0.8 f.as-eu.falkag.net
127.0.0.9 data.as-eu.falkag.net
127.0.0.10 ads.guardianunlimited.co.uk
127.0.0.11 ads.guardian.co.uk
127.0.0.12 a.as-eu.falkag.net
127.0.0.13 as1.falkag.de
127.0.0.14 code.fastclick.net
127.0.0.15 adfarm.mediaplex.com
127.0.0.16 smarttargetting.co.uk
127.0.0.17 data.coremetrics.com

Now any site that tries to load an ad hosted on one of those sites will instead display a message akin to the one in the screenshot above. If you find any other sites that host ads that you don’t want to see, just add another line to /etc/hosts.

Thanks to my dad for showing me this trick.

6 Mar 06 man boobs and Chicago

So I totally got felt up by a three-year-old last night. I was hanging out at Todd[1] and Kelly’s with Eric, Brent, and Todd, and we were all standing around about to go get ice cream when Artemus, Kelly and Todd[1]’s child, came up to me and tucked his fingers into the waistband of my pants, pulling down on them. We started laughing at him and Todd[1] said, “I love my son,” or something like that. Well, later on, Kelly, me, and Todd were sitting on the couch. Artemus had been coming up to me and sitting on my lap all night, and he came up again so I pulled him onto me. Well, he turns around and starts poking at my right boob. Kelly looked shocked and pulled him onto her, saying, “No Artemus! Man boobs and girl boobs are different.” “Sarah’s a girl,” - Artemus. “Yes, she is, but you can’t touch girl boobs,” - Kelly. Todd gets up from beside me and goes to yell up at Todd[1], “Todd, your son’s awesome.” “Why?” - Todd[1]. “Because he’s feeling Sarah’s boobs,” Todd.

Hopefully, Todd, Ashlee, Jess, and I can watch Lady and the Tramp tonight because Jess bought it. Todd’s been wanting me to watch it with him since he loves it and I’ve never seen it, so this is very convenient. He and Ashlee are currently both in class.

Another thing I’m hoping for is to go to Chicago for a couple of days over spring break with Eric, Todd, and Todd[1]. That would be so much fun, I think, because we’d stay with Todd’s friend Matt and go sight-seeing. I’ve never been to Chicago, though lucky Jess is going to get to stay there for a week this summer because of her internship.

That’s something really neat that I’ve been aiming to write in here: my friends and I have had a series of awesome things happen recently. Todd got his new job at the College of Pharmacy as web admin, along with a great pay raise; Jess got an internship for the summer where she’ll get to work both here and in Chicago; and Tiffany is going to study abroad in Brazil this summer. As for me, I’m still excited about the whole co-oping at Lexmark thing, which is still as fun as it was when I started in January.

7 Mar 06 Wild West

Note: This was a dream of mine. I have this warning here because some visitors have thought my life had just gone to pot, when really they were only reading one of my crazy dreams. :)

I was in the old west and traveling around; it had the feel of some adventure game since I was periodically given gold coins and other things. I was riding on a train between two cars and I thought I would fall off, but just as I did, the train stopped so I ended up on a platform next to a bank. I went in and decided that I had been carrying around way too much money, so I opened an account. The clerk had me go to a back room to verify my email address, so I turned and went down a long hallway. The walls were a dark, shiny black. I got a bad feeling as I reached the end of the hall, so I turned around to find Todd[1] there with a large, curved sword held up. He pressed it against my neck, grinning, and pushed me backward. I offered him $123, which was all I had with me, but he didn’t want my money; he was a hitman. Somehow I was able to wrestle away from him and I took off running back up the hallway. It had been a setup; the bank was involved in wanting me dead.

I kept looking behind me and saw that while Todd[1] was still at the hallway entrance, there were two other guys after me that were closer. One of them I couldn’t really make out, but the other, who was closest to me, was bald and had his face painted white like a mime. I finally got tackled by him and then the three of them stood around me with their swords.

The dream shifted and I walking around campus with Todd; we were behind the Cat’s Den in the parking lot. He had just gotten out of class and we were trying to find somewhere to talk, but had to swing by the library first. It was a sunny summer day.

11 Mar 06 home for spring break

I’m at home for spring break. I finished packing things up at the dorm yesterday after work, then Todd took me out (well, I drove, but he paid) to dinner. I got back around 8:15 p.m. and somehow managed to stay up until midnight, catching up with my parents. My phone is now doornail dead, sadly, because I forgot my charger at UK and can’t find my car charger. Mom and I are going shopping tomorrow, though, so I’ll pick up another one.

Dad and I went out in the woods earlier and I’ve taken a lot of photos today. Here are my favorites:

peacock
Every time I go to photograph one of these guys when their feathers are spread, they get camera shy and put them down. I guess I lucked up this time.

gum balls
I just like the vibrant browns in this one.

daffodils
There are little clumps of Easter flowers like this all over the place here.

11 Mar 06 new theme, updates

I added the Pastel theme (which is now the default). Updated Current Favorite Songs on Music and added several new photos.

11 Mar 06 image generation in PHP

Note: If you enjoy this article, you might also check out the Geeky Stuff section.

Creating images on-the-fly can be a very useful skill. Using PHP's built-in image generation functions, it's pretty easy, too. This tutorial will detail how to have the titles of blog entries show up as automatically generated images.

What we'll be doing is passing arguments via the URL to a separate file that will be our image. Why use a separate file? Because of headers, my friend. If you try to generate an image in the middle of a regular PHP or HTML page, you're going to get an error about the headers having already been sent. That's because with the first bit of text or HTML that got passed, the page was determined to be an HTML page. By attempting to generate an image in the middle of it, you're essentially trying to say, "Oh wait, this HTML is suddenly going to become a GIF," which isn't possible. Therefore, we'll use a separate file where no text data is echoed, and pass the headers manually, via the header() function, declaring the file to be an image.

So create a file called image.php. In that file, we'll put all our image-generating code. Since we're going to want the image to be dynamic (i.e. its content changes based on what the title of our blog entry is), we're going to need to pass arguments to it. The simplest way to do that is via the $_GET superglobal. $_GET is just an associative array consisting of all the key/value pairs passed in the URL. You may have seen URL's such as index.php?page=about_me before. In $_GET, there would be an index 'page' and its value would be 'about_me'.

image.php:

PHP

<?php
if ( array_key_exists('text', $_GET) )
     $text = $_GET['text'];
else
     $text = 'No title supplied';

What this is doing is testing to see if the index 'text' exists in $_GET. If it does, store that value in $text; if it doesn't exist, then that means no value for 'text' was passed in the URL, and therefore we want to supply some default value (i.e. 'No title supplied').

Your entry titles may well have funny characters, such as spaces, slashes, and quotes, in them that won't work well if you just pass them as-is in a URL. Therefore, you'll need to use urlencode() on any text that you send to image.php. After receiving it, though, you don't want your image to have the encoded version of the entry title, so you'll need to decode it like so:

PHP

$text = urldecode( $text );

Now that we have a way of getting our entry title, we can move on to doing something useful with it. To create an image in PHP, you'll use the imagecreate() function. You'll then want to define some colors with imagecolorallocate() to use throughout the image, the first of which will be set as the background color:

PHP

$image = imagecreate( 200, 40 );
$white = imagecolorallocate( $image, 255, 255, 255 );
$black = imagecolorallocate( $image, 0, 0, 0 );

This is creating an image that's 200 pixels wide by 40 pixels tall, and stuffing it into the variable $image. Then we're defining $white to be a color with the red-green-blue values of 255-255-255, which is white. This becomes the image background color since it was the first color allocated after creating the image. We then define $black as a color with RGB values of 0-0-0, which is black. We'll use this for our text later.

Now we need a font to work with. While PHP has some built-in fonts, they aren't all that attractive, and it might be nice to have a font that matches the rest of the images in your layout. Ergo, upload a copy of your favorite TTF and we'll use that:

PHP

$font_regular = 'Times_New_Roman.ttf';
$size_regular = '12';

This defines $font_regular to be Times_New_Roman.ttf. We also define a font size for later use.

All right already, let's do something with this blank image. imagettftext() is your function du jour for this particular project:

PHP

imagettftext( $image, $size_regular, 0, 5, 15, $black, $font_regular, $text );
?>

The parameters are as follows: the image, font size, angle, distance from left, distance from top, color, font face, and the text. You may wonder why I didn't set the distances to be 0 and 0; if I had done that, the text would be partially cut off.

So we're well on our way to having a complete image. There are a few last steps we need to take before it'll work, though. First is to pass a header notifying the browser that this file is actually an image. Then we need to use imagepng() to convert our image into a PNG file. Then, as clean up, we need to use imagedestroy() to free the memory associated with our image:

PHP

header( 'Content-type: Image/PNG' );
imagepng( $image );
imagedestroy( $image );

Now all you need is to pass the title of your entry to image.php. In Wordpress, this might be done like so:

PHP

$url = 'image.php?text=' . urlencode( the_title('', '', false) );
echo '<img src="' . $url . '" alt="Generated image" width="200" height="40" />';

You can find out more about WP's the_title() function on the Wordpress Codex.

Try our script so far. That's really nice, of course, but if our generated image is going to be that dull, what's the point of having an image at all? If only we could have all the nifty stuff that we can create in The GIMP or Photoshop, with just our dynamic text on top of it... But wait! PHP is awesome like that, so we can using the imagecreatefrom*() functions, such as imagecreatefrompng().

Let's start with the following base image:
Base image
We'll use that as a background for each of our entry title images.

We'll modify our script from

PHP

$image = imagecreate( 200, 40 );

to

PHP

$image = imagecreatefrompng( 'base.png' );

Now try it. Adjust the position of the text a little bit, maybe change fonts or your base image, and you could have a really snazzy entry title that is completely dynamic. Don't stop there, either: you could use this same technique for your entry dates, page titles, or even your entries themselves, if you were crazy.

There are lots of other useful functions that PHP provides for your image generation needs, including tools for drawing geometric shapes and creating transparent colors. Visit the Image Functions reference for more information. I also recommend this tutorial for a more general (and thorough) introduction to image generation with PHP.

13 Mar 06 leaked Intel memo about Chinese Linux boxes

Note: If you enjoy this article, you might also check out the Geeky Stuff section.

Intel is offering an affordable computer in rural areas of China. …the product sells for $350 using an inexpensive but high-quality Intel processor, with an expected take rate of 73 percent. The originator of the document believes that they will sell hundreds of millions of units. The operating system marketed with the product uses an unnamed distribution of Linux.

Personally, I consider it somewhat of a betrayal of the American people. If Intel can sell a Linux computer in rural China, why can’t they do the same thing in the United States? What about the No Child Left Behind Act signed by President Bush in January 2002? What about the poor in the US who, with proper training, could easily fill the supposed skills gap that has led to the overseas outsourcing of so many crucial, even sensitive, IT jobs?

Leaked memo from Intel shows Major Linux Effort

I’m in agreement with the second paragraph up there: if Intel can sell such computers overseas, why aren’t they trying to here? There are plenty of people in the US who could otherwise afford a computer if it didn’t automatically come with the huge overhead caused by Microsoft Windows. Solution: make it easy to purchase a PC with an operating system that doesn’t cost anything.

13 Mar 06 more new photos

I’ve been taking photos like crazy since getting home for spring break, and today was no exception. See the full entry for my favorites.

me holding a peach blossom still
I love the ‘Foliage’ setting on my camera because it makes the colors so much brighter.

forsythia blossoms
Gotta love that bright yellow. That’s our forsythia bush starting to bloom.

« Older entries