Eddie On Everything

Tips & tricks on things that interest me

Entries Tagged ‘code’

Managing Server Load when unzipping many large files

So, I have about 500 zipped up files that I needed to unzip.  Each of these files is about 100M when decompressed.  I ran into a big problem when unzipping the files all at once – when I did a simple “unzip \*zip", the server load eventually skyrocketed.  The load got so high, in fact, [...]

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 [...]

Disabling TextArea Scrolling in Flash AS3

Had a problem while working on a new Flash App today. I have a number of dynamic text fields (TextAreas), and they scroll in-place when the user highlights the text and when the user uses the mouse wheel while hovering over them. I searched for a way to stop this scrolling for quite a while [...]

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 [...]

Making Yahoo! Sports Fantasy Pro Football Pickem Sortable

I play Yahoo! Fantasy Sports Pro Football Pickem. In it, you pick the winner of each NFL game every week. I play a version that requires you to not only pick the winner, but to assign “confidence points” to each pick as well – that is, you assign a score to each pick indicating how [...]

mod_rewrite in .htaccess to Force www in URL Not Working

Setting up a new site today, I ran into a problem with a .htaccess not working. It was a pretty simple solution, and was the result of a minor oversight my part. Still, it took me about 10 minutes to realize the mistake I’d made. I just thought I’d post here in case someone else [...]

MySQL Performance Tip: ON DUPLICATE KEY is faster than INSERT IGNORE, but failing with a duplicate key error is a lot faster

I’m working on merging a couple of pretty big MySQL databases. Each database consists of just three tables, but each of those tables has at least 9 million rows. Because I need to maintain and update a number of data associations, it was necessary to write a custom script to perform the merge. (I chose [...]

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 [...]

How to Block a Quote

Blockquotes are a great way to reference others’ material. A blockquote lets your reader know that you are quoting another source, and it pays proper attribution to your quoted source. HTML supports the <blockquote> tag, which does exactly what one would suspect. To block a quote in HTML, simply use this tag. Example: <blockquote> This [...]

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 [...]

How To Set a Class Name using Javascript in IE and Other Browsers

I was working a client project today had to use a little javascript. As anyone who’s worked with Javascript knows, Microsoft’s Internet Explorer can be a real pain the butt. Things that work in Chrome, Firefox, and Safari don’t always work in IE – so you always have to come up with workarounds to make [...]

Optimizing the Google Syntax Highlighter WordPress Plugin Even Further

I use the Google Syntax Highlighter for WordPress plugin to display the code I share on this page all pretty-like. The problem is, the thing isn’t very robust – it causes every single page on your blog to load up about 10 separate javascript files, regardless of whether the plugin is actually doing anything on [...]

Customizing the Calibre Associated Press (AP) Recipe

I’ve been using Calibre to manage my eBook library and download daily news to my Kindle.   It’s great.  If you have a Kindle or other eBook reader, I recommend that you check it out. Calibre comes stocked with a number of “recipes” for popular news sites.  One of those is the Associated Press (AP). [...]

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, [...]

Rotating Backup Directories using cp -al (hardlinks) to Save Disk Space

The copy command “cp -al” found on all versions of Unix/Linux creates what’s called a “hard link” to a file. The nice thing about this command is that it doesn’t create an actual copy of the file on disk – instead, it creates a “link” or pointer to the file data on the disk. Basically [...]

Using rsync & ssh to Backup Files Between Linux Machines (Perl)

This script performs a network backup using unix’s rsync command over ssh. It performs an incremental backup, which means that it only updates new files and files that have changed since the last backup, thus minimizing network traffic. This script runs on the source machine (SOURCE) and connects to the backup machine (BACKUP). (SOURCE->BACKUP). It [...]

“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 [...]

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 [...]


Buy me a pizza