Archive for the 'Computers' Category

Smarter Filtering

At work I have a bunch of scripts that tail logs with STDOUT being redirected to some grep statements to filter out just the parts that I am interested in. Well, it would be nice to do the same thing but have the filter be smart enough to discover interesting lines.

Read the rest of this entry »

Getting Ready For DST

Daylight saving time has been extended. Effective this year it’s starting on March 11 and ending November 4. This means lots and lots of patching. For the most part it’s only the OS that needs to be patched. But there are a few applications out there, notably Java, that don’t make standard system calls to manipulate dates and times. At first I didn’t think this was a big deal. However, how many different databases embed JVM’s in them as a stored procedure language? Oracle, Informix, and DB2 come to mind. What other apps am I missing?

Playing With Ruby

A couple of weeks ago I was bitten by the Ruby bug. I’m not entirely certain why. From my perspective the language isn’t terribly intuitive. The default library that comes with it is huge, and there’s alot of stuff that can be done pretty quickly using it. For example, here’s a really simple script that can be used to calculate when your mount point will be full:

#!/usr/bin/ruby  require "time"  startdate = Time.parse( ARGV[0] )
startsize = ARGV[1].to_i
enddate = Time.parse( ARGV[2] )
endsize = ARGV[3].to_i
maxsize = ARGV[4].to_i

growthrate = (( endsize - startsize ) / ( enddate - startdate ))

maxdate = (( maxsize - endsize ) / growthrate )

p ( enddate + maxdate )

Here’s I’m running it with arguments that indicate the total size of my mount point was 123456 bytes on Jan 1st and 234567 bytes on Jan 31st. The maximum size for this mount point is 678900 bytes.

$ ./diskspace.rb "2006-01-01" 123456 "2006-01-31" 234567 678900
Wed May 31 00:16:50 -0600 2006

According to the output I’m either going to have to grow my volume or remove some data by May 31st.

*nix dates

Something interesting that I found this week, with the GNU version of the date command you can do this:

$ date -d ‘yesterday’ +%Y%m%d
20070106

What’s special about that? Well, the standard *nix date command only supports three options (-a, -u, and -s) and optionally let’s you pass it a string dictating the format that you want it to display the date in. So, it makes it easy to find out what today’s date is, but how do we know what yesterdays date was? Because of that limitation I have this big library of functions that can be invoked in a shell script that perform some of the common time and date manipulations that we need in our scripts at work. The GNU version makes it too easy. For instance, let’s suppose that you need to pass the first and last days of the previous month in a script:

$ date -d “$(date +%Y-%m-1) -1 month” +%Y%m%d
20061201
$ date -d “$(date +%Y-%m-1) -1 day” +%Y%m%d
20061231

How about the start and end of next month:

$ date -d “$(date +%Y-%m-1) +1 month” +%Y%m%d
20070201
$ date -d “$(date -d “$(date +%Y-%m-1) +2 month” +%Y-%m-%d) -1 day” +%Y%m%d
20070228

While I’m talking about date and time stuff, nobody should forget that they moved up Daylight Savings Time this year in the United States to March instead of April. You need to make certain that your servers are patched to handle the new dates.

Stone tablets …

I’m at Saturn right now getting my oil changed. The computer they provide customers with the browse the Internet for free is running Windows NT 4.0 with IE 5.0. Nothing works right. Almost every page that I visit is rendered with errors. GMail complains about unsupported browsers. I couldn’t even get my rss reader to render the little toolbar that tells me if I have any unread rss feeds. This sucks. I had forgotten how bad the Internet was before Ajax.

Shell script stupidity …

Earlier this week I was told that I had to add some SQL to a batch process that we run every night to correct an error. Basically, this was a stopgap measure until the programmers were able to get in new code. I was in a silly mood that night, so I got a little more creative than I usually would be.

Read the rest of this entry »

Google Maps API

I spent most of this afternoon playing around with the Google Maps API. I created a page that highlighted many of the local coffee resources. It was a little more difficult than I was expecting, but mostly I think that was due to my relative unfamiliarity (is that even a word?) with Javascript. It’s been years since I’ve used it.

If anyone takes a look at the code, which was hacked together from a couple of the examples on Google, you might question why I created the addMarker function. I think that I might have found a tiny little bug in Firefox, even though it might just be an issue with Javascript. Initially I had all that code embedded in the for loop a couple of lines above. No matter which marker you clicked, the Information Window would always open over the last one that was created. For some reason throwing everything into a seperate function got it working.

Finally, one of the things that is seriously great about this API is that GXml object. That simplified everything a great deal. At this point it would be a very simple matter for me to just create a PHP page that generates that XML and then I could store everything in a database.

Making Gallery2 accept photos via email.

Gallery2 doesn’t support emailing photos to it by default, so I had to make alot of changes to get it working. Look behind the cut if you’re interested in how I did it.
Read the rest of this entry »

Minority thinking …

I was reading this article the other day, Every Time You Vote against Net Neutrality, Your ISP Kills a Night Elf.” I know that I am in the minority thinking like this, but our government doesn’t exactly have a sterling record when it comes to the types of regulation that these guys advocate. I’m reminded of the businesses of James J. Hill. He built the first privately funded transcontinental railroad in the U.S. He was able to do this without government subsidies because he built farms and industry along the route to ensure the success of his railroad. One of the companies that he started, a steamship company that opened up east Asian markets to U.S. cotton and wheat, relied on the railroad to move export goods at a reduced rate to the ports.

The other three transcontinental railroads had been heavily subsidized by the government, and farmers in the west complained to Congress about the economic power that these railroads were exerting. As a result the government created the Interstate Commerce Commission and granted them vast regulatory powers restricting who could own or operate railroads, and the maximum or minimum rates that they could charge for shipping. James J. Hill was forced to shutdown his steamship company because he was no longer allowed to offer discounts on getting products to the port. On the other hand, the companies that Congress was seeking to regulate were the ones that benefited the most from the regulation.

Fast forward to the present. You have giant cable and telecommunications companies that have been expanding and improving their infrastructure, hoping to earn a return on their investment by offering VOIP and IPTV services in the future. You have companies who rely on this infrastructure, but who haven’t been forced to invest in it, and in some cases are already offering VOIP or IPTV services. I don’t think it’s a stretch to see a parallel between what is happening here and what happened a hundred years ago. I also don’t think that I’m going out on a limb by suggesting that any attempt by the government to legislate the same kinds of regulations into the ISP industry that they legislated into the railroad industry a century ago would likely backfire the same way it did then.

Odd …

3 years ago someone told me that shell scripts couldn’t core dump. Would never ever happen. Last night I found a core that was generated by one.

(root)!/home/someone >ls -ltr
-rw——- 1 root sys 76613004 Nov 16 22:00 core
(root)!/home/someone >file core
core: core file from ’sh’ – received SIGSEGV
(root)!/home/someone >rm core