Wikipedia:Reference desk/Archives/Computing/2011 April 21

= April 21 =

Font fallback
I know that in html and css I can specify a font fallback list, but where does Windows 7 get its fallback list from please? When I do some maths characters and set default serif and nothing else then I notice that Internet Explorer and Word on my machine seem to choose in order from Times New Roman, MS Mincho, Arial Unicode MS. Dmcq (talk) 08:04, 21 April 2011 (UTC)


 * Provide a web font with the characters you require and you won't have to worry about it. ¦ Reisio (talk) 22:15, 21 April 2011 (UTC)

Making a function that returns a dynamic array in C++
After having spent many years programming in higher-level languages, I've finally decided to buckle down and learn a lower-level one, specifically C++. I've just started and I've run in to some trouble already. I was making something where I needed a function that returned a dynamically generated array, where I wouldn't know going into it how big it would be, so that I would also have to return the final size of it. Since a C++-function only returns one value, I figured that I would have it return the size of the array, and one of the arguments would be a pointer to the array that I passed by reference, so that that pointer would point to the start of the array when the function would finish.

However, no matter how much I tried, I couldn't make it work. I couldn't figure out the right configuration of asterisks and ampersands in the pointer to have it do anything other than segfault. What I finally did is that I reversed the size-variable and the array; the function now returned the array pointer and the size-variable was passed by reference as an argument. I pasted some code showing how I did it below.

It works, but it doesn't seem to me to be the best solution. Or maybe it is, and I'm just kidding myself. I figure since this is something that proper grown-up C++ coders presumably must handle all the time, there's probably a "standard" way to do it. If anyone can enlighten me as to the best way to solve the problem, I'd much appriciate it!

By the way, feel free to comment on anything else you might think of with this code. I'm just learning, maybe I'm doing something else really stupid or something, and I'd appreciate the feedback. Thanks! 83.250.233.57 (talk) 11:42, 21 April 2011 (UTC)


 * That's fair enough (I'm sure "real" C++ programmers, which I am not, will feel you should use a datastructure like a Vector rather than a native array). If you want to have make_array return the count and change the data called, you'd say


 * which you'd call with s = make_array2(&a); -- Finlay McWalter ☻ Talk 11:57, 21 April 2011 (UTC)


 * Your code is fine, really. You don't need to #define ENDL because there's already an endl manipulator in std. And if you put main at the end, you don't need to forward-declare make_array -- Finlay McWalter ☻ Talk 12:03, 21 April 2011 (UTC)


 * You know, that solution seems so damn obvious now, I don't know how I couldn't figure it out! Thanks! 83.250.233.57 (talk) 12:08, 21 April 2011 (UTC)


 * Actually you can simplify the above further, by simply saying *data = new int[size]; and dispense with v altogether. -- Finlay McWalter ☻ Talk 12:12, 21 April 2011 (UTC)


 * I always forward-declare everything, because I figure I might at some point change the code so that it calls a function before it's defined, and it's less work to write the declarations than to recognize the error messages and rearrange the function order. Don't know if this is "proper" style or not. I too get paranoid about doing things properly. Card Zero  (talk) 13:58, 21 April 2011 (UTC)


 * There is no right way to write in C, only an endless variety of wrong ways. :) -- Finlay McWalter ☻ Talk 15:27, 21 April 2011 (UTC)
 * If you meant C++, then I disagree. Even if you meant C, I disagree. -- BenRG (talk) 22:16, 21 April 2011 (UTC)


 * Don't use . Use a , like this:


 * If you're learning C++ from a tutorial or book that tells you to use, find a better tutorial or book. Fortunately, it's easy to tell the good ones from the bad ones: the bad ones mention   early on. (And the really bad ones mention  .) -- BenRG (talk) 22:16, 21 April 2011 (UTC)
 * As a way to teach C++ that makes sense, but the learner should be aware that this code copies the whole contents of the array, which can increase the big-O of an algorithm.  /  are painful, so avoiding them for demonstration purposes is justifiable, but in the "real world" (assuming that C++ is being used for performance reasons), they are unavoidable in a situation like this. Paul (Stansifer) 05:20, 22 April 2011 (UTC)


 * No, the code does not copy the array, because of return value optimization. In principle compilers aren't required to implement that optimization, but in principle they aren't required to support function inlining either. In practice, I think they all do. Anybody learning C++ does need to learn under what circumstances objects are copied, because, all efficiency concerns aside, changes made to one copy won't affect another. When objects are moved, though, as here (from 's local variable   to wherever the caller puts the vector), you don't have to worry about lingering copies, and you also don't have to worry about efficiency. (At least now that C++ finally has move semantics.)


 * If an object has an owner that knows when it should be d, then the owner can simply incorporate the object by value instead. That will usually be faster than  / . It's one of the primary reasons C++ is fast in the first place, compared to languages that require every object to be heap-allocated. If an object has no clear owner,  /  based code is very bug-prone and   is better. It might be slower, I admit, but there shouldn't be many objects without an owner in the first place. It's a recipe for aliasing bugs of the sort that can exist even in type-safe garbage-collected languages (which effectively wrap every object in a  ). -- BenRG (talk) 08:34, 22 April 2011 (UTC)

Do the high level chess AI programs use Bayesian networks?
Subject says it all. 20.137.18.50 (talk) 14:18, 21 April 2011 (UTC)
 * Not that I know of. Chess is a perfect information game. Bayesian networks are good at dealing with uncertainty. One can imagine some use of them, but it would be fairly contrived. --Stephan Schulz (talk) 14:23, 21 April 2011 (UTC)
 * I see, thanks for pointing out perfect information. Maybe with the AI card game programs like poker (assuming the computer opponent thread doesn't have access to the player's cards). 20.137.18.50 (talk) 14:40, 21 April 2011 (UTC)
 * Thinking about it again, though, Stephan Schulz, if the computer were playing against someone with a reviewable history, like Garry Kasparov, the computer could identify a style and calculate probabilities of how often a player does so and so in such and such situation. The other player's mind is an unknown, and maybe their proclivities will lead them in other directions than that of a completely logical move. I think I read somewhere that Kasparov did anticipate that the computer would think he would take a certain move (that he could see a computer would calculate as better at the moment) and used that knowledge to his advantage. 20.137.18.50 (talk) 14:57, 21 April 2011 (UTC)


 * I don't think there's enough information to train it. What you're interested in is not a general summary of how Garry Kasparov plays chess in general, but how he'll play in this specific move. So you'd need lots of examples of this specific position, or one very very like it. He's played a lot of chess, but it's quite varied (problem space is very divergent), and not yielding the huge amounts of info that say a spam filter sees. You might end up with some rule that "knows" that Garry Kasparov likes using knights in the 6th file, but that just gives you a (probably) slight statistical weight, and isn't much use for formulating a strategy. Bayesian inference really isn't that powerful, anyway - the most obvious case is in filtering spam: it does a pretty good job, but it's still a poor substitute for you or I (that is, it only rejects spam we humans would trivially identify as such).  Figuring out what move to play isn't a trivial task for anyone, so I doubt Bayesian analysis would really help.  I suppose if your expensive tree-traversal algorithm was running out of time (and couldn't afford to do another layer of traversal) then a Bayesian guess to pick between candidate moves might be worthwhile - but it'd be statistical icing on a very brute-force cake. -- Finlay McWalter ☻ Talk 15:53, 21 April 2011 (UTC)


 * You might all like this video: http://www.c-spanvideo.org/program/MostH :) &brvbar; Reisio (talk) 03:09, 26 April 2011 (UTC)

Where does Firefox 4 store its bookmarks?
My PC at work has been re-imagined from Win XP to Win 7. I neglected to export my bookmarks from Firefox before the re-image but I have a back up of my whole hard drive that I can access. I thought that all I would need to do is copy my bookmarks.html file from my backup to my computer but apparently Firefox doesn't store my bookmarks in this file. Anyone know where they're stored? I know its my fault for not doing an export before the re-image but the data has to be stored somewhere where its recoverable. A Quest For Knowledge (talk) 14:28, 21 April 2011 (UTC)


 * places.sqlite (in the same profile dir as the old <tt>bookmarks.html</tt>). You can browse it with the sqlite-manager plugin. I think Firefox 3 used sqlite too. -- Finlay McWalter ☻ Talk 15:39, 21 April 2011 (UTC)


 * Yep, it did. More information on Profiles and how to recover them here. --jjron (talk) 15:47, 21 April 2011 (UTC)


 * You can just copy the contents of your old profile directory into and over a new profile directory. ¦ Reisio (talk) 22:16, 21 April 2011 (UTC)


 * Thanks! A Quest For Knowledge (talk) 16:45, 22 April 2011 (UTC)

Backing Up A Computer
Right, I have not addressed this before, simply because I think that backing up a computer (i.e. copying the entire hard disk) is going to take up double the amount of space that your hard disk has, because by definiton, copying something means reduplicating it, and if you only have one hard drive, then where do you copy it to? Thing is, I'm very interested in why there are so many softwares out there (yes, I use plural for this) blerting out that they will help you backup. How? I mean, I have 20GB left from a 250GB HDD. I would like to ask once and for all, are these 'backup' thingies only for instances when you have an external drive (of the same size or bigger than your partition)? An example of what I am being told is here.


 * We have a whole article on this: backup. Your intuition about disk space is not quite correct.  If you simply copied all the files, then the backup would take up as much space as the original files (not as much space as the whole hard disk).  But every decent backup program also compresses your files while copying them, so the backup will take a bit less space than the original files.  Another reason there are many backup programs &mdash; we've got a list at list of backup software &mdash; is whether they support convenient features like incremental backup, or a mirror backup, sector by sector, of the hard disk.  Also, lots of backup software lets you back up your hard disk (or your "My Documents" folder only, or whatever) to optical discs like DVD+R discs.  Having a second hard disk is much more convenient for backups, of course, than inserting 50 DVD discs in a row.  There are also services like Mozy that cost like US$5 per month which back up your computer's data to servers located God-Knows-Where on the Internet; this is even more convenient.  You should definitely back up your important files, though.  The correct attitude to adopt is:  It's not a question of whether your hard disk will fail and lose data.  It is a question of when.  Comet Tuttle (talk) 18:15, 21 April 2011 (UTC)


 * I suggest you buy an external USB hard drive for backups. (You can get a 2 TB drive for $97  and fit 8 full backups on it, at least.) StuRat (talk) 06:18, 22 April 2011 (UTC)


 * Buying a single 2TB HDD and putting all your backups on that one disk is IMHO not a sound backup strategy. It would much more prudent to buy several external USB HDDs, each of which is about the same size as your internal disk, and store one backup on each USB HDD. This is because when your internal disk fails, if your single 2TB disk happens to also fail before you are able to recover your data to another computer, all of your data is lost. OTOH it is highly unlikely that several external HDDs would simultaneously fail. Rocketshiporion ♫ 00:26, 26 April 2011 (UTC)


 * If two hard drives fail simultaneously, that implies some type of disaster like a fire, in which case any hard drives stored on site may be destroyed. Also note that multiple small hard disks are considerably more expensive than one large hard disk, as an economy of scale applies. StuRat (talk) 06:48, 26 April 2011 (UTC)

how to monitor cumulative bandwidth - windows vista
I use T-Mobile stick (MF100 web stick) which comes with connection software that just so "happens" to not work when it comes to tracking usage (the data record window is blank). Obviously this is T-Mobile wanting to keep its customers from seeing their data usage and changing their habits accordingly.

But anyhoo, is there some free Windows Vista software I can install that just lets me see all cumulative uploads and downloads? Or do I have to keep waiting to get the next SMS through the software, saying I've again used up my top-up allowance.

Thanks. 79.122.79.3 (talk) 18:44, 21 April 2011 (UTC)


 * Windows Task Manager can show your cumulative data transmitted up and down on each network interface. You may need to enable "cumulative statistics", explained in our article subsection.  Windows can report total bytes uploaded, downloaded, and other more technical network diagnostics.
 * If you need more detail, or want cumulative data across multiple system reboots, you can use Network Diagnostics in the Windows Event Log, explained here. Nimur (talk) 19:41, 21 April 2011 (UTC)

Custom Cursors in HTML5
If you do

&lt; html &gt; &lt; head &gt; &lt; /head &gt; &lt; body &gt; &lt; div style=" background-color:red; cursor:url(pen.cur) " &gt; Test &lt; /div &gt; &lt; /body &gt; &lt; /html &gt;

where "pen.cur" is a standard Windows cursor file, this cursor will be used when the mouse is hovering the DIV.

But if you insist on the document's being a HTML 5 document, that is, if you write

&lt; !DOCTYPE HTML &gt; &lt; html &gt; &lt; head &gt; &lt; /head &gt; &lt; body &gt; &lt; div style=" background-color:red; cursor:url(pen.cur) " &gt; Test &lt; /div &gt; &lt; /body &gt; &lt; /html &gt;

it doesn't work anymore. I have tried this in Internet Explorer 9 and Google Chrome 10. What's going on here? --83.183.172.203 (talk) 19:54, 21 April 2011 (UTC)


 * It's not uncommon for browser engines rendering in a legacy quirks mode (because of a lack of a doctype declaration, for example), to be more forgiving to malformed CSS. This includes things like omitting required units in code like   which should be , and also things like this, omitting a comma separator and value name.  The W3C CSS validator would have pointed this out to you.  What you probably want is something like  , and to always, always use a doctype declaration that validates properly, which has no characters whatsoever before it. ¦ Reisio (talk) 22:33, 21 April 2011 (UTC)


 * Thank you! --83.183.172.203 (talk) 13:06, 22 April 2011 (UTC)

research question related to Apple product history?
Are the leather Smart Covers the first leather product Apple has directly sold (as opposed to third-party leather products) in its history? I'm having difficulty finding an answer to this question. It seems that there are maybe a couple of niche cases, but I can't decide if Apple made them. Anyway, my question relates mainly to mainstream products that Apple is targeting at a lot of people: is the smart-cover in leather the first such leather product? Thanks. 188.156.7.193 (talk) 20:14, 21 April 2011 (UTC)


 * The Twentieth Anniversary Macintosh had leather wrist pads. -- Finlay McWalter ☻ Talk 21:36, 21 April 2011 (UTC)


 * Nice one, Finlay McWalter! I forgot about that machine.  Comet Tuttle (talk) 16:55, 22 April 2011 (UTC)


 * Thank you, nice response. The article states that it was a "limited-edition" personal computer, and further, that it was delivered by a door-to-door concierge service.  It's still a good example though!  Anything else like that, anyone?  Maybe something a little more "mass-market"? 188.157.186.22 (talk) 23:43, 21 April 2011 (UTC)


 * It appears Apple sold leather cases for the Apple Newton. I googled Apple Newton leather and saw this expired eBay auction showing one off.  The top search result was a set of Flickr photos for a weird Newton prototype which had a similar leather case with the Newton logo.  I am not 100% sure Apple sold these directly, but it's very probable, because of the existence of the Newton logo on the leather.  Off the top of my head, I can't think of any non-Apple vendors who were ever allowed to put the Apple logo itself on their hardware, and I figure Apple would have been similarly protective of their Newton logo.  Comet Tuttle (talk) 16:55, 22 April 2011 (UTC)

StartManSvc.exe
How can I get StartManSvc.exe off my computer? Corvus cornix talk  21:49, 21 April 2011 (UTC)


 * Searching Google suggests it's part of the install of several PC Tools products, including their Spyware Doctor system. -- Finlay McWalter ☻ Talk 22:05, 21 April 2011 (UTC)


 * If it is a service, as the file name suggests, then you can stop it and set it to "Disabled" to prevent it from starting in the future. The article Windows service explains how. Uninstalling PC Tools would also work, and might be a good idea, since there are probably free programs that will do a better job of whatever PC Tools is doing. -- BenRG (talk) 22:44, 21 April 2011 (UTC)

I don't have Spyware Doctor or PC Tools in my list of programs, and I don't have Windows service in my Control Panel. Corvus cornix talk  01:11, 22 April 2011 (UTC)
 * OK, I ran "Services.msc" and stopped PC Tools. Thanks.   Corvus cornix  talk  01:14, 22 April 2011 (UTC)