Random tidbits, thoughts, ideas, reviews, etc.Aaron Goes Yakkity Yak Photo: April Sun Sets on Shuntavi ButteYou are not logged in. Click here to log in. | |
Here are a few of my latest Yakkity Yak web log entries. Don't forget to check out my GPS cache hunt adventures, Astounding Adventures.
Page 3 of 14
Ruby ActiveRecord Newbie Question (Answered) and a PHP Cake/Rails Question
Wednesday, 15 August 2007 2:14 PM MDT
Yakkity Yak
I'm using Ruby's ActiveRecord single-table inheritance to define several types of objects. I've got a burning question that perhaps someone may be able to answer for me.
[NOTE: I've since answered this question, though I would still love to hear an answer to the question at the bottom of this post.] Read on, and if you can help me, please send me a message. First, an example of an ActiveRecord set of classes:
In the above, class Bar and the two subclasses Baz and Bop are all be stored in a single database table, with a type column that will determine which class each row in the table belongs to.
What if I want to make sure that for any particular set of Bar, Baz, and Bop instances that exist as rows in the database belonging to a particular Foo instance, that only a single Bop instance can exist at any one time in the database.
I can think of many ways that are quite cumbersome to enforce this restriction, but nothing simple and elegant. It would be nice to even be able to create a new Bop instance that was not yet saved to the database, and perhaps on save, to enforce the single instance rule, delete any previous Bop instances from the database.
Any suggestions? UPDATE: (Later, the same day as the above question was first posted) With a little experimentation with the has_one relationship, I answered my own question. I'd previously believed I couldn't use it with the above class structure, but in fact I can. So my modified Foo class looks like:
Of course this is only enforced if I don't bypass ActiveRecord's normal operation and set the foo_id field of a Bop class instance directly, but instead do something like foo.bop = Bop.new to replace the Foo's single Bop instance.
There's nothing like yet-even-more online searching of documentation to answer one's own questions. END-of-UPDATE Oh, and here's another only vaguely related question: Does anyone know if PHP Cake's implementation of ActiveRecord is 1:1 compatible with Ruby's ActiveRecord such that a PHP application and a Rails application could share a single back-end database data store? Think of it, the PHP app. creates an object, saves it, then sometime later, the Ruby app. accessess and modifies the object. It would be a thing of beauty. UPDATE II: Electric Boogaloo Now that I'm more familiar with Cake, it turns out it isn't really a PHP implementation of the Active Record though overall it shares some similar behaviors. So it definitely is NOT 1:1 compatible with Ruby's Active Record, though I'm sure with a little extra code one could get an application in one to work with objects from an application that uses the other. Just What I Needed: Match-Returning String Substitution
Tuesday, 12 June 2007 6:03 PM MDT
Yakkity Yak
I'm posting this from work, so this is your geekiness warning.
I've been working on some ruby scripts and I really could use a method in ruby's String class that does what String#sub! does but instead of returning the modified String returns the MatchData from the Regex that was String#sub!'s first argument.
Also, when passed a block of code, I wanted the MatchData passed to the block as the argument, not the string of the entire match.
So here's what I came up with:
class String
def matchsub!(*sym, &blk)
unless (blk.nil? ? (sym.size == 2) : (sym.size == 1))
raise ArgumentError.new(
"wrong number of arguments (#{sym.size} for " + (blk.nil? ? '2' : '1') + ')'
)
end
unless (sym[0].is_a?(Regexp))
raise TypeError.new(
"wrong argument type #{sym[0].class} (expected Regexp)"
)
end
m = sym[0].match(self)
return nil if (m.nil?)
s = blk.nil? ? sym[1] : blk.call(m)
self.replace(m.pre_match + s + m.post_match)
return m
end
end
Yes, I could have just used $~ (a.k.a. $LAST_MATCH_INFO when using require 'english') after calling String#sub!.
For example: String method:String class and one is able to avoid using $ variables.
Yes, there are other ways to accomplish the same thing using $1..$9, but for me, coming to ruby from perl, I like to avoid as much $ clutter as possible so my ruby code looks less perl-ish.
Microsoft: Who Can We Annoy Today?
Saturday, 14 April 2007 10:17 PM MDT
Yakkity Yak
Okay, I understand Microsoft's logic in requiring a "validation code" or other form of validation before allowing downloads. But sadly it affects honest licensees of Windows products like myself negatively.
Tonight at my parents home, my brother installed an 802.11 wireless networking card in their validly licensed Windows XP Pro workstation. I installed the drivers from the accompanying CD-ROM. Their wireless network uses WPA2 encryption, and unfortunately the software from the CD-ROM did not include WPA2 functionality, and their installation of Windows XP Pro lacked support as well. So I hop onto the net with my trusty Macintosh thinking I'll download whatever is necessary (KB893357) for WPA2 support under Windows XP, save the file(s) on my handy 2 gig USB thumb drive, take that to the windows box, and voilą all will be well. No such luck! Thanks, Microsoft! NOT! Thanks instead for a headache! I can't download the files to my Mac as it isn't running Windows and thus can't validate. Yes, there are work-arounds. I could download the validator software, stick it on the thumb drive, copy it to the XP box, run it, get a validation code, hand-type the code in on my Mac, then download the software I wanted in the first place. But what a rigamarole of hoops Microsoft makes one jump through! Annoying! So instead of taking the time to do just that, here I am griping on my blog. *chuckle* I've just managed to put off the inevitable is all I've accomplished here. Now I must stop typing and go do just that. Or I could fire up Parallels and use my valid XP Pro license running there to download it. Either option is an unneeded annoyance that makes non-Microsoft alternatives look more and more pleasing to recommend to those around me. So, Microsoft, get a clue! I'm running a Mac now and I love it. Perhaps if you didn't annoy your legitimate customers so much, they might stick with you. I only run XP for a very, very few applications. Sometime that reason might disappear, and then Microsoft will have lost me as a customer completely. Well there ya have it, my Microsoft is a pain-in-the-neck peeve of the day. UPDATE: -- 11:28 PM the same evening I gave in, launched Parallels and downloaded the WPA2 Windows XP package from Microsoft. My Parallels-installed copy of XP Pro validated perfectly as expected. I even went so far, once my parents' computer was finally online, to validate their XP Pro installation--it validated perfectly. This annoyed Microsoft customer may suggest a Mac mini the next time the parental units need a computer system. Hooked on Sanderson
Saturday, 07 April 2007 8:01 AM MDT
Yakkity Yak
Mistborn: The Final Empire by Brandon SandersonI first heard about Brandon Sanderson in October 2004 and devoured his debut book Elantris when it came out in 2005. Then this winter I belatedly learned he had another book in print, Mistborn: The Final Empire, the first volume in a fantasy trilogy.
Immediately I headed to Brandon's web site and scarfed down the sample chapters. That only fueled my appetite for the intriguing story, interesting characters, and the unusual magical world those few chapters introduced. I was an hungered. To feed the need to read I did something unusual for me. I paid a visit to the nearest local brick-and-mortar book store with intent to buy immediately, but was thwarted by lack of inventory. As usual, the store's clerk offered to order the book which would arrive in a week. In these days of online stores why on earth would I want to order something at a store that I'd then have to go pick up when it arrived when I could far more easily order it online and have it brought to my doorstep? Doesn't my nearby bookstore realize that their competitive advantage over online orders has to be either price, immediacy of inventory, or charm or atmosphere? As the store in question was a small B. Dalton in the nearby mall, a store essentially unchanged since it opened in the early 1990s (or was it late 80s, circa 1989?), it distinctly lacks charm and atmosphere. And in price it can't compete with online stores that include free delivery. The only chance they had to make a sale with me was to sate my immediate thirst, but they had not wherewith to quench. When the book arrived it was consumed in short order. The book did not disappoint. On the contrary, it lived up to my every expectation, and even exceeded them. I'd worried that as it was the first book in a trilogy that the story might end abruptly with a cliffhanger that would leave me a reader without nourishment until the second book arrived later in the year (August 2007 I believe). To my delight, the first book is a story complete in itself, though yes, there are plot threads-o-plenty to continue the overarching story. But the first book delivered a satisfying climax that will leave me well-fed enough to survive until the sequel comes. This is another excellent book. I'm now officially a Brandon Sanderson fan. (Okay, I already was based on Elantris, but now I'm doubly so.) I discovered that Brandon has been releasing chapters of another book he is finishing up called Warbreaker. Anyone can read the draft chapters online. In a few more weeks all chapters will be available online. That's the entire book! Of course I've been reading the chapters since I learned of them, eagerly awaiting Brandon's weekly release of the next one. He should consider this strategy of releasing a book completely online a success, as I will definitely be buying a hard copy when it's finally published. What can I say more? I'm definitely hooked on Sanderson. Dana Glover's CD
Monday, 26 March 2007 8:15 PM MDT
Yakkity Yak
Dana Glover's album TestimonyThere I was a few weeks back browsing the iTunes store when I heard a tidbit from an artist I'd never heard of before, Dana Glover, a track titled Reason from her album Testimony. The 30-second excerpt was intriguing enough that I bought the track for 99 cents.
Then I checked out samples from the other tracks. And with a little scouring of the web, found a much, much longer track sample to listen to. Enough of the bits I heard sounded good, and the longer sample from a track titled Thinking Over convinced me to buy the CD and not waste more money on iTunes, since the CD has much higher quality (uncompressed) audio. I ordered the CD from Amazon.com right away. The CD arrived last week, and I've had it on rotation in my RAV4. I love it! It's an instant favorite. It also gave me a chance to hurt my ears by cranking it up beyond loud. I admit it's fun to do, though I don't do it too often. The first track, Rain, hooked me right off the bat. The next track, Thinking Over was every bit as good as the bit I'd heard online. I enjoyed the other tracks a lot as well, but I think the first two and track five (the aforementioned A Reason that I already had from iTunes) are currently my favorites, and perhaps track seven, Make It Real, though I reserve the right change as I become more familiar with the other songs. This weekend I got the newest Norah Jones CD. It was pleasant, and I suspect I'll come to have a favorite track or two on it. But I think I've got enough Norah Jones in my music library for now. Unfortunately it had to compete with Dana Glover's CD and it lost. Ah, well. I'll give Norah some more ear time later after Dana's album has worn out its welcome. Did I Mention the RAV4? And a Macbook Pro? (No More iTunes Skipping...)
Monday, 19 March 2007 10:35 PM MDT
Yakkity Yak
My new white 2007 Toyota RAV4 enjoys the sunset amongst the mesas between Virgin, Utah and Rockville, Utah near Zion National ParkDid I mention I'm now driving a Toyota RAV4?
I'm no longer a Hyundai Sonata driver. It was a great car the three-and-a-half years I drove it. But I missed driving the dusty dirt roads of southwestern Utah. My old black Chevy Blazer 4x4 that I kept parked in Hurricane at my parents house most recently failed to pass it's safety inspection last year. I knew I could spend more money on it and get it to pass, but it had just a few too many things that annoyed me for me to want to pour any dough into it. I finally sold it to someone willing to take a fixer-upper and resurrect it. So on President's Day weekend last month, on the Saturday before President's Day, I asked my sister Janna to go test driving new vehicles with me. The first and only vehicle we drove was a white 2007 Toyota RAV4 Limited 3.5 liter V6 4x4. I'd spotted it the evening before and had done some reading on the 'net about it. We drove it, and I knew it was to be mine. Now my sister drives the Sonata and I drive the new RAV4. I never knew that I'd enjoy a sun roof. It never crossed my mind. Now I'm glad to have one. In the warm late-winter southern Utah weather, it's been a blast. My friend and coworker Cassidy recently acquired a sweet black Saab 9-3 Aero in November. (See it here on Cassidy's web site, or read Cassidy's blog entry about it here.) That Saab is a sweet, sweet ride, sunroof, quick acceleration, satellite radio, ready for bluetooth, nice stereo... Maybe it was his purchase that subconsciously inspired me to consider a change in automobiles. It turns out my new RAV4 is bluetooth enabled. If it hadn't been for Cassidy talking about bluetooth options for his car, I probably wouldn't have even thought about it. Sadly I don't have a bluetooth capable cell phone yet. And while I'm thinking of bluetooth, that reminds me. Since late November I've been typing on a new 17" Apple MacBook Pro with the Intel Core 2 Duo processor and 2 gigabytes of RAM. It came with bluetooth built in (but again I don't have any bluetooth devices to take advantage of it yet). I love it! I love my Mac! I still run Windows XP Pro sometimes with Parallels in coherence mode so I can balance my checkbook with MS Money. But other than that, I'm an Apple user now. On the new MacBook, I no longer have iTunes skipping issues. I don't know if the newer versions of iTunes (I'm running 7.1.1 currently) would have fixed my problem or not on my old Windows XP notebook. This laptop computer is beautiful. I love Apple's minimalist design. The metallic case is truly a thing of beauty. I love the backlit keyboard too when typing at night (like right now). And the built-in iSight camera makes Skype videoconferencing fun too. I had to plug in a USB camera on the old Windows notebook. Okay, I've ranted and raved enough about the toys. Forgive me, please, for the indulgence. P.S. It's now 11:23 PM and I've had the television on in the background while on the computer. My ears perked up when I heard the words "Technical Maintenance Minute" emanate from the television. I looked up and on the David Letterman show (oh, I mean the Late Show with...) were three ordinary, seriously looking guys talking television tech. geek speak. What was a little shocking and sad is that I understood the terminology they were bandying about. Eeeek! I chuckled at the short skit, and at myself. Man, I'm a geek! John Williams Still Has It!
Sunday, 11 March 2007 9:31 PM MDT
Yakkity Yak
By Request... The Best of John Williams and the Boston Pops OrchestraThis evening I listened to a CD that I've owned since the late '80s. It was one of the first CDs I purchased after receiving a boom-box-style CD player (which included the '80s-required built-in dual cassette player) from my parents for High School graduation -- no mean feat, considering they weren't remotely wealthy and CD players were newfangled gadgets -- a gift which totally boggled me out of my mind. That was back in the days when cassette tapes ruled the music world and in small-town Hurricane, Utah CDs were hard to come by.
What's the CD? John Williams and the Boston Pops Orchestra's "By Request... The Best of John Williams", a collection of John Williams' own well-known compositions performed by the Boston Pops Orchestra under the direction of the composer-conductor. At 18-years-old, I heard for the first time "The Cowboys Overture" and was swept away. So tonight I queued up track 2 and gave it a listen. Wow! John writes good stuff! It had the same impact, the quick tempo and catchy melodies sweeping me up in the sound. I listened, eagerly awaiting the climax moment (at a little over 7 minutes into the nearly 9 minute song). Would the vivid imagery from those years ago be the same? There it was, at about 7:15! The mental imagery was there! The song still took me to a high mountain peak on a sunny afternoon with cool, crisp air and a stunning vista spread out below me in panorama! Perhaps it was Pine Valley Mountain's Signal Peak, a mounain top at over 10,000 ft. in altitude that stands out so well that if you ever fly out of Las Vegas for parts north or east of Las Vegas on a clear day, and if you know where to look, you can't miss it -- it is visible from the air for hundreds of miles. The peak overlooks the surrounding southwestern Utah communities of St. George, Hurricane as well as proffering grand views of the majestic sandstone cliffs of Zion National Park to the east, which cliffs tower above broad mesas that Wile E. Coyote would be right at home chasing Roadrunner around. That passage in The Cowboys Overture always makes me think of standing atop a peak or tall cliff with majestic vistas spread below in the crisp, clear air. Quite apropos to think of such Western U.S. landscapes while listening to a piece titled "The Cowboys Overture" I think. I think I appreciated the middle passages of the song now that I'm older. Just as I've grown to love Holst's Saturn, I've come to love melodies and passages that include a hint or more of melancholy, struggle, sorrow, or pain, especially those that do so without wallowing in it, instead expressing the emotions in context of continuing life and future hope. As a teenager I probably mostly wanted to skip through the slower middle section to get back to the upbeat quick-moving stuff. (I'd never seen the 1972 John Wayne movie "The Cowboys" that the music was written for nor have I seen it since, so I have no mental association between a movie and the music.) Thank you John Willliams! You're amazing! I love your music, have from my teens, and will ever love it. You're right up there in my book with Holst, Grieg, Copland, Gershwin, Dvorak, Ravel, Bach, Vivaldi, Beethoven, and all them thar other musical geniuses since the list could go on forever and cover a bazillion musical styles. (Hmmm, the "them thar" phrase, is that "The Cowboys Overture" infecting me with Western-cliche-style-speak?) FreeBSD Jail Script
Saturday, 13 January 2007 2:47 PM MST
Yakkity Yak
Back in summer, I wrote a short, short little perl script for setting up a bunch of FreeBSD jail environments using a single base directory from which each jail would access via read-only nullfs mounts within each jail. This web site is running inside just such a jail environment.
I've since used the script on my personal server and at work where it has proved very useful. Like much of my computer geek stuff, it comes with little-to-no documentation other than the comments in the script itself and also those on the web page I made for it. The web page is here:I'd intended to post this in September, so the web page has been available for over four months, but without any links to it. This post should remedy that. UPDATE: 13 June 2007 Since I originally posted this, I've been converted to ezjail from the FreeBSD ports collection. It does much, much more than my script. Very useful!
Thanks, Dirk Engling! O Holy Night - New Orleans Musicians Play It Sweetly
Thursday, 14 December 2006 6:58 PM MST
Yakkity Yak
New Orleans Musicians Playing O Holy Night on NBC TelevisionI don't know how long it will be available, but a sweet brass and woodwind rendition (with what sounds like some synth strings during parts, but I could be wrong) done by New Orleans musicians who have been helped by the Tipitina's Foundation for an NBC television program is currently available from NBC's web site. Right click on the MP3 web link to save the file to your computer. Here's the link to the file on NBC's web site:[UPDATE (August 2008): The above NBC download link has long since stopped working. As of today (19 August 2008), try the link below, hosted on the Tipitina's Foundation's own web site instead:] [UPDATE (January 2010): The updated link above no longer works. I hope the musicians don't mind if I instead link to the copy I obtained from the above links earlier and to which I added MP3 informational tags including the musicians' names. Here it is:] O Holy Night.mp3 Check it out before NBC moves the file or removes it or it otherwise goes away. Thanks, NBC, Troy "Trombone" Andrews (on lead trumpet), Kirk Joseph (sousaphone), Roderick Paulin (saxophone), Frederick Shepherd (saxophone), Stephen Walker (trombone), Mervin "Kid Merv" Campbell (trumpet), Bob French (drums), and anyone else involved, for a Christmas music treat! I hope the Tipitina's Foundation's rebuilding of post-Katrina New Orleans music culture keeps up (especially with sweet sounds like this)! Voice Mail - Beware of Voice Phishing
Monday, 11 December 2006 3:22 PM MST
Yakkity Yak
The first time it happened, I just thought it a little odd. I checked my voicemail for my home telephone and an elderly gentleman appeared to be asking about a relative who was in the hospital or under some other full-time medical care. I deleted the message, assuming it was one of those random wrong numbers, and speculated that perhaps because my home phone has one of those "Press 1 for X, 2 for Y" style voice prompts that maybe the caller mistakenly assumed he'd correctly dialed an institution of some sort.
This afternoon it happened again. A nice woman with a Latin American accent left a message asking about an insurance approval for her son's. She left a call-back number. What if she didn't realize that she'd called the wrong number? What if, whatever her insurance issue, it was important that it be handled in a timely manner? What if it was very, very important? These questions worried me. I called her back and she answered. I let her know she had dialed the wrong number. Afterward, I felt safe to delete her voicemail message. This can't be a coincidence. Once could be a random misdial, but two medical-related voice mail messages in the past two weeks when I usually get only voice mail that really does belong to me. So I did some checking. It turns out that if one transposes two of the digits in my number, they get the phone number for Dixie Regional Medical Center. Well, at least one of DRMC's numbers. That explains it. Now I'm debating whether it would be a good idea to mention that my home number is definitely not the local hospital's number in my automated greeting. If this happens again, I'll be sorely tempted to do so. The computer security and personal information protection sides of me are hollering loudly that malicious phishers could obtain telephone numbers close to those of a medical institution and illegally obtain personal medical information and exploit it (perhaps insurance fraud). That would be terrible! (And it would increase costs to all of us. We all pay for insurance fraud through higher premiums.) So please, when calling anywhere, be very, very careful you are dialing the correct number. And don't leave personal information until you have confirmed that you are correctly connected.
Page 3 of 14
Part of The Singles' Blogward web ring (powered by RingSurf)
Home Teach | Join | Ward List | Who's that? | Visit Teach | |