I have been in a Strange Loop 1

Posted by s.f. on October 29, 2010

About three months ago while browsing Proggit, I came across a thread titled simply “This is an awesome conference”. Idly browsing the speaker list, I stopped dead at the first two.

I still haven’t gotten around to working through SICP, but I’ve wanted to hear Guy Steele talk ever since reading “Growing a Language”. The sheer amount and variety of the other speakers and subjects gave me pause–most software conferences that I knew of were either heavily buzzword-based(JavaOne), expensive(RailsConf), or both(again, JavaOne). Hitting up my boss for support was comically easy after showing him the registration fee and location.

Continue reading…

peg-trees and you

Posted by s.f. on June 11, 2009

Recently at work, I needed to parse ugly data files from an ancient classified-ads database that a predecessor devoted an entire Ruby application to. While painstakingly building regexes, I remembered looking at Treetop a few months ago.

Treetop is a Ruby library for writing Parsing expression grammars. PEGs are another way of constructing grammars and could be thought of as super-regexes: they don’t allow left-lookup or ambiguity in the parse tree, making them not so useful for natural language but killer for computer languages. Around 40 lines of code and 7 rules took the place of what the original author devoted dedicated tempfiles and regex arrow code to.

That being said, PEGs are conceptually harder to get grips on, and Treetop’s documentation is not entirely clear on some hangups you might find. Most of which you can solve using the excellent mailing list, but I know I wished during the past few days that I could get it summed up for me.
Continue reading…

it “should insert foot in mouth” do … end

Posted by s.f. on June 15, 2008

Last time, I was complaining about rSpec refusing to play nice with the TextMate plugin. I owe the team an apology(in the unlikelihood event of them actually reading the entry), as getting it working is a bit confusing.

On my systems, the TM plugin would insist that I had an ancient rails/rubygems version, and to try upgrading. After a long headscratch, I deduced that it was probably seeing the ancient Apple-installed gems even though I have shiny MacPorts-installed gems. For some reason, the TM plugin will ignore your .bash config files and even any TM_RUBY variables you try to set in the project. Instead, you’ll need to add a PATH variable to your underlying MacOSX environment file(~/.MacOSX/environment.plist).

Take your PATH from your bash profile(specifying your preferred location for rSpec/ruby/macports/etc.) and place it into a key just like the other variables in the file. Mine ended up looking like:
<key>PATH</key>
<string>/opt/local/bin:/usr/local/bin:/usr/local/sbin:/bin:/sbin:/usr/bi
n:/usr/sbin</string>

Save the file, then logout/reboot. The TM plugin should now be working.

After getting it working, I can say it’s been a resounding success in my testing. All of the new features for Depot Central have been thoroughly spec’d out, and even though this release will open the floodgates for public posting, it’s been the least problematic so far.

God, sphinx, and you

Posted by s.f. on April 15, 2008

god is my newest favorite tool for server and Rails monitoring, not to mention the entertaining conversations it can produce(“God was spanking the mongrels repeatedly, without letting them fully start”, “god spammed my mailbox with over 700 emails this weekend”, “I’m killing god right now, it should be back in a minute”). One of the last pieces I forgot to include in this setup was Sphinx and, in an apt demonstration of Murphy’s law, it decided to silently die this weekend while I was out of town. So the first thing I did today was to let god manage it as well.

One hurdle people might run into is whether to let god auto-daemonize the process(a useful feature indeed), but our hand is forced by Sphinx already daemonizing itself along with its own PID file(trying to let both god and a process daemonize itself is pretty much crossing the streams). Fortunately, sphinx provides its own “stop” command so we don’t have to go crazy trying to lookup a PID in our god config:


w.start = "searchd -c #{RAILS_ROOT}/config/#{RAILS_ENV}.sphinx.conf"
w.stop = "searchd -c #{RAILS_ROOT}/config/#{RAILS_ENV}.sphinx.conf --stop"
w.pid_file = File.join(RAILS_ROOT, "log/searchd.#{RAILS_ENV}.pid")

Easy peasy. I absolutely adore god’s ability to plug into the event system on OSX, so between god and launchd, I’ve almost got a bulletproof config[1].

[1] “bulletproof” for the value of “resists .22 rounds hand-thrown at it by a grade-schooler”, mind you.

sittin’ calm after pres butan 2

Posted by s.f. on March 11, 2008

Last Monday, the Rails pseudo-content-management-system that I’ve been working on for the past nine months went live at the Yakima Herald.com, replacing a 4-year old system that ezmobius designed as his first Rails project.

This one’s brand-spankin’ new: Rails 2.0 from the get-go, fairly proper REST(where possible), using a dedicated SQL database, adherence to clean design(again, where possible), and copious use of plugins.
(current favorites: has_finder, thinking_sphinx, acts_as_state_machine, will_paginate, and acl_system2).

Granted, there’s still holes, and I’m already working to fix some poor architectural assumptions I made four months ago, but the newsroom is breathing relief at not having to jump through server hoops anymore(which weren’t ezmobius’ fault so much as limitations of tech and budget at the time).

Now eagerly waiting to see if I merit one of the expected Internet replies:

  • “Newspapers are no different than blogs! You’ve wasted your time reimplementing Mephisto! You’re dragging the rest of us Ruby folk down by not implementing something new that nobody’s ever seen yet!”
  • “Man, Rails isn’t really cut out for building a CMS. Why didn’t you use Drupal or Django? Fail, dude, fail.”
  • “Obviously your paper has money to throw away if they let you sit around for nine months instead of buying Ellington!
  • “you use rails haha i could hav don it in a month with PHP u suk”

My human brain needs beer now.

you are in a twisty little maze of developer packages, all alike

Posted by s.f. on November 29, 2007

“Use Fink until it pisses you off, then switch to DarwinPorts. That’s what everyone else seems to do.” : from jwz’s blog.

“Indeed”, he said, as he executed “sudo rm -rf /sw” on his developer machine at work.
(That’s not to say MacPorts is a utopia free from stupid issues though, it just seems to guarantee more consistency).

Shells at 30,000 Feet

Posted by s.f. on November 28, 2007

One of the things I’ve noticed is that most OSX hints for setting up anything in *nix-land tell you to add path statements just to ~/.bash_profile, usually assuming that you’re working on your own machine. But if you’re ssh’ing to another OSX(or -nix based) and set up the path in the same way, this will probably cause vlad(and capistrano, I guess) to fail with “command not found”, since they use a non-interactive shell to run commands. There are simple fixes: enable PermitUserEnvironment in your /etc/sshd_conf file. Which works, but 1: it’s a potential security hole(paranoia, a game we all can play!), and 2: it’s overkill, because having your path in ~/.bashrc is the proper way to do it, as pointed out here.

protip: you see no protip here

Posted by s.f. on September 19, 2007

I had bullet points for a Visual Studio rant after wrapping up the C# side-project that has consumed my summer, but this guy already said much of what I wanted to say.
About all I can add to it is a harumph at Microsoft documentation: yes, MSDN is obviously a force to be reckoned with(if you can pay the entry fee), but it’s tedious to play the back-n-forth game of “look up the actual API via IntelliSense, and look up actual examples in MSDN’s clunky public web interface / hope that a google search for the control will return more than a ‘getting-started tutorial’ that covers what MSDN already did”.

Contrast that with How To Learn Cocoa, Cocoa Dev Central, and Apple’s own Cocoa Reference Library. All free, fairly well written, and more than enough to get you started with basic Cocoa apps.

Meanwhile, discovering exactly how to fire events from buttons in .NET took up most of a week’s evenings.

i only meant to interop for awhile..

Posted by s.f. on August 27, 2007

And lo, the Visual Studio build tool did proclaim to the masses, “Interop.Photoshop8.dll” and “Interop.Photoshop9.dll” both declare “ps.Application”. And there was much wailing and gnashing of teeth, for another clever approach had failed.

(seriously, if anyone knows how to get multiple interop DLLs for a single interface to play together in VS.net, or alternatively, why an older interop DLL would not be able to invoke a newer version of the same interface in COM, please please please let me know)

Edit(2:09AM): hurr, if you build the object library manually with a different namespace, you can use both. Of course, now this opens up multiple namespaces for a single set of actions, but that does reduce it to a design issue rather than a “bang the rocks together” issue..

full speed sideways 1

Posted by s.f. on June 06, 2007

After moving to Eastern Washington, Qwest thought it would be fun to break my Internet connection not once but twice; the latest involving a corporate thought process similar to: “Oh, you’ve had an external ISP for the past four years and moved twice, but you really didn’t want us to switch you over to MSN this time?”. le sigh.

Work is going great. I’ve spent the past two weeks hacking away on custom WordPress sites, which is good and bad. Good is boning up on my apache admin knowledge and regular-expression mastery. Bad is that it’s PHP, and trying to color outside of the lines on WP results in lots of headaches with mod_rewrite, and designers who thought it was totally cool to hack in custom css/js compressors.

Additionally, I’ve been formally introduced to distributed source-control by a longtime friend. I’m now itching to try out Mercurial on some personal projects, to evaluate it for possible use at work. I have to admit that most of my exposure came from slashdot fallout about git, which put me off of the concept for quite awhile, but realizing that you don’t need to setup a personal server just to try it has gotten me excited.

Finally, E is a new text editor for Win32, which promises “the power of TextMate on WIndows”. This had me all hot and bothered to try it, until the actual setup time came:
The setup needs to be run as Administrator. OK, fine, installing for all users, great. What? Update Cygwin? OK! Great, it’s intelligent enough to..wait, you’re installing to the user-specific directory? Even though I already have a cygwin installation on this machine? And after it finishes for the administrator user, it needs to do it again for my personal account?
That being said, it does have some promise. I’ll report back later on it.