Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Post
  • Reply
Scaramouche
Mar 26, 2001

SPACE FACE! SPACE FACE!

I have to fix a few of these every year (hint: guess why it comes up once a year). This is for initializing date/time pickers on windows/web forms using VB.net to by default show a report that spans from a month ago to today:

code:

StartDate.Value = New Date(Now().Year, Now().Month – 1, 1, 0, 0, 0)

Adbot
ADBOT LOVES YOU

Scaramouche
Mar 26, 2001

SPACE FACE! SPACE FACE!

WildFoxMedia posted:

Is it because Month is 0 indexed, and in January the result of (Now().Month - 1) is -1?

Close, but not quite. It's more that January (1) - 1 = 0. I had to switch them all to using the in-built date.AddMonths(-1) so it would roll under/over properly.

Scaramouche
Mar 26, 2001

SPACE FACE! SPACE FACE!

I don't know if this is a horror or a moby hack:
http://blogs.msdn.com/developingfordynamicsgp/archive/2008/10/15/what-is-column-dessprkmhbbcreh.aspx

I was going through a great plains DEXSQL.log file and kept seeing what looked like a 'legit' error message, 'Invalid column name 'desSPRkmhBBCreh'. It turns out that it's faster to determine the presence of a table by asking for a non-existent column within it instead of waiting for a system meta table to build a list of all the tables. So these guys built their 'doestableexist' calls into GreatPlains by trying to select from a column composed of their initials; if the table exists they'll get 'invalid column' error message, if it doesn't they'll get another one.

Scaramouche
Mar 26, 2001

SPACE FACE! SPACE FACE!

Ugg boots posted:

This one is my favorite, haha.

I don't have the code in front of me but a friend was doing some RPG style coding and basically made a giant exception list for items that don't pluralize generically. E.g. "pair of pantses" that looked like the above. Not many elegant ways to do it though; maybe identify the major sub-cases and use some kind of opcode to control pluralization behavior. (Already plural, ends in s, default plural, etc.)

Scaramouche
Mar 26, 2001

SPACE FACE! SPACE FACE!

It's SQL and not 'code' per se but I just wacked this query together for a onetimer to get a series of strings I needed:

code:
select DISTINCT Replace(Replace(Replace((Replace((table6.ProductTitle 
+ '-' + CONVERT(varchar(16),Table1.IDProduct)),'/','-')),' ','-'),'--
','-'),'--','-') as MyString FROM
table1 INNER JOIN
(six table joins later)
The replaces are because it'll have to be communicated in a URL and I got lazy working from the inside out. The joins are because the data I need from table6 is only joined to table1 by a series of FKs distinct to each table.

Scaramouche
Mar 26, 2001

SPACE FACE! SPACE FACE!

I need to nullify an if...then loop across several hundred files on several remote servers, with the contents of the loop changing slightly (so no easy search/replace). That and it's several dozen lines long. Lord help me I'm considering just replacing the triggering If for all of them with:
code:
If 1=0 then
Can't wait for someone to come across that later.

Scaramouche
Mar 26, 2001

SPACE FACE! SPACE FACE!

I found something of my own that's a small h horror but still resulted in head slapping from me. It was a quick little log viewer app that I whipped up in a couple minutes a few years ago:
code:
If Thing = 'blah' then
   'Do nothing
Else if Thing = 'blah blah'
   'Do nothing
Else
   'Do something
End If
Nothing like testing for conditions that don't have to be handled first...

Scaramouche
Mar 26, 2001

SPACE FACE! SPACE FACE!

Incoherence posted:

I've done the "if X, do nothing, else do something" pattern before when the condition was sufficiently painful to look at that I didn't want to deal with inverting it. The else if is a bit interesting, though.

I guess the best way would be to do "if Thing <> 'blah' or Thing <> 'blah blah' then DoSomething" but I guess the younger me can't think clearly (these weren't complex cases). It gets even better though, I shouldn't even have been checking for blah there anyway because the input gets scrubbed before the function starts. Basically the condition is always met. Remember kids, friends don't let friends code when they're in a hurry.

Scaramouche
Mar 26, 2001

SPACE FACE! SPACE FACE!

If it was x87's fault wouldn't this... be an issue in other languages? Ditto for compiler switches?

Scaramouche
Mar 26, 2001

SPACE FACE! SPACE FACE!

Found a routine today that assigns a waybill number for a certain shipping company. You would think that it'd be easy; connect to the shipping company via API, grab a waybill number, record/relate it, and move on. Apparently the first step is impossible because the shipping company can't definitively determine the status of waybill number at assignment, it has to clear their system after 24 hours.

Instead we're assigned ranges of shipping numbers that are 'ours' in the format of <char>12345, usually from 0-9999. This part is the horror. The previous guy made a proc that basically goes 'WayBillNo = <char> + Substring(WaybillsPrimaryKey,2,5)' after inserting each waybill registration. For those not following at home the horrors are:

- Every time the 'range' changes you have to manually increment the primary key to match the new range. So if the new range was 500-15000 you'd have to make sure the next PK inserted is x00500.
- Every time the <char> changes (which it does every time the range does) you have to change the stored proc's hardcoded value of <char>
- Because of the first part the primary key will grow unnaturally fast as you're always jumping to the next thousand/ten thousand/hundred thousand after a range change.
- The best part, related to the above: the whole thing will fail as soon the primary key reaches the next significant digit (e.g. moving from 10,000 to 100,000, 100,000 to 1,000,000, etc.) because the substring call doesn't care how long the thing is (there's a convert(varchar) I left out of the above for clarity).


I wonder how many other ticking time bombs like this waiting to be discovered... I mentioned it to a coworker and he just smiled and said "job security!"

EDIT-bonus points to whoever works in logistics and can identify the shipping company based on the structure of their waybill numbers

EDIT EDIT-It gets better; he's storing the result WayBillNo as a string in a varchar column. The column's defined size is varchar(6); as soon as the numbers pass 5 digits it would have broke there too.

Scaramouche fucked around with this message at 00:58 on Jan 21, 2011

Scaramouche
Mar 26, 2001

SPACE FACE! SPACE FACE!

Well... at least the brackets and white space look nice?

Scaramouche
Mar 26, 2001

SPACE FACE! SPACE FACE!

Plorkyeran posted:

The indentation is wrong, so no.

I didn't mean it was right, I meant it was aesthetically pleasing. Like if ee cummings were a programmer.

Scaramouche
Mar 26, 2001

SPACE FACE! SPACE FACE!

Do you guys know if the recent eHarmony breach was php-based? I noticed they're running php and their press release said 'third party dlls' so I'm just assuming...

Scaramouche
Mar 26, 2001

SPACE FACE! SPACE FACE!

rt4 posted:

Oracle can't kill MySQL soon enough.

Is there another OSS solution out there that's actually good? I've always worked in MS/Oracle for everything I've done since the 90s, but I'm curious now if I ever actually have to develop something low cost/personal after my MSDN/OTN expires what I would use.

Scaramouche
Mar 26, 2001

SPACE FACE! SPACE FACE!

EDIT - ^^^ what he said but more polite

bobthecheese posted:

That's what PHP 6 is meant to do, I think. Problem is that it's pretty much never going to get finished. For the large number of 'php developers' in the world, there are actually very few people developing php, which means that it takes time for features to get added/changed/updated.

While it's fun to rag on PHP for being poo poo, it's still a damned popular language, and actually quite powerful (when it's not being abuse by idiots). Most of the problems with php are, as you said, pretty much centred on people not reading the available documentation (which is really some of the best language documentation I've ever come across).

Doesn't mean it's not fun to pay out on it, though.

I realize that this may be an unfair generalization, but the impression that I get is that the large majority of PHP users are more concerned with having a rapid deployment language with lots of examples and frameworks that they can just copy and paste and it'll 'just work'. Again, anecdotal impression, this implies to me that the actual developing user base who work on the core language is quite small. This is also likely true of say, .Net, but there's a company investing time/money/etc into it regardless of the user base.

Scaramouche
Mar 26, 2001

SPACE FACE! SPACE FACE!

NotShadowStar posted:

The only thing that PHP has for it is the same thing that Windows has, obtain a massive legacy base because it was the only thing around at the time that did something reasonably okay. Now they're chained to that legacy. So if PHP6 fixed everything and made it a decent language, stopped using the global namespace and fixed all the dumb poo poo in PHP it would have to break the huge legacy that relies on that dumb poo poo. Which wouldn't be worth it because even if you fix PHP it would be just another interpreted C-style syntax Java-class-style based language. Which at that point, you might as well write in C# or Java, or look at more interesting and less verbose languages like Ruby, Python and so forth.

I agree that's the case as well. I'm curious what the endgame will be. Will it end up like COBOL/FORTRAN where too many 'untouchable' applications are running on it, and therefore stays around forever? Or will it be like pre-Borland Pascal and just disappear entirely?

Scaramouche
Mar 26, 2001

SPACE FACE! SPACE FACE!

rt4 posted:

It's already like this. Shops that use PHP do so because they can get a quick turnaround time with cheap developers. What was at first a cheap hack to make things work soon becomes a huge unmaintainable mess. The software is much slower to work on, but the pace of the business' demands continues. The developer becomes frustrated and quits. The company hires two new developers to replace him, who last for maybe a couple years then quit for the same reasons.

I think the real metric will be, how important are the applications running on the PHP platform? I mean, will the world collapse because bloggers can't post any more? I have an acquaintance who works on financial COBOL systems who has put off retirement for the last 5 years; his salary has nearly doubled each year. I don't see the institutions and organizations invested in PHP making that kind of fiscal commitment to keep the language alive.

Scaramouche
Mar 26, 2001

SPACE FACE! SPACE FACE!

Hammerite posted:

"Content-oriented"? I've not heard that before. What's an example of something that isn't content-oriented?

I would guess maybe feature-oriented? The interesting question arises in that what would be a contentless feature. Maybe I should make a web site that does... something. You never know what it is, but when you push a button something happens. It might add two numbers together. It might open a garage door somewhere. I could call it SchroedingersDoubleSlitBlackBox.com

Scaramouche
Mar 26, 2001

SPACE FACE! SPACE FACE!

Yeah, I did a full year of Miranda in university (good lord so old, don't even think it's in use any more) to get my introduction to FP. I'd already taught myself Turbo Pascal and ANSI C at that point (oh man it gets even older) in high school, and man did I hate Miranda at first. However after the first quarter or so it was pretty neat how it made you think differently. I think I "got it" when I had to make a roman numeral parser/displayer and realized that the old way of planning it out was just plain wrong.

That said, I look at the programming I do now, day in and day out, and just don't see how FP would do it. I can bet that the stuff it can do well is pretty awesome (which, I'm guessing would involve pure math and analytics), but tweaking web layouts, database massaging, file parsing, etc. doesn't seem to fit the bill.

Which leads me to a question; has anyone been exposed to both Miranda and Haskell and can tell me how similar they are? Wikipedia says 'very similar' but doesn't really give specifics, but I'd be curious to know how much changeover would be involved if I wanted to pick up Haskell based solely on my Miranda exposure (I got to be pretty good at it at the end).

Scaramouche
Mar 26, 2001

SPACE FACE! SPACE FACE!

Alllll right, finally some religious discussion!

:munch:

Scaramouche
Mar 26, 2001

SPACE FACE! SPACE FACE!

shrughes posted:

So they have a tree of 4096-byte pages, a straightforward fixed-depth sparse vector with each node taking exactly one page. What's the horror?

I think some would find the vomiting of raw meat kind of horrible. Also making a comment that says "I'm not explaining this" and then never going back and fixing it.

Scaramouche
Mar 26, 2001

SPACE FACE! SPACE FACE!

Hah I remember doing this back in the day. It was when I was just learning and didn't know anything about compiler operation. I was teaching myself C and I had some module that had to be 'super fast' so I thought 'well what's faster than asm?'.

Ended up being problematic to debug and modify when I came back to it a few years later for some reason...

Scaramouche
Mar 26, 2001

SPACE FACE! SPACE FACE!

That's great. Nearly 1:1 between Waiting and actual Receiving.

Scaramouche
Mar 26, 2001

SPACE FACE! SPACE FACE!

Thought this was kind of neat. ISC has the 'Application Security Streetfighter Blog'. They post a (closed usually) vulnerability each week from an OSS project every Friday, and then people figure out what the actual vuln was. I only found it today but I am going to keep checking back I think. Haven't checked if any true horrors are to be found there, but couldn't think of another thread that would appreciate it:
http://software-security.sans.org/blog/

Scaramouche
Mar 26, 2001

SPACE FACE! SPACE FACE!

I think for me, of course it's possible to do the same things in other languages. But from a development standpoint, it just seems harder to do so, as opposed to PHP which seems to encourage these shortcuts. I say "seems" because I'm more of a "solve the problem in front of me" kind of programmer than "hmm yes algorithmic approach A will provide x% of performance gain versus B". I'm just glad I stopped with PHP around 3.0 when I started realizing "man this getting pretty complex for a glorified scripting language; if I wanted this kind of heartache I'll stick with Perl."

Scaramouche
Mar 26, 2001

SPACE FACE! SPACE FACE!

I wonder if there's a point where something passes being a horror and becomes a crime against coding...

I mean what's next, make a wrapper that de-normalizes an RDB into name value pairs?

Scaramouche
Mar 26, 2001

SPACE FACE! SPACE FACE!

Janin posted:


Perhaps IBM's customers are paying by the byte.

IBM owns our EDI VAN provider (EDI being another overwrought overdesigned unreadable flat file specification) and they charge us by the byte. Wouldn't surprise me if that's true.

Scaramouche
Mar 26, 2001

SPACE FACE! SPACE FACE!

Zombywuf posted:

The EDI based XML I've seen looks mostly like this:
code:
<xml>AUOIIE  9828309 X-XAEUAOEUU23cdl23c4f13c23---Q-AE-</xml>
Now that's how you save bytes in an XML encoding.

Yeah, mine's all flat file so it looks a bit more exploded/bizarre text file than that. What's funny is some of the partners use the old spec that insists the ascii flat file actually has reserved white space. So if field A can contain a max 16 characters you better believe that it's going to look like:
code:
REF*          123456*
and so on. Really pushes those bytes up.

Scaramouche
Mar 26, 2001

SPACE FACE! SPACE FACE!

TRex EaterofCars posted:

PIC X(16)

I've worked on some COBOL ERPs and they pull that dogshit all the time. Have to trim() every single data element you get.

Sad part is even though we say we use the 4011 spec there's all kinds of little exceptions to the mapper. Some guys will provide *0000000000123456~, some the above, some don't care so it's *123456~ etc. Thank goodness the spec itself is relatively strong when it comes to typing so I don't have to test for number/bit/string/ness all the time.

Scaramouche
Mar 26, 2001

SPACE FACE! SPACE FACE!

All Hat posted:

I truly have no idea. I can't really think of a situation where concatenating >500 strings would seem like a genuinely good idea, so I suppose not.

Probably just about every corporate intranet that should be using a dedicated database/CMS setup but isn't.

Scaramouche
Mar 26, 2001

SPACE FACE! SPACE FACE!

Ugg boots posted:

I can't loving stand this when I see it.

Which part bugs you the most? For me it's the unexplained lines of code cluttering up the project when you already have a revision control system in place. The rare times I do it I put a date stamp and a one line explanation of why at least.

Scaramouche
Mar 26, 2001

SPACE FACE! SPACE FACE!

I did a query on the repository, next ID will be 31304.

We're efficient yo :cool:

Scaramouche
Mar 26, 2001

SPACE FACE! SPACE FACE!

When I worked in vidya games it got pretty crazy sometimes. I checked an easter egg into the non-gold fork (e.g. the one we used for loving around) which changed one AI script and one object. It ended up pulling over 300 binaries into the changelist.

Scaramouche
Mar 26, 2001

SPACE FACE! SPACE FACE!

It's to the point now where I don't even know what CSS is >for< anymore, since it's been manhandled into so many roles, and seems worst-suited to what it was originally intended for (a nice portable way of presenting formatting). It seems like to do anything worthwhile with it you have to have JQeury, JSON, less.js, etc. etc. unless all you're doing is changing link behaviour and image alignments. I think making it a 'proper' language is almost moving in the wrong direction because it just becomes a less ugly JS with relatively sane markup and totally insane everything else.

Scaramouche
Mar 26, 2001

SPACE FACE! SPACE FACE!

Dooey posted:

Am I the only one who finds reading code in mixed styles not a big deal? I always use the same style for my own code, but at work we all have different styles and when I read other peoples code I have no problems at all.

I actually kind of like it in a way because I can generally tell who on my team has written a particular piece of code.

Scaramouche
Mar 26, 2001

SPACE FACE! SPACE FACE!

Thel posted:

I once wrote a 20k LOC GUI application ... in a single file. :derp:

(Hey I didn't know any better. And it worked. So nyah.)

I've got a shared VB web service file; 67,000 lines.

Scaramouche
Mar 26, 2001

SPACE FACE! SPACE FACE!

Zamujasa posted:

I hope it's not as easy as it seems but about thirty seconds of Googling revealed this solution.

It is that easy. The only thing I can think of is that the guy forgot the admin account password or something.

Scaramouche
Mar 26, 2001

SPACE FACE! SPACE FACE!

No Safe Word posted:

I always learned it as "decameter", and all units were prefaced with "deca-" and not "deka-". Weird.

It's not super important, I think it might even just be a Greek/Roman thing. I know it's worthless but deka loses the GoogleFight: http://www.googlefight.com/index.php?lang=en_GB&word1=decameter&word2=dekameter

Scaramouche
Mar 26, 2001

SPACE FACE! SPACE FACE!

Don't remember if this was posted when it was originally written, but a nice vindication of most of what we discuss (except the PHP part, but I'm convinced no PHP programmer actually uses comments):
http://www.webmonkey.com/2011/02/cussing-in-commits-which-programming-language-inspires-the-most-swearing/

Adbot
ADBOT LOVES YOU

Scaramouche
Mar 26, 2001

SPACE FACE! SPACE FACE!

Ensign Expendable posted:

I saw this in production code before. Sadly, I fixed it and I can't be bothered to dig through subversion, but it was very similar. A dozen or so constructs, with hardcoded (identical) UI elements for each, a few boolean flags, three ArrayLists, some Strings. And lots and lots of if statements. When I rewrote the class to use a HashMap and proper OOP, I think it ended up being about a tenth of its original size.

I had to do something similar as well; it was because the guy who created the original table denormalized it into setting / value pairs. The table looked like this:
code:
Name | Setting | Value
Site1| URL     | [url]http://www.thing.com[/url]
Site1| Logo    | Logo.png

etc., about 15 times for each 'Name'
The problem was the guy who wrote the parser, who decided that all of these have to be in order or else it breaks/applies random values to random settings. But there's no way to order them. So I had to make 15 interface elements numbered 1-15 and use that as an informal index. Didn't get fixed until a year later when we got sick of it and made the first guy put a synthetic PK on the table.

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply