Spellcheck
Posted by Andrew Flanagan in Geekiness on May 21, 2007
I have a spelling checker,
It came with my PC;
It plainly marks four my revue
Mistakes I cannot sea.
I’ve run this poem threw it,
I’m sure you’re please too no,
It’s letter perfect in it’s weight,
My checker tolled me sew.
-AnonymousÂ
Sunrise/sunset code?
Posted by Andrew Flanagan in Geekiness on May 8, 2007
It appears that the PHP bug has mysteriously righted itself? If so, great! If it’s still flipping between two different hours, oh well…
iTunes server on Gentoo?
Posted by Andrew Flanagan in Actual Events, Geekiness on April 28, 2007
The post says it all — I have all my music on Gentoo Linux but I would really like it if I could stream music onto the computers around the house using the iTunes interface. It’s easier than browsing files and it’s got nice built-in search features.
Lo-and-behold, you can do it! Thanks to Apple for making software that can actually be interfaced with! Also thanks for to the wonderful users of Gentoo who somehow find time to write HOWTO guides for practically everything. The details can be found here.
FLAC -> MP3
Posted by Andrew Flanagan in Actual Events, Geekiness on April 28, 2007
So… I finally got my hard drives installed on my home server and now I just need to get my music collection into shape so I can actually play stuff. When I originally made copies of my CDs I converted them to FLAC. Why FLAC? Because I was being anal and didn’t want to “downgrade” my music to a measily 192kbps MP3 format. I know this is probably trivial, but if I retain the FLAC versions, it’s as if I have the original CD. Yes, I can’t tell the difference between 192kbps MP3 and the lossless FLAC, but the point is, if I ever want to convert all my music into AAC or (heaven’s forbid!) WMA format, I can do it fairly easily if I’m starting from a lossless format. If I start from the 192kbps MP3 I’ll start getting really degraded sounding stuff pretty quickly. So that’s my excuse.
How to accomplish this? In the past I’d used mpg321 to do the conversion but this time I used ffmpeg. I have all my CD collection in a directory on my system.
find "/var/mirror/Data/Audio/My CD Archive/" -name *.flac -exec /var/scripts/convert.sh {} \; |
And /var/scripts/convert.sh contains:
ffmpeg -y -i "$1" -ab 192 "`echo "$1" | sed -e 's/.flac/.mp3/g'`" |
This seems too much mess, but it appears to be working. The drawback? ffmpeg doesn’t seem to parse the “tag” information for each file so I’m ending up with “naked” MP3s (no ID3 tag). Not the end of the world. I’ll clean them up when I’m done.
The process is still chugging away — it’s completed about half of my collection.
Edit: I went ahead and figured out what I need to do to get the tags across. I installed the flac and id3 ebuilds and can now run the following script (using the same find command) to get the tags to match up from the flac files to the mp3 files.
OUTF=`echo "$1" | sed s/\.flac/.mp3/g` ARTIST=`metaflac "$1" --show-tag=ARTIST | sed s/.*=//g` TITLE=`metaflac "$1" --show-tag=TITLE | sed s/.*=//g` ALBUM=`metaflac "$1" --show-tag=ALBUM | sed s/.*=//g` GENRE=`metaflac "$1" --show-tag=GENRE | sed s/.*=//g` TRACKNUMBER=`metaflac "$1" --show-tag=TRACKNUMBER | sed s/.*=//g` id3 -t "$TITLE" -T "$TRACKNUMBER" -a "$ARTIST" -A "$ALBUM" -g "$GENRE" "$OUTF" |
Thanks to this page for the info.
Some helpful SQL
Posted by Andrew Flanagan in Geekiness on April 4, 2007
I had needed this before and I had to go out and find it again so I figured I’d post it this time. Here’s a really helpful SQL script that will let you do a “search and replace” within a single column of data in a table. Very, very handy when you need to update inline links (which is what I’m doing in the example below). I had set the default location of where images are saved to a folder called “uploaded_images”. I later changed this to wp-content/images but the old posts still pointed to the old location even though the new posts pointed to the correct location. In order to make the old point to the new, I moved the files on the server and then ran the below script.
UPDATE `wp_posts` SET post_content = REPLACE(post_content, "uploaded_images", "wp-content/images") WHERE post_content LIKE "%uploaded_images%" |
A rather mean but funny quote
Posted by Andrew Flanagan in Geekiness on April 4, 2007
Some people are like Slinkys… Not really good for anything, but they still bring a smile to your face when you push them down a flight of stairs.
Geeky Stuff
Posted by Andrew Flanagan in Geekiness on March 30, 2007
I’ve been somewhat annoyed by PHP recently. For an example, see the script running the sidebar that shows the sunrise/sunset. Now granted, it’s an odd script to include in the main PHP libraries. However, if it IS included, I really wish it would work correctly. It’s really odd because it fluctuates between the correct time and 1 hour offset from the correct time. I have no idea what it is doing. I’ve also found quite a few ways to break it and make it return bogus output. It’s kind of annoying.
On the home front, I finally got my RAID solution in place. I went cheap and got two 500GB hard drives ($145 each) and a HighPoint RocketRAID 1740 RAID 0/1/5 4 channel SATA 3.0 GBps card ($110). I set the hard drives up (went smoothly) and then after only a little bit of a struggle, reconfigured my Gentoo kernel with the rr174x driver. I’ve had so many bad experiences with poorly written linux kernel device drivers but this one was fun. I did a make patchkernel on the device driver and then a make menuconfig on my kernel. I had wanted to clean up some junk that was currently being compiled into my kernel so this was an opportunity to do this. Recompiled the kernel and rebooted and voila, I see /dev/sda1 ready to go. I went ahead and formatted it with XFS and shared it out to my local network as a Samba share.
I also wanted to configure the RAID Management daemon in order to monitor the health of the RAID array. I thought this was going to be hard but it seemed to work just fine. I downloaded the RPMs provided by HighPoint on their website and just did a rpm -Uvh –nodeps on them (it was listing some bogus dependencies so I had to ignore them — I’m not sure why this is). Both the daemon and the CLI installed like a charm. I had to remember my ISP’s SMTP settings (always a pain) and although their mail server is SLOOOOW, it appears to be working.
I also went ahead and installed smartmontools in order to check my non-RAID hard drives on the system. Might as well make sure everything’s working nicely!
Down the road, I may go ahead and upgrade this array to a 1.5TB RAID 5 array. For now, it’s a lowly 500GB RAID 1. I think for now, 500GB is plenty for my needs. I have a lot of other hard drive space, so the 500GB is only for the stuff that I can’t afford to lose. My bet is that when 500GB becomes too small, they will have dirt cheap 1 or 2TB drives that I can use in place. Then again, who knows how long SATA II will be a standard…?
Life
Posted by Andrew Flanagan in Actual Events, Ranting & Ravings on March 26, 2007
It goes on… Thinking of refinancing the house and that’s about all that’s new. I’ve been spending very little time with computers recently. I got two new 500 GB hard drives and a nice RAID card that I was going to set up in a mirrored array but I’ve been slow on that. Other than that, it’s just been work and boring stuff. Spring is here and things are starting to become more green and colorful. Hopefully it stops frosting soon…
I think I need to stop doing projects for a little bit and just relax. Maybe catch up on some reading that’s been piling up. I have about 20 books that I’ve started but not finished. That’s not good.
Anyway — more interesting stuff when my life becomes more interesting…
Fun with PHP
Posted by Andrew Flanagan in Geekiness on February 20, 2007
A neat little bit of code to display sunrise and sunset (the functions are built into PHP but I’m guessing many people don’t realize).
<?php $lat = 47.133031; $lon = -122.274538; $zenith=90+50/60; $offset=0; $location = "Puyallup, WA"; $sunrise=date_sunrise(time(), SUNFUNCS_RET_TIMESTAMP, $lat, $lon, $zenith, $offset); $sunset=date_sunset((time() + (12 * 60 * 60)), SUNFUNCS_RET_TIMESTAMP, $lat, $lon, $zenith, $offset); $message = "<ul>"; if (date("U", $sunrise) < date("U", time())) { $message .= "The sun rose today at "; } else { $message .= "The sun will rise today at "; } $message .= date("g:i a", $sunrise); if (date("U", $sunset) < date("U", time())) { $message .= " and the sun set today at "; } else { $message .= " and the sun will set today at "; } $message .= date("g:i a", $sunset); $message .= "</ul>"; echo($message); ?> |
Software Engineering
Posted by Andrew Flanagan in Geekiness, Ranting & Ravings on January 28, 2007
There has got to be a better way of doing Software Engineering than what we’re currently slogging through at work. I heard a guy on NPR talking about Software Engineering broadly and mentioning that one of the problems is that there really aren’t any established standards. Why is software so much harder to build than “real stuff” like bridges and buildings and highways. Granted, there are plenty of examples of poorly constructed bridges, buildings, and highways but it seems like there are more standards and better practices applied in those disciplines. Maybe it’s because people’s lives depend on quality design and construction. But then again, much software out there can be “life saving” in similar ways. The software than runs medical systems or military systems is life altering. Maybe that’s why so many of those systems are out-dated technologically simply because no quality product (no matter how much newer) has been successfully developed.
So, what’s the problem and why hasn’t it been solved? Maybe it’s because software is too easy to build (hey, it’s just rearranging rust on a metal plate). It’s easy to release something, hope for the best and just fix problems when they come. A lot easier than constantly taking a bridge apart to fix engineering faults. So maybe the issue is that because software is “so easy” to fix, few people take the time to get it right first when they can almost just as easily get it wrong the first 20 or so times. Why debug a program when the public does this for free by submitting trouble tickets? Of course, some products actually work remarkably well and seem to have been tested and released in an environment that really was focused on quality. But even these products DO have major problems and DO have major releases that fix problems and create new ones.
In building bridges, we have physics to contend with and although it’s difficult to beat and it’s amazing what humans can accomplish to “beat physics”, it’s a relatively simple set of rules that will determine whether the design will work or not. Civil engineers don’t get involved in string theory to build a bridge, they assume a pretty normal set of conditions — the same sort of conditions that allowed Greek builders 2,000+ years ago to build beautiful and functional buildings. In software, we don’t really have a set of rules. We’re trying to make the customer happy and so we have to modify it to meet their needs. Their needs (and desires) change daily so it’s an always moving target. A bridge might be built a certain way but will only be rebuilt when the desire is so great that it warrants the amazingly high cost to redo the work. Software suffers from the problem that every change is just so darn easy — or at least that’s the belief.
Or maybe it has to do with what we’re building. We’re not trying to build something that exists, we’re trying to optimize (automate and streamline) the flow of information. When you’re building a bridge, you’re concerned (usually) with making a platform that things can move across to get to the other side of the bridge. When you build a software program you’re concerned with making stuff move quicker and quicker and better and better to more and more places. It has no solid end-goal. “Better” is pretty much what Version 2.0 of all software products advertise. Better because it moves information faster, or more efficiently to more places or presents it differently (in some abstractly “better” way). It’s all so subjective. If you have an existing software program that runs “slowly” you could rewrite it specifying that it should run “twice as fast”. But this is a silly requirement if current technology allows it to run 200 times as fast. Things change so often and so quickly that what you want at the time of the writing of the software is “the best”. But the best will have changed between the time that the project requirements were written and the time that the software product is released. It seems just as silly to say “200 times as fast” at the beginning of the project (because the engineers assure you it can be done) and meet that goal only to find out that your system is now out of date because it can now be done 400 times as quickly with only minimally more effort.
A bridge has subjective elements of design. It should be “beautiful” or “classic” or something like that. These details are worked through with the architect and the customer who nail down what that means exactly. Functionality is essential though. With regards to these subjective aspects, the customer has to decide how much beauty can be got for how much money and come to a decision on that. There’s going to be a trade-off on the beauty part. In software, although I rarely would call one of my own creations “beautiful”, most of the design ideas are subjective. “We want it better” means little. “We want it faster” means more but doesn’t tell me as an engineer what the final product should look like. “We want it 100 times faster” means a lot but either it’s not feasible to do this at this time, or if it IS feasible, it’s unlikely that the customer really wanted it that much faster (i.e. it was probably the engineers idea to put the number “100 times” into the requirement since they knew that was what WAS feasible). If this is the case, the customer might end up with a product 100 times faster but won’t be happy to find that this puts them behind the curve when the product is done. When you’re talking about a highly integrated product or a “system” of multiple software packages, hardware, and processes, it’s almost impossible to ever deliver a “modern” system.
What’s the answer? I have no idea. It seems like there’s got to be some sort of way structuring a design and development process to focus on the unique aspects of software products. Check this space for more ramblings.