Most Popular

1500 questions
1043
votes
17 answers

How do I use vim registers?

I only know of one instance using registers is via CtrlR* whereby I paste text from a clipboard. What are other uses of registers? How to use them? Everything you know about VI registers (let's focus on vi 7.2) -- share with us.
vehomzzz
  • 40,940
  • 72
  • 178
  • 214
1043
votes
23 answers

Best way to use Google's hosted jQuery, but fall back to my hosted library on Google fail

What would be a good way to attempt to load the hosted jQuery at Google (or other Google hosted libs), but load my copy of jQuery if the Google attempt fails? I'm not saying Google is flaky. There are cases where the Google copy is blocked…
Nosredna
  • 79,970
  • 15
  • 92
  • 122
1042
votes
14 answers

Why can't I use switch statement on a String?

Is this functionality going to be put into a later Java version? Can someone explain why I can't do this, as in, the technical way Java's switch statement works?
Alex Beardsley
  • 20,690
  • 14
  • 51
  • 67
1042
votes
21 answers

How do I duplicate a line or selection within Visual Studio Code?

Using Microsoft's Visual Studio Code, how do I duplicate a line of code and then move it up and down? (Similar to Sublime's cmd+shift+d behaviour) It's a feature that I use constantly, and am struggling using Visual Studio Code without it.
Chris
  • 51,502
  • 28
  • 142
  • 180
1042
votes
24 answers

How to permanently set $PATH on Linux/Unix

On Linux, how can I add a directory to the $PATH so it remains persistent across different sessions? Background I'm trying to add a directory to my path so it will always be in my Linux path. I've tried: export PATH=$PATH:/path/to/dir This works,…
Ali
  • 253,395
  • 261
  • 567
  • 754
1041
votes
18 answers

Shell: How to call one shell script from another shell script?

I have two shell scripts, a.sh and b.sh. How can I call b.sh from within the shell script a.sh?
Praveen
  • 10,701
  • 4
  • 15
  • 7
1041
votes
19 answers

Why is setTimeout(fn, 0) sometimes useful?

I've recently run into a rather nasty bug, wherein the code was loading a had a pre-selected value. In IE6, we already had code to fix the selected
Dan Lew
  • 84,442
  • 30
  • 180
  • 175
1041
votes
20 answers

How to emulate a do-while loop?

I need to emulate a do-while loop in a Python program. Unfortunately, the following straightforward code does not work: list_of_ints = [ 1, 2, 3 ] iterator = list_of_ints.__iter__() element = None while True: if element: print element …
grigoryvp
  • 38,339
  • 61
  • 167
  • 270
1041
votes
13 answers

Check whether a string matches a regex in JS

I want to use JavaScript (can be with jQuery) to do some client-side validation to check whether a string matches the regex: ^([a-z0-9]{5,})$ Ideally it would be an expression that returned true or false. I'm a JavaScript newbie, does match() do…
Richard
  • 29,871
  • 28
  • 106
  • 145
1041
votes
25 answers

Find all files in a directory with extension .txt in Python

How can I find all the files in a directory having the extension .txt in python?
usertest
  • 26,642
  • 29
  • 68
  • 93
1040
votes
14 answers

How to dispatch a Redux action with a timeout?

I have an action that updates the notification state of my application. Usually, this notification will be an error or info of some sort. I need to then dispatch another action after 5 seconds that will return the notification state to the initial…
Ilja
  • 42,166
  • 79
  • 252
  • 468
1040
votes
22 answers

How do I remove/delete a folder that is not empty?

I am getting an 'access is denied' error when I attempt to delete a folder that is not empty. I used the following command in my attempt: os.remove("/folder_name"). What is the most effective way of removing/deleting a folder/directory that is not…
Amara
  • 13,221
  • 9
  • 31
  • 28
1040
votes
16 answers

List comprehension vs. lambda + filter

I have a list that I want to filter by an attribute of the items. Which of the following is preferred (readability, performance, other reasons)? xs = [x for x in xs if x.attribute == value] xs = filter(lambda x: x.attribute == value, xs)
Agos
  • 17,896
  • 10
  • 54
  • 69
1039
votes
17 answers

Remove rows with all or some NAs (missing values) in data.frame

I'd like to remove the lines in this data frame that: a) contain NAs across all columns. Below is my example data frame. gene hsap mmul mmus rnor cfam 1 ENSG00000208234 0 NA NA NA NA 2 ENSG00000199674 0 2 2 2 …
Benoit B.
  • 11,564
  • 8
  • 25
  • 29
1039
votes
17 answers

How to list all commits that changed a specific file?

Is there a way to list all commits that changed a specific file?
Daniel
  • 10,725
  • 4
  • 18
  • 15
1 2 3
99
100