Archive for the ‘Programming’ Category

Slicing Code with a Rusty Razor Blade

A year or two ago I was returning to my office from lunch with some co-workers. I spotted an old, rusty, razor blade on the sidewalk. “You don’t see that every day,” I said. In retrospect I was probably wrong. Everyone likely sees dozens of rusty razor blades on sidewalks and in gutters every day. We just don’t notice them. That’s not the point. The point is that I told my friend, Jon, that it would make a good domain name. “You should register rustyrazorblade.com,” I said. And he did. Now, if you’re looking for an esoteric, complicated, intense Apache and / or MySQL resource, it’s the place to go. True story.

Found: One brilliant article about being a programmer
Source: MeFi

I Always Said ColdFusion Sucked

I was glad to see ColdFusion make it on this list of the top 10 dead (or dying) computer skills. It’s a ridiculous “language” that I never bothered to learn and used to tell people was craptastic and worthless when it was brand new and everybody and their mother was looking for people that knew it. I clearly remember being told that I just had to learn ColdFusion or I was going to miss the next web wave. I scoffed, learned ASP and PHP, and think I made the right call.

I was surprised to see C on the list, though. I guess I can understand that there aren’t many people actually programming in the original C, but I’d say that the basic principles of the language — including C++ and all of its children — are still pretty important.

Delete Empty Folders

Delete Empty FoldersLooking for a way to clear some of your computer’s clutter? Getting rid of empty directories is a good start. I was looking for a file and realized that my machine was spending a long time searching through folders that I knew had nothing in them. A quick Google search returned a handy DOS trick to zap them all. It took me about one minute to delete just over two thousand empty folders. There’s nothing like a little command-line scripting to get something done.

WordPress Gunning-Fog Analysis PlugIn

A few weeks ago a friend of mine asked me to build a WordPress plugin to display a Gunning-Fog analysis on his blog. The math part was pretty easy stuff. I was having a borch of a time getting the plugin to count syllables, so I hunted through Google and found someone else had written a pretty good function to do that. I squished it all together and it seems to be working pretty good.

You can download the plugin here and see it in action here.

Amazon Wishlist Yahoo! Pipe

Today I decided that my life would not be complete if I didn’t learn how to use Yahoo! Pipes. So I gave it a shot. I couldn’t really think of anything I wanted in a pipe, so I decided to try building one that would let me search eBay for items on my Amazon wishlist. Shouldn’t be too hard, right?

Yahoo! PipesI learned that it is possible to pull your Amazon Wishlist items as an RSS feed, which is cool. I found an example on the Amazon Web Services Developer Connection. You need to have an Amazon Web Services Access Key (AWSAccessKeyId), but they’ll give those away to anyone nowadays. You don’t need to read the full article; I’ll summarize.

Read the rest of this entry »

How to Display RSS Feeds Using PHP

If you’re interested in displaying an RSS feed from an external source using PHP, you simply must grab RSS_Fetch by Drew Phillips. It is by far the easiest implementation that I have found. The readme file is very detailed and the code is well-documented. I highly recommend it.

Timeline WordPress Plugin

This domain of mine has had stuff on it for a long, long time — before WordPress or MovableType or even Blogger. The original davidgagne.net is, sadly, lost forever. Some pieces of it have been kicking around on my various hard drives and FTP locations for a decade now.

One file that I could never seem to bring myself to delete was an ancient hand-coded HTML <TABLE> listing of a bunch of important events in my life. A few friends of mine actually built a company based on the idea. It was called “ShareTimelines.com”, had a magnificent interface, was all webbed up, and the site — last I checked — is completely dead. I wanted to have that timeline on this site again. I hadn’t updated it in years and years, and I would rather poke hot needles in my eyes than sit and hand-code a bunch of <td>s all day. “It should all be in a database, of course,” I said to myself. “And I should be able to edit it right in the WordPress Administrator, too. And seriously it should be written so that I can just give other people the ability to add timelines like that to their own sites.” ( I should stop talking to myself.)

Read the rest of this entry »

Disable WordPress File Upload

Although I can appreciate that it’s a really nifty feature, I am likely never going to use the built-in File Upload feature in WordPress. What has bugged me is that it’s in an IFRAME in the Write Post panel; I think it slows the page load. I was trying to get rid of it, but the best I could find was the Clutter Free plugin from Tempus Fugit. It’s a great plugin, but unfortunately it doesn’t really remove the IFRAME, it just hides it.

So. I dug around in the code and did it myself. If you aren’t the file-uploadin’ type, you only need to change a few lines to prevent the File Upload widget from appearing on your Write Post panel. Open wp-admin/edit-form-advanced.php and look for the line containing $uploading_iframe_ID. It’s near or around line 223. There are a few different ways you can handle removing this.

Read the rest of this entry »

LIMIT and OFFSET in MS SQL Server

How to Hack MySQL Paging Functionality into Microsoft SQL Server

Web developers using PHP and MySQL have a crucial piece of functionality that classic ASP developers working with Microsoft SQL Server don’t. It’s pagination. Using MySQL’s LIMIT and OFFSET commands you can very easily add pagination to recordsets that you want to display on web pages. If you’ve spent any amount of time searching for a way to do this with ASP and SQL Server, you know that the code is pretty hard to find. You’re lucky if you find it at all. The few tutorials on the ‘net tend to be overly complicated and pretty bad hacks, usually involving convoluted and resource-intensive subqueries on top of subqueries. This solution is certainly not the best, and it, too, is a resource hog, but it’s the only one I’ve got, so I’m sharing.
Read the rest of this entry »

DropCaps, Amazon Tags for WordPress

I have finally updated two of my WordPress hack tutorials so that they are compliant with v. 2.04.

The first one — DropCaps — allows you to put that nifty “dropcap” into a post. This post begins with a dropcap I.

The second one — Amazon Tags — adds two new buttons to your editing screen. They allow you to link directly to an Amazon item by its ASIN or to add a link to an Amazon search.

The second one includes a link to a zipped copy. You can just extract quicktags.js into your wp-includes/js folder and the images into your wp-images folder and you’re set.

Happy WordPress modding!

MySQL Triggers Tutorial

Jon is one of my developers at work. He recently started a WordPress blog called Rusty Razor Blade. I’m guessing that most of what he’ll be posting is going to be fairly technical stuff about MySQL, LAMP, AJAX, and JSON. So far his first really interesting post is a MySQL Triggers Tutorial. It’s actually a bit better than the help page on mysql.com, and if you know what a trigger is in Microsoft SQL and have always wanted the same functionality in MySQL, you should give it a read.

Dot Don’t

What system are people using to create web sites that have .do files? It seems that every site I visit that employs this coding is slow, slow, slow. Men’s Health and Capital One both have sites built with tons of .do files and redirects and both of them drive me nuts.

Business Days

(Q) How do I calculate total number of working days between two dates?

(A) Use this function.

Lewies Blog

Update: Lewies used to have a good article on how to execute FTP processes via ASP. It is apparently no longer there.