|
`For-case` wins the lifetime achievement award here, I think
|
# ? Nov 26, 2008 20:33 |
|
|
# ? May 14, 2024 18:40 |
|
I thought we agreed that it was forever to be known as Duff's Enigma.
|
# ? Nov 26, 2008 20:54 |
|
Lord Uffenham posted:I thought we agreed that it was forever to be known as Duff's Enigma. Who is Duff and what is his enigma?
|
# ? Nov 26, 2008 21:16 |
|
MEAT TREAT posted:Who is Duff and what is his enigma? http://en.wikipedia.org/wiki/Duff's_device e: fixed url brokenness
|
# ? Nov 26, 2008 21:18 |
|
I am so thankful I am at my my 2nd to last day here. Here is some sweet "cache" code. We have code that can take a student number and retrieve a bunch of information about that student through an HTTP request. The best part is that the system only allows for 1 student per HTTP request, if we have a registration form with 700 signups we sometimes need to retrieve 700 students at once with 700 HTTP requests. AWESOME! To fix this my boss implemented this sweet "cache". It uses a server wide application variable (it is server wide because my boss thinks the whole website should be under 1 Application.cfm file) to store all the students, and then loops through the whole array of up to 1000 students 1 by 1 looking for a student number. It also has some sweet dynamic variable names and some other crap too. code:
Also if any of you have never experienced Coldfusion it is best language if you really enjoy typing. EDIT: P.S. This code times out if over 100 students are requested, and can sometimes crash the server. da keebsta knicca fucked around with this message at 21:26 on Nov 26, 2008 |
# ? Nov 26, 2008 21:19 |
|
da keebsta knicca posted:Also if any of you have never experienced Coldfusion it is best language if you really enjoy typing. who the gently caress in the history of computing thought, "ah, yes, xml is a decent markup language for organizing data... let's make code out of it"
|
# ? Nov 26, 2008 21:30 |
|
ashgromnies posted:who the gently caress in the history of computing thought, "ah, yes, xml is a decent markup language for organizing data... let's make code out of it" PFFT "XML" this language before 6.0 didn't even have an XML parser, lower down in this code it text parses the XML document. The pro's that came up with this thought "ah, yes, HTML is a decent markup language for organizing data... let's make code out of it". The language was originally created for non programmers, or not good programmers to create basic forms and things that interact with a database. But as soon as you try and do anything of any size it is giant poo poo heap. This was basically my first job out of school, and has super good benefits and good starting pay. Monday I move departments C# ASP.NET 3.5 with full MSDN licenses, and being the only "web dude" will be a dream. da keebsta knicca fucked around with this message at 21:47 on Nov 26, 2008 |
# ? Nov 26, 2008 21:41 |
|
ashgromnies posted:who the gently caress in the history of computing thought, "ah, yes, xml is a decent markup language for organizing data... let's make code out of it" It worked for lisp
|
# ? Nov 26, 2008 22:56 |
|
Vanadium posted:It worked for lisp Really? Can't say I've seen evidence of this. Prolog on the other hand...
|
# ? Nov 27, 2008 15:46 |
|
Zombywuf posted:Really? Can't say I've seen evidence of this.
|
# ? Nov 27, 2008 19:31 |
|
ashgromnies posted:who the gently caress in the history of computing thought, "ah, yes, xml is a decent markup language for organizing data... let's make code out of it"
|
# ? Nov 28, 2008 03:11 |
|
Zakalwe posted:A colleague and I were looking through a ray-tracer that someone released as we were implementing one of our own algorithms in it in order to see if the gains we were seeing were peculair to our own code. At first glance this kinda looks like Duff's device, but then you realize its just pure utter poo poo.
|
# ? Nov 28, 2008 05:18 |
|
Victor posted:When compared to some of the other utter and absolute crap out there, like healthcare's 837 file format, XML would be a godsend. One site calls it "overwhelmingly difficult to understand", and yet it's just supposed to be a hierarchical data format. Yes, there is much better for specific cases, but there is also much worse, and at least nubs can use XML... He's talking about how XML is pretty good at what it does, but the language syntax of ColdFusion is like XML/HTML because it's what people already know. So check this out. I work in a highly regarded genetics research lab. I'm the only one who knows anything at all about programming yet genetic research depends highly on it. People who were in my position I think knew very little outside of the classroom. For example, this is part of a pipeline script written in COMMAND LINE PHP. Let that sink in for a second and then behold php:<? // // parseField (string, n, delimiter) // returns the 'n'th 'delimiter' separated field of 'string' // e.g.: parseField ("how are you?", 3, " \t<br>?") returns 'you' // n.b.: fieldNo starts with one // function parseField($inputString, $fieldNo, $fieldDelimiters) { // // format of tracefile names: // lab_murrayId_machinelane_population_family_person.direction_primer_dnaRef // murray_13_F09_dani_160_11.g_p1ex3f2r_075.ab1 // murray_21_H09_phil_20000513_01.b_t3_5uta3f_076.ab1 // $currentField = 0; $fieldValue = ""; $i = 0; $j = 0; // allow at most 2 delimiters, default to space if only one specified // essentially rendering it as a dummy var // if (strlen($fieldDelimiters) == 1) { // $fieldDelimiter[1] = " "; // } // if (strlen($fieldDelimiters) == 0) { // $fieldDelimiters[0] = " "; // $fieldDelimiters[1] = " "; // } while ($i < strlen($inputString)) { // // skip the delimiters // if ( (strncmp($inputString[$i], $fieldDelimiters[0], 1) == 0) || (strncmp($inputString[$i], $fieldDelimiters[1], 1) == 0) ) { while ((strncmp($inputString[$i], $fieldDelimiters[0], 1) == 0) || (strncmp($inputString[$i], $fieldDelimiters[1], 1) == 0)) { $i++; if ($i == strlen($inputString)) { break; } } $fieldValue = ""; } // // get current field value // $currentField++; // n.b. may want to re-write above code to conform to code below so that index is checked in inputSTring before // the while loop instead of in it if ($i < strlen($inputString)) { while ((strncmp($inputString[$i], $fieldDelimiters[0], 1) != 0) && (strncmp($inputString[$i], $fieldDelimiters[1], 1) != 0)) { $fieldValue = $fieldValue . $inputString[$i]; $i++; if ($i == strlen($inputString)) { break; } } } if ($currentField == $fieldNo) { //echo "returning: $fieldValue<br>"; return $fieldValue; } } } ?>
|
# ? Nov 28, 2008 21:15 |
|
Fenderbender posted:
I think I saw a benchmark somewhere comparing different approaches to sorting, and one was some kind of heap sort using dynamically eval'd strings. It didn't do too bad.
|
# ? Nov 29, 2008 13:00 |
|
oldkike posted:At first glance this kinda looks like Duff's device, but then you realize its just pure utter poo poo.
|
# ? Nov 29, 2008 13:47 |
|
NotShadowStar posted:He's talking about how XML is pretty good at what it does, but the language syntax of ColdFusion is like XML/HTML because it's what people already know. Gee, if only there were a built-in function that, say, "exploded" a string into an array based on a delimiter.
|
# ? Nov 30, 2008 02:46 |
|
dancavallaro posted:Gee, if only there were a built-in function that, say, "exploded" a string into an array based on a delimiter. I really don't know anything about PHP beyond what I just read on php.net, but it looks like explode only works with a single delimiter (which may have multiple characters). To do multiple delimiters, you apparently need to construct a regex for split or preg_split. You could also do it with strtok and a bit of extra code. Anyway, I just love how there are so many things wrong with it. I think my favorite is the example invocation: quote:// e.g.: parseField ("how are you?", 3, " \t<br>?") returns 'you' It doesn't work as advertised. It would end up returning "you?" instead of "you" due to the arbitrary delimiter limit of 2. Even worse, if the code were fixed to support an arbitrary number of delimiters, the example invocation would end up returning "e" since "b" and "r" would become delimiters (as there's no way to designate a multi-character delimiter). And that's not even getting into the crazy WTFitude of having the second delimiter turn into a space if only a single delimiter is specified.
|
# ? Nov 30, 2008 03:37 |
|
Indeed, when I started admittedly I wasn't a PHP expert but I looked at that and thought Why go through all the trouble of making a terrible function that splits strings when we have... split. Here's another example. A lot of the data crunching depends on the filenames are EXACT or else the whole thing fails and stops processing things (silently, as you'll see); splitting the filename using the werido function listed above. Furthermore, the scientists and research assistants are expected to name the files (up to 384 per experiment) themselves. You can imagine how this goes. When something is named wrong there's no explanation as to why so I have to go figure it out and people get angry at me because I'm limping along with this bullshit until I can redo it all. Here's one of the conditionals on parsing the filename. The filename is expected to start with YYYY-DD-MM_SERIAL#. This little bit checks that. php:<? if (strncmp($runDir, "200", 3) == 0) { $deletePreviousSnp = "delete from snp where run = " . $runId; $success = mysql_query("$deletePreviousSnp"); // if (mysql_affected_rows() < 1) { // fputs($errfile, "ERR: " . mysql_error() . "\n"); // fputs($errfile, "ERR: delete failed for run: " . $runId . "\n"); // // } else { // fputs($errfile, "deleted " . mysql_affected_rows() . " from snp " // . "for run " . $runId . "\n"); // } } else { // // cannot update snp records that are from pop-gene-region runs // } ?>
|
# ? Nov 30, 2008 08:24 |
|
If you're ever working with a C compiler for microprocessors, and you come across a line like this in the support filescode:
I was 20 and I think I thought I was being clever somewhere else by doing "<<2>>6" to pick off bits 5:4. That one actually might not have been inefficient on some hardware. Still dumb of course.
|
# ? Dec 1, 2008 00:47 |
|
Ryouga Inverse posted:When I left today he was "stuck" on a compiler error which said "You can't have a method with the same name as its containing type". How is this a hard error to interpret? I spend a lot of time in a C++ help channel and, from my experiences there, I've concluded that many people's brains simply freeze up when they see an error message. They see "error" and they just panic and stop thinking. It used to be that people would come in and ask "what does (incredibly self-explanatory error) mean?" and I'd explain it. But I realized after a while that they didn't need me to explain it. They just need me to repeat it. More than a few times I've quite literally just copy-and-pasted the error message, without the word "error" at the front, and suddenly they understand it, without even realizing what I've done. I weep for humanity.
|
# ? Dec 1, 2008 19:25 |
|
ZorbaTHut posted:I spend a lot of time in a C++ help channel and, from my experiences there, I've concluded that many people's brains simply freeze up when they see an error message. They see "error" and they just panic and stop thinking. You know, that makes total sense. Lots of things only click when the context is changed. It seems that taking the information out of the context of "an error message" makes the problem much easier to solve. quote:I weep for humanity. Oh, you were just being a dick.
|
# ? Dec 1, 2008 19:54 |
|
pokeyman posted:You know, that makes total sense. Lots of things only click when the context is changed. It seems that taking the information out of the context of "an error message" makes the problem much easier to solve. Sure, when dealing with HCI you should always try to avoid causing undue panic. Programmers who shut down on encountering 'Error:', on the other hand, are in the wrong profession.
|
# ? Dec 1, 2008 20:05 |
|
Really the thing that causes more freeze-ups than anything else in modern C++ is the deluge of a hundred lines (of which three may be informative) that occurs when you gently caress up in a way related to templates.
|
# ? Dec 2, 2008 00:09 |
|
Otto Skorzeny posted:Really the thing that causes more freeze-ups than anything else in modern C++ is the deluge of a hundred lines (of which three may be informative) that occurs when you gently caress up in a way related to templates. Yeah I'm really psyched about Concepts.
|
# ? Dec 2, 2008 00:48 |
|
New job in C#, take over old staffs code.code:
EDIT: Looking through their old email on project updates I saw this task was completed. "• Continued reading online .Net book." Sounds about right. da keebsta knicca fucked around with this message at 18:02 on Dec 2, 2008 |
# ? Dec 2, 2008 17:58 |
|
The last place I worked most of the code was actually pretty good, but we had one programmer who managed to produce some, shall we say, interesting pieces. The only one I can recall well enough to recount was she was given the task of writing a data validator which would sweep over our data as it was read in and make sure all the values were was in the correct ranges and it was all there, etc. The data we were processing came from a team of scientists who were notoriously lazy about data correctness (hence the need for validation in the first place). Anyway, in a function intended to read a list of numbers from the database and make sure they were all integers between 1 and 10 (despite being stored as doubles) I found something like this: code:
|
# ? Dec 3, 2008 12:53 |
|
Some code I found in our app at work in a support class for our custom parser (don't ask).php:<? /** * function to display template in the product page like finance option in highlights * case 3 is added for status page, if the coupon redeem value is 0 then dont display the couponredeemed msg. * else display the redeemed value **/ function EVALTEMPLATE($aarr_args) { $aarr_args[0] = intval($aarr_args[0]); switch ($aarr_args[0]) { case 0: $lstr_rtn_value = $aarr_args[1]; break; case 1: $lstr_rtn_value = $aarr_args[2]; break; case 2: if (isset($aarr_args[3]) && $aarr_args[0] != "") { $lstr_rtn_value = $aarr_args[1]; } else { $lstr_rtn_value = $aarr_args[2]; } break; case 3: if (isset($aarr_args[1]) && $aarr_args[1] > "0") { $lstr_rtn_value = $aarr_args[2]; } else { $lstr_rtn_value = ''; } break; default: $lstr_rtn_value = ''; } return $lstr_rtn_value; } ?>
|
# ? Dec 4, 2008 00:41 |
|
da keebsta knicca posted:Looking through their old email on project updates I saw this task was completed. "• Continued reading online .Net book." Come on You can't knock a guy for trying to learn.
|
# ? Dec 4, 2008 03:07 |
|
geetee posted:Come on You can't knock a guy for trying to learn. No I can't I haven't coded C# ASP.NET myself for a couple of years and have to reference a lot lately. But I just found it I guess ironic after going through the app.
|
# ? Dec 4, 2008 05:59 |
|
Code from a coworker I noticed in a library that's meant to combine CSS or JS files into a single file, minimize them and cache them (ie. only 2 http requests needed)php:<? //<snip $content = file_get_contents() the css file> if(isset($content)) { $content = $this->_fix_urls($group, $content, $style['view']); if($this->csstidy_on) { $this->csstidy->load_template($this->csstidy_compress); // SLOW AS gently caress $this->csstidy->parse($content); $document .= $this->csstidy->print->plain(); } else { $document .= $content; } } if($this->_needs_rewrite($document, $filename)) { $this->_write_file($document, $filename); } ?> Execution time has now dropped from ~8.65s to 0.03s after some tlc
|
# ? Dec 4, 2008 06:48 |
|
More from the saga of terrible sdet! I told him to make sure to separate view and controller/model code, and this is what he's come up with: code:
Oh, also: code:
|
# ? Dec 4, 2008 19:09 |
|
code:
|
# ? Dec 4, 2008 20:12 |
|
Not to mention reentrancy issues...
|
# ? Dec 4, 2008 20:30 |
|
I think I'm going to make note of the current value of the table, reset it to 1, and watch the excitement unfold.
|
# ? Dec 4, 2008 20:34 |
|
Lone_Strider posted:I think I'm going to make note of the current value of the table, reset it to 1, and watch the excitement unfold. "What's this bullshit table full of sequential numbers? We don't need this!" code:
|
# ? Dec 4, 2008 20:39 |
|
royallthefourth posted:"What's this bullshit table full of sequential numbers? We don't need this!" I like TRUNCATE best because it isn't immediately obvious what's going on when the app breaks. Also, potentially it could go for a while without being noticed (if previous records are deleted)
|
# ? Dec 4, 2008 21:05 |
|
Lone_Strider posted:
Be very careful here, there are legitimate reasons to do this. Although unless your db's default isolation level is serializable (and you db properly supports serializable (which it doesn't)) this is the wrong code to do it. There are two reasons to do this: the first is where keys must be unique across multiple tables (i.e. table1.key must never be equal to table2.key), the second is if you require sequential keys. If a transaction that has allocated a key for an identity column rolls back when there is another transaction active that has allocated the key after it, the rolled back transaction will leave a gap in the keys. Of course if your system doesn't need either of these there is no reason for this function to exist and as I said, it's wrong. The fix would be to set the isolation level to at least repeatable read and use an update lock table hint on tblNextID in the SELECT statement.
|
# ? Dec 4, 2008 22:11 |
|
It's SQL 2005, keys have no need to be unique to multiple tables, nor do the keys have to be sequential. The dev who created this is one of those "stuck in his ways" people who's best fit is maintaining some Access 97 application. I have the joy of rewriting everything he's done! I actually ran the truncate just to see what would break and where, but I haven't heard a thing & the "counter" is still at 1. I hope this is just an old procedure that no one uses anymore.
|
# ? Dec 4, 2008 23:09 |
|
Lone_Strider posted:I actually ran the truncate That's some serious balls you got there. What made you think it wouldn't be an absolute disaster?
|
# ? Dec 4, 2008 23:13 |
|
|
# ? May 14, 2024 18:40 |
|
small company, backed up the table beforehand & it wasn't part of a database that was mission critical. But I'm gonna restore it regardless before someone who works here sees my post & I wind up explaining myself
|
# ? Dec 4, 2008 23:23 |