New version of AssetPackager 12
Thanks to Dan Kubb for alerting me to a new version of JSMin, the library used by AssetPackager to compress javascript.
With the release of the latest jQuery 1.1.1, it triggered a bug in how jsmin was treating characters within a regexp.
AssetPackager now has the latest version.
Also, for those using Prototype, the v1.5 release that comes with Rails 1.2.1 has a missing semi-colon on line 846. This of course breaks when compressed. To fix it, this line should have a semi-colon at the end. This:
if (params && /Konqueror|Safari|KHTML/.test(navigator.userAgent)) params += '&_='
Should be:
if (params && /Konqueror|Safari|KHTML/.test(navigator.userAgent)) params += '&_=';
Update: Michael Schuerig has posted this to the rails trac so hopefully this will be fixed soon. In the meantime, it’s pretty simple to make the change yourself.
Hash - to_query 2
Look what just appeared in Rails trunk – Hash#to_query – turn a hash of values into a form-encoded query string. I’ve wanted this on occasion in the past. Check it out:
Simple Conversion
{:a => 10}.to_querya=10
Nested Conversion
{:person => {:name => 'Nicholas', :login => 'seckar'}}.to_queryperson[name]=Nicholas&person[login]=seckar
Multiple Nested
{:person => {:id => 10}, :account => {:person => {:id => 20}}}.to_queryaccount[person][id]=20&person[id]=10
Array Values
{:person => {:id => [10, 20]}}.to_queryperson[id][]=10&person[id][]=20
You can do the same thing in Prototype:
$H({ action: 'ship', order_id: 123, fees: ['f1', 'f2'], 'label': 'a demo' }).toQueryString();
Becomes this:
'action=ship&order_id=123&fees=f1&fees=f2&label=a%20demo'
It doesn’t look like Prototype handles the nested conversions yet though.
Asset Packager is in a book! 7
My plugin AssetPackager has been featured in Scott Raymond’s new book Ajax on Rails !
Thanks Scott! Everyone go buy a copy. AssetPackager has a full section in Chapter 9 – Performance. Nice.
New Plugin: MySQL Tasks 9
I wrote some convenience rake tasks to automate creation and backup of MySQL databases, and I use it all the time, so I figured I’d plugin-afy it to make it simple to use in all my projects, and share it with the world as well! Here’s the repository
MySQL Tasks
Some rake tasks to automate common database tasks (create/destroy & backup/restore).
Install
./script/plugin install http://sbecker.net/shared/plugins/mysql_tasksComponents
rake db:mysql:create # Create database (using database.yml config)
rake db:mysql:destroy # Destroy database (using database.yml config)
rake db:mysql:backup # Dump schema and data to an SQL file (/db/backup_YYYY_MM_DD.sql)
rake db:mysql:restore # Load schema and data from an SQL file (/db/restore.sql)Specifying RAILS_ENV works if you want to perform operations on test or production databases.
Asset Packager Updates 4
Some updates to Asset Packager
- asset_packager now tolerates periods in asset names. (Ex: “admin.base.css”) Thanks Timur Vafin.
- updated Capistrano integration docs
- before the compressed assets were getting the subversion revision for the entire repository. Now they get the last modified revision possible for each file. Now it should work as intended – no revision stamp change unless the source files have been updated!
We've completed the switch 1
So a little over a year ago, I said “I currently run Windows XP. Next year, I plan to buy a Mac laptop when the Intel versions come out, and our server setups will all be *nix based. By the time Vista rolls around, I plan to be completely devoid of Microsoft products.”
Well, it’s been a year. I bought a Macbook Pro about six months ago and today Steve bought his own, which makes all two of us here at Electro Mac users. Our servers run on Linux. I still have one Windows desktop machine which will probably stick around so we can interface with the rest of the Windows world when needed.
Now if I can just get my own cinema display. (damn you Steve!)
Re-claim your space
JDiskReport is a cool disk usage analyzer that helps you see where all the space is going on your hard drive. Find big un-used files, and delete them! It’s got a cool interface, it’s cross platform, and it’s free!
Sit back and REST
In Scott Raymond’s latest post, he discusses refactoring IconBuffet.com and following the latest DHH Rails dogma – REST-style resources. He manages to simplify IconBuffet from 10 controllers & 76 actions to 13 controllers and 58 actions total, without removing or adding any features. Thats about 20 less actions. Needless to say, following the recommended REST-style pattern can simplify your work a lot.
“Cutting actions is great, but even more significant is that the remaining ones are almost completely uniform. There are seven standard Rails actions: index, new, create, show, edit, update, and destroy. Everything else—oddball actions—are usually a clue that you’re doing RPC. In the old version, there were forty oddball actions; now there are only five (and four of those are essentially static pages in the about controller.) The upshot is that the controllers are very uniform, which makes the entire application conceptually simpler, and thus easier to maintain, test, and extend.”
Check out more at his site.
Self Control
Great Article: Self Control is the Key to Success
Thinking back, this makes lot of sense. :) When I was disciplined at enforcing self-control, I acheived great things. (Graduating college, completing recordings of albums, quiting smoking early on, buying a house, getting my current project done) and well, everything else. When it comes to finishing something, it all comes down to self-control.
RailsConf
RailsConf was great. Tons of new ideas. People using their brains. Outlines of most of the talks at RailsConf can be found here and here.
Now I’m just hanging out at my g/f’s dad’s house in suburbs outside Chicago for a day before we go back to Florida. Gotta hang with the fam. Hopefully we’ll get to hang out IN Chicago a bit tomorrow before the plane.