gist JS

Wednesday, December 31, 2008

Top 17 Netbeans Ruby and Rails keyboard shortcuts

cmd-shift-1 show selected file in project
cmd-shift-f search whole project
ctrl-tab switch between files
ctrl-shift-o open file
shift-esc maximize view

ctrl-enter ooo... redoing blocks and logic is sexy.
cmd-space actually works. sometimes. meh. cmd-r rename

ctrl-shift right/left indentation
ctrl-g goto line

cmd-shift-w close all editors

shift-enter new line below this one (sexy!)

cmd-b goto works sometimes, but 1 million times better than aptana because if it's not going to work it fails fast and never just freezes up for 40 seconds.

cmd-shift down duplicate line
ctrl-shift down move line down

ctrl-shift . expand selection
ctrl-shift , retract selection

cmd / comment
ctrl-shift-f format

Now with 4 more!
cmd-shift t open test for file (or file for test)
cmd-shift a open action for controller
cmd + expand fold
cmd - collapse fold

Tuesday, December 30, 2008

NetBeans 6.5 vs Aptana RadRails

Well after finally losing my cool and pitching in the Aptana towel I decided to erase a couple years of Eclipse finger muscle memory and start again with Netbeans.

Before I did that, I did give UNA a 10 second look and actually liked a lot of the ideas. Logical keyboard shortcuts sounds brilliant and sane, and collaborative features sounds neato, but I'm not looking for flashy new relationships at this point of my life. So, NetBeans it is!

In general, coding in NetBeans is a good experience. For the most part it feels like it's focused on helping you get real development tasks done quickly (as opposed to pie in the sky GUI generator editors that I'll never use). The best bits are the slick little things like the functionality around inserting variables in a string by typing #. It's tough to pinpoint just how these things are better than Eclipse/Aptana, but they feel nice and have me thinking that NetBeans may yet win me over.

It's definitely opinionated software though and it takes a bit of getting used to. For me at least the icons aren't very intuitive and being a new user it's obviously a pain to get my fingers on the right shortcuts. Of course that brings up the main sticking point, which is the preferences system. Ouch. (Update: NetBeans FTW! NetBeans 7 totally fixes this!!) While Eclipse's preference window may feel labyrinthine the addition of the search bar makes finding things workable. On NetBeans, there may be fewer options, but they're organized in a illogical un-searchable heap that had me cursing. Can't win them all I suppose. At least my damnable home and end keys worked without having to fix them like I did in Eclipse.

Cool NetBeans Features:
  • Neat rake task browser
  • Neat db:migration tool
  • Integrated JavaScript debugging. Wow. Haven't used it in anger yet, but it is definitely sexy.

Sadly JRuby is dead to me, so I can't comment on that. I ended up running everything with MRI instead, which seems to work fine. While JRuby is cool and looks like it's almost as fast as Ruby 1.9, if it can't do native C stuff like sphinx / image magick it's of no use to me right now.

Overall, I think I'm going to be staying here a while. Netbeans certainly isn't an extension of my brain yet, but it doesn't freeze up and the search is fast so at least I feel like it isn't working against me. It also seems to handle Git switching branches beneath it much better. Aptana would freak out from time to time and force me to refresh the entire project. NetBeans just trundles along.

Anybody know if the NetBeans for Ruby and Rails book is worth getting? OMG there's a new Neal Stephenson book: Readme.

Miscellaneous thoughts:
Help -> Keyboard Shortcuts Card Is a great idea... but it doesn't know I'm on a Mac so it just spits up the PC versions and is thus rendered less useful. Worse, it doesn't actually take into account your keyboard shortcuts! It's just a static PDF. So, nice idea, but doesn't it kind of miss the whole point?
Bookmarking. Again, nice idea, but wtf it only works within one file? Fail.
Format and save on exit. Didn't see any way to do this in NetBeans. Loved it in Java/Eclipse-land.
Link file to project navigator. Command-shift-1 is a substitute I guess, but I do miss automatic linking. It's a pain switching between partials otherwise.(Update: NetBeans FTW! NetBeans 7 totally fixes this!!)
Can't copy paste from test result window into editor wtf? Totally annoying.
Awful Awful Awful keymapping UI. Want to add a keymapping for 'goto test'? It's hidden behind one of 25 doors. Is it in the door marked Ruby? Test? Navigation? I'm not telling because I gave up. Oh and each door has a list of 20 things to scroll through. Eclipse is 1000% better in this regards.(Update: NetBeans FTW! NetBeans 7 totally fixes this!!)
Test window is braindead. Clicking on show this test failure show me where in test_process it failed. Um.. I think I'd prefer to see the assertion kthxbai. (Maybe this is just shoulda throwing for a loop)
DB Service, right click on table -> view data. Automatically does a select * from table. Not so helpful when the table has a million rows. How about a default limit 100?

Finally, here's a list of my top 17 NetBeans keyboard shortcuts.

Finally, if you've read this far I figure it can't hurt to give a shout out to two killer tips that have been making me happy:

being able to use emacs or vi from within a irb session is out_of_control brilliant. Thank you utility-belt gods!

Monday, December 08, 2008

An Open Letter to Aptana, re: RadRails

Dear Aptana,
I just wanted to give you my $.02 about Aptana & RadRails.

I'm an eclipse guy from my java past, so radrails was my first stop looking for a rails editor.

I was pretty happy with the free version. It worked ok.

Everything was fine until HAML came along as the new hotness and I couldn't find a good HAML syntax highlighter.

Then somebody here bought Aptana and said that in the beta releases there was a HAML editor.

We bought 5 licenses for ~$500 total.

But me and the other guys are getting pretty close to tossing this whole stack.

  • Every time Eclipse freezes up 'Saving the Cloud model' I think about switching to textmate.
  • Every time I have to click away from the useless Rails Search to the slow as nuts Aptana search. I think of switching to I don't know what.
  • Every time there is a bug that doesn't allow me to type { to start a line, I assume that none of you actually uses this to develop rails apps on a day to day basis.
  • Will clicking f3 to go to the method declaration? Or will it freeze up for 2 minutes? It tough to predict.

I could not care less about rails helper GUI things that run script/generate for me. Or run my rake tasks. None of us could. We use the command line and it's fine.

I could not care less about 'the cloud'. Or Jaxster. Or pretty much any of the other features that you seem to be working on. Are you an IDE company or a hosting provider? I have a hosting provider. I have no idea what you are doing in this space.

What we want:
  1. Faster search.
  2. Awesome Git Support.
  3. Code completion that isn't brain dead. (I saw Josh Susser present some awesome ideas on how to make this happen! (registering observed classes with the meta callbacks that happen when you run tests))
  4. And as much refactoring support as you can make happen.
Code Editor + Git support + the standard eclipse outline, problems etc views.

We will pay for this. We paid $500 for HAML syntax highlighting for goodness sake, but I feel like what you're doing and what I want are diverging. Quickly. Maybe that's just the way it is and it'll be a better future for us both, but I can't say I understand it. I feel like you guys should be making the killer rails IDE but instead you're doing things that have no value (to me) and driving me away in the process.

Thanks for absorbing my rant. Personally, I know I appreciate hearing from users, even if they're frustrated and I figured it's more useful to send it your way than to grumble silently here.

good luck,


Thursday, November 06, 2008

ubuntu slicehost sun java apt-get

So as part of the ToCollege.net migration from GoDaddy to SliceHost I had the 'opportunity' to learn a new linux distro. After some going back and forth about whether I really felt like doing this and with much reassurance from the assorted linux-heads I decided to take the ubuntu plunge. 

Reassured that apt-get was the indeed the new hotness, I proceeded to attempt the very difficult and subtle and arcane process of... installing java. Easy right?

That's what I thought. Turns out that the open-sources freakos in Ubuntu land are so fixated on free software, that installing Java on Ubuntu is not painless. (Yes I know you thought Java was free, but it turns out it's not free enough to qualify as really free, or something like that. I quite frankly don't care.) 
Long story short, you need to update your source list. Anyway, you might think that adding 'universe' to the list of apt-get sources would be good enough to tell apt that you don't care about the useless OpenJDK, go get me the real Sun JDK, but you'd be wrong. You'd be wrong, because universe actually isn't the largest scope.

But what's bigger than the universe? Well, for standard window/mac user's maybe the universe is as big as it gets, but in Linux land the new hotness is... 'multiverse'

Yes I do know what the multiverse is. Yes I did read Timeline. Yes it is neat. But no, this should not be a prereq for installing Java. The next person who tells me linux is ready for desktop users everywhere gets punched in the nose.

vim /etc/apt/sources.list
add 'multiverse' to the end of all of the strings.

sudo apt-get update
sudo apt-get install sun-java6-jdk

Then, if you were unfortunate enough to get tricked into installing the OpenJDK in your fruitless struggle to get this working.

sudo update-java-alternatives -s java-6-sun

To test that everything is no longer rogered:

java -version

You're looking for something akin to the following.

java version "1.6.0_06"
Java(TM) SE Runtime Environment (build 1.6.0_06-b02)
Java HotSpot(TM) 64-Bit Server VM (build 10.0-b22, mixed mode)

Tuesday, September 30, 2008

Merging with Git: conflicts!

Dramatis Personae:

git-svn rebase: our hero/ protagonist
(no-branch): a mysterious stranger
.dotest: an even more mysterious interloper

Scene I - The Setup

>>mate config/environment.rb
>>git add config/environment.rb
>>git-svn rebase

>>CONFLICT (content): Merge conflict in config/environment.rb

>>mate config/environment.rb (and fix problem...)
>>git add config/environment.rb

Scene 2 - Where it all goes wrong

Well, since we just added, maybe we should just commit.
>>git commit -m "merged conflict

At this point, everyone dies, commits are forever lost and you are left to rot in the bizarre (no branch) land that your $9 git tutorial, or not-yet-published book, never mentioned. Return to start.

Scene 2 --ammend

>> git rebase --continue !!!

Milk & Honey*
(or not. see the postscript)

Scene 3 - Where all is explained

The problem with scene 2 is that once a conflict occurs, git pops you into a new 'branch'-ish thing called (no branch). This is not a regular old branch afaict however. If you were to decide not to fix the conflict and just go on your merry way committing new code you'll be in for a lot of pain. You can tell if you're in this mysterious state by running 'git branch'. On git <>>[jdwyah@silvia sample]$ git rebase --continue
>>Applying: test
>>No changes - did you forget to use 'git add'?

Basically when you committed you essenitally stole your continue's thunder and it isn't happy about it.

Now you can do a --skip instead, and this is also written up here: Larry vs. the Git Rebase Merge Conflict but from what I've been able to reproduce I think he must've done the commit accidentally like I did and there's no reason not to do the continue instead. It's such a twitch reaction to add then commit I'm guessing that he did the same thing I did. That said, git rebase --skip does work as a way to get out of this mess.

Postscript (--ammend --ammend)

* Note, it might not necessarily be all milk & honey here. You may in fact, be left with... MORE CONFLICTS! Now why might this be? Well, the fact is that you may be rebasing onto your local branch which may have multiple commits. If this is the case, when git goes to replay your changes after the rebase merge it may well conflict multiple times: once for your first local commit, once for your second, etc...

It's quite possible to think that you're losing your mind at this point, since you can continue to get conflicts for the same darn file over and over again, but if you do keep merging things you should eventually make it out of the rabbit hole. Hodgies merge option is probably a good solution here, or alternatively you could merge your local commits into one big commit.

firefox bookmark bar broken and I can't tab

fwiw I'm dropping Firefox like a sharp knife the second chrome comes to mac. I'll admit I got my hopes up that 3.0.2 might fix one or more of:

  • the out of control CPU usage

  • the bookmark sidebar that won't close

  • or the bookmark autocomplete which isn't keyboard navigable

but I should've know better.

Who else is running chrome under vmware in unity mode so they can pretend that they're not feeling left out of the fun?

Non sequitor, but I have to say I'm hugely tempted to just continue reading The Time Was Soft There and dream about Paris for the rest of the day. Now that's browsing I could get in to.

Friday, September 19, 2008

InfoQ interview and GWT SEO Sample Chapter

I'm pleased to announce that there is an interview I did with InfoQ is now available online here: http://www.infoq.com/articles/progwt

As an added bonus, Chapter 12: Search Engine Optimization Making AJAX Searchable of Pro Web 2.0 application Development with GWT is available as a sample chapter with the interview.

In this chapter, we’re going to look at how to make our GWT site search engine
friendly. To do this, we’re going to reimagine the way that we get data to our GWT widgets,
moving from RPC to a bootstrapping method where we’ll use GWT serialization to serialize
our objects right into the HTML host page.


Tuesday, September 02, 2008

Pro Web 2.0 Application Dev with GWT links

Jeff Oakes put together a great document that captures all of the weblinks from my book Pro Web 2.0 Application Development with GWT. You can find them here:


Thanks Jeff!

Sunday, June 22, 2008

Your Amazon Wish List is Public!

I'll bet you didn't know that! I sure didn't.

Just go to http://www.amazon.com/gp/pdp/search and search for your friends & enemies.

Hours (well ok, minutes) of fun seeing what everyone desires.

We're number 1!

I found a neat app called RankForest, which simplifies an authors task of checking their Amazon sales statistics every 20 minutes. Looks like Pro Web 2.0 Application Development with GWT is doing well! (Ok that's #1 out of GWT books and not #1 out of all books on Amazon, but still, considering there's no magic wands in the whole book it's not bad. Amazon Top 100)

The book also got it's first review on Amazon the other day and I'm pleased to report that that was positive as well. Whew.

Thanks to everyone who came to my talk on Real GWT Applications at TheServerSide Prague. If you missed it, the presentation is up on ToCollege.net's download section. I focussed on the three stumbling blocks that I've found when using GWT. Design patterns for integration with a web framework, Hibernate, and Security.

Saturday, June 14, 2008

MySQL Apology

I need to apologize for recommending MySQL in my book Pro Web 2.0 Application Development with GWT.

I didn't realize it didn't support DDL in transactions.

I thought it was a real database.

Please forgive me.

I promise never to do it again and to always use PostgreSQL.

Seriously, migrations have been one of my favorite parts of working with Rails at my new company and using the transactional_migration plugin made working with them all the sweeter. Not being able to do this on ToCollege.net without a switch to Postgres is really bumming me out.

Tuesday, June 10, 2008

Maven & GWT a new simple plugin

One small part of the ToCollege.net site is its Maven / GWT integration. While there were a number of projects that tried to make this work I found them either overkill or dead in the water.

As of today, I've released the net.tocollege.gwt_maven plugin as open source on Google Code.

See how to integrate this into your pom.xml here.

See the source code here.

And check out Pro Web 2.0 Application Development with GWT for some 400 pages of walk through of the ToCollege.net project.

Thursday, May 29, 2008

Updating ToCollege.net to 1.5 RC1

With the very exciting release of GWT 1.5 RC1 finally here, I thought I'd drop a quick post in to show you how to upgrade ToCollege.net to RC1. If you're not familiar with it, ToCollege.net is an open source GWT 1.5 example codebase that serves as the sample code for the book Pro Web 2.0 Application Development with GWT. Read more about it here.

Add GWT 1.5 RC1 to your Maven Repository

1) Download GWT 1.5 RC1 for your OS http://code.google.com/webtoolkit/download.html
2) Unzip
3) cp workspace/ProGWT/Setup/maven/gwt/install-* Downloads/gwt-mac-1.5.0.rc1/
4) cd Downloads/gwt-mac-1.5.0.rc1/
5) chmod a+x install*
6) ./install-mac 1.5.0.rc1

This should look something like this:

[INFO] Scanning for projects...
[INFO] Searching repository for plugin with prefix: 'install'.
[INFO] ----------------------------------------------------------------------------
[INFO] Building Maven Default Project
[INFO] task-segment: [install:install-file] (aggregator-style)
[INFO] ----------------------------------------------------------------------------
[INFO] [install:install-file]
[INFO] Installing /Users/jdwyah/Downloads/gwt-mac-1.5.0.rc1/gwt-servlet.jar to /Users/jdwyah/.m2/repository/com/google/gwt-servlet/1.5.0.rc1/gwt-servlet-1.5.0.rc1.jar
[INFO] ------------------------------------------------------------------------
[INFO] ------------------------------------------------------------------------

Update ToCollege.net to revision 85:

svn up

Revision notes: Update for GWT 1.5.0 RC1:
*Needed to change TabPanel to DecoratedTabPanel and PopupPanel to DecoratedPopupPanel
*Copied in changed to GWT css.
*Moving to the net.tocollege.gwt_maven GWT Maven plugin. Had been using xi8ix-gwtc, but this plugin did unescessary work and didn't seem to be up to date. Run Setup/maven/install-all to install the net.tocollege GWT Maven plugin. (See the pom in revision 85)

Install the new net.tocollege.gwt_maven plugin

cd Setup/maven/



Tuesday, May 20, 2008

Big GWT App!

Wondering about using GWT on a big project? Curious whether Google's eating it's own dog food? Well look no further than Google Health.  

A quick 'view source' of the just launched Google Health site will show some code that should be very familiar to GWT developers.

<script language="javascript"
<iframe id="__gwt_historyFrame" src="javascript:''" style="width:0;height:0;border:0;overflow:auto"></iframe>

Get kick-started with your own GWT app with 15,000 lines of GWT source and my book Web 2.0 Application Development with GWT which will show you how integrate GWT with Spring MVC, Hibernate and Spring Security and a host of other Java technologies.


Wednesday, May 14, 2008

GWT and Tickling your Google Analytics Urchin

To see how the new Google Analytics Urchin is integrated with GWT ToCollege.net see the decorator

At the bottom it contains the Analytics page tracker:

<script type="text/javascript">
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
<script type="text/javascript">
var pageTracker = _gat._getTracker("UA-YOUR_TRACKER");

The analytics code is in this one file. ToCollege.net uses
SiteMesh to decorate all of the pages in the site with this decorator, so if you're using SiteMesh this is still the HTML you'll need.

Because GWT will allow you to navigation within a page without reloading the page, you may end up with fewer page views than you'd like and no way to track what users are doing on your site. The way around this is to poke the urchin to let it know that it should record another page view.

See the JSUtils.java file, which has a 'tickleUrchin'
method. This is a JSNI hook so that you can trigger a Google Analytics
page view from within GWT.

For more info on the GWT 1.5.3 code behind ToCollege.net check out the Google Group

Thursday, May 08, 2008

GWT Book Released, Time For Reviews

Well, she's out there. Web 2.0 Application Development with GWT from Apress has finally hit the shelves. I'm can't tell you how happy this makes me.

I've really tried to write the book that I would've wanted to read when I started with GWT, so I hope you like it. For me, GWT itself was fantastic and easy to use, but the biggest stumbling blocks towards getting GWT to work within a complex Java ecosystem. To that end, I've tried to save some trees and leave API specs where they belong (in your IDE's autocomplete).

Continuing with this line of reasoning, instead of giving you a bunch of trivial sample applications, ninety percent of the book is devoted to one big, real world example: a full tour of a real Web 2.0 startup’s codebase. The example is ToCollege.net, a real world startup with an open source codebase. That means that along with the book you get 15,000 lines of source code that includes everything from Google Gears integration to Acegi OpenID, Compass full–text search, and Google Maps, all of it integrated with GWT 1.5.

My idea is that you should be able to leveraging this book’s available source code, to see the nitty–gritty details of how to merge a modern Web 2.0 application stack including Hibernate, Spring, Spring MVC 2.5, SiteMesh, and Freemarker.

Packaging GWT into a WAR file can be a bit of a headache out of the box, so you'll also see how I've wired GWT into an industry standard Maven build environment, which will help you get up to speed quickly and avoid configuration headaches.

One of the The great pitfall of many Ajax applications is they’re mostly opaque to search engines. I spend a lot of time in the book going over ToCollege.net solution to this thorny problem.

Finally, I spend a good bit of time showing how ToCollege.net protects itself from XSS and XSRF attacks. Security is often left as an 'exercise for the reader', but this is a real concern for a site like ToCollege.net. The book will cover the ToCollege.net security architecture in detail.

Thanks for reading and please feel free to get in touch with any questions. There is a Google Group setup here: http://groups.google.com/group/tocollege-net


-Jeff Dwyer
Author of Web 2.0 Application Development with GWT

Monday, March 10, 2008

Mac Leopard OS X, Windows Convert: Color Terminal, Fixing Spaces, Home & End Keys, Mouse

As a new Mac convert, I was pretty excited to get my hands on Leopard. In general it's been lovely, though I can't say there weren't a couple rough edges on the way to mac nirvana. I've chronicled the things I needed to do to get my mac working the way I wanted it to.

Better Terminal

The first thing any self respecting programmer comme mac user will do with a new leopard box is, of course, to drop into the terminal and setup my shell. Bash is fine with me, so here's my ~/.bash_profile

#better prompt
PS1='[\u@\h \W]\$ '
#better prompt for sudo
SUDO_PS1='[\u@\h \W]\$ '
alias ll='ls -l'
alias emcas=emacs
alias ss='ssh -l username site.com'
#easy copy
alias sc='scp $1 username@site.com:/var/tmp/ '

#Color for mac leopard bash terminal
export CLICOLOR=1
export TERM=xterm-color
alias pstart='sudo -u postgres postmaster -D /usr/local/pgsql/data'

Fixing Leopard Spaces

Ok, spaces is allright, but by default I'm getting whiplash. Any little popup window can make the space switch, which means that a gmail calendar alert will take away the focus from your window and you'll end up typing into a void. blech. I'm not the only one to have notice this thankfully. All you need is the following in the terminal.

defaults write com.apple.dock workspaces-auto-swoosh -bool NO

I also did:
defaults write com.apple.dock workspaces-wrap-arrows -bool NO
which stopped letting spaces wrap around and seems infinitely more sane.

Thanks be to:

Still Not Perfect

Spaces and command-tab are now essentially useless however. Command-tab has no idea what apps are in the current space. This isn't ideal, but worth it for me since I think expose is close to being as fast. Sadly, clicking on an icon on the dock is now insufficient to switch your space.

OK, here's a 1/2 solution. A cool little utility called Witch gives me command tabbing between applications within a single space. Excellent! Mapping it to option-tab seems like a decent compromise. That way you can get quicksilver on ctrl-tab, witch on option-tab and regular old tab switcher on cmd-tab.

function keys without 'fn'

Keyboard and mouse settings, use function keys without fn is a must have as well.
Now f8 for spaces and f9, f10,f11 for expose work great. plus f5,f3,f2 (refresh, go to type declaration, rename) work in eclipse. Much better.


Quicksilver is the hotness. You know you want it.

Subversion visualization in OS X ie TortoiseSVN for Mac

OK, I've tried http://scplugin.tigris.org/ but I've been pretty meh about it so far. Not sure what's going on, but icons only appears sometimes. And it's total hidden in the "more" menu. This needs work.

Seems to do the trick for FTP

Keyboard Home & End

First, I think something needs to be done to get my windows keyboard on board. Ah yes, switching option and command in the keyboard modifiers screen is much better. Otherwise my fingers can't cope switching between pc & mac keyboards.

But the real joy is getting the darn Home & End keys to work. I can't believe anyone thinks the default behavior is useful. Home flings me to the top of the page? Blech blech blech. Can someone explain this to me? Happily there's help to be had, but you need to do things pretty piecemeal. Once for Firefox, once for OSX and then seemingly infinitely depending on how many other apps you use that do their own keyboard bindings (ie Eclipse)


Of course for Eclipse you still need to erase the bindings for 'text end' and add bindings for 'line end'. Sigh.
oh and modify the bindings for 'select text end/start' to be shift page up/down and modify 'select line start/end' to be shift-home/end. phew... finally.

Finally to get home/end in terminal you need to do Terminal Preferences and then set Home and End to 'Send signal to terminal' then do ctrl-A and ctrl-E respectively.  I'm sure the Mac-guy ads will detail this procedure soon. What could be simpler?

Now if I could just cut and paste files in Finder... I'm sorry, but drag n' drop is in no way faster than cut n' paste.


Now coming back to my old home setup, my normal mouse is waaay too slow. Installing MouseZoom 2.2. solves this... kinda. Restarting works even better. Grumble. I still feel like using a mouse on this machine is unbelievably imprecise.

Well, there's my story. Hopefully this compendium of hard googled forum postings will save you some time.