Jump to content

Wikipedia:Reference desk/Archives/Computing/2012 October 18

From Wikipedia, the free encyclopedia
Computing desk
< October 17 << Sep | Oct | Nov >> October 19 >
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.



October 18

[edit]

Android phones under $100 unlocked

[edit]

Are there any Android phones that cost under $99 unlocked? Write English in Cyrillic (talk) 10:26, 18 October 2012 (UTC)[reply]

Yes. See here. Other mobile phone retailers are available. - Cucumber Mike (talk) 10:42, 18 October 2012 (UTC)[reply]

HTTP request in java.

[edit]

Hello!, so I'm having trouble with this ridiculous java API. It just doesn't like HTTP responses that start by 4 or 5.

So for example if I want to read the response of the 403 error I can't, because it throws:

Exception in thread "main" java.io.IOException: Server returned HTTP response code: 403

So, How can I make java ignore these 'errors'? (And still be able to 'read' from them)190.60.93.218 (talk) 14:57, 18 October 2012 (UTC)[reply]

I am not much at Java programming, but surely the intention is that you will catch the errors and — having caught them — know that the server has returned an error, and then handle it correctly? --Mr.98 (talk) 15:24, 18 October 2012 (UTC)[reply]
I assuming you're using java.net.HttpUrlConnection()? I don't have a url offhand that 403s to test this, but you should be able to get the full response message line by calling the connection's getResponseMessage() method (as opposed to getResponseCode(), which should just give you the 403 itself). If someone can think up a public URL that 403s then I'll test this myself. -- Finlay McWalterTalk 15:28, 18 October 2012 (UTC)[reply]
It was harder than expected to find a 'public' 403 error. Just had to find and old server... Altough you can simulate one with php.. or python.. anyway here you go. [1]190.60.93.218 (talk) 17:10, 18 October 2012 (UTC)[reply]
But to your general point - can you handle error codes without the library turning them into exceptions (and thus turning your code in to layers of nested catch blocks) - I don't think so: error->exception is the style of the library. Apache's HTTPclient library isn't so keen to throw exceptions on ordinary server error codes. -- Finlay McWalterTalk 15:4I2, 18 October 2012 (UTC)
Hey, thanks guys you kinda solved it. Anyway a 'simple' try/catch managed to fix it. (I don't really like try/catch, seems unclean)
InputStream is;
      try{
      is = connection.getInputStream();}
      catch(IOException therror){
      is = connection.getErrorStream();
      }

so that fixed it, thank you. 190.60.93.218 (talk) 19:12, 18 October 2012 (UTC)[reply]

Try-catch blocks are an essential feature of the Java programming language: in fact, they are documented in the officialJava Essential Tutorials. If you come from a C++ background, you may have had some strange experience with exception-handlers and catch blocks; but in Java, try/catch blocks are a lot more robust. Every exception must be explicitly declared and handled. Exceptions in Java are quite unlike C++; in C++, a "throw" is basically a glorified goto statement, and a "catch" is essentially little more than a statement label. In Java, the exception mechanism is strongly-typed, strongly enforced, and guarantees certain program flow. Here's an interview with Java creator James Gosling, on Failure and Exceptions, in which he extolls the virtues of Java's programming language features. Compare this toStroustrup on C++ exception handling, which is put forth as an easy way to implement the RAII paradigm, (in a way that's un-enforceable by a C++ compiler). Nimur (talk) 23:56, 18 October 2012 (UTC)[reply]
Uh... your description of C++ exceptions is pretty far from reality. -- BenRG (talk) 06:54, 20 October 2012 (UTC)[reply]
By all means, please provide a counter-point and cite a source. With exactly which part of my description do you take exception? Nimur (talk) 17:04, 21 October 2012 (UTC)[reply]

cpu fan

[edit]

1: my pc has two fans in the case, one in the power supply, and one on the heat-sync over the cpu. if i unplug the cpu fan, what are the chances of the cpu overheating, and the motherboard shutting off power? 2: the fan and heat-sync came with the cpu. can i get a replacement fan that fits from a different company? 3: how much would that cost? 4: there is a quit grinding sound coming from the cpu fan. every two seconds or so. what might cause that, and how might i fix it? thank you, 70.114.254.43 (talk) 20:34, 18 October 2012 (UTC)[reply]

  1. Very high chance. Not a good idea.
  2. Yes
  3. Not much. $10 to $30, maybe, depending on what sort of processor it is cooling
  4. Odd time signature, but most likely failing bearings. Essentially unfixable. Check that it's not merely bunged up with dust; clean it with an air duster (air can) and/or paintbrush and vacuum cleaner. If that doesn't fix it, replace it. --Tagishsimon(talk) 20:53, 18 October 2012 (UTC)[reply]

what would cause the bearings to fail? is that catastrophic, or does it just make an annoying sound?70.114.254.43 (talk) 02:11, 19 October 2012 (UTC)[reply]

Cause is probably poor seals, ingestion of abrasive particulate matter, leading to wear. Tends to be degenerative, in that it gets worse and eventually seizes. --Tagishsimon (talk) 02:15, 19 October 2012 (UTC)[reply]
Yes. Once the fan starts making noise like that, its life span will usually be very limited. You should replace it now, or expect to have a nonfunctional computer while you acquire a new one. Unless you have a very low-power CPU or a very special setup, you usually can't run for more than a couple of minutes without a fan without overheating. Looie496 (talk) 02:25, 19 October 2012 (UTC)[reply]
If the CPU fan does fail before you can replace it, remove the case and point a window fan at it. This workaround should keep your computer operational until you can replace the CPU fan. StuRat (talk) 02:48, 19 October 2012 (UTC)[reply]
Back to the original question:
  1. Without the fan, the CPU is going to overheat, but it'll do so slowly enough that the computer will shut down without anything being damaged.
  2. Computer fans are highly standardized. Any fan of the same diameter and thickness with a two-pin, three-pin, or four-pin connector should work (the extra pins give the computer better control of the fan speed; without them, the computer usually just runs the fan at full speed).
  3. I'd be amazed if a replacement fan cost more than $10.
  4. Intermittent grinding is almost always a failing bearing: with a ball-bearing fan it's caused by an irregularity moving on and off of the bearing surface, with a sleeve-bearing fan, it's caused by alignment shifts in the bearing. You could try to fix it by disassembling the fan and cleaning or lubricating the bearings, but that's a lot of work for an uncertain outcome. Replacing the fan is faster and more reliable.
--Carnildo (talk) 01:36, 20 October 2012 (UTC)[reply]
Another possibility is that a cable in occasionally striking the fan blade. StuRat (talk) 05:17, 20 October 2012 (UTC)[reply]
my experience: inherited a dead PC from a friend. upon examination, cpu fan was not running. figured what the heck, got a combination cpu fan and heatsink from radio shack for something cheap. (didn't have just a fan). removed the fan from each, swapped them, now have a working PC and a spare cpu heatsink, plus a dead fan. interesting point is that overheated cpu apparently causes no permanent damage to the cpu or the files on the drive or anything else.Gzuckier (talk) 15:21, 25 October 2012 (UTC)[reply]