John Gardner Quote: 02/01/10

We must strive to reach that simplicity that lies beyond sophistication.

Posted in Quotes | Tagged productivity, quote, Quotes, simplicity, sophistication | Leave a comment

iCalendar and webcal subscription feed in Rails

I’ve been working on a project where I needed to have an iCalendar webcal subscription link. Webcal is a protocol that is recognized by applications that support the .ics iCal format (iCal, Outlook, etc) to subscribe to a feed of events. It’s essentially a RSS feed for calendaring applications. Thanks to the awesome iCalendar gem, adding this feature to my Rails app was pretty much a breeze. Here’s how to do it.

The first step is to install the gem and set it up in your Rails app.

sudo gem install icalendar

Add this to your environment.rb file:

config.gem 'icalendar'

Now that you have the gem setup, you just need to add the code to your controller. Say we have a method called ‘feed’ that generates the webcal feed for our events. We could have something setup like this:

def feed @user = User.find_by_feed(params[:feed]) @events = Events.find_by_user(@user) respond_to do |format| if @user.valid? format.ics { render :text => self.generate_ical }
else format.ics { render :nothing => true, :status => :forbidden } end end end

Pretty simple so far. You’ll just want to create a new responder for the webcal and set to render text. That part is important. Next we have the method that actually generates the webcal feed, which uses the iCalendar gem.

def generate_ical cal = Icalendar::Calendar.new cal.custom_property("METHOD","PUBLISH")
@events.each do |e| event = Icalendar::Event.new event.start = e.start.strftime("%Y%m%dT%H%M%S") event.end = e.end.strftime("%Y%m%dT%H%M%S") event.summary = e.summary event.description = e.summary event.url = "http://yourwebsite.com" event.add_comment("More info at http://yourwebsite.com") cal.add event end headers['Content-Type'] = "text/calendar; charset=UTF-8" cal.publish cal.to_ical end

I implemented many of the available fields here, but you can check the gem’s docs for a full list of stuff you can add to an event. You can event setup things like alarms and todos.

It’s important here to set the method to publish, to set the content-type as a calendar format and to publish the calendar. Then, you need to return it in, basically, an iCal string to the feed method, which will actually serve it.

Now, to link up your fancy webcal feed, just add this in a view:

< %= link_to "iCal", {:controller => 'events', :action => 'feed', :feed => current_user.feed, :format => :ics, :only_path => false, :protocol => "webcal"} %>

This is really just using a link helper, but it’s important that you make sure the link is in the format: webcal://yourwebsite.com/events.ics. Of course, the helper can do this. By passing it a format parameter in the options hash you’ll get a .ics. To make sure the link is a webcal link, it’s important to pass the :only_path => false parameter first and then passing the helper the protocol parameter.

And that’s it. It’s pretty simple. Hope this helps you out. It turned out to be a really awesome feature for my app.

Update: If you’re running ruby 1.9.x, the iCalendar gem will not work properly. It seems to output invalid .ics files because it treats the strings as arrays. I’m not sure why, but I couldn’t find a workaround so I moved instead to the much newer ri_cal gem.

Posted in Code | Tagged ical, icalendar, rails, ruby on rails, webcal | 2 Comments

Aristotle Quote: 02/07/10

As the poet says of women, “Silence is a woman’s glory,” but this is not equally the glory of man.

Thanks to the ever-wonderful Brandy Ryan for sharing this with the world.

Posted in Quotes | Leave a comment

Ketchup

Ketchup is one of the most wonderful things known to man. It’s the king of condiments and goes great with almost everything. I absolutely love ketchup. I mean, I’m even a ketchup snob. I totally look down upon anyone who uses anything other than Heinz and people who refrigerate their ketchup. That’s almost as bad as screwing up homophones. Seriously, it’s one of my top 10 favorite things ever (next to sweet tea, of course).

So, naturally, I was really shocked when I heard there was a new ketchup packet. After all these years, I can’t believe they would go and change the classic, familiar ketchup packet. And then I saw this wonderful diagram and realized: this is going to change the world.

First of all, it’s triple the capacity — triple! For someone who routinely has to ask for more ketchup, this is a blessing. Secondly, it’s multi-functional: you can dip and squeeze! There’s no more need for those egregious tiny paper cups. These new packets mean serious business. And they didn’t make it small, either. The orifice through which dipping occurs is so big that almost everything I can think of will fit right in.

I am so super stoked for this. I think it might even be more revolutionary than the iPad — and that’s saying a lot.

Posted in News | 4 Comments

iPad

Yesterday Steve Jobs took the stage, and after triumphantly announcing impressive economic statistics, showcased a new device that everyone has been longing for: a device the internet predicted would revolutionize every industry under the sun and a device that Apple itself heralded as magical.

And so it came: the iPad.

The iPad is not unlike most Apple products that break into a new industry. When the first iPod was released, most received it negatively — “not another mp3 player, please.” But 240,000,000 units later, there’s no denying that the iPod changed the music industry. When the first iPhone was released, nearly everyone had something to complain about: no 3G, no GPS, no removable battery, and a closed ecosystem. And now, after 40,000,000 units, there’s no denying that Apple changed the mobile devices industry.

People hate the iPad. Even fanboys are complaining. About the name, the form factor, software and design bugs, even the concept — almost everyone who has a voice on the internet is claiming the iPad is a failure.

That’s absolutely balderdash. The iPad is the exact opposite of a failure. It’s exactly like the iPod and the iPhone: it’s Apple’s triumphant entrance into a new market, one that they will likely overtake. And here’s why: it is magical.

Looking at it from an engineer’s standpoint, it’s phenomenal that Apple was able to pack all that technology into such a form factor. It’s 0.5 inches thick and 10 inches wide. It packs an 802.11n WiFi chipset with 3G, GPS and a compass. It’s got probably the biggest fully-capacitive display ever mass-produced and it’s an IPS display, which means you can view it at virtually any angle.

What’s even more incredible is the Apple A4 chip. Clocking in at 1 GHz, this magical piece of silicon can decode full HD videos for ten hours — ten hours. To me, the engineer, the single biggest victory of the iPad is the A4 — it’s a technical masterpiece. If this is the same chip that they plan to put in the next iPhone, then no one stands a chance — it’s that incredible.

But it’s not just the hardware: the software is equally amazing. You might think that it’s just an oversized iPhone or iPod Touch — but that’s completely off base. The software has been completely reworked for the form factor. It’s elegant in a whole different way than the iPhone OS or OS X. It gets out of your way and just allows you to use the device — to experience it. It’s an OS imagined to do only basic personal computing — i.e., email, personal productivity, browsing, media functionality — using the most familiar input device known to humans.

If you look at it only from the standpoint of an engineer, the iPad is a truly magical device.

But the engineering triumph isn’t the biggest point of the iPad or why it’s going to be successful. The iPad is going to be successful because of the form factor and the targeted market. The biggest opponents of the iPad — the fanboys, geeks and professionals who rely on powerful computing — are exactly the market for which the iPad wasn’t intended. The iPad was intended for people like my mom and my uncle, both of whom are over 40 and completely technologically illiterate. But they use their iPhones with absolute ease and after a few short weeks were veritable power users, rivaling most geeks. This goes back to the brilliance of software: everyone knows how to point their finger and touch a screen. The interaction is natural. And so this target market — the casual user who just needs basic personal computing — is the exact market that the iPad will dominate. They don’t need full-powered OSes like Windows or OS X. They need the iPad, they just didn’t know it.

The other reason the iPad will succeed is because of developers. The same people who are complaining about the device are the same force that will create thousands of apps to be downloaded — and paid for — by millions of consumers. Because Apple didn’t just create another device, they created an entirely new platform. A new platform with more to offer than the iPhone.

The iPad is pure brilliance, so much that I’m not necessarily convinced that the iPad isn’t what Apple was working towards all along. It’s so hard to believe that when Apple was looking at the future they didn’t see the iPhone as just the first iteration of the iPad. It’s very clear now what Apple sees as the future of personal computing, and as the most powerful entity in the mobile device space, it’s almost entirely likely that this is exactly where the industry is going. And I’m not convinced that that is a bad thing — I’m actually convinced it’s a good thing.

The iPad is sexy, well thought out, well implemented and damn near perfect. Steve Jobs, the man who pontificates and perpetuates perfection, has done it again. Not once, not twice, but for the third time he has produced a device that will change and nearly create an entire industry. Because Apple isn’t gunning for their typical audience with the iPad; they’re trying to dominate a completely different sector they have yet to penetrate. The iPad is perfect, in the sense that the original iPhone was perfect, and it will succeed — we just don’t know it yet.

Posted in Article | Tagged apple, apple a4, ipad, steve jobs, thoughts | 1 Comment

Apache mod_ssl, Snow Leopard and Ruby on Rails via Passenger

Introduction

I’ve been working on a Ruby on Rails app recently that requires a little bit of ecommerce. Obviously, one of the first things I have to setup is an SSL to secure communication of sensitive customer data between my server and the credit card processor. I was able to snag a good deal and get a SSL with GoDaddy for $12.99 / year and set it up on my MediaTemple (dv) with relative ease. However, I first needed to test the app in development using SSL. I’ve been running Ruby on Rails via Passenger on my Mac OS X Snow Leopard with the help of the Passenger PrefPane and it’s been like a dream come true. If you’re doing Rails development on OS X, this is a must have. Continue reading

Posted in Code | Tagged apache, mac os x, mod_ssl, passenger, rails, ruby on rails, snow leopard, ssl | 3 Comments

Conan O’Brien Quote: 01/26/08

All I ask is one thing, and I’m asking this particularly of young people that watch: Please do not be cynical. I hate cynicism, for the record it’s my least favorite quality. It doesn’t lead anywhere. Nobody in life gets exactly what they thought they were going to get. But if you work really hard and you’re kind, amazing things will happen.

Posted in Quotes | Tagged Coco, Conan O'Brien, Cynicism, NBC, quote, Quotes, Tonight Show | Leave a comment

Steve Jobs Quote: 01/25/10

Apple, at the core, its core value, is that we believe that people with passion can change the world for the better.

Posted in Quotes | Tagged apple, passion, quote, Quotes, steve jobs | 1 Comment

Saints

I honestly never thought I’d live to see this day. The Saints are going to the Superbowl and I literally couldn’t be more proud of Brees and the team. Congratulations, boys — bring home the trophy!

Posted in News | Tagged Drew Brees, new orleans, Saints | 1 Comment

Conan O’Brien Quote: 01/25/10

“When I was a little boy, I remember watching ‘The Tonight Show with Johnny Carson’ and thinking, ‘Someday, I’m going to host that show for 7 months.’”

Posted in Quotes | Tagged Conan O'Brien, NBC, quote, Quotes, Tonight Show | Leave a comment