Stories
Slash Boxes
Comments
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

use Perl Log In

Log In

[ Create a new account ]

mako132 (2925)

Journal of mako132 (2925)

Tuesday November 26, 2002
03:43 PM

Doesn't Get More Non-Intuitive Than This!

My cheap cell phone has a "STO" (STORE) button for saving numbers.

But when you delete a number, you get a message that says,

"TO DELETE PRESS STO"

Sad thing is, the phone has better buttons that could have been used: CLR (CLEAR) or END.

Friday November 22, 2002
03:01 PM

Defined, But Never Called

More code review rebop: During this week's code review meeting we spent 15 minutes raking a poorly-coded subroutine through the coals, only to discover that it was never called in the CGI!

So I was wondering one might test for that...do I need to compile perl with debugging enabled?

This is a different issue than detecting code that is never reached or isn't reached in the normal functioning of the CGI. The subroutine is simply never called anywhere.

So I need to get a list of all the subroutines and then somehow look at byte-code-execution tree whatnot and see there's no entry point. [here the author waves hands frantically]. I have no idea what I'm talking about :(

Now Drinking: Diet Coke

Tuesday November 19, 2002
05:02 PM

And So It Begins

Our $org is embarking on the first attempt at sharing code within $depts. There's no business demand for it (but hey, we're non-profit), but we suspect that we're all reinventing the wheel. Smaller $depts within the $org will benefit too - they'll start building their apps with stronger code and it will lessen the likelihood of seeing freaky CGI code in production.

It's all volunteer work, but with benefits to the current tasks at hand.

Our first guess is that we need some sort of "CPAN" in place for our modules. Each $dept will submit a single module at first. We'll see if anyone uses it, how generic it can be ($org::$dept or just $org::), etc. Then we'll announce it among the $staff and see what more should be done for it to be useful.

Monday November 18, 2002
11:25 AM

Where You Been, Jelly Bean?

Perl: Using Exception::Class::DBI (see Theory) in my own local DBI wrapper module.

Tech: 1GHz Titanium Powerbook on order :) But may have to give up FreeBSD laptop in exchange :(

Home: 3 mice trapped and released (I was in good mood). 3 mice trapped and snapped (I got fed up).

Thursday October 31, 2002
07:24 PM

Shocking News

The other half of our department runs a large video encoding facility with 4 bays of parrallel production fanning out to 3 encoding systems per bay.

The operators have been complaining that encoding would break suddenly at seemingly randow times. But days would go by with no problems, then some days would be full of problems -- all the while the systems haven't been touched (not upgraded, rebooted, tweaked).

Then today the chief operator, standing next to a digital video tape deck, wondering why his luck had been so bad today, reached over to restart the tape, felt a small static electricity spark an noticed his video output monitor go blank for a second.

We've got static electricity problems! Pervasive problems. By dragging our shoes across the carpet and touching equipment we can bring down the firewire network or insert seconds of blank frames into the video stream.

Much of our equiment's power plugs are two-prong - no grounding. Sure, the computers and monitors are all three-prong, but all these firewire repeaters and tape decks aren't.

I'm also concerned that our room's power circuits may not be properly grounded. It's a newly renovated space in an old building. Maybe someone cut corners....

Luckily, the director of the group is an ex-telephone guy, who used to design telephone switching systems. He specified in the renovation that we have separate grounding terminals around the walls, just in case.

So I think with a bunch of anti-static mats, and maybe some wrist-connectors, we should be safe.

$trickOrTreaters++;
$bowlOfCandy--;

06:59 PM

Should I Bother Writing my Own DBI Module?

Clearly we saw after the first code review that the database code should be pulled out into its own module.

The code is pretty simple: open/close the connection, do a few trivial SELECTs, build some HTML tables.

We don't have a standard on dealing with errors, so a module could help there...

I looked at the various DBIx modules and wondering if I should bother.

Maybe the real issue is that we need a application-centric database module. Our application consists of around 7 CGIs. Maybe pulling all the database code out of there into an MYORG::DEPT::APP::DB module is fine and iternally the module has raw DBI code.

Musing whilst I wait for Trick or Treaters.

Tuesday October 29, 2002
03:12 PM

Factoring

Doing more work on the repeated code tools.  My grand idea was a tool
which took repeated code out of a script and put it into a library
file.

I doubt I could get it completely automated.  My goal is make a tool
that helps build this library file.  I would probably have to leave
repeated code (for context sake) in the original file (commented out).

As a start, I wrote a separate script which took the output of my
repeated-code detector and marked up the file with lines such as,

>>> 435      ## Gets the starting time
>>> 436      $decode_start_time = timelocal( 0, $minutes{$decode_start_minute} , $hours{$decode_start_hour} , $sys_day , $sys_months{$sys_month} , $sys_year);
>>> 438      my $current_time =  scalar(localtime( $time ));
>>> 439      my $decode_sess_start_time =  scalar(localtime( $decode_start_time ));
>>> 440      my $decode_sess_end_time =  $decode_start_time + $seconds{$seconds_decode} + (  $minutes{$minutes_decode} * 60 ) + ( $hours{$hours_decode} * 60 * 60);
>>> 441      $decode_sess_end_time = scalar(localtime( $decode_sess_end_time ));

The numbers above are the line numbers of the first occurrence of the
same code.  For example ">>> 435" means this exact line (not counting
whitespace) appeared earlier on line 435.
02:55 PM

Wired(less)

The Linksys WAP worked like a charm. Since I already had the Linksys 4-port router, the wireless one replaced it. The 9600 and the Powerbook is happy. FreeBSD doesn't seem to want to update its DNS settings via DHCP. Will investigate.

Sunday October 27, 2002
06:15 PM

Aiport's Goose is Cooked

So it seems that the first generation Apple Airports like mine overheat and cook their power conditioning circuitry.

So early last week I started noticing that my connection kept dropping. By Friday it was up for 5 seconds, restarting for 15, up for another 5 and so on. And now I've got red LEDs instead of amber and green.

Now I'm forced to use my only directly networked computer, a Mac 9600 running 8.6.

I am used to carrying my laptop around the house, noodling in front of the tv, the kitchen or the dining room. Alas, the desk I have the 9600 on is barely big enough to hold the monitor and a SCSI drive, so I can't easily use its network cable for the laptop.

Linksys is in my future.

Thursday October 24, 2002
09:12 PM

Repeated Code

As we ended this week's code review session, the facilitator remarked that next week's code (two large CGIs of 2600 and 3900 lines each) would be difficult to get through. I replied that they are actually about a third of the real size because they consist of so much repeated code and HTML.

I got to thinking there must be some way I could find all the repeated code before I start reviewing it and so I wrote a script which gives output like:

Line 309 repeated on line(s) 610, 752, 841, 891, 1100, 1484, 1502, 1546, 1567
Line 310 repeated on line(s) 611, 753, 842, 892, 1101, 1485, 1503, 1547, 1568
Line 311 repeated on line(s) 612, 754, 843, 893, 1102, 1486, 1548, 1569
Line 312 repeated on line(s) 613, 755, 844, 894, 1103, 1487, 1504, 1549, 1570
Line 313 repeated on line(s) 614, 759, 848, 898, 1104, 1488, 1508, 1553, 1574
Line 314 repeated on line(s) 615, 760, 849, 899, 1105, 1489, 1509, 1554, 1575
Line 315 repeated on line(s) 616, 1510, 1555
Line 316 repeated on line(s) 617, 762, 851, 901, 1491, 1511, 1556, 1577
Line 317 repeated on line(s) 618, 763, 852, 902, 1108, 1492, 1512, 1557, 1578
Line 318 repeated on line(s) 619, 764, 853, 903, 1109, 1493, 1513, 1558, 1579

The above is an example of a block of 10 lines of code repeated 8 times, with a minor variation.

So with a report like this, I can take a printout of code (w/line numbers), a highlighter pen and block out the large repeated code blocks.

Naturally, my script detects things like "$i = 0;" or "=cut", but such code is usually not found in large blocks of lines, so it doesn't stand out.

Now I'm thinking how to take this forward - perhaps process the original file and insert footnotes or glyphs like [snip] in place of the repeated code.