Wikipedia:Reference desk/Archives/Computing/2016 June 26

Computing desk
< June 25 << May | June | Jul >> Current desk >
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.


June 26

edit

Looping and Deleting a property in JS

edit
var user = {terms:1};
    var targets = ['terms'];

    for(var key in targets){
      delete user[key];
    };
    console.log(user); // Doesn't work

    for(var key in user){
      if(targets.indexOf(key) > -1){
      delete user[key];
      }
    };
    console.log(user); // Works

How come the second way works but the first way doesn't work? Is it just me or is this nuts? I'm using Node.js 4.4.5, but I suspect this behavior is considered normal in JS and thus should be reproducible across all JS engines. Johnson&Johnson&Son (talk) 05:30, 26 June 2016 (UTC)[reply]

Also:

var user = {terms:1};
    var targets = ['terms'];

    user = {terms:1};
    delete user['terms']; // Works 

    user = {terms:1};
    delete user.terms; // Works, grammatically identical to user[key], simply just syntax sugar

    
        for(var key in user){
          if(targets.indexOf(key) > -1){
          delete user.key; // Doesn't work anymore
          }
        };
        console.log(user);

Every question/answer I came across[1][2] says delete foo.bar and delete foo[bar] are identical, and that you can use whatever one. And every one of those answers are accepted by thousands of people with no significant disagreement. So I'm assuming those answers are correct.

And yet I'm seeing actual JS engine behavior that shows that delete foo.bar won't work in certain situations, and thus I should be using delete foo[bar] in all cases, just for uniformity sake. What's going on here? Johnson&Johnson&Son (talk) 05:39, 26 June 2016 (UTC)[reply]


The key that you get from for(var key in targets) is not the string "terms" but the number 0 (the index of the only element of targets), so you need to say delete user[targets[key]]; AndrewWTaylor (talk) 09:28, 26 June 2016 (UTC)[reply]
Your sources say (correctly) that delete foo.bar is equivalent to delete foo["bar"]. In your code, you want delete user[key], not delete user["key"]. -- BenRG (talk) 18:01, 26 June 2016 (UTC)[reply]
I still can't reproduce how they're equivalent:
var user = {terms:1};
var user2 = {terms:1};
var targets = ['terms'];

for(var key in user){
  if(targets.indexOf(key) > -1){
  delete user[key]; // Works
  }
};
console.log(user); 

for(var key in user2){
  if(targets.indexOf(key) > -1){
  delete user2.key;  // Doesn't work
  }
};
console.log(user2);
user's terms get correctly deleted, but user2 doesn't. Somehow user2.key doesn't work.
Like I mentioned before, if it doesn't work in this particular narrow situation, then that's incentive enough to **never** use the user2.key form for consistency's sake.
What am I missing here?Johnson&Johnson&Son (talk) 09:29, 27 June 2016 (UTC)[reply]
You're confusing the value of the variable key (which is "terms") with its name, which is the string "key". The line delete user2.key means "delete the element of user2 whose name is (the string) "key", but what you want to do is "delete the element whose name is the value contained in key". Using the actual name of the property, the two versions of the code are delete user.terms and delete user["terms"]. If you don't know in advance what the property name is then (e.g. if you get it from a for loop) then you can't use the first style. (Well, except by evil code such as eval ("delete user." + key);AndrewWTaylor (talk) 11:36, 27 June 2016 (UTC)[reply]

Kibibyte popularity

edit

Is there any reason "kibibyte" hasn't gotten into common use even nearly 20 years after it was first proposed?? Do many people disagree with it even in response to being aware of the reason it was proposed despite understanding why?? Georgia guy (talk) 13:28, 26 June 2016 (UTC)[reply]

It sounds silly. And to my Slav ears also slightly dirty. Asmrulz (talk) 15:45, 26 June 2016 (UTC)[reply]
It sounds like a brand of catfood to me. But I agree it's a horrible word, and "kilobytes" (unlike "megabytes") has never meant anything other than 1024. Tevildo (talk) 18:33, 26 June 2016 (UTC)[reply]
It also fails in some situations. Try converting a "1.44 MB" floppy disk to an exact number of bytes using either (increment-of-1000) kilobytes or (increment-of-1024) kibibytes. The floppy manufacturers counted up how many (1024-byte) kilobytes they had, got a total of 1440, then divided the 1440 by 1000 (not 1024) to get "1.44 MB". --Guy Macon (talk) 18:35, 26 June 2016 (UTC)[reply]
I think most people who were accustomed to speaking of kilobytes and megabytes and gigabytes in terms of powers of 1024 simply saw no reason to change. We knew that those prefixes have other meanings in other contexts, but so what? Lots of things in English are like that. (And anyway, we usually just say "K" and "meg" and "gig".) But I'm speaking from a North American perspective. It would be interesting to know if "kibibyte" and the others have been more widely accepted in countries where the metric system is more firmly entrenched in people's minds. --69.159.9.187 (talk) 04:53, 27 June 2016 (UTC)[reply]
No, here in central Europe Kibibyte is not used very often. You lern that kilo means 1000 that doesn’t mean Kilobyte is always meant to be 1000 Bytes. --Morten Haantalkskin draft 01:20, 29 June 2016 (UTC)[reply]

3 long beeps 4 short beeps HP Pavilion B&O all-in-one

edit

Dear Wikipedians:

What is the meaning of 3 long beeps and 4 short beeps for HP Pavilion B&O all-in-one computer? I got this after I turned it on today, it was a black screen, accompanied by several cycles of 3 long beeps followed by 4 short beeps (i.e. 3 long beeps, 4 short beeps, 3 long beeps, 4 short beeps, 3 long beeps, 4 short beeps, so on an so forth). But my computer eventually booted up Windows after the cycles of beeps and black screen.

Any help regarding the meaning of these beeps would be much appreciated. The computer is still usable right now. I bought a 5 year warranty for the computer, I was also wondering if I should take it to the shops?

Thanks,

198.91.175.103 (talk) 15:12, 26 June 2016 (UTC)[reply]

HP has a support page detailing the meanings for beep codes here, but I don't see 3 long and 4 short on there. If the machine is under warranty, I'd recommend contacting HP (or whoever sold you the warranty if not the manufacturer) directly and inquiring about service. It may be something as simple as a stuck keyboard key or dust build-up in the fans or air vents on the chassis. clpo13(talk) 15:19, 26 June 2016 (UTC)[reply]
Thanks, I will do that. L33th4x0r (talk) 16:25, 26 June 2016 (UTC)[reply]
Does it happen consistently ? If not, there may not be much point in taking it in for service, as it may not happen for them, or may stop happening just by chance, after they do something, making them incorrectly think that was the problem. StuRat (talk) 18:14, 26 June 2016 (UTC)[reply]
No it does not happen consistently. Things seem to work properly for now. So I'll take your advice and continue observing the computer and not take it to the shop for now. 198.91.172.66 (talk) 02:39, 2 July 2016 (UTC)[reply]
  Resolved

Identification of model of White-Rodgers

edit

Dear Wikipedians:

Could anyone identify which model of the White-Rodgers thermostat in the photo below?

 
A White-Rodgers Thermostat of unknown model. Which model is it?

Thanks,

L33th4x0r (talk) 16:24, 26 June 2016 (UTC)[reply]

It would appear to be a 1F82-51. This is the user manual from the manufacturer's site. Tevildo (talk) 18:00, 26 June 2016 (UTC)[reply]
Actually, it's more likely to be a 7104. This is the 7104 manual. Note that the 7104 does not have the three indicator lights above the LCD of the 1F82 - neither does the thermostat in the photo. Is it battery or mains powered? That should be decisive. Tevildo (talk) 18:06, 26 June 2016 (UTC)[reply]
Thanks a lot!!! 198.91.175.103 (talk) 17:10, 27 June 2016 (UTC)[reply]
  Resolved

What's up with missing model numbers ?

edit

Inspired by the above Q, what's up with manufacturers not putting the model number on their products ? Many seem to lack that info next to the manufacturer name, where it used to be placed prominently. If listed at all, it seems to be on a sticker on the back along with the serial number and specs. Do customers not want to see model numbers on the front ? If that's not the reason, what is ? StuRat (talk) 18:10, 26 June 2016 (UTC)[reply]

Maybe they think it make it look too cluttered? I don't know any product designers to ask ): 104.229.143.192 (talk) 22:26, 26 June 2016 (UTC)[reply]
Some manufacturers use very long model numbers that presumably encode detailed meanings for them. For example, we have a Bosch SHX9ER55UC/50 dishwasher. That wouldn't look good if it was prominently placed on the exterior. --69.159.9.187 (talk) 04:57, 27 June 2016 (UTC)[reply]
Now I wonder why they have such ugly model names/numbers. Do they really expect people to walk into the store and say "Show me your SHX9ER55UC/50, in white, please" ? Car manufacturers seem to have it figured out. Use a model name and number that's memorable and not too ugly to display, like Corvette ZR-1. StuRat (talk) 04:22, 28 June 2016 (UTC)[reply]
No, they don't. And you're being silly. This is not a request for information. --69.159.9.187 (talk) 08:17, 28 June 2016 (UTC)[reply]
I don't understand your response. After I research a purchase online I then often go into the store and ask for the model number I decided on. StuRat (talk) 16:45, 30 June 2016 (UTC)[reply]

Headphones

edit

A Logitech headphone with a mic attached is sought. The average desired spec limit is as follows: Frequency response - 17-21,000 Hz|Cable length - 1.5 m|Impedance - 32|Sound pressure level - 115db (1kHz/1V rms). Around $10-20 or so? -- Apostle (talk) 18:11, 26 June 2016 (UTC)[reply]

Err - there aren't any. This is their current range of headsets that meet your performance requirements, and you'll note that the prices are decidedly above your budget. This is their range of headsets within your budget, but they don't have the performance you're looking for. Tevildo (talk) 18:26, 26 June 2016 (UTC)[reply]
Okay, thank you.
I'm specifically looking for one with the microphone stick that can be turned 180 degree or more; if you know what I mean. Do you know what it is called? What type? from your second link, Model No: H111, H151, H150, H110 looks like it does what I wish for it to do...
What brand is highly praised for Headset w/Microphone anyway? -- Apostle (talk) 18:52, 26 June 2016 (UTC)[reply]
For the rotatable microphone, the term is "reversible". If you're prepared to compromise on the maximum volume and (to a lesser extent) on the frequency range, any of the cheaper Logitech headsets should be OK. There are plenty of review sites available for consumer electronics, so one of those sites might be a better place to look for opinions. Tevildo (talk) 20:29, 26 June 2016 (UTC)[reply]

Just out of curiosity, do you imagine that you can hear as low as 17 Hz or as high as 21,000 Hz? Are you by any chance a dolphin? :) --Guy Macon (talk) 06:19, 27 June 2016 (UTC)[reply]

He could be one of them humans. From Hearing range: Under ideal laboratory conditions, humans can hear sound as low as 12 Hz and as high as 28 kHz. 91.155.195.247 (talk) 11:23, 27 June 2016 (UTC)[reply]
Lmao. You two are too funny. -- Apostle (talk) 20:05, 27 June 2016 (UTC)[reply]
Thanks Tev   Don't mind about the opinion thing; I thought you (or any other) might do a research and, at least provide a link or so if not a name. -- Apostle (talk) 19:51, 27 June 2016 (UTC)[reply]

How to find out what s my current Headset w/Microphone specification is? I don't have the packaging... -- Apostle (talk) 19:05, 26 June 2016 (UTC)[reply]

Check the device, battery case for modell information. Use google picture search. --Hans Haase (有问题吗) 20:28, 26 June 2016 (UTC)[reply]
Didn't cross my mind... -- Apostle (talk) 19:51, 27 June 2016 (UTC)[reply]
It's not just a question of being able to hear as high as 21,000 Hz. A high upper frequency response is beneficial to the rise time of lower frequencies. That is, the upper limit is a measure of how well the device is able to reproduce the steeply rising waveforms of lower frequencies. Therefore, a person whose hearing cuts off at say, 12 KHz, still derives benefit from the better reproduction of frequencies up to 12 KHz. Think of it this way: assume a square wave running at 5 KHz. If the device's frequency response cuts off at say, 6 KHz, the square wave will be reproduced but it won't sound very 'square'; the vertical sides and corners will be rounded. With upper reproduction extended to 21 KHz, the ability of the device to reproduce the steeply rising sides and corners is very much enhanced. Akld guy (talk) 15:38, 27 June 2016 (UTC)[reply]
Noted.   -- Apostle (talk) 20:07, 27 June 2016 (UTC)[reply]
Sennheiser are often recommended for good price/quality, you might find one of their products suits your needs. SemanticMantis (talk) 19:36, 27 June 2016 (UTC)[reply]
  Thank you for your research too. -- Apostle (talk) 19:51, 27 June 2016 (UTC)[reply]

Thanks all. Regards   -- Apostle (talk) 19:51, 27 June 2016 (UTC)[reply]

@Akld guy: Did you possibly mean 'a person whose hearing cuts off at say, 12 KHz, still derives benefit from the better reproduction of frequencies up to 21 KHz'...? --CiaPan (talk) 09:34, 28 June 2016 (UTC)[reply]
He meant that a 12 KHz square wave will be more accurately reproduced if the frequency response is designed to go up to 21 KHz. See Fourier analysis. Dbfirs 12:01, 28 June 2016 (UTC)[reply]
I know the nature of the Fourier analysis and I get the rectangular waveform stuff. That's exactly why I suggest one of '12's was infact meant to be '21'. --CiaPan (talk) 16:39, 28 June 2016 (UTC)[reply]
@CiaPan: Well it was a little ambiguous. I'll spell it out properly: a person whose hearing cuts off at say, 12 KHz, still derives benefit from the better reproduction of frequencies up to 12 KHz (i.e. in his hearing range), when the device's response extends to 21 KHz. What he can hear is improved, even though he can't hear anything above 12 KHz. Akld guy (talk) 19:37, 28 June 2016 (UTC)[reply]
Such an extraordinary claim needs extraordinary evidence. AllBestFaith (talk) 13:35, 29 June 2016 (UTC)[reply]
Why do the very best audio amplifiers have frequency ranges far in excess of what the human ear can hear? 50 KHz, 50 KHz, >100 KHz. Why do those amplifiers not cut off at say, 20 KHz? Akld guy (talk) 22:27, 29 June 2016 (UTC)[reply]
Manufacturers are aware that many consumers of these products are preoccupied with numbers. If frequency response outside the range of human hearing sells, they will make it. We may be stupid, but they aren't. ―Mandruss  23:11, 29 June 2016 (UTC)[reply]
No, that's not the reason. The higher the frequency response that the device has, the better it will reproduce transients in the audible frequency range. The listener will appreciate the more faithful following of the waveform in the range that he can hear. Akld guy (talk) 00:24, 30 June 2016 (UTC)[reply]
You said "he can't hear anything above 12 KHz". To me that means that, by definition, any changes to frequencies above 12 kHz will be inaudible to him. If they are audible then by definition he can hear above 12 kHz. If that's not what you mean by it, what do you mean?
I wonder if what you're saying is related to the common misconception that sampling at some frequency limits the resolution of attack times to that frequency. See this video by Monty Montgomery starting at 20:57 (or the whole thing). He demonstrates with vintage analog equipment (since many people don't believe the theoretical argument) that you can time attacks with far higher precision than the sampling frequency. -- BenRG (talk) 01:44, 30 June 2016 (UTC)[reply]