Echographia

making things better, making better things

Tuesday, September 6, 2011

awake! from nib!

Tonight’s MacRuby/Xcode lesson: An object (say, an instance of a subclass of NSArrayController) created in Interface Builder won’t necessarily have its initialize method called when the program runs. This, I guess, is because the object was instantiated when you created it in Interface Builder, and cryogenically frozen, and when your program runs, it doesn’t instantiate the object, it merely wakes it up. So you should put the initialization code in awakeFromNib. I think.

(The init method on an instance of a subclass of NSObject was called. I don’t know why init and not initialize. I’ve got a lot to learn.)

posted by erik at 7:32 pm  

Wednesday, June 29, 2011

Tumblr Tags

I just put another hobby project on GitHub. It’s a web service that’s meant to help me (or, in theory, someone else) insert a dynamic list of most-used tags on my Tumblr blog. It doesn’t really help with the inserting, yet, but it will get me the list. And it gave me some experience with Sinatra and MongoDB!

posted by erik at 12:26 pm  

Friday, June 10, 2011

I wrote something with MacRuby, finally. It’s a tool to help me post music every day over on my non-technical blog. The MacRuby part is that it uses iTunes to convert uncompressed audio to MP3, add metadata, and post it to my web site. And add it to my library along the way. That’s pretty cool. The script also uploads the track to my web site, but that’s straight Ruby.

In retrospect I think iTunes is not the right tool for this job. It’s a hammer, not a scalpel. It doesn’t give you a lot of fine control, and it takes more energy than the task really warrants. For example, sometimes I need to find a specific track in the library. The API iTunes offers through Scripting Bridge doesn’t let me look up a track by multiple criteria (track 28 from the album “Music Every Day” in MP3 format) – it just gives me the same keyword search you find in the UI. So I can search for the album “Music Every Day” and then loop through the returned tracks looking for the one I need. It gets the job done, but it’s not ideal.

So if I were starting over I might use LAME and RubyMp3info, or something. But it was interesting to get some practice with MacRuby, and if I ever decided to put a GUI on this it’ll be good to have had the experience. The code is on GitHub, if you’re curious.

posted by erik at 11:51 am  

Friday, May 6, 2011

my plans for Minnebar

Posted here, because why write something down if you’re not going to put it on the web somewhere?

9:40: Geeks Connecting Neighbors. Because talking with a bunch of fellow geeks about how to use technology to help people connect with their neighbors seems easier than actually talking to my neighbors. Backup: Mirah.

10:40: Making Music Like a Nerd II. I make software and I make music, but not at the same time, and for decades now I’ve been alternately intrigued and irritated by the tools to do it. Time to look again. Backup: Maps? Fonts? Android?

11:40: Building the Tech Community You Want to See. Because I like diversity. Backup: ?

1:40: I don’t know, maybe social networks.

2:40: OpenStreetMap 101. I like maps! And openness! I used OSM on Touring Machine and was impressed. Backup I should be going to instead: Negotiating Consulting Contracts That Work.

3:40: Color Theory & Consumption. Not sure why. Backup: Get More From Your Data, or Why Don’t You Blog More?

4:40: Personal Rapid Transit. I’ve been skeptical about this concept since I read Bruno Latour’s Aramis back in the ’90s, but I don’t really remember why. Time for a refresher course!

Minnebar is “an (un)conference aimed at getting those in Minnesota’s tech and design communities together to discuss topics that interest them.” It happens tomorrow, and it’s sold out.

posted by erik at 3:08 pm  

Monday, March 14, 2011

Back to Java

When I picked up Ruby on Rails in 2006, it was a great relief after several years in Java and C to be using a language that let me express things concisely, without a lot of boilerplate, and without fighting the type system all the time. But this week I was contacted by an old client to do a little touch-up on a Java program, and you know what? Java is kind of fun again!

And it turns out I’ve missed some things about Eclipse – specifically, the way Java and Eclipse, working together, can let you know you’ve made a dumb mistake long before your tests or your web browser do. And although I’m comfortable using ruby-debug at the command line, I’ve missed having a GUI around my debugger. Maybe I’ll give RadRails or NetBeans or RubyMine another shot.

posted by erik at 9:52 am  

Thursday, January 13, 2011

“Element not found in the cache”

I was getting the above error, intermittently, from Selenium/WebDriver via Cucumber/Capybara. My code looked something like this:

When /^I wait for the popup to close$/ do
  wait_until { !page.find('#nyroModalContent').try(:visible?) }
end

What’s happening, I think, is this:

  1. Capybara asks Selenium for a handle to the #nyroModalContent element.
  2. Selenium, after returning it, gets the response from my server that tells it to close the popup.
  3. Capybara asks Selenium, hey, that element you just gave me a handle to? Is it still visible?
  4. Selenium is all, “What element?”

For my present purposes, it turns out I don’t need the “visible” check, so I could just do this:

  wait_until { page.has_no_css?('#nyroModalContent') }

If I had needed to get the element and then act on it, though, I think the way to do it would be to write JavaScript that performs both actions, and call it with page.evaluate_script.

[Ran across John Nunemaker's exhortation to "clog it before you forget it."]

posted by erik at 11:25 am  

Monday, April 19, 2010

sane Sinatra stack traces in Cucumber

I’m building an app in Sinatra and testing it (in part) with Cucumber. When exceptions were raised in my application, I’d get a stack trace wrapped in pages and pages of HTML – very nice when you’re testing in a browser, but almost impossible to work with in a command-line test. After a surprisingly long investigation, I added these lines to env.rb:

# Don't generate fancy HTML for stack traces.
disable :show_exceptions
# Allow errors to get out of the app so Cucumber can display them.
enable :raise_errors

Both are required. If you just disable :show_exceptions, you’re spared the fancy HTML, but you’re also spared any useful information about what’s going wrong. (You just get “Internal Server Error”.) But if you just enable :raise_errors, well, the errors don’t get raised – they’re trapped by the exception-showing code.

posted by erik at 8:52 am  

Monday, March 8, 2010

Release announcement: Flickr Watchr

Just kidding, mostly. I got email today informing me that Watchr “has been released successfully in Brothersoft”. Congratulations!

Watchr is a tiny program I wrote five years ago. Ken and I were talking about how we’d like something that pops up images when they’re posted to Flickr. For reasons I don’t now recall, we then wrote two separate applications, his in Python and mine in Java. (By the way, that page is the only use so far of erikostrom.com, except as a mirror of drowning.org, the equally dated site about my singer-songwriter career.)

I’m a little surprised to find that it still basically works. Write once, run everywhere, I guess! Although it still has the same Mac bug noted in 2005, which bothers me more now that I’m a Mac user.

posted by erik at 8:42 pm  

Wednesday, December 23, 2009

setting up browser automation with FireWatir

Ruby-based testing will only get you so far in the web development world – sooner or later you need to make sure your code works in a real browser. So for the last few years I’ve been occasionally trying to get a browser-based test automation tool running – often something in the Selenium family. It usually takes a full day for me to give up, usually because I just can’t get the tool to actually drive the browser.

Today I got FireWatir working! It wasn’t that hard, but I had to consult a few different web pages, so here it is all in one place.

  1. Via FireWatir Installation, install the gem:
    sudo gem install firewatir

    and the JSSh Firefox extension (Mac FF 3.5 version) to make Firefox steerable.

  2. Set up a Firefox profile, so you can run tests without all your weird extensions in play, and without messing with your personal browser session and history. Mine is called “tester”.
  3. Start up Firefox with JSSh and your new profile (you can do this while Firefox is running):
    /Applications/Firefox.app/Contents/MacOS/firefox -jssh -P "tester"
  4. In an irb session, try some stuff – for example, on a new Spree instance:
    ff = FireWatir::Firefox.new
    ff.goto 'http://localhost:3000/'
    ff.link(:text, 'Clothing').click

Voila! Now I want to try Cucumber and Watir.

posted by erik at 12:14 pm  

Friday, December 11, 2009

John Resig on JavaScript testing, performance analysis, and jQuery 1.4

John Resig, of jQuery and other fame, spoke tonight at the BayJax meetup in the Yahoo! cafeteria. His slides are probably online somewhere, but they are lucid, informative, illustrated with pictures and code samples, and written by someone who knows what he’s talking about, not to mention who was paying attention while writing them. (Update: Video on iTunes and not on iTunes.) If that’s not your bag, you’ll want to read my notes instead:
(more…)

posted by erik at 11:39 pm  
Next Page »

Powered by WordPress