Most Popular

1500 questions
1184
votes
12 answers

Selecting element by data attribute with jQuery

Is there an easy and straight-forward method to select elements based on their data attribute? For example, select all anchors that has data attribute named customerID which has value of 22. I am kind of hesitant to use rel or other attributes to…
Hazem Salama
  • 14,891
  • 5
  • 27
  • 31
1184
votes
10 answers

How to install a previous exact version of a NPM package?

I used nvm to download node v0.4.10 and installed npm to work with that version of node. I am trying to install express using npm install express -g and I get an error that express requires node version >= 0.5.0. Well, this is odd, since I am…
stewart99
  • 14,024
  • 7
  • 27
  • 42
1184
votes
4 answers

What are Long-Polling, Websockets, Server-Sent Events (SSE) and Comet?

I have tried reading some articles, but I am not very clear on the concepts yet. Would someone like to take a shot at explaining to me what these technologies are: Long Polling Server-Sent Events Websockets Comet One thing that I came across every…
user1437328
  • 15,546
  • 9
  • 34
  • 44
1183
votes
23 answers

Sort array by firstname (alphabetically) in JavaScript

I got an array (see below for one object in the array) that I need to sort by firstname using JavaScript. How can I do it? var user = { bio: null, email: "user@domain.example", firstname: "Anna", id: 318, lastAvatar: null, …
Jonathan Clark
  • 19,726
  • 29
  • 111
  • 175
1182
votes
5 answers

What is a cross-platform way to get the home directory?

I need to get the location of the home directory of the current logged-on user. Currently, I've been using the following on Linux: os.getenv("HOME") However, this does not work on Windows. What is the correct cross-platform way to do this ?
Nathan Osman
  • 71,149
  • 71
  • 256
  • 361
1182
votes
14 answers

How to replace innerHTML of a div using jQuery?

How could I achieve the following: document.all.regTitle.innerHTML = 'Hello World'; Using jQuery where regTitle is my div id?
tonyf
  • 34,479
  • 49
  • 157
  • 246
1181
votes
11 answers

How to mock void methods with Mockito

How to mock methods with void return type? I implemented an observer pattern but I can't mock it with Mockito because I don't know how. And I tried to find an example on the Internet but didn't succeed. My class looks like this: public class World…
ibrahimyilmaz
  • 18,331
  • 13
  • 61
  • 80
1181
votes
30 answers

How to print a number using commas as thousands separators

How do I print an integer with commas as thousands separators? 1234567 ⟶ 1,234,567 It does not need to be locale-specific to decide between periods and commas.
Elias Zamaria
  • 96,623
  • 33
  • 114
  • 148
1181
votes
47 answers

Git push results in "Authentication Failed"

I have been using GitHub for a little while, and I have been fine with git add, git commit, and git push, so far without any problems. Suddenly I am having an error that says: fatal: Authentication Failed In the terminal I cloned a repository,…
zkirkland
  • 12,175
  • 3
  • 16
  • 18
1180
votes
12 answers

How to create a checkbox with a clickable label?

How can I create an HTML checkbox with a label that is clickable (this means that clicking on the label turns the checkbox on/off)?
laurent
  • 88,262
  • 77
  • 290
  • 428
1180
votes
26 answers

Is there a simple way to delete a list element by value?

I want to remove a value from a list if it exists in the list (which it may not). a = [1, 2, 3, 4] b = a.index(6) del a[b] print(a) The above gives the error: ValueError: list.index(x): x not in list So I have to do this: a = [1, 2, 3, 4] try: …
zjm1126
  • 63,397
  • 81
  • 173
  • 221
1180
votes
33 answers

Are there constants in JavaScript?

Is there a way to use constants in JavaScript? If not, what's the common practice for specifying variables that are used as constants?
fuentesjr
  • 50,920
  • 27
  • 77
  • 81
1178
votes
7 answers

WebSockets vs. Server-Sent events/EventSource

Both WebSockets and Server-Sent Events are capable of pushing data to browsers. To me they seem to be competing technologies. What is the difference between them? When would you choose one over the other?
Mads Mobæk
  • 34,762
  • 20
  • 71
  • 78
1178
votes
16 answers

"Large data" workflows using pandas

I have tried to puzzle out an answer to this question for many months while learning pandas. I use SAS for my day-to-day work and it is great for it's out-of-core support. However, SAS is horrible as a piece of software for numerous other…
Zelazny7
  • 39,946
  • 18
  • 70
  • 84
1176
votes
47 answers

Error: Can't set headers after they are sent to the client

I'm fairly new to Node.js and I am having some issues. I am using Node.js 4.10 and Express 2.4.3. When I try to access http://127.0.0.1:8888/auth/facebook, i'll be redirected to http://127.0.0.1:8888/auth/facebook_callback. I then received the…
DjangoRocks
  • 13,598
  • 7
  • 37
  • 52