Friday, November 4, 2011

Getting delayed_job to Work with Rbenv and Mongoid

Rbenv is another option that we can use besides RVM to be able to manage different Ruby versions.  I have always struggled getting RVM to manage everything right, from gemsets to bundles. Since Bundler manages your gems and dependencies for you, gemsets are just an extra layer that caused me a bunch of problems.  So I switched to Rbenv for my production environment.  All went well except delayed_job. It would work just fine with rake jobs:work, but script/delayed_job start would start just fine, but wouldn't pull anything from the database. I am using Mongoid, so I assumed that the script was defaulting to the sqlite database.

Well, I looked at the script and noticed that their was a shebang at the top mentioning ruby (#!/usr/bin/env ruby). I just changed it from ruby to ruby-local-exec and it started working again! This made the script run in the bundled environment and pick up on that fact that I am using Mongoid instead of sqlite. Hope this helps someone.

Tuesday, October 25, 2011

Another Rails Editor and User Authentication

Just another update for any of my past students following along.  Redcar seems to have won over all of the students as their favorite Rails editor.  To install it, you just type "gem install redcar".  It looks pretty promising.  The students found it on their own, and preferred it to Sublime Text Edit, mostly because it's free and doesn't ask you to pay for it every 10 minutes.

Also, we have been working on developing authentication systems, and the following videos are videos that I have been using for the class.


Migrating from Wordpress to Blogger

Here are some detailed instructions on how I moved my blog from Wordpress to Blogger, including how to get my old Wordpress links to redirect to my new blogger style links.  I would like to thank Jesse Stay for his blog post that convinced me to switch and gave me a head start in the process.  After the switch, I also learned that Google+ will integrate with Blogger, so that is even more of an incentive.

This should work with a self-hosted Wordpress blog and a blog.  If you don't have your own domain, you can transfer your blog to Blogger, but you will not be able to preserve and redirect your old links.

Before you begin, you might want to use OpenDNS for your DNS on your local machine. You can refresh the DNS cache at any time, so you can see your changes immediately instead of waiting up to 2 days for the DNS cache to expire. Plus using OpenDNS has many benefits. Instruction for configuring your local machine to use OpenDNS can be found here.

Also, if you want to redirect your old Wordpress style URL's to your new Blogger style URL's you will need a server somewhere that will handle the redirections.  If you don't have one, you can use Heroku for free.  I will show you how to set it up, but you will need Git, and Ruby installed on your machine.  Mac users already have ruby installed (they might need to install x-code from the app-store), and they can get git from here.  I also recommend installing RVM to install Ruby version 1.9.2. Window's users can get Ruby and Git (and a lot of extras) from You only need Ruby, Git, and Bundler, so you don't have to install all of the packages. I don't have a Windows machine to try it out, so this is just my best guess.

We will be doing the following steps to make the transfer from Wordpress to Blogger:
  1. Exporting the posts and data out of Wordpress and importing them into Blogger.
  2. Configure Blogger to meet our needs.
  3. Set up a redirection server that will redirect Wordpress style links to Blogger style links.
  4. Transfer the domain from Wordpress to Blogger.
  5. Install Disqus comments (if you want to use it) on Blogger and migrate all of the discussions.
I organized the steps to reduce the amount of downtime your blog will face. You should be able to keep the blog up the full time, but your readers might not be able to comment until the DNS changes have fully propagated. Also, you will lose all of your Facebook likes and +1's, except on your main domain.  Facebook/Google will not follow your redirections and combine the old Likes/+1's with your new ones.  If this is unacceptable, then you will need to stay with Wordpress.

Exporting your posts from Wordpress and importing them into Blogger.
To export your Wordpress post and import them into Blogger just follow these instructions. My blog was less than 1MB, but if you have a bigger blog, you will have to download the converters and run them manually. More details on that process can be found here.

You should create a new Blogger blog, and don't worry about the URL if you have your own domain. Once it is up you can change the URL to the right domain. After you import your Blogger file, you should see all of your posts and comments. They will all be drafts, and you can select them all and publish them.

There are a few things that might be a lot of work after you complete this step. First of all, all the pictures will work, but only until you move your domain to Blogger. They are pointing to your Wordpress blog, so once your domain is moved over, they will stop working. You will need to get them off of your old blog and upload them to Blogger, or somehow host them on your redirection server. I didn't have many picutres, so I just uploaded them to Blogger, but I will describe how you can host them on the redirection server. Also, on Blogger, your urls will be missing words like "the", "a", and "with". Which will create a little bit more work down the road, but I'm not sure if you can do anything about that.

Configure Blogger
You can look at all of the settings.  I wouldn't set your domain until after you have the redirections in place. You can also take the time to edit the layout and add widgets to the side.  Make sure your happy with how it looks, so you will know if you want to continue or not. Your Wordpress blog should still be up. You can also add your Facebook like buttons I described in the previous post.  Don't install Disqus until after you have your redirections in place either.

Now is also a good time to follow these instructions to get your author picture in your search results.  You can also see Google's instructions as well.  What I did was create an About page and linked to it with a text widget (not the page's widget) that is included on all pages in my blog. I edited the HTML to include the a link with rel="author" in it. On the About page, I have a picture, short bio, and a link to my Google+ profile with rel="me". Make sure the Google+ link begins or ends with a +, or is a profile button, with rel="me" in the anchor tag (not rel="author").

Set up your redirections
To redirect your Wordpress style URL's to your new Blogger blog, you will need a server to handle the redirections. If you have an Apache server, you can use the rewrite mod to create the redirections. Below is a sample .htaccess file that I used to redirect my links.  You will need to customize it for your domain.  The redirection server needs to be a sub-domain of your domain. So if you host your blog at or, your redirection server needs to be (I used

Here is the .htaccess file I used before I thought about using Heroku.

The .htaccess file includes redirections for my author page, about page, categories, tags, the feed, and the posts.  In Blogger, there are just labels, so both categories and tags redirect to the label pages. I also had to add in some rules to redirect posts where Blogger didn't include words like "the" and "a" in the URL.  You will need to search for these and add in those redirections as well.

If you don't have a server to host the redirections (I migrated to ditch the server), you can use Heroku for free.  When I was trying out different blog solutions, I ran across toto and learned a little about Rack.  Since I develop in Rails, I really wanted to make toto work, but I couldn't easily migrate my posts. But I did learn enough to know that I could use Rack to redirect URL's. I created a simple Rack app that would redirect the URL's, and even host some static assets. You can use this app to redirect your URL's and even host your pictures from Wordpress.

I uploaded my app onto Github.  If you want to use it, just clone it and change the file. Again, you will need Git, Ruby, and Bundler installed on your machine. You can then use Heroku to host your redirection server.  Here is my file that you will need to change:
You should change the root to your domain, and then change the author page. You can remove my specific post redirections and add in your own.

To pull the code to your machine, in the terminal or commad prompt type:
git clone

 Then you should have a wp2blogger-redirector directory.  Change into the directory and edit the file.  You can test it by typing in the terminal or command prompt: rackup.  This will start the server on your local machine.  Then in a browser goto http://localhost:9292. You should see "Nothing Here". You can then type the Wordpress URL after the :9292 (like http://localhost:9292/2011/09/blog-post/) and you should be redirected to the right URL (  As you fix things, remember that your browser will cache the redirections, so you need to clear the browser cache if something goes wrong and you want to retest it.  Also, every time you make a change to, you will have to kill the server and start it up again (Control-C, and then type rackup again), or install the shotgun gem ("gem install shotgun").  Then you can launch the server by typing: shotgun.  It will start the server on 9393 instead of 9292, and you shouldn't need to restart it after changing the file (but if things aren't working you might want to try restarting it before you pull all your hair out).

You can also add in your old pictures by copying the /wp-content/uploads directory into the public directory. You will also need to add in the /wp-content to be served statically. To do this change line 3 in the file to be:
use Rack::Static, :urls => ['/index.html', '/favicon.ico', '/wp-content'], :root => 'public'

You can also test to make sure the server serves your old pictures. Heroku will only let you use 100MB in disk space.  So you might need to delete some pictures. Wordpress does store several sizes of pictures, and you can remove all of the sizes you don't use on your blog.

After you get the redirection server working locally, you can push it to Heroku.

To commit the changes locally, type:
git add -A
git commit -m "some message"

Then create an account on Heroku. You can follow these instructions to launch your server on Heroku.  Don't worry about bootstraping your database, you don't have one. In summary type the following:
heroku create
git push heroku master

If everything worked your redirection server should be live. Test it by typing heroku open, and you should see it in your browser. Remember the URL, because you will need it when changing your DNS.

Migrate your domain to blogger
Now you are ready to migrate your domain.  First create a CNAME record in your DNS to point to Heroku, and follow these instructions for adding the subdomain to your Heroku app (you are probably not on the Cedar stack).  You only need to add one subdomain, not your full site.    While you are at it, you can now point your main domain (or a subdomain) at your new blog and edit your new blog's settings to add your domain.  It's under Settings -> Basic. You will also want to add a missing files host, and put in "old" (if you used for the name of the host.  Blogger has a link with instructions on how to set your domain name to point to Blogger that should appear as your change your settings.

If you are using OpenDNS, you can go here, and check their cache. After you check, you can request a cache refresh and it will update the DNS settings from your registrar. (It might take a couple of hours for your registrar to update it's DNS servers.) You will also have to refresh your local DNS cache by rebooting your machine.  Your domain should be pointing to your new blog. Remember, it takes a couple of days for the DNS changes to propagate to everyone, but with OpenDNS you can try it a lot faster.  You should leave your old blog up for at least a few days, so if your readers haven't gotten the DNS update, they will still see your old blog.  You might want to disable comments, because they will not migrate over to your new blog.

Migrate Disqus comments
You can now install Disqus on your Blogger blog, by going to, logging in, clicking on your blog, and then clicking the install tab.  Click on blogger, and it will install it to your blog. You will then need to edit your layout in Blogger, to add the widget (preferably on the bottom). You should see Disqus take over for your comments, but all of your old comments will be gone.  Now, back in Disqus, go to tools, migrate threads.  You can try the redirect crawler, if your redirects are all set up. You can also upload a URL map.  Once done, your comments should re-appear.

Unfortunately, your likes and +1's will be reset. You should now be up and ready to to go. Hopefully, Google+ integration, and a free hosting solution will make all the work worth it. If you have any questions, just leave them in the comments.

Sunday, October 23, 2011

I Moved to Blogger

Since it has been another year, it was time for me to reanalyze how I am hosting this blog. A little while ago, I read a blog post by Jesse Stay about switching to Blogger. What I remembered the most was that he has able to host his blog on Blogger for free. Since I don't use this blog much, I don't feel like it is worth it to pay too much for hosting.  I have been hosting it with a self-hosted Wordpress install, and as Jesse points out, it was too time consuming keeping it up to date and running smoothly.  Without the super cache plugin set up and configured correctly, I was getting up to 3 seconds per page load which would never survive a high traffic day. Even with the cache setup correctly, I still even doubted that my blog would withstand a heavy traffic day.

I could have moved my blog to, but that comes with ads and additional fees that Jesse details in his blog post. Some other options I looked at were using Github pages and using toto hosted by Heroku. I really like the idea of having a git repository being the source for my blog, but I couldn't format my old posts in the markdown, and none of the scripts translated things over correctly. It ended up being too much effort to transfer my old blog posts over so decided to try blogger. (I was really hoping to edit my posts with a plan old text editor too.)

In less than 5 minutes, I had all of my posts and comments transfered over to Blogger, so I was sold. It did take a little while to configure things the way I wanted, and then I had to redirect my old Wordpress style links to my new blogger links. I plan on doing a post in the near future describing the process of transferring my Wordpress blog to Blogger (including how to redirect your links), so stay turned.

I do want to explain how I set up some features (usually supplied by a plugin) that I had on Wordpress on Blogger.  First of all, I have been using Disqus as my comment engine on my Wordpress blog.  As you post comments on a lot of different sites, there isn't a way to aggregate all of your comments together.  Disqus lets your readers create a single profile they can use to comment on every site that uses Disqus, that way all of your users' comments can be aggregated together. It also allows users to use their Facebook or Twitter accounts to comment.  Lots of sites are using it, including newspapers and Foxnews.

Disqus installation is easy. Create an account on Disqus, then add a new site. Fill in your url and look through all the settings to make sure it's setup the way you want. Import your current comments by going to Tools -> Import/Export. Then click on the install tab and click on Blogger. It will ask you to select your blog. Once you finished with that, you will have a Disqus widget. Add it to your layout (preferably on the bottom part).  You should see Disqus take over for your comments.

The next feature is Feedburner, which will optimize your feed for each of your subscribers.  Your feed is what Google Reader and other news/feed readers use to know when your blog has been updated. Since FeedBurner is owned by Google, installation is easy. Go to and create an account. Then burn your feed by putting in your URL (make sure you select your posts' feed and not your comments' feeds).  It will also let you assign your feed a url. Then, go to your Blogger settings, under other.  You will see a "Post Feed Redirect URL" setting. Paste in your Feedburner feed URL. Now your subscribers should be getting their feeds from Feedburner.  To test it go to (or if you have your own domain).  You should be redirected to Feedburner and see your posts.

Finally, I wanted to add a Facebook like button to my posts. By default, I already had the +1 button (Google+) and a Twitter button but no Facebook button. To get a Facebook like button follow these instructions. There are some old instructions that don't work for the current layouts so be careful.  If your like count is strangely high (around 16,000 likes), than your readers will be liking some page called post.url instead of your post!

Sorry for the long post, but I hope the information is helpful.

Wednesday, September 21, 2011

Rails Editors and the Command Line

One of the first questions you will need to answer when starting with Ruby on Rails, is what editor should you use.  For the mac, it has been TextMate.  I haven't really liked the IDE's for Ruby on Rails (although I never really used them).  So, I needed to find a good text editor for Windows.  Turns out Sublime Text looks like the best one I was able to find.  It works in Windows, Mac, and in Linux.  It is a lot like TextMate, and might even surpass it in features.  I almost switched from TextMate to Sublime, but I didn't because the snippets and plugins aren't quite up to par with TextMate's.  However, if TextMate 2 doesn't come out soon, Sublime will probably surpass it soon.  Must have features are snippets, and a sidebar file browser.  Both TextMate and Sublime have them.  (Of  course if you're a vi or emacs pro, than stick with it.  None of my students are.)  My only question is, should my students pay for it?  I told them they should when they start making money using it.

I also notice that none of my students had any command line experience.  Thinking about it, I had to learn the command line (in Linux) in a Software Engineering class that made us learn Linux and C++ pretty much on our own and then write two substantial programs in C++.  Although frustrating at times, it turned out to be a very good class.  We never teach the command line in any of our classes.  I got a big blank stare when I mentioned make. The downside to only teaching with IDE's.  Luckily, I need to revamp my Operating Systems class.  Maybe I will make it a lot like my Software Engineering class.

See this post for more information about editors:

Thursday, September 15, 2011

Getting Rails

I am teaching a new class this semester called advanced web application development. The main topic: Ruby on Rails.  A lot of students who have either graduated or couldn't take the course for some other reason wanted to me to make videos for them.  I won't have time for videos, but I will post all the material I use here.

The first step is getting Rails installed.  Most of my students have Windows machines, so the best place to get Rails for Windows would be (I haven't really searched too long, but this seem sufficient).  I wouldn't worry about installing the SQL Server stuff unless you know you are going to use it.  For now, just stick with SQL lite.  You will want Git.  The only downside to all of this is that there isn't RVM, which allows you to switch between Ruby versions and create gemsets.  During the semester, all my student will be using Ruby version 1.9.2, so it won't be necessary for the class.

The next step is to create your first application.  The video on walks you through your first application.  I plan on doing a similar demo in class also using the scaffolding.  After, I will walk students through the code, starting at the routes.rb, then going to the controller, and then the model and view.

Wednesday, March 23, 2011

Kynetx App Store

Kynetx just launched an App Store to be able to find and manage all of your Kynetx apps. Instead of installing a bunch of different browser extension, you can now just install one. It will keep track of all of your Kynetx apps for you.  If you have already install one of my Kynetx apps it should still be working for you.  (If not comment or email me.)  I recommend uninstalling all of the Kynetx App extensions or browser add-ons, and then go to  From there you can browser various extensions.  Once you install your first app, you will be directed to download and install the Kynetx add-on. Once installed, you can install any Kynetx app without the need to install any more extensions.

Now you can get my apps from here:

AmaCraigBay with Google Products


Happy App Hunting!

PS.  I want to add icons to the listings in the Kynetx app store.  If you want to help out let me know!


Friday, January 28, 2011

Initial thoughts on my iPad

I know that many reviews have been written about the iPad, so I will keep this short. I just wanted to record my thoughts after owning the iPad for about a week.

I never even thought about buying an iPad because I didn't think it would fit into my work flow. My MacBook pro docks as a desktop, which I enjoy because I can take my work wherever I go. My Android phone does all things mobile. I just didn't see where an iPad would fit in. Now that I won a free iPad and used it for a week, I still don't think I would buy one. However, I decided that it is useful enough to not be tempted to sell it.

Here is what I like:
1) Netflix (and other videos). It is really nice to watch movies on it.
2) It is a lot easier to write emails on my iPad than it is pull out my laptop or type them on my phone. Now I can be more responsive to my students' emails while I am not at my office.
3) I will actually follow links on twitter now. The Twitter app makes it easy to do. When I am at work I feel too busy to even check twitter, and it's too slow on my phone to follow a link, unless it really sparks my interest.

Here is what I don't like (I'm easy to please so there is only one complaint.) I still want it to be a computer, and Apple doesn't. I would like a documents folder. I find it frustrating that I have to open an app and then my document. Can't I just click on my document, like I always do on my computer? A USB port would also be nice. I just feel like the iPad goes out of it way to limit what I can do. I think that main reason is so that people will not trade their laptops for iPads. I know the iPad can do more, but Apple won't let it.

Saturday, January 22, 2011

My Facebook News Feed

Take control over your Facebook news feed. Facebook uses a secret formula to decide who makes it into your news feed. Unfortunately, this formula prefers very active Facebook users over less active ones. (Look at the link for some other tips and trick to get you on more of your friends' news feeds.) Anyway, this always bugged me a little bit, so I decided to fix it for the next Kynetx developer contest.

Faces and names blacked out for privacy.

There are a few friends that I would really like to know about and these friends are not the most avid Facebook users. Therefore, they don't show up on my news feed very often. When I look at their profile, I realized I missed some big news. To make sure I don't miss their posts, I wrote a Kynetx app to display the most recent post from everyone in a Friend List. It will display it above your regular news feed. You can change the list it displays by selecting a different list at the top.

If you don't know, you can organize you friends into lists. Just click on friends on the left, then click the edit friends button. You might want to keep this list private, or your friends might find it and realize that you are not as interested in them as they think you should be.

I suggest that you keep your list to about 5 to 10 people, or else it will take a long time to load. Hopefully I can find a way to speed it up. If you really want a longer list, just read your "filtered" news feed for a little bit, and it should show up after about a minute or two. If you have too big of a list than it might time out and never return the results. If this happens, delete your cookies from It is still a little rough around the edges especially since I have only spent one evening on it. I hope to improve it as I find time. Here the browser extensions you can download and install to use the app.  You need to accept cookies (even 3rd party cookies) from or you cannot authorize the app with facebook.

Firefox, Chrome, Internet Explorer

If you don't want to install an extension, you can use this bookmarklet. Drag the link below to your bookmark toolbar and click on it when you want your personalized news feed to appear. When it says to refresh the page, you will have to click the bookmarklet again after you refresh the page.


Here is a list of currently known bugs. I will try to fix them as I have time.

  • Some posts don't display correctly, especially your friends who don't give you permission to see their news feed. (I can't ever show you them, but I need to display a message that you can't see them.)

  • It won't show up on every news feed. There are a lot of different URL's that display your news feed, and I haven't found them all. If it doesn't show up, type in into your url, and it should show up there.

Wednesday, January 5, 2011

AmaCraigBay now with Google Products

I have updated AmaCraigBay to include Google Products.  If you already installed the browser plugin or bookmarklet, you don't need to do anything to get the update.  It should just start showing up.  Google products will include a lot more options to compare from, including stores like Walmart, Target, and KMart.

If you don't have it installed yet you can get them from my previous post.

There is a problem when you refine your search.  It will currently show the result from your first search after you refine your search.  If you want to get the refined results, go back to Amazon's home page, and then search again.  You can also click on a product and search from that page.  I am working on fixing it, and hopefully that will happen soon.

Thanks to Kynetx and YDN for making this so easy!