Friends Blog Links

Recent Tracks

Powered by AudioScrobbler

iPhone Adventures

Monday, July 14, 2008, 05:44pm

 

As I sat in line outside of the Stonestown mall in San Francisco Friday evening, waiting to purchase the brand new iPhone 3G, I couldn't help but take a step back and look at myself from a 3rd person perspective. I thought of what I would think of myself if I were 5-6 years younger, back in the days when I was in a punk band and whatnot. I would definitely think my current self was a big tard. I've grown into a huge, flourishing nerd and that's OK.

I've never waited in a huge line for anything, not for new Nike shoes, not for an XBox or a Wii, nothing. So this was a first, and probably a last for me. I got in line at around 7pm and I was thinking, "If this line moves along nicely, I'll stay, otherwise I'm getting the hell out of here." We had tried going to the AT&T store by our house about 15 minutes before the store opened that morning. We waited til about 15 minutes after it opened, with no line movement with the 200+ person line, and left. After standing in line at Stonestown for about 15 minutes, I was told by a friendly Apple Store employee that I was the very last person that was going to receive an iPhone that night, and I was now accompanied by a security guard that was going to make sure of it. It was a sign, and I had to stay now! I was the chosen one!

The Chosen One

The most entertaining and sad part of the night was all of the people who just couldn't believe the line was closed. It's truly amazing how selfish people can be! Apple Store employees are human after all, and need to go home—don't they? There must have been a good 50+ people who came and argued with the security guard and/or the Apple employees monitoring the line, things like: "But I called ahead and they told me to come down and it was only an hour wait", "But I drove here all the way from the northern part of the city (for any non-San Franciscans, that's a grueling 8.5 minute drive)", etc. I mean it's just a phone. And everyone who was complaining followed their complaint session with a cell phone call (a good 90% of whom made their calls with 1st gen. iPhones) to bitch to their friends about it, so it's not like they were in dire need of the phone.

You might be thinking, "Well Chris, you were waiting in the gigantor line, so you're as pathetic as those complaining people". No dude. I was the chosen one. And if they had told me the line was closed, I simply would have left and gone to eat at Chevy's, which was conveniently located within about 60 feet of the line. They have this really good corn stuff and Dos Equis Amber, mmm.

Delicious Dos Equis Amber

So we waited until 10:30pm, when we were about 15 people from the front of the line they announced, "Sorry folks, the AT&T servers are completely down". Lots of cursing, ooh-ing and aww-ing ensued, but thankfully they gave us front-of-the-line vouchers to use the next day. Woohoo! While waiting for our vouchers, me and the wife manage to thwart a few would-be line-dropper-inners who tried to grab the goods without waiting the 3.5 hours. Hi 5, wife.

So Saturday we took a nice leisurely morning, headed back to the Apple store around 12:30 and got right in line with about 5 people ahead of us and got our phones, woohoo! I have to say the iPhone is pretty amazing, and with all of the new apps, so very useful and fun! I've always resisted getting a Twitter account because it's just never seemed interesting to me, but as a result of my iPhone and the Twitterific app, I am now the nerdy owner of a spankin new Twitter account.

Twitter

I'm not sure if it's because I'm already a Mac user, but it's crazy how easy and intuitive it is to use. Within hours of using it, I already felt like a pro. The one tricky part is the keyboard, but I'm sure I'll get used to it. I've already got the AIM app, Loopt, Twitterific, and I'm going to give Evernote a try since it has an app, and I've heard such good things about it from TUAW. Anyone else get a new iPhone? Any new apps that are rockin your world?

On an entirely unrelated note (or two), Juan stayed with us for the week and stole our toothpaste upon departure. We all went to Phil's (another fellow Cubano) wedding last Sunday, which was beautiful and awesome. We had the most delicious tacos in the world on Friday at La Taqueria, and it was bitter-sweet without Phil around. Normally we all do 2 tacos without going into a food coma but Phil always challenges us to a 3rd. He's usually the only one who accepts the challenge. He's in Jamaica with his lady, rockin' the ganj and getting dreadlocks. That's all for now folks, talk to you soon!


Easy click tracking with MooTools & CakePHP

Thursday, July 3, 2008, 10:50pm

 

My pal and fellow Cubano, Juan has always hated how I track my links on this site. When I first started it up, I wanted to create a shared library on here, where I could sync up all of my links from del.icio.us in a table in my local database, and use those links all over, in my posts, etc., track their clicks, and then have a listing of all my links by tag, and, from tracking clicks, also be able to sort them by popularity. It still might happen eventually, but I haven't been thoroughly motivated to finish it up. I used to want to finish it really badly so I could use it for my own purposes. I use Firefox along with the Delicious plugin, and I always want to search links by all of the tags I enter. For example, if I put in 'Subversion Manual' (that combo is used a lot), I only want to see the links that have both of those tags, not either of them. Well it seems with the update to Firefox 3 there was also an update to the Delicious plugin that takes care of this for me. Motivation fully depleted.

Either way, I have been thinking of reworking the link tracking for quite some time. I've been using the format '/links/go/123' to track the links, rather than the URL itself. I think this frustrated Juan because he likes to see his status bar update at the foot of his browser and decide if he wants to go to that link or not. There have been a number of projects I've worked on where link tracking has been asked for by the client, so I decided to throw something together today.

I created a MooTools class called 'LinkTrack' that, in a simple 19 lines of code, scans the page for the links you specify, and, on the click event, sends the link information to a specified URL via AJAX. Here's what the class looks like:

var LinkTrack = {
    track: function(links, url) {        
        links.each(function(item) {
            item.addEvent('click', function() {
                var request = new Ajax(url, {
                    method: 'post', 
                    data: {
                        'url': item.getProperty('href'),
                        'title': item.getProperty('title')
                    },
                }).request();
            });
        });
    }
};

And here's what the function call looks like:

window.addEvent('domready', function() {
    LinkTrack.track($$('a[target=_blank]'), '/links/track/');
});

So here I passed in all 'a' tags with a '_blank' target, so I track every link leading away from the site. You could easily change this to track all links with the class 'link', or whatever else you can think up. I've got this site running in CakePHP, so I made a 'track' method in my 'links' controller that looks like this:

<?php

class LinksController extends AppController {
    
    ...
    
    function track() {
        $this->autoRender = false;
        if (preg_match('/http:\/\/(www\.)?ascendvisual.com(.*)/', $_SERVER['HTTP_REFERER']) && $this->RequestHandler->isAjax() && !empty($_POST['url'])) {
            
            $data = $_POST;

            if ($find = $this->Link->find(array('url' => $data['url'])) {
                $this->id = $find['Link']['id'];
                $out = $this->Link->saveField('clicks', ($find['Link']['clicks'] + 1));
            } else {
                $data['clicks'] = 1;
                $out = $this->Link->save($data);
            }
            
        }
    }
}

?>

I run a check to make sure the request is coming from my own site, that it's an AJAX request (using CakePHP's RequestHandler Component), and that a URL is set. The I scan my links table to see if that URL is already in there. If it is, I increment the click count, if not, the record is created with a click value of '1'. Pretty simple eh?

Feel free to let me know what you think, and, if you'd like, you can download the MooTools LinkTrack class I made by clicking here or over on the right under 'Related Snippets'. That's all for now folks, have a fantastic 4th of July weekend!


New Website: Ashley Forrette Photography

Friday, June 20, 2008, 12:48am

 

Hey folks! It's been a while! Sorry it's been a while but that's just how I roll. I've actually been thinking up all sorts of nerdy subject matter, it's just been crazy as always and I haven't forced myself to post. I finally got myself into a corner to post for you today, awesome right?

It's been live for a while now, but I finally got my wife Ashley's photography portfolio website launched, go check it out! Today I'm going to spill the beans on how I made it, and hopefully give some of you folks some good ideas. It was a fairly quick and simple build using CakePHP, the Flickr API and some MooTools magic.

Ashley Forrette Photography

So the coolest thing about the site is that it's all Flickr-fed. Ashley chose a set of categories she wanted to use and I had her create Flickr sets for each of them. Each category you click on references a specific Flickr set that's pulled in and cached via a nice, reusable table-less Flickr model I created for CakePHP. Why is that even cool you ask? Because I didn't have to worry about handling and storing uploads or anything—the site requires no admin interface at all—and it also works as a bit of extra exposure for her shots, being both on the Flickr site and her portfolio site. The Flickr model I've created has proven useful in a number of cases—I even use it on this very site for when user comments are posted. I basically just disable Cake's table linkage and used a few methods to access Flickr's various API methods.

The most challenging part of the site was the Javascript. If you check the site out, you can see that the image is preloaded (using the MooTools Assets class), the thumb menu is animated, and there are some nice fade transitions in there too. I accomplished it all in a custom MooTools class called 'Photoset'. It ended up being about 180 lines of code—not too bad—and handles all of the javascript on the site—the loading, fades, menu, everything. The load/fade transition was the trickiest part, but I used the Asset class along with MooTools chaining and did it in about 12 lines of code:

this.loader.start(1).chain(function() {
    new Asset.image(load, { 
        onload: function() {
            this.loader.start(0).chain(function() {
                this.photoFade.start(0).chain(function() {
                    this.photo.src = load;
                    this.photoFade.start(1);
                    this.showing.setText((index + 1));
                    this.loading = false;
                }.bind(this));
            }.bind(this));ˇ
        }.bind(this)
    });
}.bind(this));

Basically I fade in the 'loading' indicator, preload the image via Asset.image, fade out the loader, fade out the previous photo, change the photo source, and fade it back up. Whew! Chaining is a little tricky to structure in a nice, readable way, but so nice to use! With MooTools chaining, you can set a stack of time-based functions in line to occur one after the other. It's basically like using an onComplete event to call another function, just much easier and cleaner.

And that's all! Check out the site and you know where to go if you need a good (and sexy) photographer. Feel free to post comments if you have any questions and look out for plenty more updates coming soon.


SpringLoops powered

Tuesday, May 13, 2008, 11:09am

 

SpringLoopsI'm proud to make a very important announcement today, that this site is now fully SpringLoops-powered. Woohoo! I mentioned before that I'm a mega cheapo and don't want to spend the $9 to get the 1GB plan and that the free 10MB wasn't enough for me. Well they've recently upped their free space to 25MB so I've managed to squeeze a couple of projects into it. Unfortunately you're limited to only 3 deploys a day, so on the days where I'm actually making updates, I'm extremely cautious, on all the other days, I'm finding excuses to use those 3 deploys. Deploying rules really hard! End nerd rant.

On a side note, I'm currently developing my wife's brand new photography website, in which her portfolio will be powered by the Flickr API and some MooTools fanciness. I'll post links and such when it's all ready. Oh and if I didn't mention it, Grand Theft Auto IV rules hard. Those damn mobsters burned down me and my cousin Roman's apartment the other day though, that sucked. There will be vengeance. Everyone have an awesome day!


Current Rockin: Protest the Hero - Fortress

Thursday, May 8, 2008, 11:29pm

 

Protest the Hero - FortressIt's been a crazy month (or so) of work and nothing will snap you in the ass like a strong latte and and an awesome metal album. My best, most productive days are when I can squeeze in a latte (or 2) from my über favorite coffee joint, Blue Bottle Coffee, and blast this album in the earbuds 3+ times a day. Yesss. This is indeed one of those albums that will scare Phil or any other innocent, faint-hearted passerby, but it rocks my pants off. Lots of incredible musicianship, screaming, growling, high-pitched singing—everything a boy could ask for in this one.

I heard about this band a while back with their release Kezia from my old buddy Ryan but I didn't get into them at the time. But, yet again, Colby comes through in keeping me hip with the kids and got me hooked on this one. Thanks again Colby, high 5. Rock on folks...