|
Not seen much SQL floating about, so here is today's project I was given to 'optimize':code:
code:
|
# ? Aug 25, 2009 18:55 |
|
|
# ? Apr 27, 2024 12:47 |
|
On an SQL flavoured note, something I saw recently. With a table with an id and sub id, where the pair id, sub_id is unique, and sub_id is guaranteed to be 1, 2, etc... for each id.code:
|
# ? Aug 26, 2009 13:42 |
|
Zombywuf posted:On an SQL flavoured note, something I saw recently. With a table with an id and sub id, where the pair id, sub_id is unique, and sub_id is guaranteed to be 1, 2, etc... for each id. Or is the horror that he named that column "rownum" since that could possibly be a little bit misleading?
|
# ? Aug 26, 2009 17:53 |
|
Jethro posted:What's the horror here? I suppose if you can 100% guarantee that records with sub_id = 1 will never, ever, ever "go missing" then it's a bit redundant. I should have been more clear, if the records with a given id do not have sub_ids increasing in steps of 1, starting from 1, the data is wrong, i.e. returning the data where sub_id <> 1 is incorrect.
|
# ? Aug 26, 2009 18:18 |
|
Something I found today in a very large, professionally developed (.NET 2.0) C# application:code:
The sorted list is completely unnecessary and is actually the cause of a bug. You can just use a normal list and add to the end. Removal is an O(n) operation either way due to the need to search through the SortedList for the value instead of the key. Also, if you Add() n > 1 items and then Remove() one or more of the first n-1 items and then Add() one more item, the SortedList will throw an ArgumentException due to a duplicate key (mStore.Count will be n, then n-1, then n again, so mInsertionOrder.Add(n, string) after the removal will find the key n in the SortedList and fail). plushpuffin fucked around with this message at 22:53 on Aug 26, 2009 |
# ? Aug 26, 2009 22:47 |
|
code:
Same project. Same author. From a class meant to wrap objects that are stored in some kind of global hash. The class does not implement an interface. code:
|
# ? Aug 27, 2009 21:00 |
|
Lines 6921-6934 of a 10458 line function:code:
Plorkyeran fucked around with this message at 07:18 on Aug 28, 2009 |
# ? Aug 28, 2009 06:57 |
|
Oh god, I had to google it to see the full horror and it's so much worse
|
# ? Aug 28, 2009 07:14 |
|
Plorkyeran posted:Lines 6921-6934 of a 10458 line function: Oh WoW addons, you'll be the doom of us all. EDIT: Hah, not an addon, a "direct simulation therycrafting tool" Vinterstum fucked around with this message at 07:17 on Aug 28, 2009 |
# ? Aug 28, 2009 07:15 |
|
Threep posted:Oh god, I had to google it to see the full horror and it's so much worse code:
|
# ? Aug 28, 2009 10:26 |
|
This is from a math rendering module for mediawiki. It's a important to get rid of all those dangerous capital >'s.code:
|
# ? Aug 29, 2009 01:00 |
|
I learned an interesting/disturbing use for XSLT when I needed to add some unit tests to some XML data exporter recently. It turns out the exporter doesn't have unit tests in the traditional sense but instead has one unit test. This test is naturally thousands of lines long and spread over several files and includes a set of unit tests for testing itself. This is only prudent for a multithreaded framework which appears* to run different programmatically constructed exports selected using cost/export time based heuristics. These exports are then tested using a combination of XSLT stylesheets which use patterns that cause the transformation to fail when their associated XPath expression matches. Now all I have to do is figure out how those stylesheets get associated with the proper permutations of options and then add my own somewhere in there. *I'd be more sure if there was a single drat useful comment in the whole thing.
|
# ? Aug 29, 2009 03:51 |
|
Nippashish posted:This is from a math rendering module for mediawiki. It's a important to get rid of all those dangerous capital >'s. edit: Ah its php. I guess /i is to ignore case. What the hell?
|
# ? Aug 29, 2009 13:05 |
|
tripwire posted:edit: Ah its php. I guess /i is to ignore case. What the hell? It may be PHP code, but /regex_goes_here/flags_go_here is standard PCRE which is found in just about every language and many command line tools Doesn't change the stupidity of specifying the case-insensitivity flag for non-alpha characters though
|
# ? Aug 29, 2009 16:55 |
|
Does that code do anything? It looks like a noop to me.
|
# ? Aug 29, 2009 18:07 |
|
The comment implies that if they don't do this, it'll be filtered by some other bit of code. Which is sort of a coding horror in itself.
|
# ? Aug 29, 2009 23:19 |
|
Yeah, code that somehow lets only lower(upper?)case angle brackets through.
|
# ? Aug 30, 2009 00:27 |
|
Maybe he's running a meaningless regex to defeat something analogous to perl's taint mode?
|
# ? Aug 30, 2009 00:47 |
|
Otto Skorzeny posted:Maybe he's running a meaningless regex to defeat something analogous to perl's taint mode? Unless whatever tainting mechanism PHP uses is very different from Perl's, you can only untaint data by extracting sub-pattern matches from a regex, not by using a regex to remove or replace characters. I don't know PHP very well at all, though.
|
# ? Aug 30, 2009 02:38 |
|
Well, I notice it says "some web-software", implying that it's not necessarily a default option of PHP (which I wouldn't discount out of hand, since it is PHP) but rather perhaps a package some people have on their servers that causes issues, and this hack is to fix it
|
# ? Aug 30, 2009 02:42 |
|
plushpuffin posted:Unless whatever tainting mechanism PHP uses is very different from Perl's, you can only untaint data by extracting sub-pattern matches from a regex, not by using a regex to remove or replace characters. I don't know PHP very well at all, though. I was assuming that any taint feature in PHP would be a shittier and dumber cargo-cult-copy of its Perl analog (like every PHP feature)
|
# ? Aug 30, 2009 02:56 |
|
Ryouga Inverse posted:Well, I notice it says "some web-software", implying that it's not necessarily a default option of PHP (which I wouldn't discount out of hand, since it is PHP) but rather perhaps a package some people have on their servers that causes issues, and this hack is to fix it I would think it's probably mod_security, but it's only a guess as I haven't played around with it much.
|
# ? Aug 30, 2009 05:46 |
|
Ryouga Inverse posted:Well, I notice it says "some web-software", implying that it's not necessarily a default option of PHP (which I wouldn't discount out of hand, since it is PHP) but rather perhaps a package some people have on their servers that causes issues, and this hack is to fix it I'd just like to see what possible input string could go through those two lines and come out different.
|
# ? Aug 30, 2009 06:25 |
|
Otto Skorzeny posted:I was assuming that any taint feature in PHP would be a shittier and dumber cargo-cult-copy of its Perl analog (like every PHP feature) magic_quotes, that is all.
|
# ? Aug 30, 2009 06:26 |
|
Supervillin posted:I'd just like to see what possible input string could go through those two lines and come out different. One with uppercase angle brackets.
|
# ? Aug 30, 2009 07:21 |
|
Supervillin posted:I'd just like to see what possible input string could go through those two lines and come out different. What I'm saying is that, while we can all lol about />/i because haha angle brackets don't have a lowercase, the real coding horror here is the security package this bit of code is meant to fix interoperability with.
|
# ? Aug 30, 2009 09:26 |
|
Plorkyeran posted:Lines 6921-6934 of a 10458 line function: For some reason I thought that was from some scientific program until I read the posts below it.
|
# ? Aug 30, 2009 17:40 |
|
A few years ago (before my hire) a coworker of mine had to choose which language/framework and methodology to design a new web application in. Which did he choose? Waterfall and MUMPS/Cache. He even wrote his own coding standards, which stipulate the maximum line cannot be longer than 400 characters, and a class implementation cannot be longer than 800 lines. I got to code review all 60k lines !
|
# ? Aug 31, 2009 02:46 |
|
BattleMaster posted:For some reason I thought that was from some scientific program until I read the posts below it.
|
# ? Aug 31, 2009 08:17 |
|
I thought it was a video encoder because of mbebuff_energy.
|
# ? Aug 31, 2009 08:50 |
|
Otto Skorzeny posted:I was assuming that any taint feature in PHP would be a shittier and dumber cargo-cult-copy of its Perl analog (like every PHP feature) http://blog.php-security.org/archives/92-CORE-GRASP-PHP-Tainted-Mode.html welp
|
# ? Aug 31, 2009 16:16 |
|
Munkeymon posted:http://blog.php-security.org/archives/92-CORE-GRASP-PHP-Tainted-Mode.html quote:maybe all these problems are gone soon
|
# ? Aug 31, 2009 17:27 |
|
Plorkyeran posted:Lines 6921-6934 of a 10458 line function: http://www.unbearably.net/blogfiles/simplecatdps.jpg
|
# ? Sep 1, 2009 00:31 |
|
Painless posted:Maybe someday someone will make the ultimate PHP security patch - a patch that causes PHP to remove itself from the server on first use.
|
# ? Sep 1, 2009 17:50 |
|
Incoherence posted:To be fair, the thing this is apparently trying to model is the following flowchart: I guess this was the John Madden section?
|
# ? Sep 2, 2009 05:22 |
|
Code to "shuffle a list into a random order" code:
|
# ? Sep 2, 2009 17:55 |
|
Please tell me you are a teacher who is grading a high school student's homework.
|
# ? Sep 2, 2009 18:11 |
|
Lexical Unit posted:Please tell me you are a teacher who is grading a high school student's homework. I've seen MUCH worse on our exam we give to people applying for jobs.
|
# ? Sep 2, 2009 18:48 |
|
-
pointers fucked around with this message at 03:34 on Jul 8, 2011 |
# ? Sep 2, 2009 23:23 |
|
|
# ? Apr 27, 2024 12:47 |
|
Why bother with the regex at all? I mean, don't you have to make sure that the value is a valid country code anyway? Can't you just check to see if the String is in some canonical set of codes?
|
# ? Sep 2, 2009 23:28 |