Tuesday, September 2, 2008
Thursday, August 21, 2008
Circular saw guide & easy grid
I recently had to square up a piece of plywood for a project and drill a bunch of aligned holes to insert C9 light bulbs. Now, I am a computer geek, not a carpenter. Needless to say, I cannot draw a straight line without a mouse, and forget about cutting straight. So first, I had to square up a piece of plywood to a size of 32"x36". I do have a table saw, but it has a ton of stuff piled on it. I also have a 18 volt circular saw, but I'm sure my final size would be (32-30")x(36-37"). Looking again at my table saw, I figured it would be worth the effort to dig it out to use the guide fence. Unfortunately, my table is not large enough to provide a good straight guide for the cuts. Luckily, I had a very straight piece of wood. I carefully measured (both with a tape measure and with the shoe of the saw) the width between the saw blade and end of the shoe on my 18 volt saw. I then clamped down the board and there you go, instant guide!
Next, I had to plan on drilling a grid of 9x10 for C9 light bulbs. The old me would just start drilling and hope for the best. Not this time! I carefully (well, almost carefully - I did re-use previously discarded measurements accidentally) marked off the spacing for the bulb sockets (3" spacing) and added a 2" header and a 4" footer. I then tried my chalk line to make nice straight lines, but that just left a blurry mess. My 4 foot T-square was buried (see the theme here?), and my straight edges were not long enough. Behold, the board I used as the saw guide to the rescue! Using the board, I lined up the markings and drew the vertical axis, then the horizontal axis. I now had a grid full of 3" square boxes. Using a spade bit, I drilled at every horizontal/vertical intersection and when done, had a nice array of holes all lined up. The best part is it only took about 45 minutes total.
Next, I had to plan on drilling a grid of 9x10 for C9 light bulbs. The old me would just start drilling and hope for the best. Not this time! I carefully (well, almost carefully - I did re-use previously discarded measurements accidentally) marked off the spacing for the bulb sockets (3" spacing) and added a 2" header and a 4" footer. I then tried my chalk line to make nice straight lines, but that just left a blurry mess. My 4 foot T-square was buried (see the theme here?), and my straight edges were not long enough. Behold, the board I used as the saw guide to the rescue! Using the board, I lined up the markings and drew the vertical axis, then the horizontal axis. I now had a grid full of 3" square boxes. Using a spade bit, I drilled at every horizontal/vertical intersection and when done, had a nice array of holes all lined up. The best part is it only took about 45 minutes total.
Tuesday, July 1, 2008
Rounding up
Quick and dirty PHP code to round up to the nearest multiple of 10 (at least 10 over the current value). This is handy when creating metrics and graphs where you want to 'trick' the viewer that a bar is not really as high as it appears without having to set a hard upper limit in a chart (e.g. If you chart value is 2, generate a bar of 2 on a scale of 0-10).
$val='some number';
$r=round($val/10)*10+10;
So:
$val=1;
$r=round($val/10)*10+10;
$r is 10
$val=11;
$r=round($val/10)*10+10;
$r is 20
$val=6;
$r=round($val/10)*10+10;
$r is 20
$val=55;
$r=round($val/10)*10+10;
$r is 70

$val='some number';
$r=round($val/10)*10+10;
So:
$val=1;
$r=round($val/10)*10+10;
$r is 10
$val=11;
$r=round($val/10)*10+10;
$r is 20
$val=6;
$r=round($val/10)*10+10;
$r is 20
$val=55;
$r=round($val/10)*10+10;
$r is 70

Sunday, June 29, 2008
Creating barcodes
Barcodes are not really a mystery. There is nothing special in the printing/ink/formating, but rather are simply a set scheme for how black bars are formatted. A barcode reader simply scans the code and measures the black/color separations. You can easily print your own barcodes at home! All you need is a barcode font for the encoding scheme you wish to use. The most popular is the 3of9 barcode format. Do a google search to find a free (or pay for one, if you wish) 3of9 barcode font, load it up and start typing! Print it out and you have your very own barcode!
Removing spaces using sed
Many times when working with files, you need to reformat them to more easily parse with cut, etc. Often, these files may have multiple/variable spaces between fields. This quick sed line will convert multiple spaces to a single space:
sed 's/ */ /g;'
sed 's/ */ /g;'
Resolving a list of IP's to Hostname
Sometimes, you have a list of IP addresses in a file you want to resolve. Here is a quick Perl snippet that will do just that. This particular script reads in from a text file, but it is trivial to take in other inputs.
#!/usr/bin/perl
use Socket;
open(INFILE, "< /tmp/host.txt");
seek(INFILE,0,0);
@inhosts =;
foreach $inhost (@inhosts){
$inhost =~ s/\n//;
$hostname = gethostbyaddr(inet_aton($inhost), AF_INET);
print "$inhost = $hostname\n";
}
#!/usr/bin/perl
use Socket;
open(INFILE, "< /tmp/host.txt");
seek(INFILE,0,0);
@inhosts =
foreach $inhost (@inhosts){
$inhost =~ s/\n//;
$hostname = gethostbyaddr(inet_aton($inhost), AF_INET);
print "$inhost = $hostname\n";
}
Saturday, June 28, 2008
Uses for velcro straps
I bought my daughter a chalk footprint making set. This amounts to large feet that have removable insoles for various types of animal track prints and bags of colored chalk that attach over the foot with a velcro strap. The idea is the child stomps along the sidewalk, leaving a trail of chalk animal tracks. Well, since there is only a single velcro strap over the top of the foot, but the strap has a wide girth, kids feet easily slide out when walking. Needless to say, my daughter was quite frustrated! I remembered a bag of velcro cable retainers I had laying around. A few quick loops and I had fastened an ankle strap to supplement the existing foot strap. No more slipping off, and my daughter can run around without fear of loosing her 'footing'. I now have blue and pink paw chalk paw prints all over my driveway and down my sidewalk.
SQL selecting past year of data for fiscal reporting
Working with dates in programming languages is always a pain. Either you work directly with unixtime, then upconvert, or you wind up transforming strings into date formats, parsing with various date functions, and pulling your hair. Computers are incredible machines, but lack basic human reasoning and intelligence. A simple task such as 'show me everything in this database for the past year, starting with October of last year' can result in a complex operation for the computer, while a human can simply deduce that the current year is 2008, so you want everything from October 2007 through current.
Here is a simple SQL statement that will select all the data from a tasks table for the past fiscal year where the field start_date is the recorded date we are interested in. Our fiscal year does not match a standard calendar year, so the start of our FY is October.
select name,start_date from tasks where date_format(start_date,'%Y-%m') >= date_format(date_sub(curdate(), interval 1 year),'%Y-10');
In a nutshell:
Select name, start_date from the tasks table where:
the year (4 digit format) and month (2 digit format) is equal or greater than October of the past year. Ex: 'select name, start_date from tasks where '2008-06' >= '2007-10';
Here is a simple SQL statement that will select all the data from a tasks table for the past fiscal year where the field start_date is the recorded date we are interested in. Our fiscal year does not match a standard calendar year, so the start of our FY is October.
select name,start_date from tasks where date_format(start_date,'%Y-%m') >= date_format(date_sub(curdate(), interval 1 year),'%Y-10');
In a nutshell:
Select name, start_date from the tasks table where:
the year (4 digit format) and month (2 digit format) is equal or greater than October of the past year. Ex: 'select name, start_date from tasks where '2008-06' >= '2007-10';
Welcome
Welcome to Kludge R Us! Being in the computer industry along with being a geek, you come across many kludges to accomplish a task. Or more likely, you are the one developing kludges to suit the task at hand. In upcoming posts, I will be sharing the various kludges my or my cow-irkers have implemented in both our professional and personal lives. I will also call out kludges experienced in the real world that may normally go unnoticed.
Subscribe to:
Posts (Atom)