Wikipedia:Reference desk/Archives/Computing/2011 August 20

= August 20 =

Permutation identification
Given two arrays containing the same elements (all distinct) in different orders, how does one most efficiently identify the permutation applied to the first to yield the second? I know one can create a map from elements to their indices in the second array, and then loop over the first accumulating the map's value for each element. But I feel there ought to be a lighterweight solution that doesn't involve constructing a temporary hashtable or BST. (I guess there can't be an asymptotically faster algorithm: it must be able to generate all $$n!$$ possible permutations, so it must do $$O(n\log n)$$ work just like a sort.) --Tardis (talk) 01:46, 20 August 2011 (UTC)
 * You could tag both arrays with indices, sort both, then just run down the sorted arrays in parallel gathering the indices. If you went with your approach, instead of constructing a hash table or binary search tree you could sort the index-tagged array and do a binary search on that. I think either approach would be pretty fast and I doubt there's any way to do it much faster, unless the elements are expensive to compare in which case you might be better off with the hash table. -- BenRG (talk) 03:50, 20 August 2011 (UTC)

Javascript program writing
I want to write a java script program. Is there any compiler for that or should I use notepad? Thanks--180.234.94.35 (talk) 10:50, 20 August 2011 (UTC)
 * Notepad isn't anything like a compiler, so your question doesn't quite make sense. Perhaps you're referring to an IDE for Javascript?  Many of  do exist.  And if you want a straight editor, there are many that are usually recommended over Notepad: Notepad++, Emacs, TextMate, BBEdit, etc.  --Tardis (talk) 18:09, 20 August 2011 (UTC)
 * Also, JavaScript code is rarely compiled; it is usually hosted or interpreted. What platform are you targeting with your script?  Many JavaScript programs are intended to be hosted inside of a web browser.  If you want to create a standalone JavaScript program, I recommend Mozilla Rhino and the OpenJDK VM.  You can also run a variant of ECMAScript in Windows Script Host, but I find that dialect to be very different from web-development style JavaScript.  Nimur (talk) 22:55, 20 August 2011 (UTC)


 * Visual Studio works. As noted above, it's not a compiled language.  You'll also want to know to use Firebug (under Firefox) or the Google Chrome browser for debugging.  Comet Tuttle (talk) 16:43, 21 August 2011 (UTC)

Firefox source code
How do I get the source code for Firefox? Asked by 123.24.96.94 (talk) at 12:09, 20 August 2011 (UTC)


 * See this, which advises you to clone the Mozilla Mercurial repository to get a source tree. -- Finlay McWalter ☻ Talk 12:21, 20 August 2011 (UTC)

Or for a more casual approach, perhaps ftp://releases.mozilla.org/pub/mozilla/pub/mozilla.org/firefox/releases/6.0/source/firefox-6.0.source.tar.bz2 &brvbar; Reisio (talk) 20:31, 21 August 2011 (UTC)

Where does Chrome keep its bookmarks?
One of my hard disks has fallen on the floor and cannot be accessed by a Windows system booted from another disk. It lists the contents as RAW. However, I can still copy most of the files accessing it from Linux. What I need is to get to my Chrome bookmarks. But where are they kept? Hoppafrogg (talk) 14:25, 20 August 2011 (UTC)


 * On Windows (Vista onward) these are in Users\ \AppData\Local\Google\Chrome\User Data\Default (for reference, on Linux they're in ~/.config/google-chrome/Default).  If you're interested in the format, some files are  Sqlite3, but looking at the Bookmarks file specifically it looks like JSON data instead. -- Finlay McWalter ☻ Talk 14:45, 20 August 2011 (UTC)


 * Alternatively, you may find them on a Windows XP/2000 system in [main drive]:\Documents and Settings\[main user]\Local Settings\Application Data\Google\Chrome\User Data. Nevard (talk) 02:05, 21 August 2011 (UTC)


 * And to be specific, they are in a file called bookmarks (with no file extension). They are always in the readable JSON format.  — Preceding unsigned comment added by TheGrimme (talk • contribs) 14:20, 22 August 2011 (UTC)

Windows 7 file explorer and all internet browsers jump back a page
I am running an instance of Windows 7 in a virtual machine on a Mac. This problem is new in that I haven't done much with the VM after this started happening. All internet browsers, whether they be Firefox, IE, or Google Chrome, revert back to the previous page. I even hear the "click" associated with clicking the back button. This even happens with Windows Explorer and the Control Panel. I tested to see if it was a stuck backspace key on my Mac's keyboard by disabling it with the Bluetooth button up in OS X's start bar. That didn't help. I then tried some more troubleshooting a month or two later by logging in, opening Command Prompt, and entered net user administrator /active:yes and I turned off the keyboard this time. I logged into the hidden administrator account that I enabled and opened up the on screen keyboard. The problem was gone and I thought it was one of those weird glitches that is solved by doing something different. So, I rebooted my VM and logged back into to my normal account with my Mac keyboard powered on. Loath (yes, loath) and behold, it was happening again. What possibly could be causing this and what can I do? (This has not been happening in my other Windows 7 VM.) --Melab±1 &#9742; 14:47, 20 August 2011 (UTC)

How to send an old computer system to schools in Africa?
Hello, I am interested in sending my old computer system to any African school who would really need another computer.

What programs/organizations/etc. would help me with this? Thanks. --70.179.163.168 (talk) 15:00, 20 August 2011 (UTC)


 * You don't say where you are located, but your IP address seems to geolocate near Atlanta, Georgia. I googled donate computer atlanta georgia and several services popped up.  As far as donating to Africa, there are a couple of problems with this &mdash; in addition to the shipping cost possibly approaching the cost of a new OLPC laptop, with any computer donation, somebody has to support it, unless you want the computer to end up as an African doorstop in a couple of years; and so in turn the person supporting the system will want to know everything about it, what parts are likely to wear out, and generally invest more time in the system than this is worth.  Comet Tuttle (talk) 16:12, 20 August 2011 (UTC)


 * Although after having written that unreferenced complaint, I notice that Computer Aid International doesn't seem to have trouble doing this from the UK. Comet Tuttle (talk) 16:16, 20 August 2011 (UTC)


 * Sorry that my IP didn't geolocate properly, as I am from Kansas. Thanks for linking Computer Aid International. In that case, is there any organization similar to CAI in Kansas or at least the Midwest? --70.179.163.168 (talk) 20:57, 20 August 2011 (UTC)
 * I am from Africa. How old a computer system is this? If it's ancient then it will most probably be useless to schools in South Africa at least. We do have a national curriculum for education which does require computer labs with fairly new computers capable of running Win7 and Office 2007, so that gruaduates are competent in the workplace immediately after leaving school. Someone living in abject poverty *might* have a use for it but figuring it out by themselves would require a basic understanding of English, which millions of rural people do not have. Also the really ancient big boxes with CRT monitors are going to contribute to the landfill problem, and we don't really want to be world's dumping ground. Also, I wouldn't recommend you making a donation to the government here due to high corruption... so I don't know what the answer is really - maybe reputable people like those in the Bill Gates Foundation might have an idea. Thanks for the kind thought though! Sandman30s (talk) 11:09, 22 August 2011 (UTC)

CSS normal text style
I am desirous of adding a short phrase at the end of a heading in the style of normal body text. So, pretending that bold italic is the style for a level 3 heading (h3), a normal heading might look like: This is the heading I want to add a bit to the heading in normal body text, in a 'span', so the result looks like This is the heading body text. What is the name of the default style for body text? -- SGBailey (talk) 15:25, 20 August 2011 (UTC)


 * If you just want to turn italics off, it's font-style:normal (rather than font-style:italic). -- Finlay McWalter ☻ Talk 15:39, 20 August 2011 (UTC)


 * But if you wanted all of the style (colours, borders, font, background, text-decoration, etc.) then you need to set those individually (or use a class which did the same). CSS exhibits optional inheritance, but as seems you'll have your span as a child of the h3, that's the element from which it would inherit its properties. CSS isn't very expressive, and one can't say "make the style of a be a copy of the style of b". The CSS2 DOM allows access to a given elements actual style using the getComputedStyle method, so Javascript can cut'n'paste a style from one element to another. -- Finlay McWalter ☻ Talk 16:34, 20 August 2011 (UTC)


 * Yes I do want all of the style. Can you point me at any sample javascript to copy? -- SGBailey (talk) 20:56, 20 August 2011 (UTC)


 * Perhaps I shouldn't have mentioned the Javascript (sometimes I feel like the H.P.Lovecraft of software...).  If we're talking about Wikipedia, this isn't going to work, and you'd typically use a template that did a span with the CSS you require.  If this is your own site, you'd be overwhelmingly better off just setting the correct styles in the stylesheet, and probably using a class for your thing at the end of a header object.  I can't think of a good reason a sane person would actually do the Javascript thing I suggested (for a site which she fully controlled, with content only she supplied) but this StackOverflow discussion has such a code. But I warn you as I warned Al Azif, do it with (unsatisfactory, but workable) CSS, for the way of Javascript is the way of madness. -- Finlay McWalter ☻ Talk 21:44, 20 August 2011 (UTC)


 * Thanks. -- SGBailey (talk) 22:21, 20 August 2011 (UTC)

Can most computers type diacritics?
There've been a good deal of discussions about the use of diacritics where people opposed to the use of diacritics have asserted that not only do many people not know how to type them, but most computers/keyboards (or U.S.-sold computers) cannot type them. I would think that at least through non-default language options, or keystrokes like Alt + ASCII number codes, or if not these special software, this wouldn't be a problem. So, can most computers type diacritics? can that many not at all? &mdash;innotata 16:38, 20 August 2011 (UTC)


 * Yes, all computers running Windows or Mac OS (at least) have built-in ways to insert any Unicode character (Windows has Character Map, and Mac OS has a similar utility called Character Viewer), although it can be quite cumbersome to use these to actually type text. I assume that nearly all flavors of Linux have similar facilities. If you are referring specifically to the editing of Wikipedia articles, there are tools to insert special characters right on the edit page; see Help:Entering special characters for more information. —Bkell (talk) 17:03, 20 August 2011 (UTC)
 * Our article, Internationalization and localization, may help. Computers have supported internationalized character encoding since at least the 1960s.  Almost every desktop, server, and mainframe operating system I know has supported such characters.  The unicode character encoding standard has been de-facto the best way to be consistent across different platforms, and has been around for a few decades (see origin and development - 1987 is cited, though mainstream support on most operating systems is more realistically "late 1990s").  Many users who do not regularly deal with international characters do not know how to enter or edit these types of characters, but the computer hardware and most modern software can usually display and handle UTF characters just fine.  Nimur (talk) 22:47, 20 August 2011 (UTC)
 * Windows XP, the first Microsoft consumer-line operating system to give really solid native support for Unicode came out almost ten years ago today. My guess would be that most people who edit Wikipedia extensively are running really quite recent computers- two or three years old. Most people who edit Wikipedia with an account, making perhaps one substantive edit every week, on average, would have a computer running either XP or something like an older version of Mac OS, where they were ahead of the game. Personally, when I need to put in a diacritic I tend to copy and paste it from earlier in the article, or from another article. Nevard (talk) 00:23, 21 August 2011 (UTC)

Many Unix systems have long had a Compose key that allows diacritics to be typed in the windowing system. On Linux systems, the user may have to configure this in the keyboard preferences, since the PC keyboard does not include a Compose key by default, but does have an abundance of recently-added keys (Windows and Menu keys) that are useless in Linux unless put to some particular purpose. —FOo (talk) 08:47, 21 August 2011 (UTC)


 * It's very easy to type in the most familiar diacritics in OS X, much easier than on regular American Windows keyboard setups. In OS X, each of the regular diacritics has an associated key (acute is e, grave is i, for example), and you type option+the key, and then type whatever character you want the diacritic to appear over. So e-acute would be option+e and then e (é). It's surprisingly easier than the Alt-codes mechanism (which is really only plausible if you use the same diacritics over and over again -- it's totally unintuitive). --Mr.98 (talk) 21:17, 21 August 2011 (UTC)


 * Windows supports switching the keyboard layout entirely with simple keyboard shortcuts, which makes it much easier, especially for languages like Russian. The technique you describe above only works for Latin characters. In Windows, if you go to Start &rarr; Control Panel &rarr; Regional and Language Settings &rarr; Languages &rarr; Details, you can add keyboard layouts. For example, I can switch to Spanish by pressing CTRL + SHIFT + 2 and then press the bracket key and e to get é. Likewise, I can press CTRL + SHIFT + 6 to switch to Russian and then press x to get ч. This functionality was also present in Windows 9x and you could switch keyboard layouts in Windows 3 by going to Main &rarr; Control Panel &rarr; International, although without keyboard shortcuts. In MS-DOS, you could switch keyboard layouts with the chcp command, although you first had to load contry.sys and nslfunc.&mdash;Best Dog Ever (talk) 22:43, 21 August 2011 (UTC)


 * I find the "easy" OS X option-character input methods to be fairly cretinous compared to composing. And actually implementing composing looks to be a pain in the neck. Fifelfoo (talk) 05:53, 22 August 2011 (UTC)


 * You can, of course, use alternative keyboard layouts with OS X as well (and switch between them with hotkeys, etc.). But for simple diacritics (like those of us who don't need to type in another language, but occasionally need to type names like Leó Szilárd) it's undeniably easier out of the box than the Windows methods offered up above. I've remained amazed that Windows never adopted something as easy as this for the simple, common diacritics like acutes, graves, cedillas, and umlauts, which are common in writing European names. --Mr.98 (talk) 22:19, 22 August 2011 (UTC)


 * Windows already uses ALT for menu shortcuts. For example, if you press ALT + e, you will open the edit menu. ALT + f gives you the file menu, and so on. How do you open menus with your keyboard in a Mac?&mdash;Best Dog Ever (talk) 03:14, 23 August 2011 (UTC)
 * Macs are not made to be used without mouses of some sort; you can activate menus by keyboard alone but it is kind of cumbersome by default (function+control+F2), but the hotkey can be changed. --Mr.98 (talk) 15:28, 23 August 2011 (UTC)


 * Of course, in Wikipedia, the insert thingy just below the save button also works. Otherwise, for Windows, hold the Alt key and type a 4 digit code on the numeric keypad (press numlock to get number mode if necessary).  The 4 digit codes appear at the bottom of the character map applet.  You will soon get used to the more familiar codes ... eg. I just 'know' the lowercase-e-with-acute-accent is alt+0233.  Astronaut (talk) 12:24, 22 August 2011 (UTC)

MS Excel - Elapsed time calculations
I'm having difficulty getting Excel to differentiate between a period of time versus the time. In short I need to sum a column of time periods such as 12:45:30 (12 hours, 45 minutes, 30 seconds) but Excel insists on handling it as fourteen and a half minutes before 1pm. I need everything to be formatted as hhh:mm:ss. The total of the column would be hundreds of hours and an some individual entries would exceed 24 hours. The answer to a sum of time periods is not "Next Wednesday at 09:45:25" Roger (talk) 16:44, 20 August 2011 (UTC)


 * You should be able to do this using the HOUR, MINUTE and SECOND functions, I think. AndyTheGrump (talk) 21:25, 20 August 2011 (UTC)


 * I don't think there is an inbuilt function / format to do this. If A6 contains your time, try =TEXT(INT(A6)*24+HOUR(A6),"0")&":"&TEXT(A6,"mm:ss") -- SGBailey (talk) 21:28, 20 August 2011 (UTC)


 * Format the cells using [hh]:mm. --Phil Holmes (talk) 11:18, 21 August 2011 (UTC)


 * Thanks for the replies. Roger (talk) 12:06, 22 August 2011 (UTC)

Router settings
I am trying to download files. Anything larger than 1.2mb seems to get stuck. The problem seems to be caused by a setting which is wrong on my router. What setting might this be? Kittybrewster  &#9742;  20:33, 20 August 2011 (UTC)


 * There's no home router setting, nor no rational browser setting, that says "break downloads at 1.2mb" or anything like that. I'd be like building a car with "wheels fall off at 150 miles from home" mode. For a download to fail, consistently, at such a low number would suggest either you have some fundamental connectivity issue or some defective hardware or software, neither of which is particularly diagnosable remotely. -- Finlay McWalter ☻ Talk 22:14, 20 August 2011 (UTC)


 * What's the MTU value set to in the router? Without knowing anything about your Internet connection this could have absolutely nothing to do with it, but I once had a similar issue with an ADSL line when I set the MTU value too high. It'd work okay, but when trying to sustain a connection it would drop off after a short while (much like your 1.2Mb). If your MTU is higher than 1478 try lowering it to 1452 or even 1412 as a test and see if it makes any difference (you'll need to reconnect to the Internet and likely need to reboot the entire router for it to take effect). Like I said though it might make no difference at all, but worth a look.  ZX81    talk  22:34, 20 August 2011 (UTC)


 * The only thing I've ever seen that fixes these kinds of problems on consumer grade routers is to update the firmware. There should be a page on the routers embedded web page that shows you how to do it. RxS (talk) 22:54, 20 August 2011 (UTC)


 * It could well be some kind of temporary problem with your ISP. If you know someone who knows enough about computers to be totally incomprehensible when they talk about how they work, get them onto it. In the meantime I would try to use a download manager if you need to get hold of any larger files. This came up in a search for 'smallest download manager'. This has worked well in the past for me, though there might be some fiddling involved. Nevard (talk) 00:05, 21 August 2011 (UTC)