« February 2006 | Main | April 2006 »

I Never Win at Blingo

March 24, 2006

Blingo Open in Tabs

If you haven’t heard of Blingo yet, it’s basically a search engine that gives you a chance to win a prize every time you search…well, the first 10 times you search in a given day. I’m usually a pretty gullible person when it comes to these types of things, but I avoided replacing Blingo with Google as my homepage mainly because I enjoy having the customized Google weather, news, and gmail. After Jeff Croft won at Blingo though, I decided to give it an earnest shot. It stayed as my Safari (not Firefox) homepage for about a week. Then I resorted to the method you see above. I made bookmarks for 10 random searches and hit “Open in Tabs” once a day, hoping each day to see the “Congratulations!” screen. I know this is technically not the way they expect people to use their system, and perhaps they don’t let people win who search for 10 things within a half-second, but I ask “Why Not?”. I want to win something. If you haven’t registered yet and would like to win with me (if I ever do) at Blingo, then use this referral link to signup. …But I’m not guaranteeing anything.

nearestSentence Function

March 20, 2006

I wanted to be able to take a string of text, a blog entry in this case, and crop it down to the nearest sentence to a given maximum length value. I am sure this function exists in php, but I couldn’t find it so I wrote my own and figured some of you might find this handy:

function nearestSentence($s) {
    //Max length of string before 
    //looking for last sentence.
    $maxL = 350;

    //Strip html tags and convert 
    //html entities (like &) 
    //to single characters before counting.
    $toCount = strip_tags(html_entity_decode($s));

    //Crop the string down to the max length.
    if (strlen($toCount) <= $maxL) {
        $s2 = $s;
    } else {
        $s2 = substr($toCount, 0, $maxL);
    }
    //Look for position of the last ., ?, or !
    $lastPunct = max(strrpos($s2, '.'), strrpos($s2, '?'), strrpos($s2, '!'));
    //Crop the string again down to the nearest punctuation.
    $s3 = substr($s2, 0, $lastPunct+1);
    //Return string with html entites re-inserted.
    return htmlentities($s3);
}

So, if you had some text like:

Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat? Duis autem vel eum iriure dolor in hendrerit in vulputate velit esse molestie consequat, vel illum dolore eu feugiat nulla facilisis! At vero eros et accumsan et iusto odio dignissim qui blandit praesent luptatum zzril delenit augue duis dolore te feugait nulla?

Then, you would get:

Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat?

If you have some flexibility for the length of your blurb, I think this looks a lot better than just cropping your string down to a particular length and adding… but maybe that’s just me.

Derailed

March 16, 2006

At work, we’re about to get started on a pretty straightforward reservation application. We have a client that offers tours of their facility and they need a web app to take and manage reservations for said tours. I know that I could code this out in php/mysql pretty easily, but it seemed like the perfect opportunity to give Ruby on Rails a shot.

I have to admit here that I’m pretty excited about the possiblity of using rails. I’ve heard so much from so many of my colleagues about it’s ease of use and flexibility that I was chomping at the bit to give this puppy a whirl. I followed Dan Benjamin’s EXCELLENT installation guide for OS X Tiger, and carefully (making a few mistakes along the way) followed the “Using Ruby on Rails for WebDevelopment on OS X” tutorial. Now, as a graphic designer, the majority of my college career was spent learning how to draw, paint, take pretty pictures, and be able to differenciate between the Madonna paintings of Cimabue and Giotto. I took some basic programming classes, but never learned anything about models, controllers, and views. Regardless, I was still able to walk through the installation, and basic app creation described in the tutorials above.

At the end of the day, I’ve got a sweet little expense tracking application (that was explained in the using rails tutorial), and one simple problem: how to deploy it. At work, we use CVS for out repository, but I guess I’m going to have to get friendly with SVN because Capistrano (aka SwitchTower) seems to require it, and I haven’t seen any other options for deployment. I did see this little guide at nubyonrails (fun name) about deploying to Dreamhost, but it too uses Capistrano and Subversion. Is this the way to go? Do I really have to source control my tiny little example app in order to stick it up on a subdomain of my site? I’m not REALLY expecting answers on all this. This is more just a journal on my thoughts and progress on the topic, but SOMEBODY ;) out there has to be able to tell me if I’m on the right trail.

The Replacements

March 13, 2006

New Camera and New Website

New Camera: Casio EX-Z750

After much deliberation and in-store camera testing, Ames and I decided on and ordered a Casio EX-Z750. Finally, our picture taking withdrawal is over and we have a replacement for our old and busted Kodak CX4300.

New Website: amesnjas.com

I had been thinking and talking about redesigning amesnjas.com for some time now, but after breaking the fragile home-brew php/mysql content management app the site was running on, I had no choice. It took quite a few late nights and some serious php/mysql tomfoolery, but the site is looking and functioning better than ever.