Posted by Larry Karnowski
Wed, 06 Apr 2011 01:31:00 GMT
I recently got an email asking about the current status of running headless JavaScript tests in a post-Blue Ridge world. They specifically asked if Jasmine would work with node.js. Here's my reply:
I'm using node.js plus zombie and vows to run headlessly. They run
very fast on node.js, but I don't have a solution for running these
headless tests in-browser. I definitely miss that from Blue Ridge.
I haven't used Jasmine on node, and it's probably possible, but since
node is architected to be so asynchronous I expect you'll have issues
eventually. Vows.js is built from the ground-up to be node-friendly.
Zombie is a fake web-browser (similar to env.js or Capybara/Webrat in
Ruby). It's pretty good, but we've had some problems with some CSS
selectors. This isn't really a problem in Zombie.js but in its html5
library dependency. Chad Humphries has been patching it. We've had
to use some strange CSS selectors (using nth-child, etc) to get around
it.
Tags javascript, testing | no comments
Posted by Larry Karnowski
Fri, 11 Jun 2010 21:36:00 GMT
My RailsConf experience this year was much better than last year's, despite not being a speaker this year. Baltimore felt like a better fit for us than Vegas. Plenty to do right near the conference center, but nothing so distracting that the conf felt empty or sparse.
The range of talks was interesting -- a bit heavy on the back-end talks, but that's typical of a technical conference. People like crunch.
Interesting new bits of culture:
- DHH usually gives the high-level motivational keynote, and Yehuda gives the deep-dive tech overviews, but this year they traded roles. It didn't really work for either, with both having only mediocre keynotes. (I'm all for experimenting, and I'm glad they did. Next year, though, let's get back to normal.)
- Lots more live music at the conference, especially before/after keynotes. I really enjoyed this.
- A certain person showed his butt on-stage (figuratively, thankfully) by defaming a business competitor. No need to mention names here and increase their Google-ability, but you know who I'm talking about. Very childish.
- Lastly, the conf, while still hip & fun, is definitely showing it's maturation. Several keynotes, most notably the Engine Yard talk show, which was fun, still felt like a commercial. Worse, instead of a fun "MVC"-style video by Greg Pollack, we had an actual commercial for his new Rails 3 screencasts. Not terrible in either case, just new.
My big take-aways from this year:
- Chris Wanstrath's ideas of what a good open source maintainer should be feel true: be transparent and ubiquitous; have lots of redundant information sources (blogs, email, getting started guide); and have a philosophy and communicate it, for example, Resque's is "zero features, only plugins".
- Agile software is real engineering for software, not what folks call "software engineering" in schools. (Thanks to Glenn Vanderburg for a great, great talk.)
- Multi-core is incredibly important -- Event Machine and especially Clojure. Very cool to see the Clojure-love (or at least, interest) at RailsConf this year.
- Rails is still fun, but it "arrived" a long time ago and is now a toolset rather than a lifestyle. I expect RailsConf to be officially boring in 2012.
Lastly, a take-away for my own personal life: writing is more effective (for me) than speaking. I will try hard to remember that.
All in all, RailsConf 2010 was fun, educational, and inspiring. It always feels good to go back to the well.
Tags clojure, rails, railsconf, ruby | no comments
Posted by Larry Karnowski
Mon, 02 Feb 2009 23:14:00 GMT
Since upgrading to Rails 2.2, you might be seeing lots of messages like this:
config.gem: Unpacked gem blah-1.0.0 in vendor/gems
has no specification file. Run 'rake gems:refresh_specs' to fix this.
Running 'rake gems:refresh_specs" takes care of most of these, and upgrading any remaining gems will usually take care of the rest. But it seems like most of the projects I'm on still have one or three home-grown, really old, or really odd gems that just don't have specs. I should write specs for these, I know. So I let Rails complain... but...
But now, months later, I'm realizing there are just a few gems I'm never going to upgrade. And I'm seeing these messages... A LOT. Every time I run a test in TextMate. Every time I run tests from rake. Every time I run almost any rake task, period. It's driving me MAD!
So, if you've been a good boy or girl and taken care of most your gems, and a few are still hanging around, here's the magic to make those messages go away:
In your config/environment.rb file:
# Bootstrap the Rails environment, frameworks, and default configuration
require File.join(File.dirname(__FILE__), 'boot')
# Add this line at your own risk!
Rails::VendorGemSourceIndex.silence_spec_warnings = true
Rails::Initializer.run do |config|
Tags config, hack, rails, ruby, rubygems | 6 comments
Posted by Larry Karnowski
Sat, 31 Jan 2009 19:42:00 GMT
I've been quietly hacking away on integrating three great tools:
- Screw.Unit, a wonderful RSpec-like JavaScript testing framework
- env.js, a wonderful fake JavaScript DOM implementation
- Ruby on Rails plugins
What does that get me? Voila! Easy headless and in-browser testing of my unobtrusive JavaScript! (For more information on Screw.Unit, I also created a mailing list with the original authors' permission.)
Tags bdd, javascript, plugin, rails, tdd, testing, env.js, screw.unit | 3 comments
Posted by Larry Karnowski
Fri, 24 Oct 2008 19:39:00 GMT
Say you're doing some drag or drag-and-drop operation in Javascript, and you notice that wherever the user drags, the underlying text or other elements are being highlighted. This can obscure what the user is doing, and it just generally feels "wrong." How do you turn that off?
Here's two quick techniques, one for Firefox and another for Internet Explorer & Safari. (Actually, this is IE7. I haven't tested in IE6.)
Firefox
This one is a CSS fix. Just add the following to your stylesheet and then add the "no-selection" class to whatever you're going to drag over.
.no-selection { -moz-user-select: none; }
Internet Explorer & Safari
We have to use Javascript for this one. Call disable when you start your drag behavior, and then re-enable when the drag is complete. Note that calling this function will disable all text selection until you re-enable, so be careful.
// This works for Safari & IE7, and it is safely ignored in Firefox. You'll have
// to add a "-moz-user-select:none;" to whatever you don't want selected in Firefox.
function enableDocumentSelection(enable) {
if(enable) {
document.onselectstart = _original_onselectstart;
}
else {
_original_onselectstart = document.onselectstart;
document.onselectstart = function() { return false; }
}
}
Tags javascript | 1 comment
Posted by Larry Karnowski
Fri, 10 Oct 2008 14:07:00 GMT
I'm flying to Ann Arbor, Michigan later today to give my "Usability on Rails" talk at the Great Lakes Ruby Bash tomorrow. If you're attending, please drop me a note (as I don't know a soul that'll be there). I'll also be hanging out on IRC in #glrb and #midwest.rb. I'm hoping to meet some new friends and convince some geeks of the wonderful ways of "teh us4b1l1t13z"!
Tags bash, conference, great, lakes, on, rails, ruby, usability | 2 comments
Posted by Larry Karnowski
Thu, 04 Sep 2008 13:37:00 GMT
- Connect your iPhone and let it sync.
- Before you disconnect, run the "Image Capture" utility. It lives in your computer's "Applications" directory.
- Go to the menu, click "Image Capture", then "Preferences".
- On the "Image Capture Preferences" window, change the "When a camera is connected, open:" setting to "No application".
- Close the "Image Capture" application.
- Voila! No more iPhoto launching automatically.
However, be aware that this will stop iPhoto from launching when you connect any digital camera. If you want to pull photos from a camera, you'll have to manually launch iPhoto and hit the "import" button. Snatch!
Tags iphone, iphoto, tips | 10 comments
Posted by Larry Karnowski
Fri, 29 Aug 2008 15:00:00 GMT
If you're using Rails' alias_method_chain mechanism, please make sure that your new method always takes a block and passes that block up the chain, even if you don't need the block yourself. Consider this being a good "alias_method_chain" neighbor. Here's why -- if you don't, no one who comes along behind you can add a block to the chain. You've effectively "block-blocked" them.
Here's an example. I wanted to add some functionality to Rails' error_messages_for method. Specifically, I wanted to be able to pass a block to it that implemented a tiny DSL for massaging the errors output before passing them up the chain to the normal error_messages_for functionality. I implemented this by adding an alias_method_chain layer on top of the error_messages_for.
In my tests this worked fine, but when I put it in my actual Rails project, the method just stopped working. It took me a while to find that another developer on the project was also alias_method_chaining the error_messages_for, but was not taking a block, and thus not passing it up the chain. In effect, he was dropping my block on the floor. No good.
So here's the template you should follow when creating an alias_method_chain:
def method_with_something_cool(arg1, arg2, &block)
... your custom pre-chain code ...
method_without_something_cool(arg1, arg2, &block)
... your custom post-chain code ...
end
alias_method_chain :method, :something_cool
Call the old method with a block even if the old method never took a block! Don't be a cock-blocker! Err.... block-blocker!
Tags alias_method_chain, blocks, rails, ruby | 3 comments
Posted by Larry Karnowski
Mon, 21 Jul 2008 00:22:00 GMT
Here are some important lessons I learned about accurately copying MP3s (or really any kind of file) from a Linux ext3 filesystem to an external USB hard-drive using FAT32.
When mounting the USB hard drive, be sure to use iocharset=utf8 in your mount options. (To be safest, I put this in my /etc/fstab so I won't forget it.) Otherwise you will have problems creating directories or files that have European or Asian characters in their names. I had some real problems with all the Mexican, Celtic, and Yako Kanno albums I own. Rsync will just flat out refuse to create them without this option. (And forget the Icelandic heavy metal. It's right out.)
Similarly, when mounting, you might want to include the "shortname=mixed" mount option too. Although I personally didn't have a big problem with this, several posts I read online mentioned that rsync might try to upload a file multiple times. The issue is that since FAT32 stores both a short-name (remember the 8.3 names?) and a long-name, the filesystem can get confused occasionally. Again, I didn't see this myself. I used the option, though, with no trouble.
Lastly, don't use the standard "rsync -a" (archive) flag. It tries to maintain user and group ownership, and FAT32 doesn't support either so you get a lot of "chown NO PERMISSION" errors, etc. Basically, you're making rsync do more work than it has to. Similarly, the "-a" option also tries to preserve symlinks which FAT32 doesn't support. I'm not really sure what would happen in that case, probably more warnings. Instead use "rsync -rt" to recurse through each subdirectory and to maintain the file's last modified time. That's about all FAT32 will let you do!
Hope this helps! Keep rockin'!
Tags backup, external, fat32, linux, mp3, rsync, usb, utf8 | 2 comments
Posted by Larry Karnowski
Tue, 10 Jun 2008 12:30:00 GMT
While doing a "git svn rebase", if you have merge conflicts here are some things to remember:
- While doing a rebase, if anything bad happens, you end up on a "(no-branch)" branch.
- When doing a "git status", you'll see a ".dotest" file in your working directory. Just ignore it.
- If you want to bail, do a "git rebase --abort". (Note there is no "git svn rebase --abort".)
- Fix the merge conflict file manually, then do a "git add [file]".
- Next do a "git rebase --continue". (Note there's no "svn" version of this either.)
- If it complains about "did you forget to call 'git add'?", then evidently your edit turned the conflict into a no-op change. Do a "git rebase --skip" to skip it. (Very weird, but true.)
- Rinse and repeat until the lather is gone, your scalp silky smooth, and the rebase is complete. At any time you can "git rebase --abort" to bail.
What happened to me? Well, I didn't realize what was going on, continued to work on the "not a branch" branch, commited changes, even dcommited changes back to Subversion. It was ugly, but not insurmountable. A buddy clued me into the "not a branch" situation, I was able to get back to my real branch and resurrect my code. It took a few "git rebase --continue" commands, and a tense moment around a "git rebase --skip", but now everything's hunky dory.
This very odd email really helped me a lot. You might be interested at some point.
Tags git | 6 comments