- Feature Articles
- CodeSOD
- Error'd
- Forums
-
Other Articles
- Random Article
- Other Series
- Alex's Soapbox
- Announcements
- Best of…
- Best of Email
- Best of the Sidebar
- Bring Your Own Code
- Coded Smorgasbord
- Mandatory Fun Day
- Off Topic
- Representative Line
- News Roundup
- Editor's Soapbox
- Software on the Rocks
- Souvenir Potpourri
- Sponsor Post
- Tales from the Interview
- The Daily WTF: Live
- Virtudyne
Admin
Bah. Quitter.
Admin
gosh if only there was widely used off the shelf software that did exactly this
Admin
But why spend thousands of dollars buying an off the shelf product when you can save money by spending tens to hundreds of thousands of dollars of employee time to make a poor version of it yourself?
Admin
I'm not entirely sure I'd class that as a positive. A less-negative, maybe, but not, as such, a positive.
Admin
When performing maintenance, never presume the existing application actually works.
Admin
I have such mixed feelings about Python. I've used it out of necessity to do some programming in Inkscape. I used it just as, shall we say, alternate syntax of languages I already know. This appears to be a mistake. A few months back I tried an online programming challenge. The task was: read in X lines that contain space separated numbers. Line 0 had a series of numbers <X that indicated access to the other lines. Those lines in turn gave access to others. Problem: indicate what lines you don't have access to. So, write a recursive function to mark what lines you can get to. Then go back and output all the ones you couldn't get to. I came in 2nd place using C#. I got smoked by a Python programmer who did it all in a single line in less than 2 minutes. It looked like APL, but I had to admit that I was impressed.
Admin
Huh. Interesting. I see how it could be done, a sort of traversal of an N-ary tree, even if there is the possibility of cycles, fan-in and self-reference, and recursion does seem to be a pretty natural way of handling it, bounded by a flag that says "I visited this already". On the other hand, a one-liner is pretty impressive, even if the end result looks like APL.
Admin
The strangest named book on my book shelf is "SNMP, SNMP2, SNMP3, and RMON1 and 2".
Admin
If it's ok to read in the data first, I've got it in almost one really, really ugly line. I'm stuck using Python 2 at the moment, so if anyone sees a way to initialize "allowed" within the for loop, that would put it at a single line of "processing".
Example data:
Admin
If pressed to do it in one line I would probably create an adjacency matrix A from the input file. Start with a 1 by X matrix B, with 1 in the i = 0 j = 0 position, then multiply it by A (this gives You all the nodes You can visit from node 0). Repeatedly do this X times (multiply a 1 by X matrix from the previous calculation by A) after which You either must have visited all the nodes, or if You have not visited a node, then it is impossible. I am almost certain I could oneline this in lisp, but in python it could be a bit more mindbending, but seems doable.
Admin
To initialise "allowed", just make it the only item in a list which is used as the source for a listcomp and then take the 0th index of the result:
unallowed = [set(range(X)) - set([l + 0 if allowed.extend(list(set(values[l]) - set(allowed))) is None else 0 for l in allowed]) for allowed in [[0]]][0]
Job done. Ship it.
Admin
Know your enemies: "we assume", "it should", "probably", "someone knows", "they believe", and "in the future": Those fragments in maintenance-related statements will indicate that you're doomed.
Admin
It's good to know we can contribute to WTFery as well as we can criticize it!
Admin
The one-lines are what I try to avoid the most. Especially, when there is nesting. Mostly, because I find it heavily counter-intuitive, because the one-liner constructs result in awkward order-of-execution due to their "postfix" syntax. This results in curious things like this:
Similarly I find the
A if COND else B
syntax to reduce the readability of ternary expressions.And then there's the issue of Python's violation of its own "explicit is better than implicit" credo, when it comes to variable declarations...
That said, my Python complaints are a case of "first-world whining". After all, I stick to the language where I have the choice, because for the tasks I do with it (data analysis, and replacing bash as a glue language) it still gives better results, comfort or performance than any alternative I've tried...
Admin
Ah, and it's a Stallings book so probably worth reading even without the cool title.
Admin
Oooohh nooooes. The powerful get-next operator turns out to be powerless when netops blocks the port. Who knew?
Admin
SNMP is a technology full of WTF. It’s supposed to be lightweight so it’s an actual wire protocol defined in ASN which means standard fields are defined in bytes and can’t be changed. Not good for duck type data glue languages like Python or Perl or Bash. Our system uptime monitoring would alert for reboot if the system was up for 497 days because the standard field used to serialize uptime value is 32 bit and rolls back over to 0. SNMP doesn’t tolerate latency or wait states at all, and the default is to run it on UDP. Got a saturated network link between your server and the monitoring system, like what you would expect trying to monitor hundreds of systems from a different network? Yeah you’re gonna get a lot of “system is down no response” alerts that clear just about the time you’re awake enough to find the VPN app on your phone and log in to see what’s going on. I said it doesn’t tolerate wait states, that includes some of the built in OS metrics. If you try to walk the whole OID tree you’ll get things like system packages and disk statistics, which inevitably lag or are totally broken (looking at you rpmdb) in any chaotically maintained large environment. That makes SNMP timeout and of course any monitors that depend on data past the failing OID freak out. There’s no logging of failure and why, snmpd maybe even spit back a UDP response long after the collector gave up. And of course to do any custom monitoring you have to work with OIDs, and write the MIBs in ASN, and then realize that OIDs are a canonical hierarchy of all nouns in existence, including every arcane data structure you or anyone else can think of, organized by the historical vendor who originally registered them. Monitors can’t be generic because the OIDs that agent returns are custom to the product and may not even implement the (still lossy 32-bit) fields that are supposed to be standard. And your extensions can’t be simple scripts or they time out, you have to gather async and read from a cache.
Admin
1st line form the zen of python "Readability Counts" doing this in one line sounds absolutely horrendous & should NOT be considered a good example of python usage
Admin
thanks for info
Addendum 2023-09-21 21:52: In the vast sea of academic responsibilities, I recently stumbled upon a navigational aid that promises to make the journey smoother. This exceptional law essay service https://essayroo.com/law-essay offers a lifeline to students grappling with essay assignments. With its commitment to excellence and a pool of expert writers, it is poised to redefine how we approach our studies. It transforms the challenging task of essay writing into a streamlined and accessible process, potentially revolutionizing the academic landscape.