Linux: Find and Replace in Files

Thanks to Jon H., I can now do find and replace in files on Linux machines from the command line. Its pretty simple, but I had never bothered to figure it out. Here are two examples. The first is for just one file, the meat and potatoes are in the second example, which does a find and replace in all PHP files. sed -i -e "s/TOREPLACE/REPLACEMENT/g" temp.txt; sed -i -e "s/TOREPLACE/REPLACEMENT/g" `find -name '*.php'`; Super helpful. »

Brian Hartsock on #Linux,

PHP: explode() vs. split()

Even though I have been a PHP programmer for 4 years or so now, I still discover new things every day. While looking at different ways to split strings based on regular expressions I learned an important lesson. explode() isn’t the same as split()! Since I learned Perl before PHP, I prefer using split() and join() instead of explode() and implode(), respectively. To my surprise, split() is not an alias of explode() while join() is an alias of implode(). »

Brian Hartsock on #PHP,

Safari Textarea bug

Well, I came across another Safari bug dealing with forms today. Unfortunately, I discovered this problem months ago and compeltely forgot it. So I figured I should document the issue so when it arises again, I won’t waste any time searching for the solution. Basically, like most other issues with forms on IE and Safari, this issue deals with setting values of elements before they are on the document. Before today, I thought that checkboxes and radios in IE were the main problem, but textareas also have issues. »

IE on Ubuntu

At first, I was hesitant to install IE on Ubuntu. Basically, I didn’t think I could trust it. But after spending hours and hours of development time waiting on my windows virtual machine to do anything in IE, I knew I had to try it. IEs4Linux work great. I only use IE6, and it is great. At first glance, it seems to work exactly like IE on my virtual machine, except it runs as fast as a normal desktop application. »

More Active Record Features

It has been a while since I have written about, or coded, my Active Record implementation. Basically, I have had too many other things to work on to enhance the functionality of an already working, albeit very beta, design. But, that doesn’t mean I haven’t been thinking of all the features I want to add to it. For many applications, the date created and date modified information for data is very useful, but annoying to set. »

The buggiest PHP function

Well, its not really PHP’s fault. array_search is misused by developers more than any other PHP function I have seen. Just today, I found two bugs caused by misinformed developers using the function. I myself am also guilty of using this function incorrectly. The problem lies in array_search’s return value if the needle isn’t found in the haystack. If the needle isn’t found, array_search returns false. In my experience, many other libraries return -1 in this case. »

Joel Predicts the future regarding Microsoft

The other day, Kevin sent out an article written by Joel Spolsky. To make a long story short, he discussed how Microsoft is shooting itself in the foot by not maintaining backwards compatibility. VB.NET isn’t backwards compatible with VB6, .NET 1.1 isn’t backwards compatible with .NET 1.0, etc. When I first read the article, I didn’t entirely agree with him. Most of the newer technologies Microsoft is developing are really cutting-edge, from a programmers prospective. »

Brian Hartsock

MythTV crash

Well, I tried to upgrade some packages on Myth, and the machine crashed. Not too bad, just wireless and X. Guess I will spend this beautiful Friday evening installing Fiesty. I have decided to create a MythTV page on my site, not only to help everyone out there with their own setups, but to help me remember when everything crashes. »

Brian Hartsock on #MythTV,

Dynamic form issues in IE and Safari

In the world of rich web applications, browser bugs and incompatibilities are the number one killer of productivity, next to YouTube, Facebook, and Myspace. Like most web developers, I have come to realize most of those issues arise from IE and Safari. Today I stumbled upon another interesting problem when trying to implement some dynamic forms. Take for instance the following code snippet: //Create form elements var form1 = Element.create('form', {name: 'test_form'}); var input1 = Element.create('input', {type: 'text'}); var input2 = Element.create('input', {type: 'text', name: 'input2'}); //Append inputs to form form1.appendChild(input1); form1.appendChild(input2); //Append form to document document.body.appendChild(form1); //Set input1's name input1.name = "input1"; //Check if form picked up on name change alert(form1.input1); alert(form1.input2); If you aren’t familiar with Prototype, this may be a bit hard to understand, but here is what is going on. »

Hokie Nation

After the horrible tragedy that took place on Virginia Tech’s campus early Monday morning, I wondered how VT would ever recover. Nearly everyone in Blacksburg, including myself, knows someone affected by the day’s events. The calm, safe environment this town and university has provided for so many was shattered in a matter of hours by one selfish individual. What was not shattered Monday became evident yesterday at the Convocation and the Candlelight Vigil. »

Brian Hartsock