Thursday, March 11, 2010

Migrate from Wordpress to Blogger

I've just finished moving my blog from Wordpress to Blogger.  The domain name has even changed to http://blog.sethladd.com to reflect my continued efforts to link my digital assets to my Name as Brand.

While Wordpress is an excellent blogging platform, their free offerings at Wordpress.com left me wanting more.  You are unable to run any Javascript widgets or code at wordpress.com.  This means you can't run Google Analytics or Google AdSense.  Wordpress.com also requires you to pay to configure a custom domain name for you blog.  Granted, it's only $10 a year, but if I can get everything I want or need for free, then I'll go that route.

The Blogger platform is a natural fit.  They offer free hosting, free domain name configuration, and let you control the HTML templates and insert Javascript.  They have lots of widgets ready to go, as well.  Blogger makes it easy to monetize your blog, too.  I was sold, it's off to Blogger!

Converting a Wordpress blog to a Blogger blog isn't actually that hard.  Wordpress lets you export, and Blogger lets you import.  The issue, however, is that the two platforms use different file formats.  As luck would have it, someone wrote a Google App Engine application to convert from Wordpress to Blogger.  I tried it, and it worked great for me!

The main issue, though, is that Wordpress and Blogger use different permalink (aka slug) schemes.  That is, the format for generating the permalink URI is different.  This makes a clean transition very difficult.

Being the good web citizen that I am, I wanted to try to keep all of my old links working.  I have some nice PageRank scores for a few of my posts, and I'd hate to simply destroy that content.  Therefore, I wanted to configure the appropriate HTTP Redirects to help users and search engines make the transition.

My first step was to configure Apache, my web server, to redirect users from the old blog to the new blog.  I changed the CNAME for my old blog domain name to point to an Apache I control (instead of wordpress.com).

The following is the Apache Virtual Host file used to redirect:



(btw, if you are reading this in a feed reader, I'm sorry you can't see the above embedded javascript snippet)

You can see that I am listening at the address which used to host my blog, and redirecting over to the new blog address. I make use of the awesome Apache mod_rewrite to handle the redirects. I also let user agents know if a resource is Gone, when I know there is no equivalent between Wordpress and Blogger.

You'll also notice the ErrorDocument line. This is the catch all handler, performing the bulk of the work. If the Virtual Host encounters a URI it doesn't know what to do with, it will ask the redirect-to-blogger.php script.



The above PHP code isn't the best in the world, but it attempts to convert Wordpress permalinks into Blogger permalinks. My tests show that for my modest collection of posts, it covers most of the cases.

I'm redirecting with an HTTP response of 301, which means the resource has permanently moved to a new location. This will hopefully tell user agents that they should no longer check the old link.

While Wordpress has more polish, the Blogger platform is very configurable and lends itself to easy monetization. I hope the work put into the redirects pays off, and search engines and people can continue to find both new and old posts.

See you on Blogger!

Tuesday, March 9, 2010

Calculating the nth Term of a Cartesian Product

I recently had to calculate the nth term for a Cartesian Product. I wanted to avoid generating the entire Cartesian Product in order to jump to the nth term. I wanted a way to derive the nth term.

For example, let's say I have two arrays:

a = [
  [1,2,3],
  [4,5]
]


The Cartesian Product of the above two arrays can be:

[[1, 4], [1, 5], [2, 4], [2, 5], [3, 4], [3, 5]]


Now, when I ask for the 3rd term of the above cartesian product, I want to receive [3,4]. Again, I want to do this without calculating the entire set.

My solution is below:

def combo(arrays, num)
  arrays.map do |a|
    v = a[num % a.length]
    num /= a.length
    v
  end
end


Example:

term = combo(a, 2)
puts term.inspect
# [2,4]


The next trick is to turn [2,4] back into 2.

Suggestions for how to improve this?

Friday, November 6, 2009

Aloha on Rails Debrief

Aloha,

I wanted to drop some knowledge in the hopes that it might help others with their own conference. Here's
what I learned from putting on Aloha on Rails:

* People wait until the last minute to sign up. I thought I knew what
this meant, but it's quite literal. Certainly, people signed up with
the early bird discounts, but I had signups all the way through the
end.

* I sent out marketing "care packages" to user groups (including
posters and hawaiian chocolates), however I don't get the sense this
actually helped with registrations.

* Oddly enough, a lot of my marketing was through Twitter.

* I did exchange sponsorship for advertising with Ruby Row, and I know
that some people signed up because of those ads.

* I invested a lot in hiring and working with a professional Design
firm (http://www.ocupop.com) This helped make the conference look
professional and legitimate. I can't stress the importance of having
a professional firm handle production of badges, banners, and
t-shirts.

* Food is very important, don't skimp on food.

* Strike a deal with your venue. Shop around, and use that as
leverage when negotiating with your venue. They will most certainly
give you discounts here or there. Don't be afraid to ask.

* Theme your conference around your location. The conference is both
a trip and an event. Work to help orient your attendees to your
location, give them tips on where to stay and certainly what to do.

* Find a local travel agency if possible. This offloads the work of
helping people find good deals on travel and activities.

* The half day two session, half day one session format seemed to
work. I didn't hear any complaints with that. It let us squeeze in a
few more talks, yet still run a lot of single track talks.

* Work to bring in speakers and topics that are new to Rails. This
adds spice and interest to the conference (e.g. we had Yahoo talk
about Hadoop)

* Pick A Theme!! This is what I should have done even more. With so
many conferences out there, you can't compete on speakers (since many
travel the conference circuit). Instead, compete on location and
theme. Revolve everything around your theme.

* We tried out an online card game, to help get people talking and for
fun. The game idea worked really well, but the online execution was
tough due to delayed emails from gmail. Next time we'll print the
cards out. In any case, build something into your back-channel. A
game is perfect for this. Our cards were Hawaiian themed. Again,
keep everything tied into a single theme.

* Your wireless mic's will run out of batteries! Keep lots of extra
batteries around (your hotel will provide them)

* Be sure to ask for Twitter names during registration.

* Be sure to ask for t-shirt size during registration (that was a FAIL
for me, oops!)

* Not sure why (economy, new conference, etc) but I landed sponsors
through word of mouth or by exchanging services. I had a Sponsorship
Prospectus, but that didn't help land any sponsors. So be prepared to
simply exchange things like advertising or work for sponsorship,
instead of simply money.

* Have a separate speaker registration line.

* 15 minute breaks between sessions are a minimum!!

* I could have bumped up the talk length to 45 minutes, up from 40,
which would have been a bit more standard. But I would have kept the
15 min breaks.

* Put out dessert in the middle of the afternoon, the hotel simply
delayed the dessert delivery from lunch. I didn't have to pay for a
afternoon snack.

* I learned that people are tired of black t-shirts.

* Don't give away books simply by pulling names out of a hat. It
takes too much of everyone's time. Devise a way to make the books a
prize and them give them out at the end.

* Run music during session breaks and during lunch. Theme it with
your conference.

* I spent approx 10 months working on the conference. It is non-trivial.

* We offered a grant for a local high school student. Use the
conference as an opportunity to reach out to the local community.
This is a perfect example of how to get a sponsor (as they will want
to sponsor the grant)

There's a lot more, but that's a good start. Feel free to email me
with follow up questions.

Thanks to everyone who has put on a regional Rails conference before
Aloha on Rails. You provided the inspiration. It's a great model and
I hope to see it continue!

Mahalo,
Seth

ps if you are interested in running your own regional Rails conference, let me know and we can invite you to the Regional RubyConf Organizers Google Group.

Featured TechHui Techie for November

Aloha! I'm humbled to be November's Featured Techie on TechHui, the Hawaii Technology Community.

Thanks to Alex for the interview, and to Dan for putting together TechHui. It's great to see our island foster a vibrant community.

Tuesday, May 5, 2009

Producing Aloha on Rails, The Hawaii Ruby on Rails and Web Development Conference

I love Ruby on Rails, I love bringing people together to talk about web development and engineering, and I love Hawaii. I wanted to do something amazing, something big, that could bring Ruby on Rails to Hawaii in style and share the Aloha of our Islands with the Rails and Web Development communities. I'm proud to announce that I am organizing and producing Aloha on Rails, the Hawaii Ruby on Rails and Web Development Conference. The conference will take place October 5-6, 2009 at the beautiful Marriott Waikiki on Oahu.


The Aloha on Rails Conference is the premier destination event for Ruby on Rails and Web Development. This unique, two day event unites the community’s top speakers and talent with motivated and excited attendees for an unforgettable conference in beautiful Hawaii. Two full days of informative and timely sessions covering Ruby on Rails and the future of web application engineering. The sessions are not simply blog posts, but will be full of wisdom, experience, lessons learned, war stories, and panel discussions, discussions, and most importantly debate.


In producing this event, it was very important to me to organize an itinerary that appealed to all web developers, not just those loyal to Ruby on Rails. I believe the Rails community has a lot to share and teach, but it can listen, too. A successful conference, in my mind, is one that truly generates thought provoking debate. One way to ensure this is to seed the pool with differing view points. A healthy discussion benefits everyone. To this end we are bringing in speakers that will address a wide range of issues and topics relevant to all web developers that are motivated and take their craft seriously (but know how to enjoy it.) The conference is certainly centered around Rails, but will extend outwards to topics such as Erlang, business models, Map Reduce, JRuby, testing, and simplicity.

Hosting the conference in Hawaii is a gutsy move, I know. Convincing people that it's very affordable to get out here is not easy. Luckily, due to the current economic situation, it's actually cheaper to fly and stay in Hawaii than it's ever been (factoring in inflation.) You'll be amazed at the deals the airlines and hotels are cutting to get you out here. True, a lot of the deals only reach out through summer, but nothing indicates these deals will stop any time soon. Hawaii almost sells itself, which helps, and who doesn't want to come out to Hawaii, geek out with some of the best talent in the community, relax, and recharge? We have a large list of hotels and travel tips on the Aloha on Rails Venue and Travel page.

I've been extremely fortunate and humbled to get some amazing speakers to come out for Aloha on Rails. For instance, Chad Fowler will present the keynote. Other speakers currently booked include Obie Fernandez, Charles Nutter, Gregg Pollack, Anthony Eden, Tim Dysinger, Desi McAdam, Scott Chacon, Giles Bowkett, and Jeremy McAnally. This list is going to grow very quickly, so keep an eye on the Aloha on Rails Speaker List.

The Call for Participation is now open and runs through July, so please submit a talk proposal. There's still time and room for your presentation!

There are numerous Sponsorship Packages available, at many different levels. This is your chance to be associated with the premier destination event for Ruby on Rails and Web Development, and directly target and reach a captive, motivated audience of Rails and web developers, designers, team leads, and managers.

This conference a unique and exciting opportunity to learn, share, and immerse yourself in Rails and Web Development with other motivated and friendly attendees and speakers with enjoying beautiful Hawaii. I'm thrilled to be able to bring the Rails and Web Development communities to Hawaii.

Sunday, April 19, 2009

Ye Olde Scala Presentation to Honolulu Coders

I presented the wonderfully named "Scala: Java, Erlang, and Ruby’s Hot Three Way Love Child" Scala presentation to the Honolulu Coders back in 2007. I went looking for the actual presentation online, and I'm not sure I ever posted it.

I had a brief fling with Scala as I was looking for multi-core friendly environments to build data processing frameworks. I came away being very impressed and look forward to deploying Scala in a future project. After Erlang and Scala, I started programming in a functional style back over in my Ruby code. I consider the experiments a win for that fact along.

This post is to prove that I knew Scala before it was cool. :P

Sunday, April 12, 2009

Extending Hadoop Pig for Hierarchical Data

I've been playing with Hadoop Pig lately, and having a fun time.  Pig is an easy to use language for writing Map Reduce jobs against Hadoop.

Our data is very hierarchical, and we calculate a lot of aggregates for self nodes, their children nodes, and self plus children.  We have a few tricks up our sleeves for SQL for handling these types of aggregates, but of course with Map Reduce an entirely new way of thinking is required.

Luckily, Pig allows for easily created User Defined Functions (UDFs) that extend the Pig language.  I was able to take an existing Pig UDF, TOKENIZE, and alter it to suite my needs.

Specifically, our data looks like this:

111,/A/B/C
222,/A/B
333,/A/B/C


We need to answer questions such as "How many records for A and all of its children?" In this case, the answer is three. We also need to answer "How many records for just A?" which is zero, or "for just C?" which is two.

Our strategy is to take the path (eg /A/B/C) and split it into all the different paths contained within. For example, /A/B/C can be split into:

  • /A
  • /A/B
  • /A/B/C
Now, we can take the original record (eg 111) and attribute it to all three paths that stem from the original /A/B/C. Once we have all paths, we can perform aggregate calculates the way Map Reduce wants to (which basically is sorted (grouped by) and then counted or summed). To see how this works, simply get the source code from Pig, look for the TOKENIZE class. Below are my modifications:

@Override
public DataBag exec(Tuple input) throws IOException {
try {
DataBag output = mBagFactory.newDefaultBag();
Object o = input.get(0);
if (!(o instanceof String)) {
int errCode = 2114;
String msg = "Expected input to be chararray, but" +
" got " + o.getClass().getName();
throw new ExecException(msg, errCode, PigException.BUG);
}
StringTokenizer tok = new StringTokenizer((String)o, (String)input.get(1), false);
StringBuilder sb = new StringBuilder();
while (tok.hasMoreTokens()) {
sb.append((String)input.get(1));
sb.append(tok.nextToken());
output.add(mTupleFactory.newTuple(sb.toString()));
}
return output;
} catch (ExecException ee) {
throw ee;
}
}


The end result now looks like this:

111,/A
111,/A/B
111,/A/B/C
222,/A
222,/A/B
333,/A
333,/A/B
333,/A/B/C


To learn more about writing your own Pig UDFs, consult the Pig UDF Manual.