Update 8 Sept: Ryan Bates’ Railscast episode #36 shows you how to setup a new rails project in Subversion, including setting up trunk/tags/branches, and a number of tips to make using svn with rails easier. He doesn’t cover undoing new files, but it’s a great introduction that I wish I’d had when I started using Subversion with Rails. Highly recommended.
I’m new to subversion, so if there’s a better way to do this, please pass it along. I just worked this out, and I’m posting here as much for my own reference as anyone else’s.
Let’s say you’ve got made a bunch of changes in the working directory of a project managed with Subversion. These changes include new files added to the tree, possibly in new directories/subdirectories. As a concrete example, suppose you’ve just run a Rails generator (e.g. script/generate resource user), and changed your mind (e.g., you should have used scaffold_resource). You want to revert to the last check in, reverting existing files and removing any newly created files and/or directories that don’t exist in the repository. Of course, this whole use case assumes you’ve committed any previous changes before making the changes you don’t like. You do commit incrementally, early, and often, right?
My first instinct was this:
svn revert -R .
But that’s only half the answer. Files already existing the repository are reverted, but new files and directories still abound. A check of svn status reveals the remaining damage:
? test/unit/user_test.rb
? test/functional/users_controller_test.rb
? test/fixtures/users.yml
? app/helpers/users_helper.rb
? app/models/user.rb
? app/controllers/users_controller.rb
? app/views/users
? tmp/sessions/ruby_sess.5337b01cd2bbeca8
? db/schema.rb
? db/migrate
Assuming you’re on a Unix-like system (oh, say, OS X), the following will remove all of the offending files and directories:
rm -rf `svn st | sed 's/\? *//'`
A check of svn status should now be blessedly quiet.
Obligatory Nag/Warning: Use Caution! Any command line that begins rm -rf is likely to end in tears. Your Mileage May Vary. Caveat Emptor. No Warranty, Expressed or Implied. Want to double check what you’re about to trash? Run the bit inside the backticks (svn st | sed 's/\? *//') to see the file list. Finally, remember to run svn revert -R . first!
- Wool-gathering
- Yak-shaving
- Wikipedia-surfing
- Hand-wringing
- Blog-posting
Note: The pedantic reader may note that some of these phrases do not traditionally contain a hyphen. The pedantic reader is asked to note this quietly to him- or herself.
In my previous post, I mentioned the Drobo as a possible option for my plan to eventually move to RAIDed storage for my backups. I forgot to mention that I expected to see a review from Sean based on this teaser post a few days ago. It looks like he pulled the trigger, complete with 2 terrabytes of drive space. Money quote:
It took more time to open the packaging than actually doing the install.
I’m looking forward to some further impressions, especially with regard to transfer speed. As a professional photographer, he shuffles some serious tonnage of data around.
Backups are the New Year’s Resolutions of computing. You start out with good intentions, and by the end of January you’re eating Twinkies and you haven’t backed up in weeks. Prior to my iMac’s premature death, by backup strategy was the electronic equivalent of keeping your savings under the mattress- I burned my iPhoto Library to DVDs, copied a few things to another machine when I thought of it, and mostly forgot about it. I kept meaning to do something about it, and then I kept not doing anything about it. I was also dragging my feet because I was waiting for the fancy new Time Machine feature in Leopard, originally due out in June. Nothing could possibly go wrong before Leopard comes out, right?
Of course, nothing leads to good backups like systems failure and data loss. This time I was lucky- my data loss was only loss of access to my data; once the iMac was fixed, all my data was right where I left it. Had my dead logic board been a dead hard drive, I would been up the proverbial creek, which empties into the Bay of Despair, where lies the Isle of Self Recrimination. And so it was, that after unpacking the Mac and confirming everything worked, and after a brief aside (read: reboot) for the latest Mac OS X security update, I started working on a backup plan.
My long term (say, 6 months tops) plan is to have automatic backups to some kind of RAID setup. Storage just keeps getting cheaper, and RAID is no longer requires rocket surgery to use. For USD 400.00 at my local Apple Store, I can get a terrabyte in box from Western Digital, usable as either RAID 0 (no protection, seen as one big drive) or RAID 1 (half the storage, but double the copies) via USB 2.0 and Firewire 400/800. For USD 500.00 I can buy a Drobo (be sure to watch the video), a USB 2.0 (sure wish it had Firewire 800) self managed RAID box that can sport 1 to 4 drives of any mix of sizes, and intelligently manage the RAID automatically. Of course, I’d still have to shell out for drive(s), but the beauty there is that you can only buy as much storage as you need (any brand SATA drive), allowing storage prices to continue to drop. Also, it’s a one-time investment; if you run out of room and free drive bays, you replace smaller drives with bigger drives, one at a time, as needed. Either of these solutions could be hung directly off my Mac for use with Time Machine, or attached to my Linux server or an NAS for a networked setup.
In the interim, I’ll settle for a nightly copy of the data I care about- In my case, that’s the /Users directory and everything in it. I have an old beige box in the basement running Linux as a headless server, among other uses it hosts 160GB of storage via Samba. Keeping my ~85GB of /Users data copied onto the 160GB drive should be good enough for now- if either machine goes, I’ll have one good copy.
To maintain my copy, I am using rsync (see also the Wikipedia entry). I recalled that there are some issues with rsync on OS X, including the fact the the HFS file system used by OS X supports resource forks, which most other file systems do not. A bit of the Google turned up this rsync on OS X Mini-HOWTO at lartmaker.nl that nicely sums up the issues and offers a patch for Apple’s version of rsync. I compiled a new rsync on both my Mac and the Linux server with no issues, and proceeded to make a full backup of /Users to the remote system. For the curious (and for my own future reference), the particular rsync incantation I used was:
sudo /usr/local/bin/rsync -aREx --delete /Users/ user@server:/var/local/sync/iMac/
Where of couse user and server are placeholders, and /var/local/sync/iMac/ is a directory I carved out to hold the backup. I already had SSH setup between the Mac and the server; any decent rsync guide can elaborate on that if you don’t know the dance. The next step is to automatically run this command nightly, which will require a little re-jiggering; my default SSH key is protected by passphrase. I found one way of automating rsync, but I plan to do a little more research. For the next day or three, I’ll run it manually before bedtime.
Good news! Sherri tells me the Apple store called, and my iMac is ready to be picked up! I’m on the train home from NYC right now (iPhone!) but I’ll pick it up tonight.
Update: The iMac is back home and running again. After a week of using my 15″ Powerbook, this 20″ screen is HUGE. Next step is to setup automated backups to my Linux server, via rsync.
(I have a follow-up planned to last night’s post, but this isn’t it; maybe tomorrow.)
My daughter Ashley starts college in a little more than a week; today she finally got a look at her schedule for the fall semester. The good news is that she got all three of the dance classes she requested (her major), the bad news is that the rest of her schedule is a train wreck. She’s not signed up for marching band, which she really wants to do, and she is signed up for Biology… the one lab science that she really doesn’t want to take. To round it out, they filled in one of her many liberal ed requirements, and she’s not happy with the choice.
While no course changes are accepted before everyone reports to school, they already have time set aside for each freshman to meet with an adviser and make changes before classes start. So we spent a couple hours tonight, going over all of the General Ed/Liberal Ed requirements and options, reading up in the catalog, and identifying the courses she’s interested in. This includes many courses she’ll be taking in semesters to come. There’s a small chance one of the dance courses will conflict with band rehearsals, but we think it will work, and she’s going to check with the band staff before check in.
It took forever, and brought back memories of collegiate bureaucracy for both her mother and I, but it was also fun, and totally worth it. She was a bit upset when she first saw her schedule; I think she’s a lot more comfortable with it now that she knows she has some options.
So I’ve got this thing. Maybe it’s a habit (got several of those), maybe it’s a quirk (many of those), but it’s certainly a thing (too many to count). If I was trying to frame it in nice terms, I’d call it restless creativity, or perhaps serial enthusiasm. I tend to get focused on something, and then I get really focused on it, for a while. Buy some books, search the web, generally soak in it for a while. And then… poof …I’m not so interested, and then something else comes along. Lather, rinse, repeat.
One thing I’ve noticed is that all my restless pursuits tend to be creative in nature; I want to make things. When my focus is on music, I’m trying to compose. When the computer grabs my attention, it’s either a programming project or a web site, that’s where this site, and a couple of redesigns have come from. I’ve got a stack of books on the shelf about hobby robotics. I’ve tried to learn Spanish several times; I guess that’s not creative, so we’ll call it the exception that proves the rule.
And from time to time I decide to write. I’ve got a file full of story ideas somewhere, which haven’t gone anywhere. Part of the pattern is that I like to spend a lot of time on upfront tasks, and never get around to the task at hand. Another problem is that I have a thing (ok, another thing) about doing things well; I wouldn’t say I’m a perfectionist, but I like to do things well, which makes it hard sometimes to practice something I’m not good at. On more than one occasion, I’ve decided to use this blog as a place to write for the sake of writing. You know, what the kids call blogging. That usually leads to a round of yak shaving, and my attention span runs out before I get back to the task at hand. Like the time I spent several days setting up a separate writing blog, which I never used.
And this isn’t new, two years ago I wrote a post about just writing someting:
In my last post, I talked about the forces that prevent me from writing blog posts- factors I collectively call friction. One of the things that I cited was a desire to get things done first- for example, to make some headway on a new project before discussing it. Another version of the same problem is the desire to work out an idea completely before trying to explain it. In this entry I’m going to try and throw caution to the wind, and write about some ideas which aren’t fully formed, but which have been rattling around in my skull for a while.
All of which is both backstory and progress. I have a current project which I’m focused on, a web application which I’d like to write. Since this one has a purpose- I’d like to turn it into a salable product- I have a reason to remain focued. At the same time, I’ve gotten the urge to write again (catching up on my Wil Weaton backlog on Bloglines seems to do that). So I thought I’d take a stab at it, and you’re soaking in it. Maybe I should try this again, tomorrow.
There’s never a good time for your computer to die, but I suppose the timing could be worse. This morning, as I was leaving the house, I stopped at my iMac only to find it was off, and wouldn’t turn on. Tonight I ran through the diagnostic I found on apple’s website. It doesn’t look good. There’s a chance my problem is covered by an Apple extended warranty; I’ve got the right serial number. If my issue is covered, the repair will be free. If it’s not, it’s probably a bad logic board, which can be quite expensive.
Which brings us to the title of this post… Tomorrow Apple is holding a media event, and popular opinion is that Apple will introduce new iMacs. If the repair is going to be too expensive, I’ll probably consider buying a new iMac. Hopefully, with the release of new macs, the current generation of macs will be discounted at my local Apple store. And of course, if the new macs are really cool, I can always get the new model :). So, I’m waiting until tomorrow night to take my poor dead mac to see the genii at the Apple store.
In the meanwhile, blogging from my iPhone is possible, but a bit slow.
Update: Good news! After a two-day wait just to see a Genius, it turns out that my repair qualifies for the extended warranty. Guess that new iMac will have to wait ’till next year. Maybe by then, a non-glossy screen will be available.
The repair will take around a week; in the meanwhile my old Powerbook G4 is back in the rotation, sitting where the iMac should be, sharing my printers to the other Macs in the house, and allowing me to post updates here. With the addition of a USB bluetooth dongle I had laying around, I can even use the iMac’s full size keyboard; add in my trusty MS Intellimouse, and it’s almost like having the iMac back. Almost.
By default, Firefox will remember what you type in form fields, and will offer auto-completion of the field the next time you are faced with the same form field. In general, this is useful, but sometimes you may not want an entry remembered. Using the ‘Clear Private Settings’ option in the Preference Dialog you can clear all save form values, but what if you only want to remove one value?
As an example, I just logged into GMail a few minutes ago. On my first attempt, I fat-fingered something and ended up typing my password into the user name field, and pressing Enter. At this point both my username (from prior logins) and my password were cached by Firefox. A malicious user who obtained access to my computer could visit the GMail log-in page, and simply press [down arrow] in the user name field to see both my username and password. I could clear all saved form fields, but I’d rather just remove the password from that field’s saved values.
In IE for Windows, after using [down arrow] to select an item from the drop-down list of remembered values, you can press Delete to remove the item from the list of stored values. This doesn’t work in Firefox; however, a little experimenting revealed that shift-Delete provides the same function in Firefox (2.0.0.4 for OS X). I’ll test this on Firefox for Windows tomorrow at work, and update this post.
Several years ago, I decided to try my hand at making salsa. The experiment was a success, however, the notes I made on how I made it were promptly lost. Months later, I tried again. I made another satisfactory batch of salsa, took good notes, and lost them again. Since then, I’ve made salsa on a number of occasions, ballparked it each time, and gave up on writing it down. A couple days ago, I made a batch, and decided to document the recipe while it is still fresh in my memory.
Before I get to the recipe, a few notes. The reason I decided to make my own salsa in the first place is that I don’t care much for supermarket salsas available in jars. These products are too wet, containing much more liquid than vegetables, and are often too sweet. I like fresh salsa, full of lots of fresh vegetables, and not a lot of liquid. These days, you can often find decent fresh salsas in the produce or deli section of the supermarket; when I first tried this recipe, this wasn’t the case. Fresh salsas which I’ve enjoyed from the local megamart include Rojos, here in the greater Philadelphia area, and Sister’s Salsa, found in Maine.
I’ll also note that this salsa recipe is a work in progress. I’ll probably make some adjustments next time; I’ll discuss some of these after the recipe. I’ll also add that my taste runs to medium-hot or less, if you like your salsa rocket hot, you’ll want to crank up the fresh hot pepper content, and possibly adjust the seasonings as well.
Fresh Salsa Recipe
- 4 cups Roma tomatoes (approx 12-14 tomatoes)
- 2 cups finely diced onion (I like 1/3 red onion and 2/3 Vidalia)
- 2 cups diced orange and yellow bell peper (1 large of each)
- 2 medium jalapeño peppers, seeded and finely minced
- 1 tbsp paprika
- 1 1/2 tsp salt
- 1 tsp white pepper
- 1 tsp chili powder
- 1 tsp cayenne pepper
- 1/2 tsp dried cumin
- 2 tbsp apple cider vinegar
- juice of 1/2 lime, freshly squeezed
To prepare the tomatoes, slice each lengthwise into quarters. Using a teaspoon or grapefruit spoon, remove any seeds and inner membrane from each quarter, leaving only the outer flesh of the tomato. Dice. Combine all of the vegetables in a large bowl.
Combine the salt and all of the dried spices in a small bowl and mix thoroughly. Sprinkle about half the mixture over the vegetables and toss. Cover and refrigerate for 8 to 12 hours.
Remove the salsa from the chill chest and stir well. Have a taste, but take note… the salsa isn’t really done yet. You just need to decide how much more of the seasoning mixture to add. I usually add about half the remaining mixture, holding the rest in reserve. Toss again to combine, and add the cider vinegar and fresh lime juice. Refrigerate another 12 hours. You can serve it now, but it improves with age- it’s really good after a total of 48 hours fridge time.
Its worth noting here that I’ve never quite gotten the seasoning nailed down. I always make approximately 3 tablespoons worth, and add it a bit at a time, sampling as I go. The first couple times, it always seemed too hot at first tasting, so I needed something to reduce the heat. I found that a tablespoon or two of apple cider vinegar seems to fit the bill. At a later tasting, I end up adding more seasoning anyway, so I’m sure there’s more tinkering to do. The lime juice was a new addition this time around, as I had limes on hand for adding to Corona, and I think it added a bright note. Next time I may try the juice of a whole lime.
For those watching salt intake, I’d suggest that the salt in this recipe is necessary. The salt draws moisture out of the vegetables, allowing them to soften slightly, and helping the flavors to mingle. Also, 1 1/2 tsp (or less, depending on how much seasoning you end up using) in about 8 cups of salsa should work out to a reasonable amount per serving.
One of these days, I’ll make a full batch of vegetables, split it into 4 batches, and try a few variations on the seasoning concurrently, to try and nail the recipe down. The other thing I want to try is to use some fresh herbs to help shape the flavor, perhaps with less dried seasonings. The obvious choice is cilantro, but I’m not a very big fan. The taste seems to overwhelm everything else in a dish. If you should try this recipe, please post a comment with your thoughts, as well as any changes you may have made.