Politics, Programming and Possibilities
20 Feb
I’m not sure if this is all black magic or what, but the process seems to be pretty undocumented around the ‘net. I’d like to make a nice drag-n-drop installer for the new syncPeople on Rails Bundle. Something with a nice background image, and an internet-enabled bit so it opens right up in Safari.
So far, the only two good links I’ve found to creating a Disk Image with a picture background are:
Still looking for that ultimate “Free, Instantaneous and Perfect” product…
19 Feb
Isn’t it great when you find some time to work on a project you’ve been meaning to do for a while?
Following the 0.5 release and the 0.6 release, the “syncPeople on Rails” TextMate bundle has reached version 0.7. Here are the feature updates:
This was a gem I picked up from the TextMate mailing list that we’ll be using at syncPeople. Basically it gathers all of your TODO, FIXME, and CHANGED messages from all of your project files and color codes them in a nicely formatted HTML window. In addition, you can turn any of the categories on and off if you need to focus on one aspect or the other in your work flow. Replaces the old TODO list with ctrl-shift-t.
Note: You may have to turn off the old TODO list key combo in your commands.
Hitting the ‘enter’ key is even smarter: it will now visit javascript and stylesheet files. For example, clicking on any of the following formats will take you to the javascript or stylesheet:
Also, following the suggestion of procreate, “Mailers also have views!” Now you can hop, skip and jump your way from ActionMailer models to their views and back.
And lastly, you can swap between your controller and helper when it makes sense to do so. Normally, hitting ‘enter’ inside a controller will take you to an action’s view, but if your caret is near the top of the file (not inside an action method) then ‘enter’ will take you to the helper. Hitting ‘enter’ again brings you back to the controller.
So that you can rest your mind and use or re-use this however you’d like, we’ve released this under the GNU Lesser General Public License.
18 Feb
Due to some great comments already, I decided to fix up what I can for the night and wrap this up. Version 0.6 will ask you before overwriting an already-existing partial, and the Intelligent Go To File command is a little bit more robust.
There’s also a subversion repository of this TextMate bundle at:
svn://syncid.textdriven.com/svn/opensource/syncpeople_on_rails/trunk
You can download version 0.6 here.
The original announcement of version 0.5 can be found here.
18 Feb
Added a small feature to the TM backtracer: it will now only load on Mac machines, helping prevent clutter for group projects where there are some Mac/TextMate developers and some non-Mac developers.
If anyone has a good way of detecting if TextMate is being used on the Mac as well, let me know.
18 Feb
After introducing the controller-to-view textmate shortcut yesterday, my coworker (Pete Lasko) and I got excited about the possibility of expanding this idea. So from some of our ideas I built the “syncPeople on Rails” bundle for TextMate, in honour of the company we both work for.
The Open Controller / View feature is the same as yesterday’s feature. It is superceded by the Intelligent Go To File command, however, and may soon be deprecated.
The Create Partial from Selection feature lets you select a section of text in your view, hit option-command-p and then name your new partial. In place of the selection you’ll get a “render :partial => [partial name]” and a new partial file to match.
The Intelligent Go To File feature is perhaps the coolest feature of the set. Hit the keypad ‘enter’ key and you’ll be taken to whatever makes the most sense. For example, if you’re on a line that reads “render :action => ‘list’” and you hit ‘enter’, you’ll be taken to that list action in the controller. If you’re inside a view file but not on any particular “render” line, you’ll be taken to the controller. It tries to use a best-match scenario, and for the most part, I think it does well enough. It still has some significant limitations, however, that I will be eliminating as I develop Rails apps with it.
Download the syncPeople on Rails Bundle and untar/unzip it in to the following folder:
~/Library/Application Support/TextMate/Bundles
Done!
17 Feb
Add a shell script to TextMate that moves you from a controller file to its corresponding view (.rhtml) file in one keypress.
See the syncPeople on Rails Bundle for even more features and a much simpler installation.
One of the most inconvenient things about the Rails directory structure is the relative distance between the controller and its corresponding view files. While it’s organizationally sound, it’s often a pain to go hunting for a view (especially in a complicated application that has modules and modules within modules).
I discovered a fantastic little key-combo within TextMate the other day that almost did what I wanted–if you hit command-option-down, you will be taken from the controller to the corresponding functional test (or from a model to the corresponding unit test). Try it out, it’s really cool.
But what I wanted was ease of navigation from my controllers to my views and vice versa. From what I could tell, that’s not a built-in feature of the Rails or Ruby TextMate command bundles. So I wrote one and bound it to command-option-up. Read on to add the command yourself.
Put the rails-open-view-partner.rb file in to the following directory:
~/Library/Application Support/TextMate/ \
Bundles/Rails.tmbundle/Support/bin
Next, in TextMate go to the Automation -> Run Command -> Edit Commands menu (ctrl-option-command-c). Navigate to the Rails commands and add a command by clicking the ” ” sign at the bottom of the window. Call this new command something like “Open Controller / View”. It should be next to the “Open Test Case” command which is the other command I mentioned above.
In the Command(s) window on the right, add this code:
rails-open-view-partner.rb "$TM_FILEPATH" &>/dev/null &
For “Input” choose “none”, and for “Output” choose “Discard”. For “Activation”, choose “Key Equivalent” and type a key combination in to the input box next to it (I chose command-option-up, since it matches the command-option-down quite nicely).
Finally, for Scope Selector, type “source.ruby.rails, text.html.ruby”. Whew. You’re done.
Note: As we’ve discovered in the comments, it’s important to make this file executable by adding the permission: “chmod u x rails-open-view-partner.rb”. Also remember that the scoping rules for this command apply to Rails mode not just Ruby mode.
Now that you’ve got that all set up, try it out. Go to a controller, and within that controller move your cursor inside of some action (e.g. between “def new” and “end”). Hit command-option-up and you’ll be taken to new.rhtml. From within new.rhtml, hit command-option-up again, and you’ll be taken right back to the controller.
Justin Forder pointed out that the RadRails team is looking to do something similar. Kyle Shank has posted about this very same issue and it looks like they’re going to add a quick shortcut command too. Nice work, guys!
11 Feb
The backtracer has been around for a while now, and seems to have done its job well enough to deserve a 1.0 mark. This release includes a small improvement from Geoff Grosenbach that limits the loading of this plugin to development mode only. Geoff notes that this “simplifies the backtrace when running tests”. Thanks Geoff.
1 Feb
Ralph Douglass has made some nice improvements to my earlier instructions for installing Ruby SDL on Mac OS X. In fact, his instructions are a mere 25 lines compared to my 90!
Now if only someone more knowledgable than myself would wrap this all up in to a Port file…
[tags]ruby, simple directmedia library, sdl[/tags]
1 Feb
OpenCV is a fast and well-designed C library for computer vision research and development. Since I’m not aware of an OpenCV library for Mac OS X, I’m using my old Ubuntu box to get things up and running.
So I don’t forget what I did, here’s some of the configuration I had to do:
#!/bin/sh
export LD_LIBRARY_PATH=/usr/local/lib
echo `pkg-config --cflags opencv`
echo `pkg-config --libs opencv`
g `pkg-config --cflags opencv` -g -o igaze igaze.c `pkg-config --libs opencv`
./igaze
26 Jan
Bundles that include javascripts, stylesheets and images are getting easier and easier. It’s a wonderful time to be a Rails developer
For those who would like to know what bundled_resource is, check out my earlier post that introduces the problem and solution offered by this package.
This release marks a much improved and nearly completely rewritten dynarch calendar bundle. Here’s what’s new:
Version 0.9 of bundled_resource now also includes a “stateful_form” bundle that makes it easier to store the open/closed states of form sections. This is particularly useful for AJAX forms that have hidden sections that the user can open up. When the form is submitted to the server and returned with an error, the form will retain its open/closed states so that it’s just as the user expects it.
You can download bundled_resource 0.9 here (345 KB) or use the subversion repository directly:
svn://syncid.textdriven.com/svn/opensource/bundled_resource/trunk
Compliments of syncPEOPLE social conference software development