thedailywtf
thedailywtf.com
Confessions: The Soft CPU Upgrade - Mon, 21 May 2012
"Years ago," writes Maxime, "we found ourselves plagued with a brand new, unusably sluggish website. Most of the team blamed the esoteric VMCMWTH-based architecture (i.e. View-Model-Controller-Model-What-The-Huuhhhhh) that was pioneered by the Chief Developer. But the Chief Developer and the CTO (who also happened to be his uncle), blamed the hardware. More specifically, it was the 'inferior, off brand' CPU."
"Now despite the fact that this 'inferior, off brand' CPU commanded over 40% of the market, and that no one had ever experienced any performance problems on it ever, the powers-that-be refused to even consider the possibility that the non-performance was a result of their poorly-designed system."
"Replacing all of the production servers to get a new CPU was extremely expensive – especially when it would come out of Network Operation's much-needed budget – and obviously wouldn't do anything except delay resolving the actual problem. After a few clandestine meetings with network operations, I thought up a novel way to deliver a CPU upgrade..."
#include#include #include static char *cpuname = "HyperTurbo 256-bit, AwesomeCache enabled"; int init_module() { loff_t i; for (i=0; i < nr_cpu_ids; i++) { strcpy((&cpu_data(i))->x86_model_id, cpuname); } return 0; }
"Sadly, after the Chief Developer ran his own series of tests, he found that the performance was tremendously improved and that no other changes were needed. A year or so (and many customer complaints) later, they finally decided to 'upgrade' the website."
Error'd: Element of Violence - Fri, 18 May 2012
"Avast blocked itself from updating on reboot," Tejio writes, "if it can't trust itself, who can it trust?"
"While browsing for a USB cable from Amazon, I found this bargain for £10431.80," wrote Dazzie Bee, "and it even comes with free shipping!"
"This panel usually displays real-time bus information," wrote Tom Wright, "the fact that the two errors are actually different suggested to me that I had just caught it as it broke. No such luck - it was still displaying the same thing on my way home."
"I recently got an 'ultra high capacity' battery for my HP laptop," wrote Tod, "I noticed that the Quick Setup guide included an unexpected instruction: 'Replace this box with PI statement as per spec'. It's repeated several times, so it must be important!"
"I got this message trying to buy a game that was included as a demo with my xbox," wrote Ryan, "it was a fun game, but I just can't justify the $53.6M cost. If it was only $50M... maybe."
"I got this from Symantec's online store," writes, D.J.. "Repeatedly.
"I guess Adobe 'Reader' doesn't 'like' too much 'violence'," notes Andrew D.
>
Representative Line: Sanity Check - Thu, 17 May 2012
"Lucky me," Ryan wrote, "I got assigned to work on Legacy, an application whose name accurately describes itself. I'm pretty sure that this system manages to have a WTF/line ratio greater than 1.0, especially if we include the 'minor' ones, like the System.Environment.Exit calls peppered throughout library code that causes the app to inexplicably exit."
"But beyond minor annoyances like that, or the random number generator class that seems to exist solely to duplicate the behavior System.Random, I discovered this gem inside a class method."
// Sanity check const int expected_length = 199 + 6;
Ryan adds, "I don't even want to know why a constant is declared inside a class... or what makes 199 + 6 better than 205. My head hurts."
Long Distance - Tue, 15 May 2012
Lawrence's employer had heard that this newfangled "Desktop PC" could reduce their IT costs, and they wanted in on it. It was the mid 80s, and at the time, their plants scattered all over Alabama connected to a central mainframe via dumb terminals connected over very expensive leased lines. It was time to upgrade, and Lawrence wasn't in charge of it. He didn't get called in until things went wrong.
"This new PC system is really slow," he was told while on a plant tour. That didn't sound likely- the PCs were running blisteringly fast 4.77MHz, 8088 CPUs with 16Kb of RAM, and since someone had connected "arithmetic-heavy accounting usage" to "floating point processing", they all had 8087 co-processors. There was no way they were slow, especially since half the time they were just running a 3270 terminal emulator.
But sure enough, when they fired up the terminal emulator, it was slower than anything. Going from the login screen to the menu, and then from the menu to the order fulfillment screen took multiple minutes. Was the 300-baud smartmodem that slow? Lawrence fiddled connections, tested the line, and then eventually got around to cranking the volume on the modem's speaker. No, the modem wasn't that slow.
Whoever had configured the deployment had tried to mirror their old system as closely as possible. In the old system, the terminal started a new connection every time the user pressed enter, and then disconnected from the mainframe until the user triggered the next command. So in the new system, they did the same thing- which meant each time the client finished loading a screen, the modem would hang up.
That particular problem was easy to fix, and simply involved making sure each PC had its own phone line, and that the terminal emulator made sure to keep the connection open. But one of their remote offices, someplace deep in the Alabama backwoods, proved intractable- they couldn't connect at all.
Lawrence tried diagnosing their problem remotely at first. The phone line seemed good- he could dial it; the plant users could dial out. He shipped them a fresh modem, and eventually a fresh PC, but nothing seemed to make a difference. They couldn't dial the mainframe. So he had to go out to the plant.
Having learned his lesson, the first thing Lawrence did was crank the volume on the modem speaker. When the computer attempted to dial out, he heard the sound of touchtone bleeps followed by a crackly voice saying, "Number please."
That particular plant was so back in the backwoods of Alabama that it didn't have direct-dial long distance. The users were so used to it that they didn't even think it could be the problem. The small town phone company had no firm plan when they would start doing it. Lawrence helped pack up the PCs and reinstall the dumb terminals. By the time he left that company, they were still using them. They might still be using them today.
Coded Smorgasbord: FAIL FAIL,FAIL FAIL,FAIL FAIL and More - Mon, 14 May 2012
"We're had been using a manufacturer's web service, but started getting errors all of a sudden," wrote Peter Lindgren. "Something has really, really failed."
InternalServerError Internal Server Error FAIL FAIL,FAIL FAIL,FAIL FAIL
"Fortunately, a short time later, it started working again with this message."
OK OK OK OK,OK OK,OK OK "I'm not sure of the purpose of this," Jasmine wrote via the Submit to The Daily WTF visual studio extension, "maybe the stack was just too small or something?"
Public Function Save() As Boolean Try SaveMeeting() Catch ex As Exception Throw ex End Try End Function
"I was asked to modify some simple web page used to generate an online store," Mihai Todor wrote, "here's a Javascript function that I found in it, which is used to validate the required fields."
function checkdata() { dataok = true; t1 = document.forms.signup.firstName.value; t2 = document.forms.signup.lastName.value; t3 = document.forms.signup.userName.value; t4 = document.forms.signup.password.value; t5 = document.forms.signup.passwordConfirm.value; t6 = document.forms.signup.email.value; t7 = document.forms.signup.url.value; t8 = document.forms.signup.adminFrontname.value; t9 = document.forms.signup.locale.options.selectedIndex; t10 = document.forms.signup.currency.options.selectedIndex; t11 = document.forms.signup.timezone.options.selectedIndex; t12 = document.forms.signup.packetType.options.selectedIndex; t13 = document.forms.signup.captcha_code.value; if(t1 == '' || t2 == '' || t3 == '' || t4 == '' || t5 == '' || t6 == '' || t7 == '' || t8 == ''){ alert("Please fill-up all the fields"); dataok = false; return(dataok);} if(t4 != t5){ alert("Please enter the password again"); dataok = false; return(dataok);} if(t9 == 0){ alert("Please select a locale"); dataok = false; return(dataok);} if(t10 == 0){ alert("Please select a currency"); dataok = false; return(dataok);} if(t11 == 0){ alert("Please select a time zone"); dataok = false; return(dataok);} if(t12 == 0){ alert("Please select a packet type"); dataok = false; return(dataok);} if(t13 == ''){ alert("Please fill-up the code field"); dataok = false; return(dataok);} return(dataok); }
"I've seen these types of constants on The Daily WTF before and always questioned if they were real," wrote Sterge, "and then I saw these."
public static final String SLASH = "/"; public static final String PERCENT = "%";
"I'm on a team that maintains a pretty 'serious' banking application," Giga B wrote, "it's pretty serious about the number of parameters in functions."
public void WriteStep1Data(int LoanRequestID, string InsertDate, string OperatorID, string FirstName, string LastName, string BirthDay, int DocuemntTypeID, int MaritialStatusID, string DocumentIssueDate, string DocumentExpireDate, string DocumentIssuer, string DocumentNo, string PersonalNo, int UniversityDegreeID, string Address, string Address2, int RealAddressLivingPeriod, int ChildrenCount, int FamilyMembersCount, decimal MonthlyIncome, decimal MonthlyFamilyExpanses, string HomePhoneNumber, string MobilePhoneNumber, string WorkPhoneNumber, string EmailAddress, string JobOrganizationName, string JobOrganizationAddress, string JobOrganizationActivity, string JobOrganizationPhoneNumber, string JobPosition, string JobWorkingYears, string JobBossName, string JobBossPhoneNumber, byte ClientSex, decimal FinTotalProductsAmount, decimal FinCommissionAmount, int FinLoanPeriod, decimal FinFirstPaymentAmount, decimal FinLoanAmount, decimal FinMonthlyPaymentAmount, string GuarantorName, string GuarantorLastName, string GuarantorBirthDate, string GuarantorPersonalNo, int? GuarantorDocType, string GuarantorDocumentNo, string GuarantorDocIssuer, string GuarantorDocIssueDate, string GuarantorDocExpireDate, string GuarantorTelHome, string GuarantorTelMobile, string GuarantorAddress, string GuarantorAddressReal, string GuarantorJobName, decimal GuarantorIncome, byte? GuarantorSex, decimal HistoryPlaticAnnualTurnOver, string HistoryDescription, string MarketingQ1, string MarketingQ2, int StatusID, string DateViewed, string DateAnswered, string BackOfficeUserID, string RepaymentDate, string ShopID, string CalculationGroupID, decimal RegFeeAmount, int clientDeptNo, int guarantorDeptNo, int guarantorMaritialStatusID, string AccountCodeWord, string ClientFatherName, string ClientBirthPlace, string ClientCityAttendingToReg, string GuarantorFatherName, string GuarantorBirthPlace, string GuarantorCityAttendingToReg, string GuarantorJobActivity, string GuarantorJobPosition, string GuarantorJobContactPhone, string GuarantorJobCodeWord, string GuarantorEmailAddress ) { ... snip a few hundred lines ... }
"I learned a neat trick from our enterprise framework," Eli noted, "if you want to convert an int to a double, just do this!"
double d = Double.valueOf(new Integer(i).toString()).doubleValue();
"I had to look over some C# code written by a colleague of mine," notes John D, "the following lines represent just the tip of the iceberg of the pain that I had to go through while understanding the code."
bool true1 =true; bool true12 = true; .... snip .... true1 = false; true1 = false;
"I found this pattern in source code I have been working on," wrote Nas Nubian, "this is how some developer decided to open a new window for when users click on a links."
link text
"So," wonders Johnny B, "I guess GUID from our production db servers are better than local GUID?"
Function GetNewGuid() Dim cnGuid, rsGuid Set cnGuid = CreateObject("ADODB.Connection") Set rsGuid = CreateObject("ADODB.Recordset") cnGuid.Open = _ "Provider=SQLOLEDB.1;" + "Data Source=; " + "Initial Catalog= " + "user id = '********';" + "password='*********'"" rsGuid.Open "SELECT newid() as Guid", cnGuid If Not rsGuid.EOF Then GetNewGuid = rsGuid("Guid").Value End If End Function
"The comment says it all," wrote Michael.
/** * Defines the value for none. Default is "none". */ public static String NONE = "none";
"This is snippet of code I found in a large program I maintain," wrote Brian. "The original developers have long since moved on. Funnily enough, this particular code was properly mutexed, but I guess the paranoid programmer doesn't trust mutexes. I only wish the original developers were so 'paranoid' when it came to avoiding things like buffer overflows, memory leaks, and sql injection."
if ( resData.state() == RESOURCE_STATE_ACTIVE ) { elapsedTime.setBase( resData.startTime() ); if ( elapsedTime.diff() >= maxDuration ) { // Do one more validity check, the paranoid programmer knows // the state may have changed since the last check. if ( resData.state() == RESOURCE_STATE_ACTIVE ) { resourceActiveTooLong( resData ); } } }





