Brian's blog

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. 

PHP's mysql_connect Function Anomalie

Recently, when trying to make 2 similtanious connections to the same mysql server with different databases, I noticed that this is not strictly possible without a little tweak.

The following will not work as expected:

$con1 = mysql_connect('localhost', 'user', 'pass');
mysql_select_db('db1', $con1);

$con2 = mysql_connect('localhost', 'user', 'pass');
mysql_select_db('db2', $con2);

Initial findings concerning iPhone web frameworks (iUI, and jqTouch)

I am in the process of completing a web based application that I will be marketing soon. One of the last features to be added is an iPhone interface. The ubiquity of the mobile platform - most outstandingly, the iPhone - has necessitated this.

There are 2 main ways in which to build any application: hand code everything or use a framework. A framework's job is to take the mundane tasks that need to be done for EVERY application you write and make them simple. Some frameworks also help with code organization.

One-liner: Convert a Directory of wav files

Usually, when I need to convert many wav files, I'll use a perl script I wrote - its on the Helpfull Apps Page.  But today, I didn't care about ID3 Info or anything like that. I use LAME for commandline encoding and here is the one-liner that took care of the directory:

find ./ *.wav | sed 's, ,\\&,g'| xargs -n1 lame -b -96

Google Searches for Which I Am on the First Page of Results

By using a combination of Google Analytics and Google Webmaster Tools I have compiled a list of the most popular pages on my site according to google and its search results.  I find this data very helpful and interesting. So, I thought I would share.  What follows is a list of search phrases, which link to the resulting page on my site, and then a link to the search.  I only inculded the search for which I am on the first page of google results. (Continued...)

Can Throwing Fridge - Part 1

I finally started my project to build a soda-can-throwing-mini-fridge.  I've talked about it for a year or so, but now, I have actually ordered parts AND stated assembling. While I do not have the actual mini-fridge yet, there is much I can do without it. For instance: assembling the electronics, computing multiple throwing distances/angles and the necessary springs and motors necessary to make them. (Continued...)

My Addiction to 'No Fear'

No Fear is a SoBe product that is billed as an energy supplement. It contains numerous Vitamins and Minerals, (C, B, Taurine, Caffeine, etc.). The drink is very lightly carbonated.