1. If a task can be automated and done better by a robot. It should. Humans should not perform such tasks.
  2. If making the robot is harder than the task, only make the robot if saved energy over time is greater than doing the task.
  3. If the task is useless, pursue it only if it enables happiness.
  4. Useless tasks that do not promote happiness are scourge and should be eliminated forthright.

Beating FFXIII was clearly category 4.

ImageMagick: Rounded-corner PHP function

I’ve converted my rounded-corner bash script into a PHP function that’ll use the Image Magick command line tools to do the same. With some added functionality to handle automatically creating thumbnails and applying a background color to the source image itself. This also allows for the insertion of basic pre-processing and post-processing arguments to IM.

For more information and output examples see. the bash version.

To see an example of thumbnails generated with some pre-processing done:

First Preprocessor Test

This is a sample done with thumbnail pre-processing. That is processing done before the rounded corners are made.

With this sample, I switched colorspace to HSL and then set the hue and saturation to a constant before applying the glass-bubble rounded corners.

Known bug: sometimes the glass-bubble method will add a single pixel to the width, which is transparent. I believe passing -trim in the postprocessing option may trim that off for you, though I have not thoroughly tested it.

Also: I have no idea if this will work on a Windows server.


Rounded Corner Script

Script Download: (v2)

Ever wanted a script that would round the corners of images for you?  Well, if you said yes, I wrote myself a bash script to do just that.  As of this post it can do the following: round of corners of images and it can also add a glass-bubble effect as described in the ImageMagick tutorials.  You can specify the border radius and a background color, which is handy if you are making JPEGs.  The script’s help screen is shown below, as well as a couple of samples.  Radius sizes are in pixels.

./ <inputfile> <outputfile> [options]
  -m   Method [plain or glass-bubble]
  -r   Corner Radius
  -b   Background Color
Method can be plain or glass-bubble at the moment. (default: plain)
Radius specifies the radius of the rounded corners. (default: 15)

Note: This should be able to function as filter command, so if you wanted
rounded thumbnails of a particular size you can:
convert <bigfile> -resize 200x200 png:- | ./ png:- smallrounded.png" 1>&2

Solved: GIMP Script-Fu Console Image ID

Problem: In experimenting with GIMP’s Script-Fu console, I could not figure out what values to feed in to scriptfu-rounded-corners (you know, to see what would happen) for image and drawable.  It was surprisingly simple though.


Programmers should strive to Expand their Knowledge Bases

With a title like “Programmers should strive to Expand their Knowledge Bases” you’d think I was referring to things like OOP, DRY, and other acronyms. However, I am not.  I’m not referring to learning additional programming languages or algorithms.  I’m talking about learning things from other domains entirely.  For example: science, knitting, cat photography, cat photograph captioning and so on.  Honestly it’s a little bit of a weak point for me as well.  My grammar is a sore example.  Of course, I’m a mediocre-self-taught-programmer, so that is to be expected anyway.  First off there’s knowledge you can apply directly to programming problems.

Having knowledge about other fields allows you to more readily solve programming problems that involve those fields.  There’s even a term for this: domain knowledge or domain-specific knowledge.  You don’t necessarily need to be an expert either.  For example, with a base level of knowledge it become easier to get input from experts in a particular domain This is because you already have a base understanding.  There are two less-obvious benefits though, and I think they are more important.

First, having a broad base of knowledge to pull from enhances problem solving skills. I don’t have solid numbers to back this statement up though. (This is a blog, not a peer-reviewed paper.) Usually, when confronted with a problem in different domains the manner in which you come to a solution differs based on the domain at hand.  More specifically: you think differently.  Being able to solve problems in programming often requires you to shift your way of thinking and having more experience approaching problems from different angles can be very beneficial.  It can even apply to learning new programming paradigms.  I didn’t fully grasp OOP until I considered things in terms of chemistry.

Second, having a broad knowledge base can make it easier to communicate with people of different backgrounds.  Much like dealing with experts above, but often a little more general.  This is also somewhat tied to the problem solving mentioned previously.  When you can shift thinking readily, it becomes far easier to think like the person you are communicating with and explain things with terms or analogies that that person can understand.  As a personal example of this: I’ve explained the Linux boot process almost entirely with car analogies to a car guy.  I’m pretty certain that had i never taken auto shop, this would have been impossible.

tl;dr version: Learn stuff. It makes you a better problem solver and communicator.  Soft skills for the win.

Now I remember why I hate HP’s website

Not entering a valid part number is not a crime.

So I go off to search for a part (specifically a replacement battery for a laptop) but I don’t have the thing with me since it’s not mine, I’ve just been tasked with finding a replacement.  (So, no stickers for me!)  As a last ditch effort before contacting the owner, I go googling and grab a random part number and decide to try to plug it into the part search and hope that it happens to match with HP’s all-knowing database, knowing full well it would probably say something like “Invalid Part Number” or something.  Plug in: SFB-HPDV7_56157 and I’m met with a much more condescending message:

A potentially dangerous input was detected from the client browser. This incident is reported to Support team. Please click ‘Home’ link to continue.

Really?  It’s always such a pain to use HP’s website to find… umm… anything, but this is a first I have to admit.  I wasn’t aware that dashes and underscores could be dangerous.  Couldn’t be polite and just say “that part number isn’t valid.”</rant>

That out of the way, why do manufacturers go through such lengths to avoid parting us from our money?  If I cannot, with ease, find a replacement part from you, I will not be able to buy it from you. For those who don’t know, with HP, to find anything you need both the product number and serial number to even begin your search. (Alternatively run their HP support assistant program on the laptop itself.)