Coding on a shoestring
Posted by Dave Minor Wed, 02 May 2007 15:23:00 GMT
I was playing with some code in irb just now and was randomly using the noun “shoe” and got this error:
NoMethodError: undefined method `pluralize' for "shoe":String
Posted by Dave Minor Wed, 02 May 2007 15:23:00 GMT
I was playing with some code in irb just now and was randomly using the noun “shoe” and got this error:
NoMethodError: undefined method `pluralize' for "shoe":String
Posted by Dave Minor Mon, 05 Mar 2007 20:32:00 GMT
When maintaining older projects that don’t have deployment scripts written and where production is not under version control, I find a lot of times that I need to diff the two directory trees looking for which files have changed and then copy them to production.
Today I had a bunch of those to do. I worked up a shell one-liner that will handle this and I’m posting it here to remember the next time this comes up.
diff -q -x .svn -r . ../production_root | awk '{print $2}' | xargs -i -t cp {} path/to/production_root/{}
Let me know if you see a better way.
UPDATE: ok, so this totally fails when there are files in the current tree that don’t exist in the production_root because my awk outputs ‘in’ instead of the filename.
I guess I really need to suck it up and implement a capistrano deployment system for my non-rails apps.
Posted by Dave Minor Tue, 08 Aug 2006 18:59:00 GMT
Dear LazyWeb,
The new trend in blogs is to have relative timestamps like “posted about 3 hours ago.” It’s cute—whatever.
I just noticed while working on a Typo theme that when you view the source, the real timestamp is plugged in! How do it know??
I assume there is some javascript code doing the cutsy stamp after the page loads, but I don’t see any calls for that to happen.
I think it’s cool and I want to know the details behind it, but I’m too behind to go looking right now. If noone enlightens me, maybe this will remind me to come back and dig into the code later.
UPDATE: ok, I found the call to show_dates_as_local_time() which I assume takes care of that.
Posted by Dave Minor Tue, 06 Dec 2005 15:20:47 GMT
In flight training, we use sight limiting glasses (called “foggles”) or a hood to block out the windows and force the pilot to fly by instruments simulating having flown into clouds or fog. It demands focus and attention on the task at hand.
I need foggles in my programming. It’s so hard to stay on task and complete the requirement. Not just from a “keep programming” perspective (ignoring email, phone, browser, IM, and making posts to my blog), but also from a “specific task” perspective (ie, “oh, it would be cool if it also did X. I’ll add that real quick then come back to this problem”).
Of course, this is all just discipline, something which I apparently lack unless I’m passionate about something. I’ve never thought that was really a problem for me.
It would also be great if I could have someone sitting beside me all day reminding me to check on things and pointing out my mistakes:
“Make sure you close that block.”
“Watch your tests.”
“What’s another way you could write that method?”
“OK, you just got hacked. What are you going to do now?”
Posted by Dave Minor Mon, 31 Oct 2005 18:19:00 GMT
Last week I went through a process to get fink off my powerbook and in the process, installed Rails 0.14.2 and MySQL 4.1.15. So today, to take advantage of the better test performance, I upgraded the mysql gem to 2.7 to get the latest native bindings.
$ gem update mysql -- --with-mysql-config
Note: This is for OS X 10.3.9 with mysql and ruby from DarwinPorts.
The great news is that it worked! My rake has gone from 3 min. 40-ish seconds to 2 minutes 40-ish seconds. Gotta love that!
Posted by Dave Minor Thu, 20 Oct 2005 13:56:25 GMT
I left town. That’s right, we picked up the family and headed south. I’m not sure of the impact that really had on the Sox, but I have to think it probably had some effect.
Back in the spring, we both (Sarah has felt this way for a long time) felt a strong urge to move closer to family. Settling into a groove in Chicago for 9 more years would have been fine, except that the kids would not want to move as teenagers probably. Sarah found a great job in Hot Springs, AR, we found a great house and moved down in August. Hot Springs is a really neat town and we love it here so far. Having my folks 20 minutes away is great too!
During this process, we were shocked to find out we’re expecting our third child! So come first week or so of November, I’ll be increasing my tax exemption status! We’re excited and glad to be closer to family during this time.
The other news of the year is that I’ve moved away from PHP development and embraced Ruby on Rails as a framework to do agile web apps. This is cool for a couple of reasons. 1) Have you seen RoR in action?? and 2) This is a unified environment that Doug and I can both agree on for doing development together. He’s definitely still the smarter one, but it’s nice to have a common plane to develop on.
Posted by dminor Sat, 07 Feb 2004 22:45:00 GMT
A while back, one of the guys I chat with occasionally sent me a link showing how to translate a task in both Perl and PHP side by side by Robert Kline. I printed it off and read it last night while at McDonald’s letting the boys burn off some winter energy. I’ve had some interest for a while about learning Perl for a number of reasons that I won’t go into.
All in all, Perl does things more succinctly as I see it. There are examples of where PHP ties things up better (faster), but for the most part, it takes several more characters to do a task than in Perl. Typically, that’s because the functions are more descriptive in PHP. For instance:
In Perl: $s =~ s/^\s+|\s+$//g;
In PHP: $s = rtrim($s);
But what excites me the most about Perl is the section on HTML Elements. Dropping variables into HTML is one of the things that excited me about PHP when I was looking for a scripting language to add to my skills coming from just a designer standpoint. Being able to switch between HTML/PHP modes in a script was nice to keep the two modes separate in my head. What has frustrated as I’ve switched to almost exclusively scripting instead of designing is that switching between modes to output PHP variables took a lot of keystrokes! and it seemed that writing the HTML for something like a form could be written by hinting to PHP what I wanted to do. I’m sure there is a PEAR package that does this, but I’m not really looking to continue developing much in PHP, so I haven’t looked.
What Kline’s comparison points to (if I’m reading it correctly) is that these lines should output the same thing:
In Perl: submit({value=>"yy"})
In PHP: <input type="submit" value="<?php echo $_POST['yy']; ?>">
My only complaint with what I see right now (and I admit I haven’t studied this much at all) is that the output of the Perl package is HTML 4.0. I would hope that there is a package that outputs XHTML too. I’ll have to look into this more.
All in all, this makes me excited about picking up Perl as another tool for development. I don’t want to start a debate about whether Perl or PHP are better. I just want to know both.