Wikipedia:Reference desk/Archives/Computing/2012 February 2

Computing desk
< February 1 << Jan | February | Mar >> February 3 >
Welcome to the Wikipedia Computing Reference Desk Archives
The page you are currently viewing is an archive page. While you can leave answers for any questions shown below, please ask new questions on one of the current reference desk pages.


February 2 edit

restriction to fiction in Google Books edit

I would like to do a Google Books search for the phrase "Euclidean geometry" in works of fiction. It wouldn't have to be Google Books; anything that gives (almost?) the same information would suffice.

Does this exceed all that the Google corporation can accomplish? Michael Hardy (talk) 00:25, 2 February 2012 (UTC)[reply]

Unfortunately that is not possible with Google Books AFAIK. Maybe someone else knows an alternative. Von Restorff (talk) 00:40, 2 February 2012 (UTC)[reply]

Have you tried a computerized card catalog at your local library? These systems often allow you to search by subject, keyword, and classification (fiction, non-fiction). Library categorization (the Dewey Decimal Classification and the Library of Congress Classification) make it possible to explicitly search for fiction or non-fiction. Google's database indexes heuristically into an unstructured data collection (intended for searching internet web-pages), requiring a complicated algorithm to determine whether a work in their catalog is fictional or non-fictional. Libraries use structured data to catalog books, so their databases tend to be more easily searchable, especially if you know what you're looking for. For example, you can use http://catalog.loc.gov to include a boolean AND search term for the "fiction" category, in addition to any other keywords you are looking for. (For reasons I will never understand, Google felt that removing structured queries makes it "easier" to locate information). Anyway, a Dewey 813 is "Fiction, American English" - you can make that a requisite for your search. Nimur (talk) 00:59, 2 February 2012 (UTC)[reply]

Thank you, Nimur. Is there a way to restrict to Dewey numbers 813 or 823 in catalog.loc.gov? Michael Hardy (talk) 16:21, 2 February 2012 (UTC)[reply]
Actually no, because the Library of Congress uses... the Library of Congress Classification! It's better suited to research queries, so if you're looking for fiction, you need to be more specific: what type of fiction? Class P may be what you're looking for.
Dewey decimals are used by general-purpose public libraries (like your local library). You may be able to access their card-catalog online. Nimur (talk) 17:37, 2 February 2012 (UTC)[reply]

Alt code for ş edit

What's the alt code to type ş (s cedilla)? --108.225.115.211 (talk) 00:44, 2 February 2012 (UTC)[reply]

In Word? ALT+0350 or ALT+0351. Von Restorff (talk) 00:50, 2 February 2012 (UTC)[reply]
Those give me ^ and _. --108.225.115.211 (talk) 01:04, 2 February 2012 (UTC)[reply]
Hm, I have just booted my desktop and I have the same problem. The source was [1]. Which inputlanguage is selected on your computer? And which version of Windows do you have? Von Restorff (talk) 01:06, 2 February 2012 (UTC)[reply]
Windows 7; English (United States) --108.225.115.211 (talk) 01:13, 2 February 2012 (UTC)[reply]
It's not quite the same method, but 015F, then Alt + X works for me.--Kateshortforbob talk 11:06, 2 February 2012 (UTC)[reply]

Does quantum immortality imply NP⊆BQP? edit

It occurs to me that if quantum immortality is correct, then a quantum Turing machine can solve any problem in NP by simulating a random branch of the corresponding NTM and killing the observer if it's chosen a branch that doesn't lead to the desired answer. In other words, quantum immortality as I understand it would imply NP ⊆ BQP. Is that right? NeonMerlin 00:49, 2 February 2012 (UTC)[reply]

Shouldn't this be on the Science Desk ? StuRat (talk) 01:16, 2 February 2012 (UTC)[reply]
Actually the Math Desk, which in itself sort of answers the question. These classes of problems have precise mathematical definitions that do not depend on physics. If quantum mechanics turned out to be different than we think it is, that discovery would have no effect on what is "quantum computable" in the mathematical sense. --Trovatore (talk) 01:19, 2 February 2012 (UTC)[reply]

A program for calculating square units of area? edit

Is there a program that can calculate area (square units) or percentage of total area—of a rectangle? I want to be able to specify the two dimensions of a rectangle—such as 36 inches by 48 inches—and then I want to be able to indicate relatively simple polygonal shapes within such a rectangle. I want the program to tell me either the area of the polygon or its percentage of the whole. Obviously the above example would have a total area of 1728 square inches. I am interested in knowing the relationship between the areas of the polygons and the area of the whole. Thanks for any ideas or leads on a computer program that might make such calculations easier. I'm OK with calculating the area of rectangles, but as soon as I get into triangles or quadrilaterals that are not rectangles (or perhaps 5 sided figures) my ability to do these calculations falters. It may be that no such program exists. I want to use it to design a painting. I want to assign a percentage of total area to a color. Like for instance if I decide from the outset that I want to use a certain ten colors and I want each to be represented equally as concerns the total square units that each color occupies, how can I make adjustments to odd shapes, while retaining, in the above example, 172.8 square units per color? Thanks again. Bus stop (talk) 01:59, 2 February 2012 (UTC)[reply]

Sounds like you need a computer aided design program. In the one I'm familiar with, CATIA, what you are describing would be planar faces, and you can measure the area of each. However, CATIA is way more than you need, in that it's a 3D CAD system with surface modelling, solids, etc. You need a 2D system. StuRat (talk) 02:11, 2 February 2012 (UTC)[reply]

Google turned up this: http://www.mathopenref.com/coordpolygonarea2.html If you know the coordinates of each vertex, you can compute it like that. 69.180.172.142 (talk) 02:14, 2 February 2012 (UTC)[reply]

(ec) The area of a triangle is easy to calculate. Probably the best formula to use for your purposes is the one involving only the lengths of the three sides (no angles, no trig). If you have the three vertices, you can easily calculate the lengths of the sides. Then for quadrilaterals, pentagons, etc, what occurs to me is to cut them up into triangles (two for a quadrilateral, three for a pentagon, etc) and calculate the areas of the individual triangles and add them up. Bubba73 You talkin' to me? 02:15, 2 February 2012 (UTC)[reply]
I learned something: one can calculate the area of a triangle if one knows the three sides. Heron's formula is one way of accomplishing that. This site even does the calculation for you. Thanks a lot. I'll work with this for awhile. Much thanks. Bus stop (talk) 04:38, 2 February 2012 (UTC)[reply]
You may laugh, but I actually played Heron (or a triangle, it was a long time ago) in a play in primary school once. --Ouro (blah blah) 12:46, 2 February 2012 (UTC)[reply]
Octave (software) (free, but not very novice-friendly user interface) should be able to do this easily, once you figure out the right command to use. Jørgen (talk) 10:07, 2 February 2012 (UTC)[reply]
Geogebra has the benefit of not being overly complex and available via Java WebStart. 131.111.255.9 (talk) 13:26, 2 February 2012 (UTC)[reply]
Crossposted question. See the Humanities desk.

I'm interested in your answers to the questions I posted at the link above. I've posted a link here because if anyone would know how this would impact the Internet and Wikipedia, it would be you guys. The Transhumanist 02:35, 2 February 2012 (UTC)[reply]

Javascript Array question edit

  Resolved

This might be a dumb question — my brain is just not wrapping around this right.

I am stacking five circles in order of size. Each circle corresponds with a different measurement. I have all the measurement data in different variables. E.g., circle_1 = 5; circle_2 = 3; circle_5 = 4", and so on. I need to figure out what order of the circles goes from largest to smallest, based on the variable data. Then I need to be able to access them all in order.

In PHP, I would plug the variable names and the values into different variables. I would sort the values in a way that preserved the original keys. Then I would iterate over the value array with a foreach, grab the index, and use that to refer back to the original variable name, perform my actions, etc.

In Javascript, I'm somewhat lost. Their array object is far more primitive and less easy to work with and it seems like sorting in a way to preserve keys, much less using a real foreach, is not possible.

How would you solve this issue in an elegant fashion? --Mr.98 (talk) 13:50, 2 February 2012 (UTC)[reply]

Does Wikipedia:Reference desk/Archives/Computing/2011 November 27#HTML/Javascript list sorting help? -- Finlay McWalterTalk 14:34, 2 February 2012 (UTC)[reply]
Exactly what I was looking for. Works like a charm. Thanks so much. --Mr.98 (talk) 15:24, 2 February 2012 (UTC)[reply]
One small thing: your sort function is wrong. It should be function(a,b){return b[0]-a[0]), not function(a,b){return a[0]<b[0]). I don't know why, but that's the case! It doesn't work otherwise (even your examples don't). --Mr.98 (talk) 15:42, 2 February 2012 (UTC)[reply]
The reason is because a comparison function should have three possible return values: less than, equal to, and greater than. A boolean only has two; in JavaScript, a signed integer is used as the compare function return type, allowing tri-state comparison. Nimur (talk) 16:11, 2 February 2012 (UTC)[reply]

DNS servers edit

Okay I've read an article about the DNS serbers, but most part is written in "hacking" language (lol jk) I didn't understood how the servers make a domain... for example... I have a Dns server and going to make a domain (wikipediapwns.net) (just an example lol) for a random IP so Does my server sends the request to the boss DNS server or what? thanks! --190.60.93.218 (talk) 14:56, 2 February 2012 (UTC)[reply]

Basically, yes; but the "boss DNS server" (rather, the authoritative name server) usually has rules about who can register names, so you have to get permission from the system administrator. On the Internet, the top servers don't accept requests from anyone - you have to register through a licensed delegate company, called a domain name registrar, who usually charge a fee of about ten dollars per registration. Nimur (talk) 16:06, 2 February 2012 (UTC)[reply]
O.O Wow that's so expensive, anyway hmm how the "request is sent?" Fbchat? lol, So who control this authoritative servers? the goverment? Aliens? Can I have one? I think there are lot's of authoritative servers, so do they have to pay each other? or what? --190.60.93.218 (talk) 16:50, 2 February 2012 (UTC)[reply]
"The Internet" is controlled by ICANN. Thirteen root name servers are generally regarded to be "the authoritative" name servers for the internet. Your internet service provider almost certainly uses those servers. Those servers were originally operated for the United States Government by NASA, the Army Research Lab, a few other government agencies, and a few academic associates. During the 1980s and 1990s, legislation changed, allowing commercial entities to connect to (and register names on) what had previously been a private internet operated by the United States Government. A few more root name servers were set up and control of these systems were transferred to commercial companies. Suddenly, there was one "internet" that people commonly referred to when they spoke about The Internet. (Previously, any inter-connected network that used the internet protocol would be referred to as "an" internet).
You can set up an internet of your own, using the internet protocol, and operate your own root domain name servers. Anybody who wishes to connect their servers to your network could do so; but unless you have something to offer, few people will connect to your network. Nothing obligates you to use the domain-name-servers or the routers that your internet service provider offers to you. Nimur (talk) 19:37, 2 February 2012 (UTC)[reply]
Wow I could own an internetZ! Without SOPA! lol jk! Thanks lots for your answer, you're very helpfull (meh maybe I can now understan those wikipedia articles) Thanks!

Generate range of hex numbers edit

How can you generate a range of hex numbers? For example, I want all hex numbers with 7 digits. In python that's quite easy for integers with the range() command. 80.58.205.34 (talk) 18:30, 2 February 2012 (UTC)[reply]

If you want exactly the 7 digit numbers, use res = [hex(i) for i in xrange(16**6, 16**7)]. Note that this will be a fairly large list - I'd experiment with 4 and 5 first. --Stephan Schulz (talk) 19:18, 2 February 2012 (UTC)[reply]
Or you could just start counting from 0x1000000 (16,777,216) to 0xFFFFFFF (268,435,455) and convert it (which is essentially what Stephan's code does. Shadowjams (talk) 16:46, 4 February 2012 (UTC)[reply]
In Python 2.x, Stephan Schulz's code will produce a very large list in memory (around 230 million numbers I think). In 3.x it will produce a generator (computer programming), which is what you want. In 2.x you can make a generator with parentheses instead of square brackets:
for hexnum in (hex(i) for i in xrange(16**6, 16**7)): ...
will use a small constant amount of memory generating the hex strings. The other thing is hex(i) has a 0x prefix that you might not want. You can strip it off with hex(i)[2:] or use '%X'%i . 64.160.39.72 (talk) 18:26, 6 February 2012 (UTC)[reply]

Is TAR safer than ZIP? edit

Because I've heard lossless compression doesn't work as it should. (you loose some bits of data) --190.60.93.218 (talk) 19:21, 2 February 2012 (UTC)[reply]

Compression of data (like numbers or text, as opposed to compression of say music files or images) must inherently be lossless or will be useless. Should you want to compress a spreadsheet or a text file, every single bit and byte is important, because otherwise the data will be corrupt or the file unreadable. In an image or sound file, some data bits can be ommitted because the human ear or eye is just not sensitive enough. I'll let someone else elaborate, I'mm too sick to write too much, sorry. --Ouro (blah blah) 19:46, 2 February 2012 (UTC)[reply]
(EC) No. Neither is safer than the other. Both tar and zip compression methods are lossless compression methods, which, as the name suggests, is lossless. By contrast, jpeg compression is a lossy compression method, in which the algorithm identifies useless or near-useless bits of data and discards them in order to achieve better compression rates. Comet Tuttle (talk) 19:47, 2 February 2012 (UTC)[reply]
There is a caveat, though. As far as I know, zip compresses files individually, and then packs them into an archive. If, for some reason, the file becomes corrupt, you can still retrieve the intact files (as long as the meta-information is intact). If you use plain tar, this also holds, as tar itself does not compress at all. Indeed, you can basically extract all non-corrupted parts of files. However, if you use tar in combination with gzip (the popular ".tgz" files), you risk complete data loss if the file is partially corrupted, since compression is applied to the complete archive, not the individual files. --Stephan Schulz (talk) 20:20, 2 February 2012 (UTC)[reply]
What if I tar it but don't compress it? That means no Gz or other compression methods? — Preceding unsigned comment added by 190.158.184.192 (talk) 04:36, 3 February 2012 (UTC)[reply]
Then you can still recovered the uncorrupted files within the tar archive. Keep in mind that zip files can serve the exact same purpose as tar if you choose the "no compression" option. 99.245.35.136 (talk) 07:03, 3 February 2012 (UTC)[reply]
Note also that most archive formats, including TAR and ZIP include some sort of checksum, usually CRC-32, therefore you can generally know if each and any of the files contained therein have been accidentally (obviously not maliciously) corrupted. This isn't possible with generic unarchived files unless you have checksums or hashes stored somewhere or know where to find them for your files. Some files may contain their own checksums although you will need something which can intepret the file and will inform you if there is a problem to check it. If the file doesn't contain any external error checking code you may be able to guess from strange errors when you intepret it, but it may not be possible to be certain it wasn't originally like that. Nil Einne (talk) 09:42, 3 February 2012 (UTC)[reply]
Small point... TAR by itself doesn't do any compression, it uses drop-in libraries, most commonly gzip, but also sometimes bz2. Those are both lossless compression algorithms. The bzip2 man page says "As a self-check for your protection, bzip2 uses 32-bit CRCs to make sure that the decompressed version of a file is identical...The chances of data corruption going undetected is microscopic, about one chance in four billion for each file processed. Be aware, though, that the check occurs upon decompression, so it can only tell you that some thing is wrong." Shadowjams (talk) 16:42, 4 February 2012 (UTC)[reply]