Jul 17 2008

Introducing Ruby PostRank 0.5 (Beta)

Categories: Programming
Tags: ,

So, the guys over at AideRSS released a REST service for their PostRank API. The new API, at PostRank.com, provides access to some interesting data.

It’s fun to see how you rank up against other sites (although, I rank pretty low, heh).

Anyway, back on track, I’ve created a Ruby wrapper around the API that people will hopefully find useful. I’ve currently tagged it as a 0.5 beta release until I can get some feedback on if the API is right for other people as well. (Plus, I know I want to change the Exception handling at some point so there will be changes before a 1.0.)

You can grab the postrank-0.5.gem or install it through the GitHub gem server by entering:

gem sources -a http://gems.github.com
sudo gem install dj2-postrank

Or, if you want to can grab the code from GitHub and build it yourself.

If you find any problems, have any suggestions or patches, you can file them on the LightHouse project page.

For a quick example of the API, I present the following:

!/usr/bin/env ruby

require 'rubygems'
require 'postrank'

include PostRank

server = Server.new("com.everburning")
eb = server.feed("http://everburning.com")

puts "The GREAT everburning feeds"
eb.entries(:level => Level::GREAT).each do |entry|
  puts entry
end

puts "\nThe top 5 posts in the last week on everburing"
eb.top_posts(:period => Period::WEEK).each do |entry|
  puts "#{entry.title} -- #{entry.post_rank} -- #{entry.post_rank_color}"
end

puts "\nGet thematic PostRanked items"
server.post_rank(["http://flickr.com/photos/14009462@N00/2654539960/",
                  "http://www.flickr.com/photos/21418584@N07/2447928272/",
                  "http://www.flickr.com/photos/pilou/2655293624/"]).each do |entry|
  puts entry
end

puts "\nGet PostRanked items"
server.post_rank(['http://everburning.com/news/on-recent-media/',
                  'http://everburning.com/news/californication/',
                  'http://everburning.com/news/the-weary-traveler/'],
            :feeds => [eb]).each do |entry|
  puts entry
end

Running it you’ll see something similar too:

Rei:ruby-postrank dj2$ ruby examples/simple_example.rb
The GREAT everburning feeds
http://everburning.com/news/the-weary-traveler/ -- Post rank: 10.0
http://everburning.com/news/book-review-the-mirrored-heavens/ -- Post rank: 8.0
http://everburning.com/news/the-incredible-hulk/ -- Post rank: 10.0
http://everburning.com/news/kung-fu-panda/ -- Post rank: 10.0
http://everburning.com/news/im-on-the-intertubes/ -- Post rank: 10.0
http://everburning.com/news/and-in-recent-travels/ -- Post rank: 8.0
http://everburning.com/news/the-chronicles-of-narnia-prince-caspian/ -- Post rank: 8.0
http://everburning.com/news/going-fullscreen-with-medium/ -- Post rank: 8.0

The top 5 posts in the last week on everburing
On recent media -- 1.0 -- #ffe08e

Get thematic PostRanked items
http://flickr.com/photos/14009462@N00/2654539960/ -- Post rank: 1.0
http://www.flickr.com/photos/21418584@N07/2447928272/ -- Post rank: 1.0
http://www.flickr.com/photos/pilou/2655293624/ -- Post rank: 5.0

Get PostRanked items
http://everburning.com/news/on-recent-media/ -- Post rank: 1.0
http://everburning.com/news/californication/ -- Post rank: 1.0
http://everburning.com/news/the-weary-traveler/ -- Post rank: 5.0
Rei:ruby-postrank dj2$

There you go. Grab the gem, whip up some Ruby, and let’s see how you can use your PostRank information.


Jul 10 2008

On recent media

I’ve fallen a bit behind in recent months with the blog. Surprise surprise. Anyway, I’ve been traveling back and forth to Seattle a few times in the intervening days and have had a chance to consume some media. Instead of individual posts I’m just going to lump it all together.

First up, I purchased a copy of RubyCocoa in beta book form. I read through what’s currently available in about a day. Well written, easy to follow and a really interesting topic. I’m waiting impatiently for the next beta release so I can get some more of that Ruby + Cocoa goodness. (Well, besides doing a bit of ruby cocoa programming when I get time.)

Next up, for those long flights, I discovered the magic of screencasts. I purchased three series of these by The Pragmatic Programmers. The list of all screen casts can be found in their Screencasts section.

I grabbed the current videos for: Creating a compelling interface with core animation, Everyday Active Record and The Ruby object model and meta-programming.

As I suspected, it’s best to watch from the start even if you know the stuff they’re talking about. Makes it easier to follow along with the examples in the later versions. All three of these series are well written, well produced and, overall, well done. I’m going to be keeping up with them as they go along.

Wizards released Dragon #364 and Dungeon #155 as PDF downloads. I’d read a few of the articles over the month but I must say, both of these downloads were really well done. Lots of interesting information, well laid out, well written. Both turned out to be really good reads.

In terms of movies, I managed to keep my plane movie time down. One full length and ten minutes of another. The full length was the new Bank Job movie. This one was actually pretty good, Stacy would probably hate it, but it’s good for a few hours on an airplane. The second was 10,000 BC. I started this on a lark and thankfully the plane was landing 10 minutes later so I didn’t have to watch any more. Sweet god, talk about wooden. The mammoths looked cool, but that’s about all I’ll give it.


May 28 2008

Tech Book :: The Algorithm Design Manual

I do a lot of programming in my spare time. I enjoy programming so that kind of makes sense. During University we had to take courses in algorithm design. At the time I wasn’t really into it but after spending a few years in the field, as it were, I’ve grown a fondness for designing fast, efficient and, in some cases, sexy algorithms.

To that end, I picked up a copy of The Algorithm Design Manual which I’d heard a few people mention as being a good book. I have to say, I agree with them.

This book works really well. The first half is a discussion of different types of algorithms and contains war stories which discuss actual instances where the author needed to call upon the previous topics. The last half the book is a reference manual of algorithms. These can come in quite handy when you’re looking for information on a specific topic.

I found it quite easy to sit down and read through the first half the book. Although, I admit, dynamic programming and backtracking still trips me up. The author has a writting style that works. As a bonus the book comes with a CD containing the information in the book. Much easier to search and carry around with you. A great addition by whoever thought it up.

All in all, if you do programming work this is a good book to read.


May 12 2008

Tech Book :: Core Animation for OS X

Categories: Books, Programming
Tags:

I ordered a copy of Core Animation for OS X about a week ago. I ordered both the PDF and print book version (which should arrive when it’s actually published). I must say, I really like the Beta Book program from the Pragmatic Programmers guys.

Anyway, I finished reading the book just before leaving for Seattle and I must say, I quite enjoyed it. It’s well written and everything seems to have made sense. There are really good introductions to transitions and keyframe animations in there. If you’re interested in doing any work with Core Animation and are looking for a good introduction you might want to pick this one up.

Hopefully I’ll be able to leverage off of Core Animation for OS X to start doing some cool Core Animation work. We’ll see how it goes.


May 12 2008

Cocoa, Core Animation, Text Size, a Lost 2 Hours

Categories: Programming
Tags: ,

So, as you can tell by the title I’ve been struggling with a font size issue when working for Core Animation. I’ve been trying to call [NSFont boldSystemFontOfSize:144.0f] to get a font of a given size and then setting it on the layer through the font property.

This hasn’t been working. I’ve been struggling, using other ways to query the font. Nothing was working.

Eventually, I figured out, if you’re working with a CALayer you have to set the size through the fontSize property. If you don’t set this property you seem to always get the default font size of 36.0.

I also discovered that you can pass a font name to the font property. So, doing something like layer.font = @"Helvetica" works.


« Previous PageNext Page »