Eddie On Everything

Tips & tricks on things that interest me

Entries Tagged ‘programming’

Validating an Email Address with PHP’s filter_var isn’t perfect

So I’m working on a project where I need to validate that the user has entered a correct email address. I don’t really care if someone sticks in a “fake” email address – to complete registration, the user needs to enter a confirmation code that I send via email, so if they put in a [...]

How to Scan a Computer for Open Ports

There are a bunch of GUI utilities for conducting port scans, but I prefer to work from a command line shell.  In the past, I’ve used a custom script for scanning a machine for open ports from the command line, but I recently needed to get a little more information from a scan than my [...]

The Zen of Taco Bell Programming – Using Unix Tools to Prevent Reinventing the Wheel

Saw this great article by Ted Dziuba that parallels my programming philosophy. ( In case you’re interested, here’s a reddit thread on the article. ) In short, the article states that much of what you want to accomplish with any project is possible with the standard, tried-and-true Unix tools. When you shun these tools in [...]

How to Make phpbb3 Forum Links Automatically rel=”nofollow”

I use phpbb3 for this site’s discussion area. It’s not a particularly popular section of the website, but it does attract one type of commenter – spammers. Spammers like to create posts that link to their own site. They do this for two reasons – one is to drive traffic directly to their site. The [...]

How To Use Global Variables From Another File In A Perl Module or Package

I’ve been doing a lot of Perl development for my latest project, and I wanted to use a single config file for many scripts. Using a single config file in a basic Perl script is pretty straightforward – you simply use a require statement to read the external file, and the variables contained within are [...]

Getting PHP’s print_r Function To Return A String

PHP’s print_r function is invaluable. It prints a human-readable string representation of a variable. It’s one of the most useful debugging features I’ve seen in any language. I like it so much that I’ve actually written print_r mimic functions for other languages. By default, print_r literally prints a variable to the screen. Sometimes it’s useful [...]

Calibre Recipe for Minneapolis Star Tribune (StarTribune.com)

I love my Kindle. And I love the Calibre eBook management software. If you haven’t had a chance to check out Calibre, you’re missing out – it’s kinda like an iTunes for your eBook collection. In addition to storing, converting, updating, and categorizing your eBook collection, the software will also download news from any website, [...]

“Argument list too long” from rm command. A Perl Script to Get Around the Problem

You’ve seen the problem – many Unix commands don’t like very long argument lists.  For instance, my Linux machine complains when I try to “rm” 10,000 files at once: [eddie@yoakam test]$ rm * -bash: /bin/rm: Argument list too long Here’s a simple script that will delete all of the files in a given directory, even [...]

Calculate the Days Since a Given Date (Javascript)

I recently needed to calculate the number of days that had elapsed since a given date. Not happy with any of the code snippets I found on the internet, I wrote my own. A demo is below, along with the the javascript code. Note that the code uses a bit of dynamic HTML so no [...]

How to Easily Install a Perl Module In Ubuntu Linux

Wow, I think I just found the best tip EVER. I had to install a perl module (WWW::Mechanize) and was stuck in a serious dispute with CPAN over dependencies.  Wow, what a mess. Fortunately I found this post by David Yin about how to use Debian’s totally awesome apt-get command to install the module. Steps: [...]

PHP Programming: U.S. State list functions / State abbreviation to State name function

Here are a few PHP functions that I find useful for United States related things. Nothing brilliant or groundbreaking – just something to save you some typing. 1. A PHP function for printing a state select box 2. A PHP function that returns the full state name when passed the abbreviation 3. A PHP snippet [...]

AS3 Error: 1046: Type was not found or was not a compile-time constant

File under Adobe Flash 9 / Action Script 3 (AS3) Errors Error Message: 1046: Type was not found or was not a compile-time constant: caseStudyLink. The Problem: I was getting this error message when trying to tween a MovieClip on the stage. Flash was telling me that the error message was coming from one of [...]


Tips graciously accepted