Sunday, September 14, 2008

Thoughts on Naming Children

I have a friend named Kayla. She has two siblings: a sister Kasey and a brother Kyle. Notice a theme? I do.

And for no apparent reason this got me thinking recently about how I want to name my children some day. What I’ve determined is that I must marry someone whose name starts with either a J, K, or possibly an I (but I can’t for the life of me think of anyone I’ve met whose name starts with the letter I).

Why?

Because, if I marry J, then all of our children could be named with J’s...

Or, if I marry K, then our children could be named progressively with L, M, N... (I hope there’s not more than three...) The same applies to “I”, but in reverse (H, G, F...)

Ridiculous? You bet! I’m of course not going to limit myself to relationships with people whose names start with I, J, and K, but who knows, maybe I’ll meet someone with my same sense of humor who likes this schema for child-naming... I’ll keep dreaming.

Thursday, September 11, 2008

Sudoing in PHP to Reset Folder Permissions

At work today I engaged our academic file server (running Mac OS X.5.4) in an on-and-off all-day battle about folder permissions. The problems:

  1. One of our teachers kept getting locked out of his folders on the server when he modified or moved them from his PC client. Bummer. I needed an EASY way for him to reset his permissions himself, meaning:

  2. I needed to create a web-accessible script (in PHP) to make a UNIX call to reset his permissions on-demand (ie, whenever he visited the page, his permissions would be reset)


Here’s how I eventually won:

I created a file in the server’s web host root (for this particular server, just the default /Library/WebServer/Documents/) called teachername.php (where “teachername” is the teacher’s name... duh). Even though our website is hosted on a separate server, the server in question also has web services enabled, which will allow the teacher to simply visit
servername.domainname.net/teachername.php and the server will run the script.

Creating that script wasn’t as easy as I expected, though. After hours researching and trying to get PHP’s system() function to work, I decided to try exec() instead. The file contents look something like this:


<?php
$output = array();
$return = -5; // Some erroneous value
exec("sudo /bin/chmod -R 770 /Volumes/Share\ Point/teacherusername/",$output,$return);
echo "chmod output: ";
print_r($output);
echo '<br /><br />';
echo "sudo/chmod return value: " . $return . "<br /><br />";
echo "<strong>Permissions reset complete.</strong>";
?>


There's really only one line that's important, the rest is all debugging info:

exec("sudo /bin/chmod -R 770 /Volumes/Share\ Point/teacherusername/",$output,$return);

This tells PHP to spawn a new child process to execute the sudo command. I had to add apache’s _www user to the sudoers file on the server (in Terminal, use the command "sudo visudo", then edit using vi commands):

_www    ALL=NOPASSWD: /bin/chmod,/usr/bin/whoami

IMPORTANT SECURITY NOTE: the _www user ONLY has permissions to sudo the commands chmod and whoami (and do so without a password), it ISN'T allowed to sudo anything else. For more information about modifying the sudoers file, refer to http://linsec.ca/Using_Sudo_to_Limit_Access, as well as the limited documentation available in the file itself. (you can try it on your own Mac, just open terminal and type "sudo visudo").


The rest is basic POSIX permissions: change mode (chmod) -Recursively to -rwxrwx--- (770) on the teacher’s folder. The other PHP variables give the exec command a place to deposit both the return value from sudo (a 0 means successful execution), as well as any output that was generated by chmod (should be none).


Yes, I had fun with this puzzle. Hopefully someone else might stumble on this and find it useful, too...

Monday, August 18, 2008

The Secret TV Show of the American 20-something

ABC Family recently premiered a new show called The Secret Life of the American Teenager, a family oriented show that, refreshingly, talks openly and directly about issues surrounding teen sex and pregnancy. Despite the potential pitfall of stereotyped characters, the acting is believable, the writing magnificently real and oftentimes hilarious, and the underlying moral messages quite agreeable to my personal taste.

Why would I watch such a show, clearly targeted to an audience several years younger than myself? It all started while I watched through the 4th season of Wildfire on ABC Family’s website a few weeks ago - every “commercial break” they play an ad... except they literally only had three ads, which, after 13 episodes and 5 ad breaks per episode, became quite old really quickly. Anyway, after seeing the add for TSLOTAT no fewer than two dozen times in a three or four day period, I was tempted enough to check it out - it looked entertaining, and I typically like “chick-flick” type TV shows anyway.

What I loved most about the pilot episode was the writing. Seriously, I wish I could talk like these characters on the fly in real life, especially Ben - even in his awkward telephone moments he ends up saying something either profound or at least potentially meaningful. I also greatly appreciated one of the very first lines that Amy’s character says near the beginning: “I had sex.... It was not that great.... And it wasn’t fun and definitely not like what you see in the movies, you know all romantic and stuff.” Despite wearing its motives on its sleeve (to adapt a cliché), I greatly enjoyed how open TSLOTAT was at making such an anti-cultural statement. It’s high time television took a more realistic and less idealistic tact toward real-life issues of teen sex and teen pregnancies. Which is why I also appreciated the PSA-style monologue Amy’s actor delivers at the end of the episode, a well-scripted paragraph something to the effect of ‘teenage pregnancy is 100% avoidable.” Because it is. Regardless of one’s views on abstinence-only education, that fact remains, there is a simple solution.

On lighter notes, I also absolutely love Ben’s friends Alice and Henry - they are so hilarious! Every time they appear on screen, I know I’ll laugh. Alice is a 100% straight shooter, she acts as the dictionary pop-up-video with facts about everything Ben and Henry might banter about; and Henry serves as one wonderfully delightful (and friendly) foil to Ben through making bets that force Ben into action.

Thanks to a really good friend (someone who is even more addicted to the show than I; yes, I’m not the only one who loves it), I’ve finally caught up to the current episode, which means Tuesdays at 7:00, I’ll be on my couch watching ABC Family... except for tomorrow, when I have to work at that specific time to tech an event at school. Alas.

Thursday, August 14, 2008

Exponential Growth

While reviewing the first 150 pages of The World Is Flat as preparation for a brief Internet introduction to a group of Minnehaha eighth graders last week, I came to a scary realization: my 16GB iPhone 3G has a larger “hard drive” (even though it’s flash based memory) than my first several desktop computers as a child. Moore’s Law, you’re creeping me out!

NetBooting from OS X Leopard Server 10.5.4

I spent the better part of my day battling our new Leopard Server installation trying to get NetBoot working. It should have been as easy as creating a NetInstall set with Mike Bomich’s software, however, turns out there’s some funky graphics driver included in X.5.4 that causes net-booted PowerPC machines to kernel panic on startup... Well that won’t do. After lots of Googling, these threads looked promising, and for some admins’ issues, they may very well solve the problem:

http://discussions.apple.com/thread.jspa?messageID=7698665
http://discussions.apple.com/thread.jspa?messageID=7240134
http://discussions.apple.com/thread.jspa?messageID=7803336
http://discussions.apple.com/thread.jspa?messageID=7515103

Careful in that last one - if you delete your /etc/bootpd.plist file (like I did several times), it also mysteriously deletes your DCHP subnets... all of them... so if you had 10 configured... gone. And it turns DHCP off, which, if you’re NetBooting from your DHCP server, means all of a sudden you can’t NetBoot at all, because your client can’t get an IP address. Arg.


It was finally this thread’s solution that worked for me. Recreating kext files, who’d’a thunk?

http://forums.bombich.com/viewtopic.php?t=12079


kextcache -a ppc -m locationofnbifolder/ppc/mach.macosx.mkext -N -L /Volumes/Netinstall-Restore/System/Library/Extensions/

Friday, August 08, 2008

I Hate Chain Mail

There’s not a whole lot more to say on the matter. I hate urban legends that spread like e-wildfire, and I’m anything but fond of the emotional letters detailing heart-wrenching events that almost always prove to be fiction. I hate the pompous arrogance of emails that promise you something good in your life... if only you’ll forward this to ten more people... because if you don’t, of course, you’re uncaring and heartless. Worst, I hate how nobody ever bothers to delete the old email addresses out of the mail they forward (because almost no one knows how to BCC, even though it’s painfully simple), which means every time I receive an unsolicited chain email, my email address is suddenly also sent to 20 other people, some of whom may have virus-ridden PCs, and others of whom will forward that letter again, *still with my email address* to more and more people... No wonder spam emails have become so abundant over the years - well-intentioned, but problematically ignorant, people are helping it.

The rant is over. Kudos and thanks to those of you who forward using blind-carbon-copy (Aunt Judi, you’ve been trained well), and especially those who check Snopes first!

Friday, July 25, 2008

Speeding Tickets from CNN

I’m not sure how I feel about news articles detailing ways to avoid getting tickets, but that aside, I read something absolutely hilarious at the end of one such article on CNN today:

The worst possible thing you can do is combine all the no-no's listed above by driving a flashy car too fast, late at night when you're the only car on the road while looking like you just robbed a bank.

If you do that, expect a speeding ticket. And expect no mercy.


http://www.cnn.com/2008/LIVING/wayoflife/07/23/aa.speeding.ticket/index.html

Saturday, July 19, 2008

I Hate Microsoft

<rant>
I’m working on a site for Bethel Lutheran Church in Northfield, and, as with any new site design, the bane of my existence always comes back to cross-browser CSS compatibility. I’ve got my design working beautifully in Safari and Firefox, now comes the scary part: testing in Internet Explorer. I start up Boot Camp and open the page... Surprisingly, IE renders almost the entire page correctly, there’s only one glaring mistake. Fortunately, this *should* be easy to fix, because IE supports conditional comments, meaning I can insert style code that only IE will read and no one else.

Here’s the funny part: in looking up documentation on how exactly to do what I want, I found this little diddy on Microsoft’s site:

Conditional comments make it easy for developers to take advantage of the enhanced features offered by Microsoft Internet Explorer 5 and later versions, while writing pages that downgrade gracefully in less-capable browsers or display correctly in browsers other than Windows Internet Explorer.


It’s terribly ironic, because EVERY OTHER BROWSER is displaying the page correctly, it’s ONLY IE that fails miserably, time after time, site after site. Oh, Microsoft, how I hate you.
</rant>

Friday, July 18, 2008

Family Bonding

It may sound weird, but some of my fondest memories of “family bonding” growing up came from cleaning up small floods in the basement, either after a very heavy rain or if the drains backed up. This happened again a few days ago at my house, after my parents finished some unrelated plumbing fixes in the upstairs bathroom. Dad happened to go downstairs to get a tool or something, and came back up to tell Mom and I that there was water everywhere. Without any pause they immediately jumped into action with the shopvac and some rugs, and in a short time our team effort resulted in a nearly dry floor. The worst part: it was almost fun.

Thursday, July 17, 2008

Free Gas!

I’ve heard and seen ads that TCF Bank is offering free $50 gas cards if you open a new checking account with them, so, given the amount of driving I’m doing between Minneapolis and Northfield, I decided I’d give it a try. Less than half an hour and a very small deposit later, and I walked out the door with my gas card. Even better, because I already had two business accounts with TCF, I was qualified for a slightly special free checking account with a few extra benefits and free checks (only pay $6 shipping, rather than the $16 cost of checks themselves). Counting that against the free $50, I still came out $44 ahead - that’s about two thirds of a tank, w00t!