Wikipedia:Reference desk/Archives/Computing/2013 August 26

From Wikipedia, the free encyclopedia
Computing desk
< August 25 << Jul | August | Sep >> August 27 >
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.


August 26[edit]

Connecting Securely[edit]

Is there a way to connect to Wikipedia securely (HTTPS)? — Preceding unsigned comment added by Rant-in-E-Minor (talkcontribs) 04:22, 26 August 2013 (UTC)[reply]

Yes. Click on https://www.wikipedia.org/ and log in from there. See WP:Secure server for more details. --220 of Borg 04:51, 26 August 2013 (UTC)[reply]

Why does printf in C use const char * instead of char *?[edit]

I understand the difference between what it means to have const char * and char *. However, behind the scenes in C or conceptually, why does printf require a const char * instead of a char *? — Preceding unsigned comment added by 70.173.127.106 (talk) 04:47, 26 August 2013 (UTC)[reply]

By specifying it to accept 'const char*', it will take both 'char*' and 'const char*'. If it were specified to take a 'char*' (which implies that printf might modify the string you passed to it) you wouldn't be able to pass constant strings to printf. Unilynx (talk) 06:41, 26 August 2013 (UTC)[reply]
Wikipedia has an article on const-correctness (the term for the concept at play here). -- 205.175.124.72 (talk) 02:46, 30 August 2013 (UTC)[reply]

Bit arrays in JavaScript[edit]

Is there any way to implement efficiently bit arrays in JavaScript, I wouldn't like an Uint8Array because then I would have to deal with bit masks, and in some algorithms for example base64, it's easier than using bit masks. In the base 64 algorithm you could simply append all bits then split by 6 and you get the result, instead using bit shifting, you must take care of the offset of each byte, add, rest, add shifts, and memorize the offset and offsetlength too, it just might be inefficient and probably more complicated, so what do you recommend? 190.157.115.179 (talk) 06:26, 26 August 2013 (UTC)[reply]

Current processors don't have architectural bit arrays (they deal in bytes and words etc.) so to do tasks like you're describing, someone has to do masks and shifts in software. Ideally this would be in C or asm, but there isn't a standard JavaScript language feature to leverage that. So it'd need to be done in JavaScript; there's any number of libraries Google and npm will find that do that. Shifts and masks are fast in-register instructions (and these kind of translations are the easiest kind for a VM to emit). Most tasks on modern computers are overwhelmingly cache and IO bound. My recommendation would be to use one of the free implementations you'll find (they vary a bit in their dependencies and the features they offer) and then profile your whole program. Only if you can show, with real hard numbers, that the bitarray implementation has a significant effect on the performance of a real task should you worry about whether the implementation isn't fast enough. -- Finlay McWalterTalk 13:24, 26 August 2013 (UTC)[reply]
Would an Array wrapper work, a wrapper around Uint8Array which reads as a bit array and sets internally a Uint8Array work? 190.60.93.218 (talk) 14:05, 26 August 2013 (UTC)[reply]

router log[edit]

every time i check the event log on my router, there's alot of entrys like this, "Monday, August 26, 2013 1:57:15 AM Unrecognized attempt blocked from x.x.x.x:port to 70.114.248.114 TCP:36117". i'm wondering what that means. (levelone wbr-6001.) thank you, 70.114.248.114 (talk) 09:08, 26 August 2013 (UTC)[reply]

It means some machine on the internet tried to connect to your network. The source port, which you've redacted, would tell us what that machine was trying to do; see list of TCP and UDP port numbers#Well-known ports. Sometimes it's peer-to-peer networking, where a machine in a p2p swarm remembers that your IP address used to contain another member, and it's trying to get back into touch (e.g. where the machine which previously had your IP address was a member). Other times it's some malware on a compromised machine, running as part of a botnet, trying to find open ports on your machine in order to try to exploit vulnerabilities and compromise your machine. If you tell us the port number you redacted (not the IP, that's not interesting) we might know more. None of this is at all exceptional - just about every address in an assigned block gets probed pretty regularly by malware. -- Finlay McWalterTalk 13:11, 26 August 2013 (UTC)[reply]

Laptop video card upgrade[edit]

Resolved

Hello. I'm planning to upgrade my laptop's 4570M to 4650M (around twice the performance). Both cards use MXM3 Type A connector, so they can be replaced with ease. However I am worry about the power consumption. From what I've heard, desktop video card upgrade depends on the PSU -- you cannot upgrade if your PSU cannot handle the power consumption of the new hardware. But I don't know whether or not a laptop has PSU. I cannot find official document from AMD, but from a quick search:

  • Mobility Radeon 4570 TDP: 15 Watt
  • Mobility Radeon 4650 TDP: 35 Watt

Is that possible to perform the upgrade? And does the TDP have anything to do with the heat dissipated? I'm afraid my laptop's cooling is not enough to withstand the new video card if its heat to be dissipated is much more than the old one's. I need some advices! -- Livy (talk) 09:35, 26 August 2013 (UTC)[reply]

The new card will draw up to 20 more watts of power from the laptop's power circuitry. It may not be able to handle this. It will also put out about 20 more watts of heat - more than double the old one, so the cooling likely will not be enough. If the laptop was ever sold with an option for the upgraded card you may be lucky, and have a system that was designed to handle the increased power load and heat output. You can also try searching forums to see if anyone else has had luck with that upgrade in that model of laptop. Jessica Ryan (talk) 14:30, 26 August 2013 (UTC)[reply]
I feel like I should add that by "may not be able to handle it", I really meant "may lead to damaged components, burnt traces, or other permanent damage to the motherboard." Of course, it could just work without a problem. Jessica Ryan (talk) 15:47, 26 August 2013 (UTC)[reply]

The TDP of the 4570 and 4650 is 15W and 25W respectively according to notebookcheck.net (they say AMD publishes that info). So the 4650M is only 10 Watt more. My laptop's cooling system is designed to handle a CPU of 35W and a GPU of 15W -- a total of 50W under full load. However when gaming, the CPU load is 70% at worst (maybe 30W I think) while the GPU is at full load (25W). My laptop is not sold with an upgrade option available, but I hope it can handle 55 - 60W, which is only 10 -> 20% more. I will perform the upgrade tomorrow, and check the temperature to see if things go well. Thanks for your answer. -- Livy (talk) 16:55, 26 August 2013 (UTC)[reply]

Livy, just following up - have you had a chance to try the upgrade yet? Did it work? Jessica Ryan (talk) 11:52, 28 August 2013 (UTC)[reply]

Java and immutable strings[edit]

I've been told that strings in Java are immutable. But you can change a string by adding or taking characters away. So what does it mean for strings to be immutable? Thanks, Dismas|(talk) 10:10, 26 August 2013 (UTC)[reply]

No, you can't change a java.lang.String by adding or taking characters away. Methods in that class which remove or replace stuff return a new String; they don't mutate the original. And if you write code that looks like this:
public class s{
    public static void main(String[] args){
        String t = args[0]+"hello";
        System.out.println(t);
    }
}
and decompile the resulting class file (with javap -c s.class) you'll see that the String+String syntax is sugar - the real bytecode constructs a java.lang.Stringbuilder, makes two calls to its append() method, and then builds the final immutable String with a call to toString(). StringBuilder and its cousin StringBuffer are mutable, but neither is a String. -- Finlay McWalterTalk 10:40, 26 August 2013 (UTC)[reply]
If my memory serves correctly, java.lang.String is unique as the only object in the Java programming language that uses operator overloading: the "+" and "=" operators are actually aliased as copy, append, and new functions, as the compiler sees fit. This is the syntactic sugar Finlay described. Strings have their own section in the Java language reference because of their special status. Nimur (talk) 15:20, 26 August 2013 (UTC)[reply]
I don't think that = is any different for String than for any other non-primitive type; it just assigns a reference to a variable (or field or array element). (The only reason I can think that it might be useful for it to be special would be to allow a magical in-place modification (instead of a pointer assignment) to take place when a String was unshared, and I doubt that the JLS allows that.) Certainly + is special — and special even when just one of the operands is a String, since the other object is stringized and can even be null. --Tardis (talk) 02:27, 27 August 2013 (UTC)[reply]
Consider: String s = "The quick brown fox..."; in which a string literal is assigned to an uninitialized String object reference. Somehow, the JVM must be informed that it should call the String constructor. To be fair, I can't recall whether the compiler does this for every string literal rvalue or only for lvalues when an "=" is present. Nimur (talk) 05:05, 27 August 2013 (UTC)[reply]
Every string literal in a Java program corresponds to a String object that is created when the class is loaded (from its constant pool). (Actually, since such strings are interned, it may reuse another String object instead.) The assignment is just that, an assignment of that prefabricated object. --Tardis (talk) 01:34, 28 August 2013 (UTC)[reply]
Tardis is correct, there is nothing special about the "=" assignment operator when it is applied to Java strings. I was in error on this detail. "+" is still a special syntax, though. The Java language specification linked above ought to be the canonical reference for this kind of information, and i should have checked it first. Nimur (talk) 15:59, 28 August 2013 (UTC)[reply]
(tangential refs:) If you are interested in a philosophical/information science point of view on these issues (mutability of digital objects, how we reference them, etc.), you may enjoy "Documents Cannot Be Edited" [1], or "When digital objects change — exactly what changes?" [2]. SemanticMantis (talk) 16:02, 26 August 2013 (UTC)[reply]
The Java programmer's response to those conundrums is that a Document should be modeled as an object that may implement the serializable interface, and may also override the toString method. This allows an instance of a document (which might be mutable) to provide methods that return a String (which is always immutable). Mutable Document objects can be modified; mutating the document instance may cause it to map to a different String object (i.e., its serialization utility method will return a different String). One fairly non-trivial example is org.w3c.dom.Document, used to represent abstractions of a Document Object Model which will be familiar to web developers and HTML authors. The experienced Java programmers will note that this Document object is not Serializable; but instead, inherits from a complex class structure, and provides numerous explicit and implicit mechanisms to produce string representations. Each potential string-representation has various useful characteristics that the Java programmer could use for specific applications. Nimur (talk) 19:47, 26 August 2013 (UTC)[reply]

Same URL, Different Behaviour[edit]

If I do a Google search for "Crush the Castle", the first hit returned is to http://armorgames.com/play/3614/crush-the-castle. The Flash window is black, and the game (presumably) never loads. If however, I go to http://armorgames.com and search for that string, I get sent to http://armorgames.com/play/3614/crush-the-castle and can play the game without problem.
What gives? Exactly the same URL, different behaviour. I can click on either of the links above and it works, so it's something about the route via Google that screws it up. I'm using Win7 and, ironically, the latest version of Chrome Rojomoke (talk) 13:04, 26 August 2013 (UTC)[reply]

The script may use a Referrer url so it reads where you came from and according to that it may behave differently. 190.60.93.218 (talk) 13:22, 26 August 2013 (UTC)[reply]
190.60.*'s probably right. Funny because you'd think the path through google would be fine... --.Yellow1996.(ЬMИED¡) 20:46, 26 August 2013 (UTC)[reply]

I want to buy this[edit]

http://enterprisesuite.intuit.com/products/enterprise-solutions/?qbes_info-b=pricing

I want to buy the quickbook enterprise 10 user license. Anybody with any idea where I can get it? Probably a second hand or maybe a site with a better price maybe like a used one. Or just the cheapest but genuine deal I can get. Please help. — Preceding unsigned comment added by 41.215.119.10 (talk) 14:48, 26 August 2013 (UTC)[reply]

Intuit's licence for Quickbooks says people may not transfer the licence. So there's really no such thing, in most jurisdictions, as a licence that's both genuine and used. -- Finlay McWalterTalk 15:20, 26 August 2013 (UTC)[reply]

Haswell benefits for desktop computers.[edit]

I know Intel's "Haswell" chip design has vastly improved energy savings for laptops which lead to better battery life. But what benefits does Haswell bring a desktop computer over the previous Ivy Bridge design? --208.185.21.102 (talk) 17:13, 26 August 2013 (UTC)[reply]

Have you read Intel's very thorough promotional literature, including An Introduction to the Intel 4th Generation Core Processor, and the rest of the material on the 4th Generation Core Processor (code-name Haswell) web-page? Those links pretty much cover the top-level features, including energy use, graphics performance, AVX 2.0, faster calculations of cryptographic functions... Nimur (talk) 19:52, 26 August 2013 (UTC)[reply]
So it sounds like the answer to my question is: "not much". Those linked articles seem very technical. Graphics performance is irrelevant on desktop since it'll almost always have a discreet GPU. AVX 2 requires programs to be specifically written for it. And energy usage -- a cooler desktop, perhaps less fan noise? Pretty minor benefits. --208.185.21.102 (talk) 18:17, 28 August 2013 (UTC)[reply]

Perl: Creating a hash that contains two lists[edit]

use Data::Dumper;
my %hash = (
    'list1' => ( 1, 2 ),
    'list2' => ( qw( a b c ) )
);
print Dumper(\%hash);

I thought this would create two key-value pairs for %hash.

$hash{'list1'} = ( 1, 2 )

and

$hash{'list2'} => ( qw( a b c ) )

However, what I get is some kind of mess that looks like:

$VAR1 = {
          'list1' => 1,
          '2' => 'list2',
          'a' => 'b',
          'c' => undef
        };

Perl actually thinks I am creating a hash that contains following key-value pairs:

my %hash = ('list1', 1, '2', 'list2', 'a', 'b', 'c');

I tried to create two lists and put them in the hash as keys' values. It doesn't work.

my @list1 = ( 1, 2 );
my @list2 = ( qw( a b c ) );

my %hash = (
	'list1' => @list1,
	'list2' => @list2
);

I then tried this way ....

my @list1 = ( 1, 2 );
my @list2 = ( qw( a b c ) );

my %hash = ();
$hash{'list1'} = @list1;
$hash{'list2'} = @list2;

Perl gives me:

$VAR1 = {
          'list1' => 2,
          'list2' => 3
        };

Dear Santa, I promise I'll be a good boy for the rest of my life. Please forgive me!

How do I create this hash correctly? -- Toytoy (talk) 20:26, 26 August 2013 (UTC)[reply]

Replace those lists with list references:
   use Data::Dumper;
   my %hash = (
       'list1' => [ 1, 2 ],
       'list2' => [ qw( a b c ) ]
   );
   print Dumper(\%hash);
--Mark viking (talk) 20:31, 26 August 2013 (UTC)[reply]
Mark is correct. Arrays and hashes can only store scalar values, so you must use references in order to nest arrays and hashes. Σσς(Sigma) 04:14, 27 August 2013 (UTC)[reply]
One small addition. Hash keys can't be references, only the values can. If you try to do it, they get flattened into a nice memory address. Sometimes that's a feature. Shadowjams (talk) 03:19, 29 August 2013 (UTC)[reply]

my acer laptop overheats how to fix it[edit]

my new acer laptop overheats how do i fix it without a new computer thx 65.175.255.68 (talk) 23:01, 26 August 2013 (UTC)[reply]

You haven't remotely given us enough information. And if it is faulty, why don't you complain to whoever you bought it from? AndyTheGrump (talk) 23:20, 26 August 2013 (UTC)[reply]
And incidentally, you'll generally find that you get better responses if you don't vandalise Wikipedia: [3][4]. AndyTheGrump (talk) 23:26, 26 August 2013 (UTC)[reply]
If your laptop gets hot, that could be normal. Most electronics get surprisingly warm, so whether or not it is even overheating is still in question. How hot does it get? Mingmingla (talk) 23:28, 26 August 2013 (UTC)[reply]
Generally speaking, if it's still tolerable to touch then it's probably okay. --.Yellow1996.(ЬMИED¡) 00:54, 27 August 2013 (UTC)[reply]
1) Make sure it has good air flow all around it. So don't set it on your lap or on a blanket. They make metal stands that allow airflow in, and also conduct heat away. Of course, this makes it less portable. A glass or metal table would work fairly well, but wood is a good insulator, so you would have to reposition it once a spot on a wooden desk gets hot.
2) If that's not enough, you can point an external fan at it. That can make quite a difference.
3) If new, the vents shouldn't yet be clogged with lint, but by "new" you might mean "new to you", AKA, "used". If so, clean those vents with a vacuum cleaner.
4) It may be defective, such as not having the heat-sink properly attached, or perhaps the cooling fan doesn't work. If so, and if it really is new, take it back. StuRat (talk) 05:10, 28 August 2013 (UTC)[reply]