Jan 21, 2012

Quick Tip: Using the Progress Bar gem

I've got a long running rake task.  Yep, I hate to have it but it's necessary.  So rather than just sit back and wonder how long it's going to take and how long I've already been waiting, I decided to take a look at the progress_bar gem.  Using it is fairly simple.. you can take a look at the documentation for some nifty options but let me step you through a very simple example on how I use it in a rake task.


require 'progress_bar'

desc "Do some awesome thing that takes a long time"
task :my_rake_task => :environment do |t|

  progress_bar = ProgressBar.new(Person.count)

  Person.all.each do |person|
    progress_bar.increment!
    person.gender = person.gender.downcase
    person.save
  end

end

Super simple. Here we have a few key things to remember:

  1.    1. Require the progress_bar gem and make sure it's in your Gemfile

  2.    2. Set up a new progress bar outside your loop and set the max correctly. In our case we're doing something for each Person so we'll set the total amount of records to the count of everybody in our Person model.

  3.    3. Increment the progress bar in the loop. By default you increment by 1 but read the docs if that's not what you want.


And that's it! I first ran into this gem from using the sunspot:reindex rake task. It's perfect for something like that and adds a little polish to your work.
Read on...

Dec 26, 2011

6 Ways I'm using my Nook Tablet


A little while back I bought a Nook Tablet. I have no idea why I did it.  I've owned an iPad in the past and the application used the most (iMockups) isn't even available on Android.  But the NT is smaller, lighter and cheap enough that I had to give it a try.  It started off miserably.  Even after rooting, it was basically collecting dust.  But then I started to embrace it and now I find it useful for a number of things.  Here's what I'm up to with it. Perhaps it can inspire you as well.



1. Reading comic books.  Yeah, how old am I?  Confession: I haven't enjoyed comic books since I was 15 or so. Somehow at that age I got the impression that collecting comic books could be worth a lot of money someday. I bought comics I thought would appreciate and kept them in immaculate condition hoping that 20 years on I could sell them for beaucoup bucks.  It didn't turn out that way.  



But years later here I am and comics are available in digital format.  I'm happy to pay and buy those same comics using the Comixology app for Android. It's got a nifty pane-by-pane viewer that makes reading a snap.  And if you've got your own CBR or CBZ files, there's Perfectviewer and a slew of other comic book readers as well.  



2. Sketching.  I know, first comic books and now I'm doodling!  Honestly I was thinking about getting an Wacom Inkling and that plan may still come to fruition. But since they aren't shipping yet, I figure I'd get back in the game using SketchBook Pro.  So far I'm having fun but not producing anything worthwhile.  I figure that'll come with practice.  Plus I also need a decent stylus. (The one I bought doesn't seem to work well.)  If you've got a recommendation please let me know!  [Update: I ended up buying the official Vara stylus from a Barnes and Noble store. Not sure why they're not sold online, but it works way way better than the other one I had.]


3. Keeping track of my music practice.  I started playing the sitar in early 2011.  Every week I'd bring a notebook and write down the notes to the song my teacher wanted me to practice. Then I'd also record what the song was supposed to sound like using Voice Recorder.  Now I record the audio in Evernote and tie those to hand-written notes in Genial Writing. Boom, both audio and text in one convenient notebook that syncs everywhere!

4. Reading and surfing.  Here's one thing I'd really prefer to do on an e-ink reader. And I mostly do use my kindle for this. (Hey BN, where's 3G and audio on your Nook Simple Touch!?)  Still, as with comic books, some web pages come alive on the tablet.  The Google Currents app is my current favorite way to consume news.  If you haven't seen it I encourage you to check it out!

5. Gaming.  Ok, I don't play a lot of games. The types of games I like to play don't seem to exist in the Android market yet. Maybe someday but for the moment I've only found a few.  Plenty of blogs can recommend games for you so I won't bother. But I will say the extra screen real estate is useful for seeing what's coming at you. 

6. Watching movies. Yep, I'm on the Netflix bandwagon. I just signed up for an account and am happily going through seasons 1-4 of That Mitchell and Webb Look.  If I could figure out a way to watch live sports on this thing I'd be a happy guy.

Now I realize all of this could be done with an Android phone too. And if you've got one with a big enough screen you might be happy with that. Still, the extra screen real-estate means that the Nook Tablet is a bit more useful doing these things in my opinion.  In any case, I finally found a few uses for my tablet and I couldn't be happier.
Read on...

Nov 11, 2011

ffmpeg problems in homebrew

File this under: things I'm documenting on my blog in case I can't find the solution next time I need it. So there's a problem with the latest ffmpeg in homebrew where it's failing to compile. Unfortunately it's also keeping a number of other unrelated packages back. Luckily we can work around the issue by pinning ffmpeg to version 0.6.3. Here's how we do it:

cd `brew --prefix`
git checkout 1563196 /usr/local/Library/Formula/ffmpeg.rb
brew uninstall ffmpeg
brew install ffmpeg


Thanks to Sharpie for posting the solution over on Github.

Next up, if they actually update ffmpeg you may need to revert to head. Do that this way:

cd `brew --prefix`
git reset --hard
brew update
brew upgrade
Read on...

Nov 4, 2011

Two things missing from Google Voice

I love using Google Voice. By default I use it to handle all my voicemails since it has some nifty features over what otherwise would be standard using T-mobile. For example, I love that I can listen to my voicemails from a web browser where ever I am in the world. The fact that it handles text messages too is a big plus. Lastly, the translation attempts are usually good enough that I can just read the message that somebody left without bothering to listen to it. (Afterall, most messages are just a variation of people I know telling me to call them back.) Then there's call blocking, cheap international phone calls, etc etc.

So with all that good stuff how could they possibly improve? Well, I think the Android app (at least for Gingerbread and earlier) has two fundamental problems:

1. There's no option for speakerphone. That means you're stuck putting the phone to your ear when you listen to the voicemails. A bit of a pain in the butt especially given #2:

2. The app doesn't take advantage of the proximity sensor. So whenever you stick the phone to your ear you may accidentally pause the voicemail as it plays back.

Overall it's a great app, but those two flaws are pretty amateur in my opinion. I can't understand how somebody who works at Google would not have reported and fixed these by now. Or maybe they have in Ice Cream Sandwich. I guess I'll know in a few months!
Read on...

Oct 7, 2011

RIP Steve Jobs

Steve Jobs died on October 5th. I can't express how sad I am in his passing. I'm fortunate to have not yet lost a parent but if I had I imagine it would feel like this. Every once in a while a great person comes to pass and if you're lucky you are alive during his or her time. I feel very fortunate not only to have been alive but to have seen him in person and worked at his company early on when he was just making his comeback to Apple. Rest In Peace, Steve.


I'm trying to think about why I feel so sad about it. Steve was the patron saint of awesome. The definition of a guy who crushed it before that was a term. And, while he was alive, we all hoped that we might distract him away from Apple to shine his light on other problems that plagued humanity.

When Steve died, my hope that somebody would fix the car industry, healthcare, government, and the environment simultaneously went up in flames. It might be selfish but that's part of the reason why I'm so inconsolable right now.
Read on...

Sep 29, 2011

Whoa, what happened to my company blog?

A few days ago I logged into blogger to write a new post for our company blog only to find that it had completely disappeared. There was a helpful link that said "My blog disappeared from my account!" which let me click through to a form I could fill out to recover it. Sadly, that didn't work.. I was only given a cryptic message that said "No blog found at econify.blogspot.com". No reason was given as to what happened to it but somewhere I read that blogs are usually removed due to TOS violations.

But here's the thing. The content on that blog was only about 4 articles. One about RPG Buddy, One about headless testing with zombie.js, an article about ClassyCAS, and a brief introduction article. Hardly the steamy sort of topics that might get you banned from blogger.

Sadly, there doesn't seem to be an official way to contact the blogger team to ask for a reason or get some help. Sure, I didn't lose a ton of content but what about this blog? Or what about YOUR blog? If somebody has a way to get me in touch with the blogger team, I'd really appreciate it. Maybe you can send them a nice note for me via twitter or retweet the note I sent them.

October 10: It's back. I had to appeal on a public forum and promise that I wasn't a spammer but somebody finally sent it over to Google to take a look at. Frankly, I felt it was a humiliating experience. For shame, Google.

Read on...

Aug 9, 2011

Recompile PHP with Postgres support in OSX

If you've switched over your local development to PostgreSQL on your mac, you may want to use a graphical interface to interact with your databases and tables. One solution out there is phpPgAdmin. Unfortunately if you try to load it up you'll probably get an error saying that postgres support isn't enabled. Instructions on Apple's site will tell you to recompile PHP with postgres support and unfortunately there's no real way to avoid that. Here, I'll step you through how to do it.


Step 1: Find, download, and extract your version of PHP
php -v

On my version of Snow Leopard it was PHP 5.3.4. To get it, visit the PHP site and download the corresponding version. Note that it may be in the archive section

curl -O http://museum.php.net/php5/php-5.3.4.tar.gz
tar -xzvf php-5.3.4.tar.gz

Step 2: Pre configuration
Change to the PostgreSQL's extension directory:
cd php-5.3.4/ext/pgsql/ 
phpize

Step 3: Configure
I'm using homebrew (you should be too) and installed postgres using these great instructions (also see the screencast)

Since homebrew puts postgres in a different directory, we'll need to specify it when we configure. As of August 8, the version of Postgres installed by homebrew is 9.0.4. Check your version before you blindly copy/paste my instructions.

./configure --with-pgsql=/usr/lo./configure --with-pgsql=/usr/local/Cellar/postgresql/9.0.4/bin
make
sudo make install

Step 4: Modify your php.ini file
You may not have a php.ini file so if you don't the first thing you'll want to do is create it

sudo cp /etc/php.ini.default /etc/php.ini

Next, add this line somewhere in your file

extension=pgsql.so

Step 5: Restart Apache
The easiest way to do this on MacOS X is to go to your System Preferences → Sharing settings and turning off and back on Web Sharing.

With that all done, visiting your local copy of phpPgAdmin should now work. One last tip, if you can't login because your postgres user doesn't have a password, you can modify your conf/config.inc.php file and change the conf['extra_login_security'] to false.

$conf['extra_login_security'] = false;


Update (Sept 08-2011): Two other tips. On lion, be sure that /usr/local/bin is ahead of /usr/bin in your $PATH. Run brew doctor to see if this applies to you:

brew doctor

Also, in your conf/config.inc.php make sure you set the host to localhost:

$conf['servers'][0]['host'] = 'localhost';

Read on...

May 13, 2011

RPG Buddy: Now on Android

About a year ago I talked about how we released our first iPhone app.  It was called RPGBuddy and it was built to help Game Masters track initiative for their Pathfinder, D&D, or other d20 type game. Today I am equally proud to announce that we've ported it to Android.

Well, ported is actually not quite accurate. It's been completely done from scratch using Android's SDK.  I suppose we could have used any of the popular cross-platform javascript/html5 tools, but somehow it felt worth the effort to do this "the right way".  In the process we learned a ton about Android development and I'm looking forward to announcing even more Android apps soon.  You can download RPGBuddy for Android here.



Read on...