Wikipedia:Reference desk/Archives/Computing/2009 May 31

= May 31 =

Perl, MySQL, TEXT, HTML, DBI escape characters
I want to store several HTML segments (ISO-8859-1 or ASCII) in a TEXT field of a MySQL database using Perl.

How do I escape certain characters for MySQL?

How do I restore them? -- Toytoy (talk) 00:30, 31 May 2009 (UTC)


 * Have you looked at the DBI documentation? Check out quote. --  JSBillings  21:13, 31 May 2009 (UTC)


 * The easiest way is to use placeholders, which will do the right thing for you, even if the parameter is NULL/undef:

$statement = $dbh->prepare("insert into mytable(html_field) values(?)"); $statement->execute(" html with quote's..."); # quotes it $statement->execute(undef); # inserts NULL
 * --Sean 12:38, 1 June 2009 (UTC)

I Remember This Website
I remember going to this website that started out as a page full of mouse cursors. Moving your mouse would cause all of the cursors to move, and you had to find the right cursor and click a button before you could continue. It then took you to this page that contained a post-it note with the words "remember this name" on it and a text area below. Typing in your name would take you to this page that copied a news website (CNN.com, The New York Times, ect.) with parts of the news story replaced by the name you typed in. If anyone could direct me to this website, I would be much obliged.

Americanfreedom (talk) 04:48, 31 May 2009 (UTC)


 * No field of mice on these, but this site offers realistic stories realistic stories and this one clearly phoney ones, both with inserting the names of your choice.KoolerStill (talk) 13:41, 31 May 2009 (UTC)

Media players for GNU/Linux
Is there a modern (e.g. Banshee or Quod Libet) audio player on GNU/Linux for GNOME that supports DSP plugins? Two specific effects I'm looking for is a compressor (I hate songs with high dynamic range) and a stereo-to-5.1 converter (not essential though). Note: I don't want ReplayGain or anything like that... --wj32 t/c 06:23, 31 May 2009 (UTC)
 * This might help. If the audio player supports JACK then you can probably do it, but I have no idea how. --antilivedT 05:29, 1 June 2009 (UTC)

I have an annoying problem...
I have a problem. There's this thing where I get a red pop-up at the bottom-right corner of the screen about an Antivirus System Pro alert about a trojan. I blocked the attack, but after some time, it appears again. I blocked it again. But it appeared again and again and again. I tried to ignore it, but then a pop-up appeared in the center of the screen about the alert. How can I figure this problem out? —Preceding unsigned comment added by Sirdrink13309622 (talk • contribs) 14:31, 31 May 2009 (UTC)
 * A quick Google suggests Antivirus System Pro is malware. It is a program which pretends to be antivirus program, but is in fact scareware. Download a decent antivirus program like AVG, McAfee Antivirus or Symantec Antivirus. AVG is free (I think), the others may have free versions. These proper antivirus programs should remove it.
 * You might want to read information about keeping safe from malware from the BBC. Page 3 has suggestions about antivirus software. --h2g2bob (talk) 16:36, 31 May 2009 (UTC)


 * "Antivirus System Pro" is well known example of scareware. Your best bet to remove scareware is to go with Malwarebytes' Anti-Malware and SUPERAntiSpyware. Both should be installed, updated, and used immediately to remove Antivirus System Pro. Afterwards, a proper anti-virus like avast! or Avira AntiVir should be installed. Under no conditions should you sacrifice your personal or financial information to this scareware product. The product isn't blocking anything but fake threats to scare you into buying it. Even Google-searching for information on some scareware threats these days can be dangerous. Some of the results may be fake scareware-removal instruction sites that may distribute the scareware itself or another piece of scareware labeled as a "remover of " or other malware. New rogue scanner sites with updated versions of scareware not yet detected by almost any anti-virus go online everyday. To help keep yourself safe while surfing the Web I highly recommend the Web of Trust add-on for Firefox and Internet Explorer. (Far superior to McAfee SiteAdvisor which I dumped a long time ago) Most importantly though, you, the user, is the most important part of online safety. Good luck.--Xp54321 (Hello! • Contribs ) 17:59, 31 May 2009 (UTC)

Where did my disk space go?
I would like to find a program (free, preferably) that would make it easier for me to track down folders and files hogging space on my hard drive. What I'm picturing is something that looks a bit like the folders panel of Windows Explorer, but with percentages or raw numbers indicating how much memory each folder is taking up. Even better would be something that broke it down to sub-folders too. Maybe something like:
 * Pictures (4.5 GB)
 * Kids (2.1 GB)
 * Molly (1.5 GB)
 * Nieces (600 MB)
 * Vacations (2.4 GB)
 * Camping (2 GB)
 * Niagara Falls (400 MB)

Is there anything like that out there? I'm running XP SP 3. Matt Deres (talk) 14:56, 31 May 2009 (UTC)


 * I find SequoiaView works great for this. It represents things visually which makes it a lot easier to figure out what's going on. --98.217.14.211 (talk) 17:34, 31 May 2009 (UTC)


 * I think that WinDirStat is great. —Preceding unsigned comment added by Andreas Rejbrand (talk • contribs) 18:09, 31 May 2009 (UTC)

Both of the above are rubbish in my experience and didn't do for me what I think you're looking for, which is integration straight into Windows Explorer. I had EXACTLY the same issue as you and I can tell you what you need is FolderSize. It's free and I've been using it for over a year now and it works brilliantly. It allows you to add columns for "Folder Size" and a few others to your Windows Explorer "Details" view, and in fact can replace your usual "Size" column. It does exactly what it says on the tin. Install it, right-click on the column headings and add "Folder Size" as one of the columns. Job done. Zunaid 20:36, 31 May 2009 (UTC)
 * Yes, and yes. I use and love "Folder size". It has made my life better, and they are not paying me to say this! :) -GTBacchus(talk) 20:40, 31 May 2009 (UTC)
 * Brief warning about folder size. It uses a background process to update the values continuously. That can sometimes slow down your system significantly. If you map network drives, it will venture off there as well, looking through all directories it can access, and start adding up. My work took twice the usual time for a week before I realized my computer was busy determining the folder sizes of everything publicly available on the company servers. /Coffeeshivers (talk) 20:49, 2 June 2009 (UTC)
 * My two cents: Treesize Free. Can give you a view pretty much exactly like your example. Rawling 4851 00:02, 1 June 2009 (UTC)
 * Is it too much to tell the OP to get Ubuntu and use its Disk Usage Analyzer :p? --antilivedT 05:21, 1 June 2009 (UTC)
 * Oh, no, no! Well, you know, not if you don't mind proselytizing instead of giving useful advice. "Oh, you have a tummy ache? You know what works really well for that? Jesus." -- Captain Disdain (talk) 06:57, 1 June 2009 (UTC)
 * I'm not worried about that. I have Jesus in my trunk!Matt Deres (talk) 23:24, 2 June 2009 (UTC)

Thanks for the options, guys. I had tried SequiaView... I think (very similar to WinDirStat in looks). FolderSize sounds more like what I'm looking for. I'll give it a go, though I'll keep an eye out for system lag. I have an external I often plug-in that has a gazillion folders on it; hopefully the proggie has a way of skipping drives or something. Matt Deres (talk) 23:22, 2 June 2009 (UTC)

Computer Graphics
Prove that two successive reflection about any axis coordinate axis is equivalent to a single rotation about the coordinate origin


 * You might like to read Transformation matrix. 87.114.167.162 (talk) 16:58, 31 May 2009 (UTC)


 * And possibly do your own homework as well. -- Captain Disdain (talk) 17:26, 31 May 2009 (UTC)

SteveBaker (talk) 21:29, 31 May 2009 (UTC)


 * Also try asking for help on the maths desk - not here...77.86.10.194 (talk) 19:09, 1 June 2009 (UTC)

goto in structural languages
One thing that's always kept puzzling me about  in structural languages is, what happens if the   jumps between different structures? For example, consider these C examples:

for (i=0; i<10; i++) { printf("%d\n", i); if (i==5) goto label; } label: printf("Hello world!\n");

for (i=0; i<10; i++) { label: printf("%d\n", i); } goto label;

Is there any formal specification about what happens in these cases? There are many other structured languages implementing  too. What is the case in them? J I P | Talk 19:22, 31 May 2009 (UTC)


 * (Answer for C++, should be mostly correct for C as well): When you jump out of a scope (such as a loop or a block), all objects declared in that scope are destroyed. You can not jump back into a scope if it bypasses an object declaration, with the exception of declarations of POD types without initializers. So


 * On the other hand:


 * And lastly


 * The same rules apply in a switch as well. decltype (talk) 20:09, 31 May 2009 (UTC)


 * Needless to say, this sort of scope goto-ing is "bad form" and will lead to unmaintainable code, so use such coding style with discretion. Nimur (talk) 21:22, 31 May 2009 (UTC)


 * (ec) In truth - the goto statement should be firmly ignored in all modern languages. They are a major disruption to the legibility of code.  Hence, you don't need to know what it does (unless you are a compiler writer) - because you aren't ever going to use one!  There is absolutely no circumstance when a goto is either needed or desirable.  The only reason so many languages retain it at all is in order to simplify the automatic translation of older, goto-laden programs that were written in non-structured languages (for example FORTRAN or BASIC).  In those cases, the lack of structure in the original language means that these problematic cases do not in fact come up at all in practice.  Hence the rules on the meaning for the ikky corner-cases generally follows whatever is the simplest thing to implement in the compiler rather than what makes most logical sense for programmers.  The last time I saw a professional programmer use a goto was about 15 years ago - and when the rest of the team found out about it, he was mocked for weeks afterwards.  Personally, I can say with authority that I've never felt the slightest desire to use a goto statement in a structured programming language  - not since I was told by one of the lecturers at the university I attended that we would be awarded an automatic zero on any coursework turned in with a goto in it!  That was in the mid-1970's - so if I can go 35 years without using one - so can you! SteveBaker (talk) 21:28, 31 May 2009 (UTC)


 * The last time I saw someone use a goto was about 3 years ago and yes he was mocked by with co-workers for weeks afterwords.  BTW, Classic VB didn't have structured exception handling so if you wanted to gracefully handle all errors, you were pretty much forced to include an On Error Goto ErrHandler in every event handler and callback function in your application.  If you wanted to keep track of your call stack, you had to code an On Error Goto ErrHandler in every single function in your application. A Quest For Knowledge (talk) 22:31, 31 May 2009 (UTC)


 * That's a pretty extreme viewpoint. It is true that in nearly all cases, goto should be avoided, but I wouldn't go so far as to say that it is always evil and should never be used by anyone ever. On the other hand, this "always-evil" attitude toward goto has become quite popular in the last 40 years. —Bkell (talk) 21:38, 31 May 2009 (UTC)


 * The only good examples I've seen of using  is for cleanup (of allocated memory, etc) after errors. An example of use is in the Python-C API docs. --h2g2bob (talk) 22:09, 31 May 2009 (UTC)


 * The earliest structured programming languages were strictly single-entry-single-exit; the only way to return from a function was by running off the end, the only way to exit a loop was by reaching the end of the range, etc. So if you use,   or   (except as the last line of a function) then you're using something that the early structured programmers would have considered a harmful goto. In order to work around those limitations programmers would explicitly assign a large value to the loop variable or introduce a boolean variable named "done", and I think C's structure-violating exit statements are more readable than those techniques. C programmers sometimes do the same thing to compensate for deficiencies in C's control constructs, like the lack of multi-level   (as found in Perl, for example), and I tend to prefer   in those cases also. But if your function has gotten that complicated you're almost certainly better off splitting it into several and solving the problem that way.


 * Probably the most important use of goto, though, is for machine-generated code. There are a lot of compilers that use C as a backend, and it's much easier to output labeled basic blocks and gotos than try to translate your high level control structures into C's. The resulting machine code is the same, since one of the first things a typical C compiler does is turn all control structures into gotos. -- BenRG (talk) 22:43, 31 May 2009 (UTC)


 * Indeed. There are 30,000+ projects written in C on sourceforge.net, and many more beyond.  Unifying error cleanup with a "goto error_cleanup" is the closest thing they've got to proper exception handling, and it's silly for them not to use it.  --Sean 12:59, 1 June 2009 (UTC)


 * Both of your examples (are horrible but) have well-defined semantics. In the first one,  behaves the same as  . In the second one,   is 10 upon exit from the loop; when you jump back in, it is still 10 and so 10 is printed, then it is incremented to 11 and the loop exits again since   is false, then it jumps back in and 11 is printed, and so on. -- BenRG (talk) 22:43, 31 May 2009 (UTC)


 * Just about all primitive (read mid-20th century) uses of goto have been superseded by more advanced constructs. The if-then-else, for-while-until, case or switch statements, break, continue, and return statements, and more recently the try-throw-catch constructs all evolved from a need to more clearly codify execution flow that at one time was accomplished with goto's.  In my opinion, the try-throw-catch construct eliminated the last need for the average programmer to use goto's.  Prior to that goto-less code containing robust error handling often contained a combination of boolean flags and nested if statements that made the normal logic less readable.  In some circles, use of the return statement is still considered bad form when used to exit the middle of a function.  Now there still may be some cases where a goto is justified, such at to achieve a few percent performance gain in a light loop of a highly optimized library function, but the typical programmer has no need for this, relying instead on the efficiency of library functions written by others.  -- Tcncv (talk) 00:32, 1 June 2009 (UTC)


 * I'd only consider goto for special applications, for example copying an algorithm out of Knuth using goto will often be more obvious and less error-prone than trying to beautify it. Also one might be using C as an assembly language and use macros with goto's in them for the higher level. They have their uses but should definitely be avoided in the primary level of programming. Dmcq (talk) 12:55, 1 June 2009 (UTC)


 * Use of 'return' in the middle of a function or 'break' in the middle of a loop (they are essentially the same thing from a structural sense) is 'iffy' - but there are cases when the clarity you get from doing it is more than worth the slight heartache each time you feel the need to do it. But:

...is incredibly painful because when you're trying to read the code, your brain is full of these buzzing little semi-conscious doubts about whether the error conditions will ever be properly resolved in the end.

It's so much nicer to get them out of the way early: ...that way you can be comfortably sure that all of the nasty things have been taken care of and go on to read the main part of the function with a clear head...and much less indentation!

But it's certainly possible to misuse 'return', 'break' and (especially) 'continue' in ways that make them almost as bad as a 'goto'. The biggest problem with a 'goto' is that when you're reading through some code and you trip over a 'label:' - you have absolutely no clue how the code gets there. But with break, return and continue, the only way to arrive at a close curly bracket is from within the brackets - or from the control statement at the top of the block. That makes it much simpler to reason about what code is doing. In most code, a block fits in a screen-full so it's easy to see what's going on as you scroll downwards through the source code reading as you go. But with a 'goto' you may not yet have seen the code that gets you to where you are reading...reasoning about what could possibly happen now requires you to have knowledge of all of the code in the scope that a goto could possibly have sent you to. Worse still, even when you find a goto that's aimed at the label you're reading, you don't know whether it's the only one or not. There could potentially be hundreds of places in the code that could get you to the code you're reading and you can't easily tell whether all of them adequately satisfy it's preconditions. This is definitely not good for debugging!

SteveBaker (talk) 21:29, 1 June 2009 (UTC)

Spreadsheet help
I have a workbook in excel 2000. There are 29 columns (A-AC) and many many rows. I want to combine column A with every other column in different workbooks. That is, I want to put comlumn A in the new workbook column A and column B in the new workbook column B. The next workbook will have column A in new A again and column C in new B, and so on. Is there a quick way of doing this without cutting and pasting? —Preceding unsigned comment added by 90.216.148.237 (talk) 19:54, 31 May 2009 (UTC)


 * I don't know much Excel (I use OOo), so workbook and worksheet are alien terms to me. Unless I'm mistaken, a workbook is the excel file (the .xls file). So you could copy your excel file (or save the excel file with a different name) and have 2 identical workbooks. Then just delete column B: right-click on the column header at the top of column B, and select delete. --h2g2bob (talk) 22:16, 31 May 2009 (UTC)


 * If you want to do this just to print the sheets separately, there are easier ways: you can go to "page setup", choose column A to be on every page you print (I think it is called "repeat column across pages" or something), and then insert manual page breaks between all the other columns. If you want to actually split the workbooks I think the easiest way would be some simple VBA code - if you have scripting experience, you can hit the "macro record" button, do some tries of what you want, and then look at and edit the code. There are also other ways, look into the OFFSET and VLOOKUP/HLOOKUP formulas, for example, and note that you can reference cells from one workbook to another. Jørgen (talk) 23:28, 31 May 2009 (UTC)


 * You can use Excel macros (Visual Basic for Applications). I used Tools > Macros > Record New Macro to record the steps needed to create the first two sheets using create sheet followed by a couple of copy & paste operations.  After stopping the recording, I took a look at the resulting commands in the Visual Basic Editor.  With a little bit of VBA programming, and replacing sheet and column names with numbers ("A:A" is column 1, "B:B" is column 2, etc) I came up with the following macro.


 * To use,
 * open the Visual Basic Editor within Excel (Tools > Macro > Visual Basic Editor).
 * Right Click VBAProject and select Add > Module.
 * Copy and paste the above code into the module window.
 * Click the run button (green arrow) at the top of the screen.


 * Unfortunately, I am running Excel 2007 on one machine and Excel 97 on another, so I cannot guarantee that the above will work for Excel 2000. (I'd give it a better than even chance though.)  If you have problems, you can generate your own macro using the steps I created above and perhaps adapt the commands to the above script.  Similar techniques can be used to automate many repetitive tasks in Excel and other macro enabled applications.  Hope this helps.  -- Tcncv (talk) 23:53, 31 May 2009 (UTC)

Why does reading scratched CDs lock up the PC?
Ever inserted a scratched CD or flaky floppy into a PC and tried accessing it? Why does the entire PC (rather than say just Windows Explorer or whatever program you're using) become unresponsive and/or extremely slow? I was copying files off a scratched CD today and could hardly operate any programs during the operation. Note I wasn't using Windows Explorer's copy but instead Total Commander. Right-clicking or double-clicking took an absolute age to respond. It is not a case of CPU usage (as confirmed by Task Manager). Also, why does reading a wonky CD cause the program to lock up anyway? Even hitting the cancel button on the copy operation took ages to register. Redrawing operations (mini- or maximizing, dragging windows around, clicking "show desktop") also took an age.

Is this just a Windows thing or is it standard behaviour that I/O operations cause everything else to lock up? And either way (either answer), why is that the case? Thanks. Zunaid 20:59, 31 May 2009 (UTC)


 * Well, a severely damaged CD or floppy will probably cause the device driver to perform multiple 'retries' to see if it can get the data that way. It may retract the drive heads all the way back to track zero of the drive - and perhaps even tell it to re-initialise it's firmware - all of which is pretty time-consuming - but necessary if you're to stand the best chance of getting the data off of the media.  I don't know about Windows - but certainly under Linux, this wouldn't cause a total OS lockup.  The retrying would be threaded just like other OS operations.  However, there are different ways to handle it - and I suppose the Windows way might be somehow crappier.  I doubt that it matters much which program you use - the retry should be hidden down at the device-driver layer. SteveBaker (talk) 21:10, 31 May 2009 (UTC)


 * Windows normally uses a high level API for accessing the CD, but in the event of crummy reads, it will switch to a low level ATAPI "raw read" utility. This is usually done when DMA fails (and therefore, is not hardware-accelerated and ties up the CPU).  Why this CPU usage is not threaded is probably a "feature/bug" of the system.  See this Windows Hardware Developer article on DMA for ATAPI devices if you want some more details - apparently six failures is the threshold for switching to PIO mode.  Nimur (talk) 21:15, 31 May 2009 (UTC)


 * I've been troubled by this issue many times. It could be that CD-ROMs produce excessive interrupt requests, in which case they hog your CPU with IRQs asking for attention. I've seen this when another piece of hardware like a network card fails and hogs the CPU. But I think it's more likely that Windows Explorer simply has to update its list of disks every time a CD-ROM is inserted or accessed. Contrast this with when you, say, print a document, in which case its the print spooler that has to wait for the printer. If the spooler locks up, you don't notice, because you don't really interact with it. I've actually seen bad CD-ROM drives cause a computer to stop booting entirely.--76.120.121.128 (talk) 21:17, 31 May 2009 (UTC)

pirated apps download
Before I got my iPod Touch, I was playing around with one of my friends'. It was jailbroken. He had something on there (don't know if it was an app or just a hack or what) that, whenever he wanted a non-free App Store app, would take him to a list of pirating sites that hosted the particular app. I don't know what it's called, but I know it exists. Anybody have any idea what it's called? Thanks, [&#65279;flaminglawyer] 21:56, 31 May 2009 (UTC)


 * It's unlikely the Reference Desk is going to help you out here. Try a search engine, I guess.  Tempshill (talk) 23:48, 31 May 2009 (UTC)


 * I'm finding it hard not to think of the Apple advert: "You want to steal other people's hard work and pay nothing for it?  We've got an App for that!". SteveBaker (talk) 21:03, 1 June 2009 (UTC)