Software

Localtunnel Ruby Gem

Introduction

Sometimes you need to quickly host a web application from your local machine but need a public address for people to connect to. What do you do? Recently localtunnel, a Ruby Gem, was released that makes all of this easy.

Installation

To install, type: gem install localtunnel

Usage

  1. Open a terminal window.
  2. Type: localtunnel -k ~/.ssh/id_rsa.pub 3000. Of course, feel free to choose a different port.
  3. Send the newly created server address (example: http://3ufx.localtunnel.com) to whoever needs to connect to your local server.

TextExpander

For those of you using, TextExpander, I setup the “;tunnel” abbreviation to expand to:

localtunnel -k ~/.ssh/id_rsa.pub %fill:port%

Notes

There is a slight downside to using localtunnel and that is that it will clutter your ~/.ssh/known_hosts file with all those auto-generated host names. It would be nice if localtunnel performed a cleanup task to remove extraneous entries after use. Make sure to run the following command if this bothers you:

ssh-keygen -R 3ufx.localtunnel.com (replace 3ufx with whatever was generated for your session).

Conclusion

Overall, a handy piece of software and worth adding to your toolbox.

Sunday, April 1st, 2012 Software No Comments

Redmine on Heroku

redmine

Introduction

Redmine is open source software for project management. It comes complete with project management (of course), calendars, issue tracking, milestone/version planning, news syndication, wikis, forums, user and role management, etc. Built on top of Ruby and Rails, it make a compelling piece of software for small teams/startups that needs a quick and dirty project management solution.

The purpose of this post is to walk you through setting up Redmine on your local development box and remotely on a Heroku server.

Requirements

The following is required to setup Redmine and makes some assumptions about your familiarity with each.

  1. Mac OS X (Lion)- Ubuntu would be fine too (except for the HomeBrew specifics, of course).
  2. Homebrew - Automates your development environment setup needs.
  3. rbenv - RVM would be fine as well but, for the purposes of this post, I’ll stick with rbenv.
  4. Ruby 1.8.7-p357 - Use the latest patch for Ruby 1.8.7. Yeah, I know, no love for Ruby 1.9.x yet.
  5. Ruby on Rails 2.3.14 - Yeah, they don’t support Rails 3.x yet.
  6. Heroku - You’ll want the bamboo-ree-1.8.7 stack. Don’t worry, we’ll get to that in a sec.
  7. PostgreSQL - Using 9.1.2 at the time of this writing.

Local Setup

The following assumes a relatively fresh Ruby install (skip ahead if necessary). NOTE: I’m using Ruby Gems 1.6.2.

  1. Open a terminal window and start typing out the following commands.
  2. brew install readline
  3. CONFIGURE_OPTS="--with-readline-dir=$(brew --prefix readline)" rbenv install 1.8.7-p357
  4. env ARCHFLAGS="-arch x86_64" gem install pg
  5. gem install -v 2.3.14 rails
  6. gem uninstall rake - Rails installs the newest version of Rake. Redmine doesn’t like this, so rip it out.
  7. gem install -v 0.8.7 rake - Required by Redmine.
  8. gem install -v 0.4.2 i18n
  9. Download the latest Redmine build, unpack, and change directory to the project root.
  10. rake generate_session_store
  11. Edit the database.yml. Example: database.yml.
  12. rake db:create
  13. rake db:migrate
  14. rake redmine:load_default_data

CAUTION: I like to use Pow to easily spin up my local rails apps. In order to do this you need to generate a config.ru file (code is provided by Pow when you try to launch Redmine). Make sure that you add the config.ru to your .gitignore file before deploying to Heroku. Otherwise you’ll get odd errors related to not being able to find your stylesheet and javascript assets when launching the app on Heroku.

Remote Setup

  1. cd to the root of your Redmine project.
  2. rm -rf vendor/rails
  3. rm -rf vendor/gems/coderay
  4. Create a .gems file in the root of your project folder (don’t forget to rename gems.txt download to .gems).
  5. heroku create <your project name> --stack bamboo-ree-1.8.7
  6. git init
  7. git add .
  8. git commit -a -m "Initial commit."
  9. git push heroku master
  10. heroku run rake db:migrate
  11. heroku run rake redmine:load_default_data
  12. Load <your project name>.heroku.com in your browser. Have a beer!

NOTE: Depending on your Heroku setup you might need to pass the --app <your project name> suffix to each of the Heroku commands above. The Heroku gem will warn you if necessary.

Next Steps

At this point you should be up and running locally as well as remotely on Heorku. You can, of course, add domain name support, update your DNS and give your new app a proper domain name. Adding DB backup support, etc. would be good. Also email and Amazon S3 file storage would be wise too along with any other goodies you can dream up. …but I’ll leave that up the reader to play with.

Credits

Special thanks to Brant for the initial setup and impetus for this.

Sunday, February 12th, 2012 Software No Comments

Mac OS X Lion Setup

The following is a breakdown of apps I commonly use and their install order (from a fresh install of the MacOS):

Install

To install Mac OX X Lion, you’ll need to be running Snow Leopard with the App Store application installed. Here are the steps necessary to configure you machine:

  1. Launch the App Store and buy Lion to start the download.
  2. Once the download completes, DO NOT start the install. Instead ensure that you make a copy of the DMG image via the Lion installer application (found in your Applications folder). You’ll need to open file info on the installer and choose to show package contents. You’ll want to make a copy of the Contents/SharedSupport/InstallESD.dmg file. More details here.
  3. Once a copy of the DMG has been made, you can start the install.
  4. Follow the screen prompts to complete.

For those that don’t like the default Lion install settings, you’ll need to perform the install twice. However, this time you have the DMG installer image. You can either make a DVD or USB boot disk. Once you have, you can reboot Lion while holding down the COMMAND+R keys to launch into recovery mode. Here are the steps for reinstall:

  1. Launch Disk Utilities and format the main partition as MacOS Extended (journaled, case sensitive). Don’t bother messing with the boot disk partition as that is where your recovery utilities are.
  2. Exit Disk Utilities and start the Lion installer.
  3. Follow the install prompts until the Lion install completes.

Configuration

  1. Rename your computer via System Preferences - Sharing.
  2. Unhide your user library folder: chflags nohidden ~/Library

Applications

  1. Mac OS X 10.7.x Software Updates (Software Update)
  2. Mac OS X 10.7.x Combo Patch (web)
  3. XCode (App Store)
  4. Dropbox (web)
  5. 1Password (App Store)
  6. Knox (web)
  7. iTerm2 (web)
  8. Sublime Text 2 (web)
  9. Alfred (web)
  10. Alfred Powerpack (web)
  11. TextExpander (App Store)
  12. PathFinder (web)
  13. Firefox (web)
  14. Google Chrome (web)
  15. Opera (web)
  16. OmniFocus (App Store)
  17. OmniOutliner (App Store)
  18. OmniGraffle Professional (App Store)
  19. OmniDazzle (web)
  20. Caffeine (App Store)
  21. Fantastical (App Store)
  22. ColorSnapper (App Store)
  23. xScope (App Store)
  24. 3Hub (App Store)
  25. ExpanDrive (web)
  26. iStat Menus (web)
  27. Growl (App Store)
  28. Air Display (App Store)
  29. Pastebot Sync (web)
  30. PDFpenPro (App Store)
  31. Gitbox (App Store)
  32. GitHub (web)
  33. Snippets (web)
  34. Patterns (App Store)
  35. Espresso (web)
  36. Gradient (App Store)
  37. CodeKit (web)
  38. LittleSnapper (App Store)
  39. Acorn (App Store)
  40. Pixelmator (App Store)
  41. DoubleTake (web)
  42. ImageOptim (web)
  43. ImageAlpha (web)
  44. VLC (web)
  45. pgAdmin (web)
  46. VMWare Fusion (web)
  47. Billings (App Store)
  48. MoneyWell (App Store)
  49. Delicious Library (App Store)
  50. GarageBand (App Store)
  51. iMovie (App Store)
  52. iPhoto (App Store)
  53. OpenOffice (web)
  54. Logitech Control Center (web)
  55. Logitech Harmony Remote (web)
  56. Colloquy (web)
  57. Skype (web)

Configurations

  1. Enable FileVault (via System Preferences - Security and Privacy).
  2. Configure Wi-Fi.
  3. Configure printer.
  4. Configure scanner.
  5. Configure Apple Mail and all email accounts.
  6. Configure iCal
  7. Configure iTunes
  8. Install the Network Link Conditioner preference pane (found via /Developer/Applications/Utilities/Network Link Conditioner/)
  9. Install Firefox extensions.
  10. Configure installed applications.
  11. Configure Ruby development environment.

Notes

For more Mac-related information, check out my Mac page.

Monday, September 5th, 2011 Software No Comments

Resizing Applications with Alfred and Ruby

Introduction

When on the move with my laptop, I end up having to resize all my applications which is time consuming to say the least. The main difference is due to two very difference screen resolutions:

  • Home Screen = 2560×1440 pixels
  • Laptop Screen = 1440×990 pixels

The worst is when moving from my smaller laptop resolution back to the big screen at home because all my applications are severely squished. I finally got fed up with the manual labor of resizing my desktop environment each time and crafted a solution: Alfred + Ruby. Win!

Requirements

This post assumes you are familiar with the following:

You might also want to read my previous post, Connecting Alfred to Bitly via Ruby, to understand my reasoning for using a bash shell wrapper script when using multiple Ruby installs.

Setup

You’ll want to download the following scripts:

  • rvm_ruby - A Bash shell script for dealing with multiple Ruby installs.
  • app_resizer.rb - A Ruby script for resizing applications.

…and install them as follows (for example):

  • /bin/rvm_ruby
  • ~/path/to/your/ruby/scripts/folder/app_resizer.rb

Feel free to configure the app_resizer.rb script to your liking. The applications and related bounds are specific to my environment but you’ll find that it is easy enough to add your apps and bounds to your liking. The script only supports two modes: home and laptop. Again, feel free to tweak as you desire.

To configure Alfred, open preferences and go to your terminal command settings (click to enlarge):

Alfred Terminal Commands

…and here are my settings for the app resizer script and command in Alfred (click to enlarge):

Alfred - App Resizer

Usage

Once the Ruby script and Alfred settings are configured, I can now perform the following keyboard commands to resize all running applications:

  • OPTION + SPACE
  • resize home + ENTER

…or…

  • OPTION + SPACE
  • resize laptop + ENTER

I wrote the Ruby script so that it only affects running applications. If you later launch an application after you have resized your applications, you can always run the Alfred “resize” command again. Easy peasy.

Resources

You have probably noticed by now that I’m using rb-appscript gem in my Ruby script. I did this because I really don’t enjoy writing pure AppleScript code. Should you decide to get more involved with AppleScript, I highly recommend downloading the associated rb-appscript tools: ASDictionary and ASTranslate.

Enjoy.

Wednesday, June 1st, 2011 Software No Comments

Connecting Alfred to Bitly via Ruby

Introduction

I love Alfred for the Mac OS. It is one of the core power tools that I use on a daily basis. Coupled with the Powerpack I’m always finding new ways of expending my capabilities. In this case, faster URL shortening.

Requirements

This post assumes you are familiar with the following:

The Problem

Recently, while using my Tweeter Gem (e.g. Twitter for the Command Line), I ran into a situation where I wanted to streamline my URL shortening experience by executing the following keyboard commands:

  • OPTION + SPACE
  • bilty + pasted long URL + ENTER

If you are thinking “Yeah, but Alfred comes with a Bitly command out of the box.” You are correct. However, it only sends you to the Bitly page for shortening URLs. I’d rather not see Bitly open in a browser tab. I only want the work performed and sent to my clipboard without the browser involved. Then I can paste the shortened URL within my terminal window with only a few keystrokes. Simple. Fast. Efficient.

The Solution

The solution is an easy one now that Alfred supports terminal/shell shortcuts. Almost. The reason is that if you are using RVM, which any sensible Rubyist should be using, you’ll find that Alfred defaults to the system Ruby environment that comes pre-installed with your Mac OS. To prove this, try running a Ruby script referencing a Ruby Gem that you DON’T have installed in your system environment. With Alfred logging turned on (via advanced options), you’ll see the following in your Mac OS Console (click to enlarge):

Alfred - Output in Console

D’oh!

While this might not be an issue for some, I’d rather use a specific Ruby version and gem set rather than install the same gem to my system library and pollute that unused space. This then requires a shell script to be crafted which allows one to launch a Ruby script within a specific Ruby environment.

Using this shell script, the following becomes possible from the command line:

rvm_ruby ruby-1.9.2-p136 <path to Ruby script>/bitly.rb <some long URL>

NOTE: I placed this shell script in my /bin folder with user, group, and world access set with read and execute access only (i.e. sudo chmod 555).

The corresponding bitly.rb Ruby script then accepts a single URL argument which leverages the Bilty API to shorten a long URL in the background with the end result being copied to the clipboard via the pbcopy Mac OS command.

Putting It Together

Armed with the shell script and the bitly.rb Ruby script, you can now setup the following terminal shortcut in Alfred (click to enlarge):

Alfred - Terminal Commands

Here are the shortcut details:

Alfred - Bitly Command

Now you can type:

  • OPTION + SPACE
  • bilty + pasted long URL + ENTER

…and have the shortened URL ready for pasting via the Mac OS clipboard.

Happy URL shortening!

Sunday, May 29th, 2011 Software No Comments

Secure Twitter

While attending MountainWest RubyConf 2011, Jim Weirich and Matt Yoho were talking about Rails security tips. One of the items mentioned was ensuring that your Twitter profile settings have HTTPS enabled. To do this, log into your Twitter account and edit your profile. At the bottom of the page, you’ll find the following:

Twitter Security Settings

Somehow I had overlooked this change with my Twitter account but have since corrected it. You should fix your account as well, if you haven’t already.

Friday, March 18th, 2011 Software No Comments

Dawn, Noon, and Dusk Actions

Introduction

After reading Creating Flow with OmniFocus by Kourosh Dini M.D., I greatly improved my flow and focus of daily actions. I had been performing these actions on a daily basis but ended up recalling actions from memory and sometimes skipping and forgetting actions which would inevitably pile up as additional work on the weekends. I’ve worked out a system that keeps these daily tasks out of my head and into my trusted system (i.e. OmniFocus) so that I maintain the consistency that I desire AND keep my thoughts clear for more important ideas. The following is a breakdown of my dawn, noon, and dusk actions that I perform on a daily basis.

The following assumes you read Getting Things Done by David Allen and use OmniFocus for the Mac.

Project Overview

To start, it helps to have an overview of my projects via the planning mode of OmniFocus. In my case, I put all daily and weekly tasks in a “Reviews” folder because in a sense, these are my daily and weekly reviews before I start or return to work.

Review Projects

Each project is described as follows:

  • Dawn - Repeats daily 5am - 8am, actions are sequential, and marked complete when the last action is performed.
  • Noon - Repeats daily 11:30am - 1pm, actions are sequential, and marked complete when the last action is performed.
  • Dusk - Repeats daily 5pm - 8pm, actions are sequential, and marked complete when the last action is performed.
  • Weekly - Outside the scope of this article.
  • Maintenance - A place for saving actions related to fixing and/or enhancing the above mentioned projects.

Dawn Actions

My actions for starting the day:

Dawn
(click to view)

For those unfamiliar with OmniFocus, there are three columns to the screenshot above. The left-most column is for the actions themselves, the next column is for the context in which the action is to be performed, and the very last column is for the note icons (which have been expanded for reading).

I won’t go into each action individually since I think you can get a pretty good understanding of what each action does (via the associated notes) but I do want to go over the purpose of each group of actions:

  • Catch Up - Each action is performed in sequence and is mainly for quickly catching up on activities that took place while I was away. For tweets and feeds that require further reading, I send them to Instapaper or (mark them as starred - in the case of Google Reader). These actions are reserved for quickly catching up on the news. In depth processing of the news happens later as you’ll see below.
  • Plan - Here is where I plan (or modify previous plans) for the day based on news read and actions required of me after processing email. For calendaring, I use Google Calendar. I usually only need to check one calendar since all my other calendars pour into my personal calendar (via sharing). Important, next, and due soon actions are easily viewed and acted upon via the OmniFocus perspective links. Screenshots of each perspective are provided below.
  • Clean Up - Based on what was read and planned for the day, here is where I go back and read up on the articles I didn’t have time for when catching up earlier. This section of actions is always “as time allows”. Some days I have more time, other days I don’t have time at all. I at least attempt to “touch the keys” even when time is limited. Notice that I don’t close my email client until the very end of this action group. This allows me to delegate or require actions of others while reviewing important, next, and due soon actions.
  • Synchronize - Most days I have the ability to work from home…but if I do need to run out the door at least I’ll have my iPhone synced with my most critical data (well, ok, “critical” really only means OmniFocus but the other data is nice to have too).

Noon Actions

My actions when resurfacing from work:

Noon
(click to view)

Basically identical to my dawn actions except that, by this time, I might have SMS and voice mail messages to respond too (as I generally don’t respond any incoming messages while working). Remember, it’s all about protecting the flow and staying focused on the work at hand which means not getting detracted by email, phone, Twitter, Feeds, etc. This is something that got ingrained in my head after reading 4-Hour Workweek by Timothy Ferriss. The necessity to sync my phone is not really required, so that is not listed here either.

Dusk Actions

My actions when resurfacing from work and winding down the day:

Dusk

(click to view)

These are the same actions as performed during the noon hour.

Perspectives

As promised, here are my OmniFocus perspective settings.

Important Actions

Perspective (Important)

Next Actions

Perspective (Next)

Due Soon Actions

Perspective (Due Soon)

Conclusion

In practice, I’ve found that it takes me anywhere from 10 minutes to 1 hour to complete the dawn, noon, and dusk projects. It used to be that these actions could pile up and get unwieldy. I’d have to claim information bankruptcy but now, with a trusted system, I can stay on task without ever letting the mountain overwhelm me. The key to all of this, of course, is being disciplined about it. When you are, the flow is smooth as silk but, let it get out of control, and it can become daunting.

These tasks, like anything else in OmniFocus, are constantly evolving. It might be that I streamline this even further in the future. For me, at least, it works and maybe it can help you too.

Sunday, March 6th, 2011 Software 1 Comment

Alfred Custom Searches

I recently tweeted about Alfred for the Mac. Since that time, I’ve been building an arsenal of shortcuts. Specifically: Custom Searches. The Custom Searches feature allows you add a URL that can be launched by a keyword. For example:

  1. OPTION+SPACE - Opens the Alfred quick entry window.
  2. google metaprogramming - Typing this phrase into Alfred opens a new browser tab with the “metapgramming” search results.

Awesome, right? Well, for those familiar with Alfred, this comes default via Web Searches feature. …but what if you want to add keywords for custom URLs. No problem, click on Custom Searches and add your own preferences. Using the example above, lets say I want to use Google’s secure search capability. Here’s how:

  • Open Alfred Preferences.
  • Click on “Features”.
  • Click on “Custom Searches”
  • Click the ‘+’ button.
  • Enter the following:
    • Search URL: https://encrypted.google.com/search?q={query}
    • Display Text: Google Secure Search
    • Keyword: google
  • Click “Save”.

Did you notice the {query} variable in the search URL above? This allows you to pass “metaprogramming” to the google keyword which ultimately yields the following URL: https://encrypted.google.com/search?q=metaprogramming.

Here is a visual example of some of my custom settings:

Custom Searches

Running with that you, could also keep keyboard shortcuts for other services like GitHub, Instapaper, Netflix, etc.

Go wild and enjoy.

Sunday, January 30th, 2011 Software No Comments

Respecting Time with Chained Scopes

Ruby on Rails

I ran into odd behavior the other day when working with chained scopes that required current time to be calculated each time the scope was called. For example, lets say that you are building a blogging application in Rails where you have a Post model. Each post has a published_at attribute which you use to determine whether a post is viewable or not. With that in mind, you might write a scope like this:

scope :published, where("published_at <= ?", Time.now.utc)

Now, when you call Post.published, you’ll only get back posts that were published before or equal to current time. Wrong. Scopes, since they are essentially class methods, get calculated at application launch. So if you haven’t restarted your Rails app for some time, then current time is actually whenever you launched the Rails app. To fix this, you simply rewrite the scope with a lambda, as follows:

scope :published, lambda {where "published_at <= ?", Time.now.utc}

There, much better. This means that each time Post.published is called, the time will be calculated at the time in which the published scope was called.

Great, so now that we’ve got that figured out. Lets build upon our “published” scope and create a chained scope that can not only display published posts but those that are meant for external/public viewing. For example:

scope :external, published.where(:external => true)

Seems reasonable, right? You should get all published and external posts based on current time because we corrected behavior for the published scope. Sadly, this is not true. You’ll only get externally published posts based on the time in which the server was started. Yep, you guessed it, we need to wrap this in another block. So the code above now becomes:

scope :external, lambda {published.where :external => true}

Now, finally, you can call Post.external and get all externally published posts based on the current time from which you called the “external” scope. Personally, I feel this is not intuitive and seems like a bug. Especially, since one of the most powerful features of Rails 3 is the beauty of building upon and chaining your scopes to condense complex operations into a single call.

Monday, January 17th, 2011 Software No Comments

Tweeting Duplicate Links

Twitter

I recently tweeted the following:

“Twitter Spam: Tweeting only a link to your blog post. Its insulting to those that follow your tweets and posts. Unfollow immediately.”

…which managed to spark the following feedback:

  • DilatedTime: Seems an excessive posture. What if one follows only one or the other? I find no issue with the practice. Tune one out.
  • gefahrmaus: I disagree. One form of tweet is not exclusive of the other. They are the same. Your argument may be missing a lot of context.

My reason for making the statement is due to the fact that it brakes what I consider Best Practices for using Twitter and is also a new form of SPAM. I see it happening more often than I like and find it rather irritating to come across. Here is an example of what I consider to be offensive:

  • <some twitter handle> New Post: <link to new post on personal site>

Notice, in this example, the person is using Twitter to republishing a link that he/she owns. The reason I find this offensive is that I usually don’t care if you have a new post on your site because, more often than not, I’m also subscribed to your site as well. What I’m looking for on Twitter is something ancillary to what is found on your main web site. I’m looking for interesting, educational, funny, witty, etc. bits of information beyond the more thoughtful, longer forms of writing found in a blog post. If you want to post a link to your site, then add something to it. Make it interesting, don’t just regurgitate the same link to an article on your site that I’ll find in my feed reader. Give me context and reason for why I should be interested in seeing the same link to an article on your site that I just saw a few minutes ago in my feed reader. Even worse is when you shrink the URL to a tiny URL so I can’t even tell what the link is before clicking on it. Basically, what you are telling me is that you don’t care about wasting my time. Well, if you don’t care, then I don’t care either and will unfollow you. Simple as that. It’s a bold statement, yes, but I also believe this is an abuse of technology and want to call people out on it.

So what do you do if you want to promote your site on Twitter? Well, don’t do it via a Twitter account that is supposed to represent you. Create a new Twitter account that is purely for marketing or self-promotional purposes. You can hype yourself much as you want. I won’t follow that account because, like I said, I’m already following your web site. But if your goal is to direct as much traffic as possible to your site, then use a promotional Twitter account. It would also be wise to ensure the links on your Twitter profile(s) point back to your main site. My personal feeling is that if I like what you are saying on Twitter, I’m going to dig deeper into your online profile to understand where else you might live digitally and start following you from those places as well.

If you respect your audience, you’ll build stronger connections that could turn into real relationships or benefit you in other ways.

Sunday, December 19th, 2010 Software 2 Comments