Blogs

PHP 'readfile' and corrupted zip/gzip/binary files

For a recent project, I needed to create a large batch of files for the user to download all at once. Creating a zip/tar was of course the solution. However, the file was always corrupted when downloaded and opened, but it was fine when read on the server.

It turns out that PHP was outputting some extra data before readfile() was called, so, I needed to clean the output buffer first, using ob_clean();

Example:

"Search in the Biblical Domain" - presentation - BibleTech: 2011

Here are the slides from my talk at BibleTech:2011. I'll be adding audio and video as I get it.

 

Can Throwing Fridge - Part 3 (Plastic)

The HDPE plastic arrived today. It's a white sheet .5" x 48" x 96". So, it's time to start stenciling individual structural components on the plastic. After that, cutting will commence!

Can Throwing Fridge - Part 2

In my last post on the fridge, I described the circuit board that would control the motors for the fridge. I have now completed the circuit board that will control a motor and some servos. For instance, the servo that will control releasing a can so it can roll into the elevator that will carry it to the catapult.

Here is that board (click to enlarge):

Add HTML5 Audio to Drupal's Audio Module (for iPad for instance)

Recently, My father got an iPad; it's his one internet-enabled device. He mentioned that he couldn't listen to any of the audio on my site. Well, I found this to be unacceptable, and, while we still on the phone, I made the following changes to Drupal's Audio Module:

1. Add a class and title to the flash player.

FIrst, edit the "1pixelout.inc" file in the audio/players/ directory (or edit the .inc file for the play you have chosen to use.) Add the following class to the flash object tag: class="1pixelflashplayer". Also, add the following title attribute to the object tag: title="{$options['soundFile']}".

2. Add javascript to the page

The following javascript will search for all the flash players with the aforementioned class, hide them, and insert an <audio> tag after them with the src of the video from the flash player. Note: This will only work for mp3 audio files. You can download the javascript at the bottom of the page.

I Hope this helps someone.  Javascript follows...

Normailze phone numbers using regex in PHP

Recently, it became necessary to normalize phone numbers for my work on SimpleChurchCRM. In order to normalize something, we must first understand it and analyze it.

The following regular expression will match phone numbers and their parts.

([(]?(?P<area>\d{3})[)]?)?(?: ?-?)?(?P<three>\d{3})(?: ?-?)?(?P<four>\d{4})( (x|(ext\.? ))(?P<ext>\d+))?

Note that this requires PHP > 5.2.2 I think. 

ATT: Only 2% of smartphone users consume > 2GB of Data a month...

So, on Monday (June 7th) ATT will be discontinuing its unlimited data plan that is currently $30. It will be replaced with a $25 a month plan that includes 2GB of data (67.5MB/Day). I believe they are also offering 200MB for $15. Supposedly, "Only 2% of ATT's smartphone users consume > 2GB data". That isn't intellectually honest in my opinion, because: This assumes that the users of different phone models use data in the same quantities.

This is erroneous.

Drupal gives " Permission Denied" to edit a node, but the user has permission to edit.

From time to time I see people getting caught by the issue in the title. There are no other permission based modules being used; the user has edit permission for the content type, he/she may even be the author of the node, but they get a 403 Access Denied.

Here is a possible reason why: The user does not have access to a Filter type used on one or more of the node's input fields. This can happen when someone else creates a node who has access to a certain filter that not everyone else does. Then, when the other user comes to edit the node, he/she can't.