Recently in Computers Category

iPhone Fail

| | Comments (0)

My iPhone 5 power button is broken. It happened to one of our iPhone 4s, too, so ... um, Apple, please fix this. Maybe they did with the iPhone 5c/s, but we won't know for some time. But I can no longer simply press the power button to turn the phone off, or hold it down to shut the phone down, and so on. If I press reallllly hard, I might be able to get it to recognize the button.

Yesterday, an app crashed the phone (running iOS 7.0.4), pretty hard. The phone had been acting up for a couple of days, but this app stopped responding, and I could no longer go back to the home screen or any other app. Siri would respond, but I could not get it to open an app. "Open Safari, Siri." "I'm sorry, Pudge, I'm afraid I can't do that." (Paraphrased.)

So I tried to hold down the power button down reallllly hard, so I could slide the phone off. Nothing. I tried to reset with power button and home button, and it took a screen shot, and shortly after ... the screen went blank. The phone wasn't off, the screen was just blank. No backlight. So I backed up the phone with iTunes, and then I figured, well, with no backlight it'll take time to run the battery down, so I'll restore the phone. But I can't do that either, because I have to turn off Find My iPhone first. Which I cannot do because I cannot turn it off by voice and I cannot see the display, even if the phone would let me do it at all.

I tried to connect to it via my laptop, since Personal Hotspot can really bring the battery down, but I had earlier turned it off, and I couldn't turn it back on with Siri. So, "play Tom Petty." It played, and the battery slowly ran down. I was able to connect it to my car stereo and play music through Bluetooth, which would help, but I didn't want to leave the car on.

Later I tried again to reset the phone by holding the power button down reallllly hard, with the home button. Didn't work. Siri activated. I played the music again. I came back later and tried again ... this time, it finally worked, the phone rebooted and I immediately saw the Apple logo.

So much fail. Is it too much to ask for a hole to stick a paper clip in?

Dare I Believe?

| | Comments (0)

Nine years ago, I pre-ordered the game The Fool and His Money, the sequel to 1987's The Fool's Errand.

Just now, I got this e-mail:

Hi and hello,

Beginning 9:00 PM EST on Friday, October 26, 2012, you may download your Game using these links.

<snip>

Below is your Pre-Order information, including your Password which is necessary to enter your Game.

<snip>

The best to you each morning,

CLiFF

-------------------------------------------------------[PURCHASE RECORDED]
Saturday, October 04, 2003
<snip>

Could it really be?

Mac::Glue Feature Addition

| | Comments (0)

One of the features I never got around to in Mac::Glue was explicit support for "tell"ing an object.

In AppleScript, you normally do a tell app "Foo" to open something, and in Mac::Glue it's $foo->open($something). Similarly, you can in AppleScript do tell app "Foo" to tell something to do_something. In Mac::Glue there's no real analogue to this. Sometimes you can do $something->do_something(), but sometimes you can't.

So I've got some basic support for a $something->tell->do_something(). It seems to be working well, but I need some more testing and cleanup. And then my first CPAN release in ... a few years now, I guess.

Infrared Debugging

| | Comments (0)

Today my infrared remotes stopped working properly. Maybe one command in a dozen would do anything, unless I was right up close to the IR receiver.

I have an IR receiver embedded in the wall of my family room, and it's wired to a repeater in my front closet where my components are, and each of those has an IR emitter on it. On the other side of the closet is the bedroom, and some of the components -- DirecTV DVR, PS3, AppleTV -- are connected (through a 4x2 HDMI selector) to the TVs in both rooms, so I have an additional IR receiver in the bedroom. Works great, but today, the IR performance was massively degraded.

I tried switching out the repeater, tried jiggling wires, did a bunch of testing ... nothing worked. Finally I removed the second receiver from the wiring, and everything went back to normal. I went into the bedroom and saw that a bright white envelope was directly in front of the IR receiver. Directly above the receiver was the red LED from the TV to indicate it was off. So it seems the red LED was reflecting off the envelope, back into the IR receiver, and causing just enough interference that I couldn't see it show up in the "talkback" LEDs on the emitters or receivers, but it was still preventing proper communication.

It reminds me a lot of the software debugging I've done over the years.

Weird Chrome Thing

| | Comments (0)

I like to cmd-click Submit buttons in my browser. This POSTs data from the current form, with the result going into a new tab. Yay.

This doesn't work in Chrome. It appears to either just do a GET, or a POST with no paramaters.

I've been using Chrome at work. It's a nice browser, but without 1Password support and a bunch of rough edges, like this one.

use Perl;

| | Comments (4)

I am no longer working for Slashdot/Geeknet as of September 30. I am actively seeking new employment. Unless you want to hire me, you don't need to care, unless you also care about use Perl;, because it has been generously hosted by Geeknet since I started the site over 10 years ago, shortly after I was hired by Andover.Net to work on Slashdot.

Long story short, I have not done much with the site in recent years, so my options at this point are to do nothing; migrate the site to a new server and keep it running as-is; or take the data and do something with it on a new site. Or something I haven't thought of.

I am hereby accepting proposals for what to do with use Perl;. In short, I would like to donate it to someone who will give it a good home. If you're interested, give me your best pitch. use.perl.orgslashdot.org

Unique

| | Comments (0)

I wonder how long it will be before people start just putting together random letters for names of companies, bands, and so on, so they can be unique in Google searches.

Your search - fobhwueufg8 - did not match any documents.

^^ my new band name use.perl.orgslashdot.org

My Slashroulette Videos

| | Comments (0)

Today Slashdot did a spoof of Chatroulette, that we called Slashroulette. We prerecorded videos of ourselves and others. Here's five of the six I did (the sixth was me tuning the guitar, I didn't post that one on YouTube): video 1, video 2, video 3, video 4, video 5. use.perl.orgslashdot.org

I upgraded the firmware on my Netgear router today and it wouldn't let me use the LAN IP I usually use for it, 10.0.1.1, because it thinks my ISP uses that subnet, because I set the router to read from my own internal DNS. Took me awhile to figure out why it thought what it did, because it didn't occur to me that it would care what DNS addresses I gave it. use.perl.orgslashdot.org

Dear Google,

When you move a 32-bit x86 perl installation to a 64-bit Mac OS X 10.6 environment, you should edit $ARCH/Config_heavy.pl and add "-arch i386" to lddlflags, ldflags, and ccflags. The compiler and tools in Mac OS X 10.6 assume 64 bits unless you explicitly tell it otherwise, but some 32-bit installs don't bother putting in an -arch flag, because at the time it wasn't necessary. use.perl.orgslashdot.org

Apaches Hanging

| | Comments (1)

When I try to print high-bit data to STDERR from mod_perl 1.x and perl 5.10.0 -- sometimes, not always -- the process hangs and sucks up 100% CPU. I wonder if updating perl to 5.10.1 might help. use.perl.orgslashdot.org

Mac-Carbon Makefile.PL 64-bit Check

| | Comments (0)

I should add a check for 64-bit mode to the Mac-Carbon Makefile.PL. This will save a lot of hassle if I can give a nice error message, with a link to more information, up front.

I can't test this easily, though, since I don't yet have a 10.6 64-bit box (it's only on an original MacBook Pro, which is 32 bits). I will upgrade to Snow Leopard soon. I could try to make my own perl before then, but I don't know it would work the same way. So. If you want to help, now's your chance!

First thought is Config, but we all know Config can be flaky. For example, on my 32-bit box:

$ perl -V:use64bitall
use64bitall='define';

Doesn't really help. I don't know if $Config{intsize} would be 8 on a 64-bit perl. It's 4 on this 10.6 32-bit perl. I do know you should be able to call perl with VERSIONER_PERL_PREFER_32_BIT=yes to give you 32-bit perl, instead of the default 64-bit perl.

So anyway ... if you can figure out a way to know, under 10.6 stock perl, if I am running under 32-bit perl or 64-bit perl, let me know. use.perl.orgslashdot.org

Mac-Carbon, and Related Things

| | Comments (0)

Please do test the aforementioned Mac-Carbon-0.80, and report it on RT if there's a problem. Please note that you MUST build under 32-bit mode, which is especially important if you are using the standard perl that comes with Mac OS X 10.6.

I've also got new versions of Mac::AppleEvents::Simple, Mac::OSA::Simple, and Mac::Glue coming out soon. I want to get Mac-Carbon well-tested out there first, though. use.perl.orgslashdot.org

Mac-Carbon 0.80 Released

| | Comments (0)

Mac-Carbon-0.80 has been released. Download it from the CPAN.

(Note: it may take time for the release to propagate to the various download mirrors.)

Changes:

* v0.80, 16 September 2009
 
Add notes for 64-bit perl
 
Bump all the version numbers
 
Fix a bunch of tests (nothing major, just make them work better)
 
Fix sound-env-var checking code for tests (no more sound tests
unless you ask for them with MAC_CARBON_SOUND, which was in the
last version, but the logic was broken)
 
Make CFStringRef typemap better
 
Remove high-bit characters from source files
 
Add new system version gestalt constants
 
Fix leak in Mac::Processes and Mac::Speech

use.perl.orgslashdot.org

Mac-Carbon Modules and Mac OS X 10.6

| | Comments (0)

The default perl for Mac OS X 10.6 runs in 64-bit mode by default. The problem for Mac-Carbon is that significant portions of the Carbon API are unavailable to 64-bit programs on Mac OS X.

Perhaps a subset of the API could be made available to a 64-bit perl (for more information see Apple's "64-Bit Guide for Carbon Developers"), and might in the future, but it's simpler at this point to just run perl in 32-bit mode.

There's a few ways to do this. Most obviously, you could simply build a 32-bit perl. I always build my own perl, and I just compile it for 32 bits.

There's also two methods mentioned in L under Mac OS X 10.6: you can set an environment variable, or set a system preference. For the environment use:

VERSIONER_PERL_PREFER_32_BIT=yes

And for the system preference, execute this line in your terminal:

defaults write com.apple.versioner.perl Prefer-32-Bit -bool yes

use.perl.orgslashdot.org

Pudge's Picks 2009

| | Comments (0)

Please, if you wish, go to join Pudge's Picks for 2009, hosted on ESPN.com.

After logging in (create a new login if you don't have one), create an entry (each user can have one to three entries).

Then for each entry, click Join a Group. Type in "Pudge's Picks" in the search field, then click on Pudge's Picks when it shows up in the list. You can also go directly to the group page, instead.

The password to join is "longhorn."

Invite others, if you wish. use.perl.org

iPhone Hacking

| | Comments (0)

I got me a used iPhone. In playing with it, I installed PCalc Lite, as I am a longtime fan of PCalc (and DragThing, by the same author, James Thomson). I liked it and so I got the full PCalc, which has a lot more features, including a bunch of different themes.

Getting into hacking the iPhone, I thought I'd try to make a theme. You can't do this, I suppose, for now, unless you jailbreak the iPhone, as the themes are stored in the app and that breaks Apple's code signature stuff. But the same themes work on PCalc for the Mac, too. So I gave it a shot. Without further ado, my Slashdot theme for PCalc. You can also download the theme archive itself. Not sure why you'd want to, unless you're me, though.

Slashdot theme for PCalc

I also have been playing a lot of Quordy and Muddled, two word games from Lonely Star Software. A friend of mine from college wrote Muddled. And I wrote a Perl program that solves both games. Both use a dictionary (I grabbed 'words.sql', a DBLite file, from the Quordy bundle, after uncompressing the ZIP file with the .ipa extension). You just enter the letters you have available to you (in order from left to right, top to bottom for Quordy), pick the dictionary options and the game you're playing, and run it. use.perl.org

Apple Cats

| | Comments (0)

Am I the only one who has trouble remember which Apple OS is represented by which cat? I don't even always remember that 10.5 is Leopard. Apple says "Snow Leopard" is building on the "Leopard" brand, but to me there is no "Leopard" brand. use.perl.org

iTunes / Front Row Updates

| | Comments (0)

My biggest gripes with iTunes and Front Row are that they don't work well with iTunes sharing.

And in fact, the last versions of both were a step backward in usability. Front Row no longer shows album art for shared tunes, and iTunes no longer shows some of the info about a track (bitrate etc.) until the file is played. And Party Shuffle feature has never worked at all.

In a networked world, it makes no sense. Why punish users for keeping their music on a shared computer?

I was hoping the latest iTunes and Front Row updates would fix these problems. Nope. And the new Genius feature is also not sharing-capable, and therefore useless.

Oh, and in the list view, I always leave "genre" turned off, so instead of three panes at the top, it's only two. Genre is completely and utterly useless to me. I could not possibly care less about it, and it just takes up a ton of space, so I for years have left it turned off.

I can't turn it off anymore.

Apple continues to be extremely stupid. use.perl.org

I wrote BBEdit Language Modules for diff (screen), and for git's blame (screen).

I also wrote a BBEdit Unix Filter for sending a JS selection to the JSLint web site in Safari. use.perl.org

We're attempting to switch use.perl.org and slashcode.com to new servers today. Please forgive any downtime. Or don't: I don't care! use.perl.org

Making Things Things

| | Comments (3)

Perl, it is said, makes easy things easy, and hard things possible.

Git, on the other hand, makes easy things hard, and makes possible things you never really wanted to do in the first place. use.perl.org

Money!

| | Comments (0)

Spam e-mail: "Hi there, you got a greeting!"

I want to have an argument with the sender:

"Yes, that is self-evident, every e-mail is a greeting, by definition." "No, I mean another greeting." "Oh, then you're wrong, no, I got no such thing." "Yes, it's in the mail." "But I didn't open it, so I didn't get it." "So open it." "I have no reason to." "So you will get your greeting!" "But the e-mail WAS a greeting."
... and so on.

I should write really bad sitcoms. It's a skill.

Which brings me to: "If you are the type of person who will take a huge cut in salary to do something you love, then you really need badly to see a therapist."

Which brings me to a short film I saw on iTunes called Cutlass, written by Kate Hudson, who has been filthy rich all her life, and is about a mom who helps her daughter spend too much money on something they don't need, because, you know, it's just money!

Just sayin'. use.perl.orgslashdot.org

OSCON Talk

| | Comments (0)

Here's my OSCON talk, Perl for Political Campaigns. use.perl.orgslashdot.org

NAND-OR's White Camel

| | Comments (0)

I am sitting in Damian's talk on rod logic, which followed the White Camel Awards, and perhaps I should have named the album NAND-OR's White Camel instead of Nandor's White Castle. use.perl.org

Time Capsule Software Broken

| | Comments (3)

Brand new 500 MB Time Capsule. Latest firmware, latest AirPort software, latest Mac OS X version.

One of my computers, a Titanium PowerBook, connects just fine and backups and it all seems happy and joyous.

My other one, the MacBook Pro ... not so much. No matter what I try, I get "The backup volume could not be mounted." Here's the system log:

Jun 18 00:49:47 bourque kernel[0]: AFP_VFS afpfs_mount: /Volumes/Shore, pid 206
Jun 18 00:49:47 bourque /System/Library/CoreServices/backupd[327]: Backup requested due to disk attach
Jun 18 00:49:47 bourque /System/Library/CoreServices/backupd[327]: Starting standard backup
Jun 18 00:49:47 bourque /System/Library/CoreServices/backupd[327]: Network mountpoint /Volumes/Shore not owned by backupd... remounting
Jun 18 00:49:47 bourque /System/Library/CoreServices/backupd[327]: [SnapshotUtilities remountVolumeRef] url could not be resolved via BonJour
Jun 18 00:49:47 bourque /System/Library/CoreServices/backupd[327]: Failed to remount network volume.
Jun 18 00:49:52 bourque /System/Library/CoreServices/backupd[327]: Backup failed with error: 19

It's some sort of authentication problem. I could not figure out what it is, tried everything. Tried messing with the Keychain, tried deleting all prefs. Nothing works. I saw a bunch of other people online with the same problem; some had fixed it, some had (apparently) not.

Eventually I figured out that if I mounted the volume as root -- which is what backupd runs as -- then it works just fine.

$ mkdir /Volumes/Shore
$ sudo mount_afp afp://pudge:mypassword@Shore.local/Shore /Volumes/Shore

Then I can run Time Machine and all is happy. Until the next time.

So I wrote this script that gets called from root's crontab. It basically does the same thing (though not quite as "neatly") as Time Machine itself should. Until Apple fixes this insanely stupid bug -- you'd think the thing would work out of the box! -- it should keep me going, although to actually enter Time Machine, I need to manually mount the sparsebundle that's sitting on the Time Capsule, but I can do that without root.

#!/usr/bin/perl
use warnings;
use strict;
 
my $backupd = '/System/Library/CoreServices/backupd.bundle/' .
	'Contents/Resources/backupd-helper';
 
# put password in this file, chmod 0600
my $passf = '/Users/pudge/.backupd-helper-helper';
my $user  = 'pudge';
my $share = 'Shore.local';
my $vol   = 'Shore';
 
chomp(my $pass = do { open my $fh, '<', $passf; <$fh> });
my $dir   = "/Volumes/$vol";
my $url   = "afp://$user:$pass\@$share/$vol";
 
 
rmdir $dir; # let fail silently, we only want to remove if dir is empty,
            # and if it doesn't exist, that's OK too
mkdir $dir or die "Can't mkdir $dir: $!"; # NOW complain loudly if it fails
system '/sbin/mount_afp', $url, $dir;
system $backupd;
 
# usually not necessary, but will fail silently
system '/sbin/umount', $dir;
 
__END__

use.perl.org

So our design guy tells us that it would be much better if, instead of throwing in double <br> tags for paragraphs, we changed it to <p> tags. Oh, and make sure it works in XHTML in case we want to use that someday, which means we need starting and ending tags.

So, this is sortof a pain, doing it right. I am trying to think of all the potential problems, and there's a bunch. So I put in a paragraph tag for the double-linebreak tag, but where do I put the ending tag? What algorithms do I use to find the right place? Pain.

And then I remembered that all comments get passed through a function I wrote several years ago called balanceTags(). You can basically throw any HTML you want at it, and it will return valid HTML. It will balance unbalanced tags (including paragraph tags), it will make sure blockquote tags include block tags inside them, and so on. If the "xhtml" flag was on, it will even make lone tags like linebreaks and images (and some paragraphs) into proper XHTML tags. So switching to XHTML is as simple as flipping the switch.

Therefore, all I had to do is find out where to put the open paragraph tags, and balanceTags() takes care of the rest. Hooray! So in this case it means putting a paragraph tag at the beginning of each comment (which is something I've wanted to do for awhile anyway), and then another one at each double-linebreak, and we're golden.

I was worrying about doing it right for nothing, since I'd already done it right years ago! use.perl.org

The slashd program in slash runs "tasks" which are separate files. It performs a require(). The problem is that sometimes symbols in each task can conflict with another.

We have many tasks so rather than edit each one, we decided to handle the encapsulation in slashd itself. It creates a package name, and has code to import symbols from main into the package, and then sets the line number correctly.

		(my $tmppackage = $file) =~ s/\.pl$//;
		$tmppackage =~ s/\W/_/g;
		$tmppackage =~ s/^([^a-zA-Z])/a_$1/g;
		$tmppackage = "Slash::Task::$tmppackage";
 
		# replace tmppackage in string where appropriate
		(my $addtxt = <<'EOT') =~ s/\${?tmppackage}?/$tmppackage/g;
 
package $tmppackage;
 
{ no strict 'refs';
	my @scalar = qw(me task_exit_flag);
	my @hash   = qw(task);
	my @code   = (qw(
			slashdLog slashdErrnote slashdLogDie
			tagboxLog verbosity db_time init_cron
		),
		grep { *{"main::$_"}{CODE} }
			@Slash::EXPORT, @Slash::Display::EXPORT,
			@Slash::Utility::EXPORT,
			@File::Spec::Functions::EXPORT,
			@LWP::UserAgent::EXPORT, @URI::Escape::EXPORT,
			@File::Basename::EXPORT, @File::Path::EXPORT,
			@Time::Local::EXPORT, @Time::HiRes::EXPORT
	);
 
	*{"${tmppackage}::$_"} = *{"main::$_"}{HASH}   for @hash;
	*{"${tmppackage}::$_"} = *{"main::$_"}{SCALAR} for @scalar;
	*{"${tmppackage}::$_"} = *{"main::$_"}{CODE}   for @code;
}
 
#line 1
EOT
 
		my($tmpfh, $tmpfile) = tempfile();
		my $tmptxt = do { open my $fh, '<', $fullname; local $/; <$fh> };
		print $tmpfh $addtxt, $tmptxt;
		$tmpfh->flush; # can't close fh until we require the file,
		               # else the file might disappear
 
		my $ok = 0;
		eval { local $me = $file; $ok = require $tmpfile };

use.perl.org

Respond to this spam OR DIE!

| | Comments (1)

Literally, I am told that I need to respond to this spam, or die. Since "please give me money, and I'll give you more in return" isn't working anymore, I guess it's time to resort to threats. Apparently this is new; I see some mentions of it, all from this month. Pretty funny, really. Complete spam is enclosed below; if I do die, you can use the header information to avenge me or something.

From: adamsjamil9@gazeta.pl
Subject: Mr SOMEONE YOU CALL YOUR FRIEND, WANTS YOU DEAD.
Date: May 17, 2008 6:36:03 PDT
To: undisclosed-recipients:;
Received: by 10.142.171.6 with SMTP id t6mr2004920wfe.12.1211031363667; Sat, 17 May 2008 06:36:03 -0700 (PDT)
Received: by 10.142.104.18 with HTTP; Sat, 17 May 2008 06:36:03 -0700 (PDT)
Return-Path: <SRS0=SQW4=WA=gazeta.pl=adamsjamil9@bounce2.pobox.com>


I felt very sorry and bad for you, that your life is going to end like this if you don't comply. I was paid to eliminate you and I have to do it within 10 days.

Someone you call your friend wants you dead by all means, and the person have spent a lot of money on this, the person also came to us and told us that he wants you dead and he provided us your names, photograph and other necessary information we needed about you. If you are in doubt with this I will send you your name and where you are residing in my next mail.

Meanwhile, I have sent my boys to track you down and they have carried out the necessary investigation needed for the operation, but I ordered them to stop for a while and not to strike immediately because I just felt something good and sympathetic about

Now do you want to LIVE OR DIE? It is up to you. Get back to me now if you are ready to enter deal with me, I mean life trade, who knows, and I might just spear your life, $8,000 is all you need to spend. You will first of all pay $3,500 then I will send the tape of the person that want you dead to you and when the tape gets to you, you will pay the remaining $4,500. If you are not ready for my help, then I will have no choice but to carry on the assignment after all I have already being paid before now.

Warning: do not think of contacting the police or even tell anyone because I will extend it to any member of your family since you are aware that somebody want you dead, and the person knows some members of your family as well.

For your own good I will advise you not to go out on.

slashdot.orguse.perl.org

Cell Phone Lunacy

| | Comments (1)

T-Mobile is my cell phone provider. I "upgraded" my old Nokia 6600 (four years old now, at least) to a Nokia 6263 for free. But when I got it, I found that -- with the exact same SIM card, same account, same network -- it would not run downloaded network apps like Google Maps.

This makes it subuseful.

So I call them up, and they would apparently rather have me return my phones and cancel my service altogether than give me a working phone. Oh they say they can give me a Blackberry, but it will cost more, and I don't want a Blackberry. And I would rather go phoneless than use a Windows phone.

So I need to either get this phone uncrippled, or find a new cell phone provider. Suggestions welcome.

Finding Lost Cell Phone

| | Comments (0)

While travelling last week I had my cell phone out, and I set it down and couldn't find it when it came time to board. I looked all over and thought it was just lost. I couldn't pull all my bags apart, as I didn't have time while boarding, so it was still possible I had it. I figured, however, I would not give it up entirely until I tried one more thing to find it.

I had been using my Bluetooth headset thingy, and I knew it had plenty of battery, so chances are if it was in the bag, the Bluetooth was still on. So when I got into my next destination, I pulled out my laptop and did a Bluetooth device scan. Sure enough, there it was. Either it was in my bag, or the person who stole it was still nearby.

It was buried in my bag. use.perl.orgslashdot.org

Stupid File Size Calculations

| | Comments (0)

I back up my PS3 to a USB drive, which has a FAT32 partition. The archive folder reported only 3.2GB, but there was about 7.2GB in use.

The Finder and du both reported 3.2GB. I finally tracked it down to a file that is 4GB, but reports as 0. Most of the time. Note that even ls -s gets it wrong, but ls -l gets it right.

$ du archive2_00.dat 
0	archive2_00.dat
$ ls -s archive2_00.dat 
0 archive2_00.dat
$ ls -l archive2_00.dat 
-rwxrwxrwx  1 pudge  pudge  4294966784 Feb 21 22:21 archive2_00.dat

The Finder was similarly confused:

Well, There's Your Problem

use.perl.org

Now Playing: Writ On Water - Trappease

*Really* Stupid Mac::Glue Tricks

| | Comments (0)

I keep all my music in lossless format (unless acquired compressed, such as through iTunes Music Store), so I am guaranteed it will sound perfect on my home systems, and so if I ever want to re-encode, I have the originals: no need to re-rip.

I have a pair of Perl scripts that convert those lossless files to 128 kbps AAC for use on the iPods. The first script will mount the drive of the iPod computer over the network, and compress any lossless file (using Mac::Glue/iTunes) that does not exist on the remote drive, or if it does exist, if it was last modified since the modification date of the lossless file. It will also straight copy any non-lossless file, and then write out text file representations of my playlists.

On the remote computer, the original computer's drive is mounted, and the first thing it does is look to make sure that every file in its directories exists on the original drive. If not, it deletes the file. Then it goes through iTunes (again, with Mac::Glue) and removes any library tracks whose file is missing from the filesystem. Then it adds any files from the filesystem missing in the library, and finally, recreates the playlists.

So last weekend I ran the first program, then the second. I came back to find the entire iPod library gone. What had happened is that the mount failed somehow, but the directory for it was there, so it was looking for the original files in an empty directory, and deleting files that didn't match, which was all of them.

Oops.

So now I am recreating the whole library, which is a simple -- but very slow -- matter of re-running the first program, then the second. I estimate it will take about 3-4 days, running nonstop (it's a G4/867 doing the main encoding job), for about 8500 files, with maybe 6000 or so of those needing encoding.

Of course, I patched the second program to make sure that the mount point really is there. A simple matter of looking for the existence of a directory or file that will absolutely be there if the mount is correct, and will not be created by the program -- so should not exist -- if it is not.

I run the first program again. Everything is basically fine ... until my local hard drive fills up.

Same problem again, on the other side: the mount failed, and so it is copying files TO the wrong place: the local drive.

At least I didn't lose much time: I move those files out of the way, mount the remote drive, and copy them into place. Then I patch the second program in the same basic way, and run it again.

Hopefully it all works this time. I've run these programs many times over the last few years, and then two failures of the same type on different machines in the same week. Weird. use.perl.org

So I tried connecting our Jabber bot to our new Jabber server (OpenFire). It wasn't happy.

At first I thought it might be SSL, and after wrestling with that and many other things, I finally decided to randomly comment out things I didn't understand. Well, not randomly: one of the errors I kept seeing when I was pretty sure I had everything right was:

Can't use an undefined value as a HASH reference at
/usr/local/lib/perl5/site_perl/5.10.0/XML/Stream.pm line 1165.

But I don't know what the heck is going on in there. Poking around though, I see that $self->GetRoot($sid) is returning undef, and right above that, there's a call to delete($self->{SIDS}->{$currsid}). And GetRoot($sid), in fact, accesses $self->{SIDS}->{$sid}.

So I add in some print statements and see that, in fact, $sid and $currsid are the same.

So, I says to myself, comment out the delete call. And so I do. And so it works.

I don't know why that was necessary. And I should send this to the XML::Stream author. Tomorrow. use.perl.org

I have been using a MacBook Pro for several months, and I finally got around to upgrading Perl on it. I figured 5.10's release, and Christmas vacation, was a decent opportunity.

I ran into a lot of problems.

  • First, note that my existing Perl/Apache installs were PPC. And this is an Intel Mac. And because some systems are not very careful about what they use to do things, I had to make sure I basically hid all the PPC things in my path. For example, a PPC perl in my path was used for part of the mod_perl build process, even though I used an Intel perl for the Makefile.PL, which caused some symbols to go missing.

  • Similarly, the Apache config kept picking up a random library I had in /usr/local/lib, and throwing errors. So I finally figured I should just move all of /usr/local/bin and /usr/local/lib out of the way until I got everything built. I selectively brought things back later.

  • But this was not my only problem with Apache. Oh, no. Apparently mod_perl 1.30 and perl 5.10 simply do not get along. I kept getting errors about bad file descriptors every time I tried to start Apache. I finally found discussion from p5p about it, from a few weeks ago, and used Andreas Koenig's patch for mod_perl, taken from Steve Hay's fix slated for mod_perl 1.31. This fixed the problem, apparently.

  • However, apparently this patch only works for fixing non-threaded perl. So I then had to rebuild perl to be non-threaded. I had wanted to keep my perl config as close to the default Mac OS X build as possible, for binary compatiblity reasons, but it's not that important, I suppose, since 5.8 and 5.10 are not binary compatible anyway, and Mac OS X 10.6 (the first likely to use 5.10.x) won't be out for a long time. So, I don't need threads, and therefore, non-threaded it is.

  • And then there was libapreq. I don't know how to properly solve this problem, but I kept getting errors about my_perl being undeclared in two functions, hooks for uploading files. As I don't use that functionality, I simply commented out the body of the functions. It was getting late.

  • Most of the other modules were pretty smooth though. DBD::mysql kept looking for the mysql libraries in /usr/local/mysql/lib/mysql instead of /usr/local/mysql/lib. I couldn't see an obvious reason why, so I just added a symlink. Shrug.

  • Also, Mac::Carbon had some errors in the tests. Those should be fixed, but I have a lot of other fixes to make before uploading a new version. More on that some other time. The broken test was for Mac::AppleEvents, and I even have a comment in there about how the tests were very likely to be broken. I was right!

  • Mac::Glue posed a problem: the glue files are not byte-order independent. Maybe they should be, but that won't help me now. So I needed to rebuild all my glue files, which isn't a big deal.

  • Also not byte-order independent: the "friends" field in the Slash database. Like the glue files, it uses Storable. I know there are ways to make it work, but I did not use those ways previously, so now I am stuck. For Slash, I just wrapped the thaw() call in an eval for now, but I'll pull that later, after I call the rebuild task.

  • Speaking of modules, what got all this started was that I was trying to build XML::LibXML for my MacBook Pro so I could use XML::Atom to make posts from BBEdit to <pudge/*>. But building a PPC binary for an Intel machine ON an Intel machine turned out to be just too much for me. So I figured it was time to just start over.

  • The CPAN autobundle worked pretty well, although after installing Bundle::CPAN and Bundle::Slash, I then took my autobundle and wrote a quick script around it to basically call perl -M$module -e1 and note any errors, and that way I could skip most of the bundle, since I am still using the pure perl version of many modules, that I already had installed, and I don't necessarily want to install every upgrade to every module, since some of them can break (cf. XML::RSS). Then I scanned the uninstalled/broken module results and installed any I wanted by hand.

  • I make note here that Data::JavaScript::Anon is "still broken." Version 0.9 is broken, version 1.00 works, but CPAN still gives me version 0.9 unless I ask for 1.00 specifically, and so when I installed Bundle::Slash, I got the wrong one. But that has nothing to do with this, it's just Something Else.

Bottom line is that now I have Slash running on my Intel Mac with native Apache 1.39, mod_perl 1.30 (with patch), and perl 5.10 (without threads), and the only brokenness -- that I know of -- that remains is missing functionality in Apache::Request that I don't use, and lack of thread-capable perl for mod_perl.

It was a long day making all that work, too. Dang it was long. Lots of futzing around. But I also now apparently have almost no more PPC apps running on a regular basis on my Mac: just Eudora. Which sucks. But not as much as every other mail app. I dunno, maybe I should give Thunderbird another go. I hate that it is not a native Mac UI, but it's not like Eudora has a great UI either. Maybe I'll try Mail.app again. use.perl.org

Leopard, CoreFoundation, and exec()

| | Comments (0)
Under Leopard, using Mac::Carbon:

[pudge@bourque ~]$ happening
Running background process /Users/pudge/bin/happening (983)
The process has forked and you cannot use this CoreFoundation functionality safely. You MUST exec().
Break on __THE_PROCESS_HAS_FORKED_AND_YOU_CANNOT_USE_THIS_C OREFOUNDATION_FUNCTIONALITY___YOU_MUST_EXEC__() to debug.

Apparently, fork-without-exec with CoreFoundation has always been bad. But it is now an exception.

So in the happening program, I had:

$pid = fork;
exit if $pid;

Now I have:

if (!$nofork) {
    $pid = fork;
    exit if $pid;
    exec($0, '-nofork');
}

YMMV. use.perl.org

Beards

| | Comments (0)
Many people on YouTube are commenting on my beard.

For what it's worth, I've had this beard for 16 years, and it's not coming off any time soon. (I've had *a* beard for about 18 years, but I periodically shaved it until first semester of my freshman year of college. It's existed ever since.)

use.perl.org
It thinks I am Japanese. Tiger Front Row did not.

It does not show cover art for shared sources. Tiger Front Row did.

When I am fast-scrolling down a list of items, and I see the item I want, and so I let go of the button to stop scrolling, I go way past that item as the list slows to a stop. Tiger Front Row stopped pretty much immediately, on or near the thing I wanted.

It does not have any way to repeat. At least with Tiger Front Row, I could use my (non-Apple) remote to tell iTunes make the currently playing playlist to repeat. I'd hit play in Front Row, then hit the button to call my "Repeat" AppleScript.

I preferred the Tiger Front Row. slashdot.org

pudge posted a photo:

Leopard Front Row Ignores Shared Source Cover Art

pudge posted a photo:

Leopard Front Row Thinks I Am Japanese

Incidentally, the top two videos in Japan are apparently both by Avril Lavigne.

So a lot of times when using Spaces under Leopard, windows just ... disappear. They are not visible in any space. So I have to open up the System Preferences and turn Spaces off, and then back on, which fixes it.

Here's a script that I put in my Script Menu (~/Library/Scripts/Reset Spaces.scpt) so I have quick access to it.

tell application "System Events"
    set (spaces enabled of spaces preferences of expose preferences) to false
    set (spaces enabled of spaces preferences of expose preferences) to true
end tell

Oh. You want a Perl version, do you?

Fine.

#!/usr/bin/perl
use warnings;
use strict;
 
use Mac::Glue;
 
my $sysevt = new Mac::Glue 'System Events';
 
my $enabled = $sysevt->prop('spaces enabled',
    of => 'spaces preferences',
    of => 'expose preferences'
);
$enabled->set(to => 0);
$enabled->set(to => 1);

I prefer AppleScript for stuff like this, since it's quicker to execute and I have to use AppleScript to figure out how to do it in Perl anyway, since AppleScript is sometimes easier to prototype with when you don't know what properties and objects you're working with. But it took only a minute to convert it to Perl, so no biggie.

System Events in Leopard has a lot of new junk in it for scripting preferences. Pretty neat, you can script many difference preferences now. Here's a list.

    appearance_preferences_object
        A collection of appearance preferences
 
        Properties:
 
            appearance: the overall look of buttons, menus and windows
            double_click_minimizes: Does double clicking the title bar minimize a window?
            font_smoothing_limit: the font size at or below which font smoothing is turned off
            font_smoothing_style: the method used for smoothing fonts
            highlight_color: color used for hightlighting selected text and lists
            inheritance: All of the properties of the superclass. (read-only)
            recent_applications_limit: the number of recent applications to track
            recent_documents_limit: the number of recent documents to track
            recent_servers_limit: the number of recent servers to track
            scroll_arrow_placement: the placement of the scroll arrows
            scroll_bar_action: the action performed by clicking the scroll bar
            smooth_scrolling: Is smooth scrolling used?
 
    cd_and_dvd_preferences_object
        user's CD and DVD insertion preferences
 
        Properties:
 
            blank_cd: the blank CD insertion preference (read-only)
            blank_dvd: the blank DVD insertion preference (read-only)
            inheritance: All of the properties of the superclass. (read-only)
            music_cd: the music CD insertion preference (read-only)
            picture_cd: the picture CD insertion preference (read-only)
            video_dvd: the video DVD insertion preference (read-only)
 
    dock_preferences_object
        user's dock preferences
 
        Properties:
 
            animate: is the animation of opening applications on or off?
            autohide: is autohiding the dock on or off?
            dock_size: size/height of the items (between 0.0 (minimum) and 1.0 (maximum))
            inheritance: All of the properties of the superclass. (read-only)
            location: location on screen
            magnification: is magnification on or off?
            magnification_size: maximum magnification size when magnification is on (between 0.0 (minimum) and 1.0 (maximum))
            minimize_effect: minimization effect
 
    expose_preferences_object
        user's expose and dashboard mouse and key preferences
 
        Properties:
 
            all_windows_shortcut: the key and mouse binding shortcuts for showing the all application windows (read-only)
            application_windows_shortcut: the key and mouse binding shortcuts for showing the current application windows (read-only)
            bottom_left_screen_corner: the bottom left screen corner (read-only)
            bottom_right_screen_corner: the bottom right screen corner (read-only)
            dashboard_shortcut: the key and mouse binding shortcuts for showing the dashboard (read-only)
            inheritance: All of the properties of the superclass. (read-only)
            show_desktop_shortcut: the key and mouse binding shortcuts for showing the desktop (read-only)
            show_spaces_shortcut: the key and mouse binding shortcuts for showing spaces (read-only)
            spaces_preferences: the spaces preferences (read-only)
            top_left_screen_corner: the top left screen corner (read-only)
            top_right_screen_corner: the top right screen corner (read-only)
 
    network_preferences_object
        the preferences for the current user's network
 
        Properties:
 
            current_location: the current location
            inheritance: All of the properties of the superclass. (read-only)
 
        Elements:
 
            interface, location, service
 
    security_preferences_object
        a collection of security preferences
 
        Properties:
 
            automatic_login: Is automatic login allowed?
            inheritance: All of the properties of the superclass. (read-only)
            log_out_when_inactive: Will the computer log out when inactive?
            log_out_when_inactive_interval: The interval of inactivity after which the computer will log out
            require_password_to_unlock: Is a password required to unlock secure preferences?
            require_password_to_wake: Is a password required to wake the computer from sleep or screen saver?
            secure_virtual_memory: Is secure virtual memory being used?
 
    spaces_preferences_object
        user's spaces application bindings and navigation preferences
 
        Properties:
 
            application_bindings: binding of applications to specific spaces
            arrow_key_modifiers: keyboard modifiers used controlling the arrow key navigation through spaces (read-only)
            inheritance: All of the properties of the superclass. (read-only)
            numbers_key_modifiers: keyboard modifiers used controlling the number key navigation through spaces (read-only)
            spaces_columns: number of columns of spaces
            spaces_enabled: is spaces enabled?
            spaces_rows: number of rows of spaces

use.perl.org

That Is Not An Available Option

| | Comments (0)
Playing MLB 07 The Show on PS3. Doing a season. Simulating most of the games, playing a few.

On September 22, with a solid lead on the wild card, and having won 10 games in a row, including sweeping the Yankees at home, we lose a simulated to Tampa Bay, with Josh Beckett starting.

The computer tells me upon game completion, "Josh Beckett sustained an injury (shoulder separation) during today's game. It appears he will be out for about 2 to 3 months. What would you like to do?"

The options are Keep Active, 15-day DL, or 60-day DL. None of the options are "kill myself," so I'm stumped! use.perl.org
So my memory usage in Leopard is WAY down. I have Safari, DragThing, SSHKeychain, perl daemons, MySQL, Apache, MacCvsX, Eudora, BBEdit, iChat, Terminal ... a lot of things running. Before this would put me into swap. Now, it does not. Not even close: with 2GB total, I have about 700MB unused.

It's ... just wow. HUGE performance increases in Leopard for me, just by not going into swap. I think some memory leak was fixed, or something. I dunno. But I like.

The biggest new memory pig is "helpdatad." Open Activity Monitor, sort by RSIZE, go into the Help menu of Activity Monitor, type into the new "Search" field, hit return, and watch helpdatad climb to the top. 180MB without breaking a sweat.

I killed the process and vowed to never type into that field again. use.perl.org

Sox Win, As Formula Predicted

| | Comments (0)
So in 2004 I predicted the Red Sox would win in 2006, using a mathematical formula. I was wrong. So I realized that my formula was off. Because the length of difference between last year won and the pivotal year of beating St. Louis crossed millennia, we had to add an extra year.

#!/usr/bin/perl
use warnings;
use strict;
 
# script to predict when the next Boston team championship
# will occur after either:
#
# * winning first championship in team history, against St. Louis
#
# OR
#
# * winning first championship since St. Louis existed as a team
 
my %boston_team = (
    # team        last year won,  year beat St. Louis
    Celtics   => [1957,           1957],
    Bruins      => [1941,           1970],
    Patriots  => [2002,           2002],
    'Red Sox' => [1918,           2004],
);
 
for my $team (sort { $boston_team{$a}[1] <=> $boston_team{$b}[1] } keys %boston_team) {
    printf "%s: %d\n", $team,
        predict_year(@{$boston_team{$team}});
 
}
 
sub predict_year {
    my($last_won, $beat_stl) = @_;
    my $base_year = $beat_stl + 2;
    $base_year += int($beat_stl/1000) - int($last_won/1000); # adjust for difference
    return $base_year;
}
 
__END__

This formula correctly "predicts" the next championship of each team:

Celtics: 1959
Bruins: 1972
Patriots: 2004
Red Sox: 2007

I CALLED IT!!!!!</colbert> slashdot.org

Tainting

| | Comments (0)
So the question is: is there a way to detaint arbitary data in Perl without using hash keys or regexes or XS?

Something hit me. This:

#!/usr/bin/perl -sTl
use warnings;
use strict;
 
use Scalar::Util 'tainted';
 
no strict 'refs';
for my $name (keys %{'::'}) {
    printf "%s:%d\n", $name, tainted($name)
        if $name =~ /^[a-z]\w+$/i
        && $$name;
}

Execute that like ./taint.plx -dakdjhasd and you get $name with dakdjhasd in it, untainted.

This is not the same thing, but what it does do is take some untrusted data that you normally might expect to be tainted, since it's just data on the command line, and makes it trusted. But this is not arbitrary data, and it is not tainted in the first place (and therefore not untainted). Interesting though. Then I thought:

#!/usr/bin/perl -Tl
use warnings;
use strict;
 
use Scalar::Util 'tainted';
 
no strict 'refs';
 
my $foo = $ENV{HOME};
printf "%s:%d\n", $foo, tainted($foo);
 
${'::' . $foo} = 'la la la';
 
my $bar;
for my $name (keys %{'::'}) {
    if ($name eq $foo) {
        $bar = $name;
        last;
    }
}
 
printf "%s:%d\n", $bar, tainted($bar);

W00t. Data is untainted!

Now, I know, this is still basically using hash keys, since the symbol table is a hash. But I don't care. Also, it wouldn't necessarily work with arbitrary data, given symbol table limitations.

Just something passing through my head. use.perl.org
Back up your hard drive before upgrading.

You're welcome.

I back up my HD every night with SuperDuper!, and I make a special point to do it for any significant system upgrade, including a minor revision (like 10.4.9 -> 10.4.10). It it borks my system, I reinstall it from the backup.

It really works. Really. slashdot.org

Slashdot Party!

| | Comments (0)
The party last night was great. We had significantly less than the 157 people who signed up, but still a lot: about a third of that, I'd say. Plenty large. Amazon provided pizza and drinks (for which there was a lot of extra for people to take home!) and I had a great time meeting new people and meeting old friends for the first time in real life, and seeing old friends I hadn't seen in awhile.

Thanks again to Amazon and especially cjcollier for all the work he did to bring it all together.

Unfortunately I forgot to bring my camera. If you took pictures and you post them, please let me know! slashdot.org

"Still Alive" Cover

| | Comments (0)
I've posted my cover of "Still Alive" by Jonathan Coulton, from the video game Portal, on the Longest Concert Evar. slashdot.org

Seattle Slashdot Party

| | Comments (0)
Don't forget to sign up for the Seattle Slashdot Party! Here's some of the details:

OK, we have a location: the 8th floor of the PacMed building on Beacon Hill. (Yes, that is Amazon HQ!).

The date is Saturday, October 20. Time is 6 p.m until whenever.

Because of security, please send me e-mail (pudge -at- slashdot -dot- org) with your name, and bring ID to the party confirming. If you don't, no huge deal, but you may need to spend a few minutes at the front desk while you fill out a paper and they print out a badge. Sorry about the minor hassle, but it'll be worth it!

Parking is free and available on the north side of the building (the graded area on the down-slope of Beacon Hill in the picture). If you give me your name beforehand and bring your ID, go to the west entrance. Otherwise, use the lower, north entrance. (If you have RSVP's and have your ID, but need a more accessible entrance, use the north entrance but skip the line and show your ID.)

If you want to network with people OR computers, feel free to bring the appropriate gear: resumes, business cards, laptops, etc. No WiFi provided (doesn't mean not allowed!).

Some food will probably be provided. Updates to follow on that. Alcohol will not be "provided."

Thanks very much to Amazon and their hospitality and generosity.

We will have some free t-shirts and things to give away.

See mullein's comment for bus information.

Thanks all, should be a great evening. See you Saturday. slashdot.org

Slashdot Party in Seattle Update

| | Comments (0)
The location and time are set for the Slashdot Party in Seattle. Address is at the top of the page.

For more information, see the comment with details. slashdot.org
<pudge/*> (pronounced "PudgeGlob") is thousands of posts over many years by Pudge.

"It is the common fate of the indolent to see their rights become a prey to the active. The condition upon which God hath given liberty to man is eternal vigilance; which condition if he break, servitude is at once the consequence of his crime and the punishment of his guilt."

About this Archive

This page is a archive of recent entries in the Computers category.

Ask Pudge is the previous category.

Longest Concert Evar is the next category.

Find recent content on the main index or look in the archives to find all content.