Mark Bowytz

Besides contributing at @TheDailyWTF, I write DevDisasters for Visual Studio Magazine, and involved in various side projects including child rearing and marriage.

Feb 2009

Beneath Dave

by in Feature Articles on

When John Smith started his job as the IT Manager/Network Admin/Webmaster for a small, sixty-employee subsidiary, he thought that he had found a pretty sweet gig. Everybody from his boss on down seemed reasonable, plus he got a laptop and a nice 19" LCD monitor. And best of all, the vending machine gave out drinks for $0.25.

Overall, things went along pretty smoothly and, once he got to understand how everything was connected at the company, he brought up some very good suggestions on how to improve things further. Including his idea for an VPN to secure transactions between his and the parent company. But instead of a round of applause, John got a nervous "Well, your VPN idea sounds pretty solid, but.....you're going to need to run that past Dave first."

Who's Dave?


Consultants of the Crystal Citadel

by in Feature Articles on

Photo Credit: 'Thristian' @ FlickrIt was the mid-1990's and business was booming at the company that Terry worked at. It was booming so much that the existing process of entering an order — faxing in an order form torn out of an outdated-as-soon-as-it-was-printed catalog — was delaying things enough that it was costing the company some serious dough in missed sales. Needing a way to re-engineer the process without hiring an army of support staff, management decided on an innovative plan that would enable customers to place orders electronically without needing to contact customer service.

With resources being tight (even the help desk was fielding order inquiries), management decided to farm out the work to an outside IT firm. Now, important work like this wasn't going to be farmed out to the boss's nephew who was a whiz at programming in Word and Excel. Instead they were going with a big name, "we named our building after ourselves" company. Yes it would be expensive, but the money that could be saved by receiving orders this new way would allow the program to more than pay for itself in short order.


The Path to WTF is Paved with Good Intentions

by in CodeSOD on

Let's say that I have a stupid report that needs constant attention and maintenance because of waffling business requirements.  Rather than buying a fruit bouquet for the server admin because of all the promotes I'd be doing, one solution might be to dynamically fetch the SQL for the report from a table. That way, all I would need to do is run a single UPDATE statement, COMMIT, and it's done!

Better yet, what if I wrote a generic procedure that could call any of the SQL my query table.  How enterprisey!!  This seems to be the general intenet of the original developer behind a web app that Patrick Magee recently inherited. 


Seasonal Slowness

by in Feature Articles on

Photo Credit: 'peterallen' @ FlickrFlash back to the early 1990s when David S. was working for a large health care provider, maintaining an application that passed data files between two servers across a leased line.

Normally, data transfers went off without a hitch - the applications responsible for shuffling data between the servers were well written and while the hardware on either end wasn't exactly bleeding or even cutting edge, it was mature enough that all of the kinks were worked out.  For David, day to day maintenance was a piece of cake.


Zipping Files - The Matryoshka Doll Way

by in CodeSOD on

Upon reading the code submitted by Eric Williams, the first thing I thought of was a series of Matryoshka Dolls.  You know, those little Russian dolls where the one doll has a smaller doll, which has a slightly smaller doll which in turn and so on...

The Windows-based application that Eric inherited from a previous developer needed to zip the contents of a folder full of files.  Normally, this functionality is a little difficult to implement without a third party library.  However, the original developer thought "outside the box" and wrote up the following implementation.

CreateZipFromFolder(CString m_outfile, CString outfolder)
{

 CString m_outputfilename = m_outfile;
 CString outpath = outfolder;
 CString p;

 TCHAR lpPathBuffer[BUFSIZE];
 TCHAR lpPathBuffer1[BUFSIZE];
 DWORD dwBufSize=BUFSIZE;

 DWORD dwRetVal;
 //find temp directory;
 dwRetVal = GetTempPath(dwBufSize, //buffer length
     lpPathBuffer); //path buffer
     
    if (dwRetVal > dwBufSize || (dwRetVal == 0)) {
        printf ("Failed to get temp path (%d)\n", GetLastError());
        FILE *fp = fopen("C:\\Zip.vbs","w+");
    }
   
    FILE *fp ;
    strcat(lpPathBuffer,"zip.vbs");

    CString fileName = lpPathBuffer ;

    if((fileName[0] != '\0'))
        fp = fopen(fileName,"w+");
    else(fp = fopen("C:\\Zip.vbs","w+"));
        p.LoadString(RESID_30);
       
    fprintf(fp,"Dim fso, winShell, MyTarget, MySource, file \n") ;
    fprintf(fp,"Set fso = CreateObject(");
    fprintf(fp,"%s",p);
    fprintf(fp,"Scripting.FileSystemObject");
    fprintf(fp,"%s",p);
    fprintf(fp,")   \n");
    fprintf(fp,"Set winShell = createObject(");
    fprintf(fp,"%s",p);
    fprintf(fp,"Shell.Application");
    fprintf(fp,"%s",p);
    fprintf(fp,")    \n");
    fprintf(fp,"MySource =");
    fprintf(fp,"%s",p);
    fprintf(fp,"%s",outpath);
    fprintf(fp,"%s \n",p);
    fprintf(fp,"MyTarget =");
    fprintf(fp,"%s",p);
    fprintf(fp,"%s",m_outputfilename);
    fprintf(fp,"%s \n",p);
    fprintf(fp,"Set file = fso.CreateTextFile(MyTarget, True)   \n");
    fprintf(fp,"file.write ");
    fprintf(fp,"%s",p);
    fprintf(fp,"PK");
    fprintf(fp,"%s",p);
    fprintf(fp,"& chr(5) & chr(6) & string(18,chr(0)) \n");
    fprintf(fp,"file.close \n");
    fprintf(fp,"winShell.namespace(MyTarget).CopyHere winShell.namespace(MySource).items    \n");       fprintf(fp,"do until winShell.namespace(MyTarget).items.count = winShell.namespace(MySource).items.count    \n");
    fprintf(fp,"wscript.sleep 1000 \n");
    fprintf(fp,"loop \n \n");
    fprintf(fp,"Set winShell = Nothing \n");
    fprintf(fp,"Set fso = Nothing");
    fclose(fp);

    PROCESS_INFORMATION pi;
    STARTUPINFO si;
    ZeroMemory( &si, sizeof(si) );
    si.cb = sizeof(si);
    ZeroMemory( &pi, sizeof(pi) );

    CString filename;
    filename = p + lpPathBuffer + p;
    CString szCommand;
   
    BOOL ret = Is64Bit();
    if(ret) {
        DWORD dwRetVal;
        //get the windows directory;
        dwRetVal = GetWindowsDirectory(lpPathBuffer1,dwBufSize); //path buffer
        strcat(lpPathBuffer1,"\\syswow64\\");
        szCommand = lpPathBuffer1;
        szCommand +="
cmd.exe /c cscript //B ";
    }   else {
            szCommand ="cmd.exe /c cscript //B ";
    }

    szCommand += filename ;
    if(CreateProcess(NULL,szCommand.GetBuffer(szCommand.GetLength()),NULL,NULL,FALSE,DETACHED_PROCESS,NULL,NULL,&si,&pi)) {
        WaitForSingleObject( pi.hProcess, INFINITE );
        CloseHandle( pi.hProcess );
        CloseHandle( pi.hThread );
    }
   
    return 0;
}

Re-enlisting the Data General

by in Feature Articles on

Photo Credit: 'glass window' @ FlickrFlash back to the early 90's when Remy P. was working as a system administrator for a major oil and gas company. Getting his hands dirty on a mix of Windows, VaxVMS, Alpha, and Solaris servers, Cisco routers, and even an old Xenix box that everybody prays never crashes, things were never dull, and today was certainly no exception.

Scratching his head the whole way down the freight elevator, Remy and two strapping lads from building services were to fetch the old, retired Data General server that once ran the old legacy accounting database before being replaced by a Dec Alpha and Oracle database from the server graveyard in one of the dimly lit storage rooms. Once in place and he would then play Doctor Frankenstein with it so that it may fulfill one request - print out all of the financial records that could be restored from tape backup for none other than the almighty Internal Revenue Service.


#WHO WROTE THIS JUNK

by in CodeSOD on

Justin de Vesine was less than thrilled with his internet service. On a good day, his high-speed would pretend to be dial-up; usually, it seemed that things would just give up loading half-way through. Through some trial and error, he narrowed it down to the brand-name DSL modem that his ISP gave him. Since it was running a stripped down version of Linux, and supported telnet administration, Justin decided to log in and poke around some of the scripts and config files to see if he could find the source of his problems.

When he came across this gem of a start-up script, Justin was not surprised that his DSL modem was the source of his troubles.