(or Sign up) :

I think I'm going to switch to Microsoft Windows Vista

Apr 16

Show_hide

As most of you know I've been a long time Macintosh user. I gave up using Microsoft products years ago, and have been much happier ever since. However this video from Microsoft on the new Windows Vista SP1 has me thinking. I mean, there's no way Apple could ever do something like this.

There's bad, and then there's this.

Jul 19

Show_hide

What do you get when you mix email with a really bad version of Second Life and spam eating sharks? Why, 3D Mailbox of course.

From their website:

3D Mailbox delivers a fantastic, smarter e-mail experience. Immerse yourself in 3-D as you read and write your mail. Relax to the sounds of the ocean, seagulls, and cool tunes. Hang with your mail poolside, or feed your spam to the sharks! Deleting spam is so much fun, you may wish you had more!

Don't Try This At Home

Mar 07

Show_hide

On the Mac there's a nifty little utility called Growl. It's a system-wide notification service that other applications use to display attractive popup status messages. There are all kinds of programs that utilize it, namely instant messaging apps and other small utilities. Sometimes they're really useful, other times they're fun and occasionally they're a little bit stupid.

I wrote a really stupid one. I mean a really, really stupid one. I added Growl notifications to dashing.com.

So now every time someone visits this site a little window pops up on my desktop announcing it. Is that the stupidest thing ever or what? :-)

Growl notifications

Now I confess that it is kind of cool. But the idea of the website sending notifications to my desktop Mac whenever people visit is really a terrible idea. But it was such a neat little hack I had to do it. :-)

So for you Rails programmers who are bored, here's how I did it.

First download Growl and install it if you don't already have it.

Next you'll need Ruby Growl. You can install that via RubyGems.

sudo gem install ruby-growl

Once that's installed add an after_filter to the top of your application.rb controller file.

after_filter :growl

Then add the following code to the bottom of application.rb.

Note: I'm using the Acts As Authenticated style user model code and helpers, so you may need to change this for your app, or remove the username display entirely.

 1   private

2 require 'ruby-growl'
3 def growl
4 if logged_in?
5 user = current_user.login
6 else
7 user = request.env['REMOTE_ADDR']
8 end
9 g = Growl.new 'home.server.address', 'Website Visitors',['visit'], ['visit'], 'PASSWORD'
10 g.notify 'visit', 'yoursite.com',"#{user} visited #{request.env['REQUEST_URI']}", 0, false
11 rescue
12 # Something didn't work
13 end

You'll want to replace "home.server.address" with the IP address or hostname of your Mac. Replace "PASSWORD" with your Growl network password and "yoursite.com" with the name of your website.

You'll need to enable incoming connections in the Network section of the Growl control panel, and be sure to set a password. Also check the "Allow remote application registration" button, at least until you've received your first message. Finally, if you have a firewall you'll also need to allow port 9887 access to your Mac over UDP.

That's all there is to it. It's really pretty fun to see all of the popups...at first anyway. Though I can't imagine this would work well with even a moderately popular website. In fact even dashing.com is too busy for this and I'll likely turn it off shortly. But it was a fun hack just the same.

Maybe this will inspire someone to come up with a useful reason to incorporate Growl into a Rails app? If you do, be sure to let me know.

Super Easy Collect For ActiveRecord Arrays

Dec 09

Show_hide

Disclaimer: Yes I'm fully aware the 99.9% of the people who read this site will not only have no idea what I'm talking about, but wouldn't care even if they did. But for the .1% who do, this is really, really cool! :-)

Recently at work I've been writing a Ruby On Rails application for our Network group to monitor and track our environment. The fellow I've been working with has written a bunch of really amazing Perl scripts that scour the network and collect lots of information about all of the devices. I'm writing the Rails front end to work with that data, and in the process teaching him Ruby (and Rails), so once we're done he can take it over and maintain the app. It was while showing him some things in IRB that I discovered an area for improvement that would really make working with a collection of ActiveRecord objects easier and the code far more beautiful.

Here's how it worked:

>> locations = Location.find(:all)

>> just_the_names_and_ids = locations.collect{|loc| [loc.id, loc.name]}
=> [[1, "New York Zone"], [2, "Los Angeles Zone"], [4, "Boston Zone"],
[5, "San Francisco Zone"], [6, "Development Center"]]

That's really groovy, and something that every Rubyist does in his/her sleep. The syntax for collect, being a block can be a bit confusing for a new programmer though. Then I remembered the ActiveRecord finder syntax.

Location.find_by_city_and_function("Los Angeles", "Production")

Why can't we do the same sort of thing with collect? Now you can!

>> locations = Location.find(:all)

>> just_the_names_and_ids = locations.collect_id_and_name
=> [[1, "New York Zone"], [2, "Los Angeles Zone"], [4, "Boston Zone"],
[5, "San Francisco Zone"], [6, "Development Center"]]

>> just_the_names = locations.collect_name
=> [["New York Zone"], ["Los Angeles Zone"], ["Boston Zone"],
["San Francisco Zone"], ["Development Center"]]

>> names_and_cities = locations.collect_name_and_city
=> [["New York Zone", "New York"], ["Los Angeles Zone", "Los Angeles"],
["Boston Zone", "Boston"], ["San Francisco Zone", "San Francisco"],
["Development Center", "Chicago"]]

I love it! It's so much more readable and "Rails like" that I'm really surprised that it wasn't something built in. But since it's so easy to extend Ruby (and Rails) it takes just a tiny bit of code to add that functionality in. Just paste the code below into your environment.rb and you're good to go.

class Array

def method_missing(method_id, *arguments)
if match = /collect_([_a-zA-Z]\w*)/.match(method_id.to_s)
attributes = match.captures.last.split('_and_')
self.collect{|array| attributes.collect{|attr| array[attr.to_sym]}}
else
super
end
end
end

This could easily be made into a plugin, or stuck into a .rb file in the lib directory and required. It's up to you. Hopefully someone out there will find this handy. I know I have.

Caveats: This won't work with included associations. Example:

Device.find(:all, :include => :location).collect_name_and_city

That will return a collection with the device names, but city will be nil because it was an included association. It would be easy to extend the functionality to support that, but I couldn't think of a clean syntax to allow it. So I figure it's best to keep it as it is.

Finally, this will work on Array's of hashes too, and not just ActiveRecord objects.

>> pets = [{:name => "Browser", :kind => "Dog"}, 

{:name => "Fluffy", :kind => "Cat"},
{:name => "Noriko", :kind => "Japanese Actress"}]

>> pets.collect_name_and_kind
=> [["Browser", "Dog"], ["Fluffy", "Cat"], ["Noriko", "Japanese Actress"]]

It's Not How It Looks, It's How It Works

Nov 16

Show_hide

It's no secret to anyone that I was not particularly impressed with the new catstevens.com. To paraphrase myself I said it was nothing more than an online brochure to promote the new album, and that the navigation was so annoying that after a couple visits everyone would hate it. What's more I felt that the content offering was so insignificant (when you could even find it) that there would be no reason to ever really go back to the site once you'd seen it once. In the interest of full disclosure, I said some other things too, which I now regret and later retracted. But having said all of that, now that the new site has been up for over a month, how do I feel about it?

I was right.

If I could have made a list of everything not to do when designing the new catstevens.com it would be a perfect description of what they actually did. I'm not joking. It's a slick online-brochure to promote album sales that is quickly annoying, hard to use, impossibly non-accessible, incredibly slow and devoid of any soul or community. What's more, it's not even a "web site." The entire thing is a single Flash .swf file, which appears to do some call-outs to display the news and other "dynamic" content. It's also 1.5 megabytes, which is unbelievably large. I can't even begin to imagine what it must be like accessing the site for a dial-up modem user. Ouch!

So when I say it's "not even a web site" what do I mean? I think it's easiest to explain by giving an example. You see, contrary to what some "Mes Amis" would like to believe, I happen to like Yusuf and am a fan of his work. I would like to keep up-to-date on the latest news and am really curious about his touring plans, and how well the album sells. The obvious way to do that is to visit the site every so often and read the news. This is where the problem comes in.

I decided to time how long it took to load catstevens.com and click on the news link before I actually was able to see the latest stories. Admittedly this is totally unscientific, I just started and stopped a stop-watch, but I think it's fairly accurate.

It took over 17 seconds.

It's important to note that I already had the 1.5 megabyte Flash .swf file cached in my browser, so the 17 seconds doesn't include download time. It is only the amount of time it took for the "Loading" screen to finish, for me to click on News, for the animation to do it's thing and the stories to finally appear. Heaven forbid I clicked on "Sing" and read the news there. I didn't bother to time how long that would take.

So in fairness I decided to time how long it took to load the home page of dashing.com and begin reading the latest stories. I could have just as easily picked any "real" web site for this, but it just seemed to make sense to use dashing. So the results?

0.335 seconds.

Ok, so I rest my case.

This could all be mitigated somewhat of course if I simply bookmarked the "News" section on catstevens.com and went straight there. But you see there's that pesky problem of it not being a web site. You can't bookmark any pages, because it doesn't have any (save the home page itself). Web sites that employ Flash in that manner effectively break the very things that make the web the web. You can't bookmark them, you can't search them and they are unaccessible to blind or similarly disabled people. It gets worse when you factor in that there's no way to skip the annoying animations, and don't get me started on the sound effects.

Now, I really don't want to not like catstevens.com, honest. I wanted to love it. I had so hoped that it would be great. But unfortunately it just isn't.

I do want everyone to know, whether you love the new site or hate it, that I tried my very best to push them in the right direction. I was very clear about what I thought they should do and told them so. Obviously they didn't agree with me. I just wish that not agreeing with me didn't translate to waiting nearly half a minute to read the news.

P.S. Would you like your very own copy of the new catstevens.com? Since it's just a Flash file you can download and save it to your computer. Right (or control-click) here and choose save. Then take the saved Flash file and drop it in your browser window. Fun for the whole family!

P.P.S. I never tried this on Windows, but I assume it should work the same as on my Mac.

P.P.P.S. That link is to their site, not dashing.com. I'm not hosting that file, just pointing you to it.

P.P.P.P.S. This could go on forever.

P.P.P.P.P.S. Alright, that's enough! Stop it!

7 results found

1 2 >>