Downloading Files in PHP for Fun and Profit

I recently had to setup a page where users could download files. You’d think such a task would hold few secrets for someone who architected a download site. Well, that’s how much you know.

Like many programming tasks, you meet it head-on, on the field of battle; you grab it by the horns and wrestle it to the ground. Victorious, you move on, and quickly forget the finer nuances which thrilled your sense of challenge and elegance. Luckily for you, I’ve started documenting these little trysts in this blog. Continue reading

Migrating Contacts From Palm Pilot to Gmail

Once he finds someting that works for him, my father sticks with it. Which is why, until very recently, he was still using his Palm Pilot Vx. But all things come to an end, and now that he and Mom got His and Her’s Samsung Galaxy S‘s, it was time to get his contacts migrated from the Pilot to Gmail, so they could get picked up by the Android.

This turned out to be less straight-forward and more challenging than anticipated. So, although I don’t expect many will need to run through this, I’m posting for the few who might. This’ll save you a couple of days of heartache.
Continue reading

Alfred’s Notes: Drupal

I’ve started studying Drupal, the open source content management system (CMS). I’ll use this page to gather interesting links to documentation and articles on the subject. Who knows? I may even sort and organize them some day.

Ajax in Drupal using jQuery

Introduction to AHAH Forms in Drupal (handbook)

Creating Drupal style tables

AHAH in Drupal: may it one day live up to its acronym

Using default views in your module
Where to put your exported Views in code, direct from Earl Miles, aka merlinofchaos, author of Views, among other essential parts of Drupal.

Describing tables to Views
To someone who already knows SQL, and is very comfortable with it, Views is like trying to fiddle with very small dials while wearing large mitts of cotton batting. The main problem is Views doesn’t necessarily know the ins and outs of your data model. Here’s how to tell Views about those ins and outs. And remove at least some of the batting.

Updating WordPress Plugins Locally, Without FTP

It’s been the bane of my WordPress life: every time I get a notification of updates available on my local installation (on my MacBook Pro), either for the WordPress core, or one of my installed plugins, I get a request for FTP parameters. This, I’ve learned, is due to WordPress trying to write a small test file to the wp-content directory. When it fails, it reverts to trying to get the files via FTP. But, sadly, I don’t have FTP setup on my local install. Besides, from what I hear, this method seldom works.

Don’t despair, though: there is a solution. And it’s fairly simple. (Don’t be put off if you’re not familiar with the OSX Terminal: it’s not that complicated. Really.) Continue reading

Importing a Distribution List in Outlook

So I had to send out a notice to about 700 users. I had the list in the users table of my app’s database. I wanted to create a distribution list in Outlook. It’s not as straightfoward as it may sound.

The first step is to generate the csv file. Small complication: although I had access to the database, I did not have access to the server. So any output files MySQL generates are essentially out of my reach. Therefore, I needed to generate the file locally. No problem: MySQL has an –execute option which allows you to run multiple commands from the command line. It gets long and unwieldy, but it works. Here’s what I used:

mysql -u root -p db01 ^
  -e "select distinct concat(first_name, ' ', last_name, ', ', email) as name from users order by last_name, first_name;" ^
  >users_list.csv

(Yes, you can use the caret to continue a command on the next line. But don’t use a tab to indent your continuation. Spaces are cool though.)

OK, step one done.

Step two is creating a new distribution list in Outlook. You do that under Contacts. Click Select Members, to bring up a dialog box.

See the Members-> button near the bottom? The text field next to it is where you can paste your extracted list. (Now might be a good time to send a shout out to the morons who architected this brilliant bit of user experience. On behalf of users everywhere, I entreat you to find another line of work.)

This is great, but there is a caveat. As I said, my list was about 700 users long. Outlook wouldn’t accept that many records in a single DL: it came back with an error message. So I tried 200. Still no go. It did take 100. So I created 7 separate distribution lists, then one more to rule them all. The last distribution list contained the other 7, so I can just send my email to the one DL.

That’s all I have for now on distribution lists in Outlook. Hope this is useful.

When WordPress Goes Wrong

This past weekend I finally sat down to upgrade my WordPress installation. I was at 2.8.4 and heading for 3.1.2. The automatic upgrader wasn’t working (it would start downloading the zip, and freeze), so I had to upgrade manually. (Using the upgrade instructions here.)

But when the dust settled, my admin dashboard was FUBAR. A number of the blocks on the page weren’t appearing. But the worst of it was that I’d select other pages in the admin and would get a 500 Internal Server Error. Yikes! Interestingly, though, the main site was working just fine.
Continue reading

Alfred’s CSS3 Notes – Multi-Column Text

Only supported in Webkit and Gecko, at the moment. Not available in Opera or IE.

section#mysection {
-webkit-column-count: 3;
-moz-column-count: 3;
column-count: 3;
-webkit-column-width: 15em;
-moz-column-width: 15em;
column-width: 15em;
-webkit-column-gap: 5em;
-mox-column-gap: 5em;
column-gap: 5em;
-webkit-column-rule: 2px solid #ff0000;
-mox-column-rule: 2px solid #ff0000;
column-rule: 2px solid #ff0000;
}

Cannot:

  • select a given column
  • size columns differently
  • specify percentages

column-rule property allows for border type effect between columns.