Most Popular

1500 questions
3277
votes
12 answers

Difference between "git add -A" and "git add ."

The command git add [--all|-A] appears to be identical to git add .. Is this correct? If not, how do they differ?
cmcginty
  • 107,539
  • 39
  • 157
  • 158
3264
votes
26 answers

Commit only part of a file in Git

When I make changes to a file in Git, how can I commit only some of the changes? For example, how could I commit only 15 lines out of 30 lines that have been changed in a file?
freddiefujiwara
  • 53,587
  • 28
  • 74
  • 104
3260
votes
30 answers

How to concatenate string variables in Bash

In PHP, strings are concatenated together as follows: $foo = "Hello"; $foo .= " World"; Here, $foo becomes "Hello World". How is this accomplished in Bash?
Strawberry
  • 62,326
  • 55
  • 143
  • 194
3254
votes
82 answers

How do I iterate over the words of a string?

I'm trying to iterate over the words of a string. The string can be assumed to be composed of words separated by whitespace. Note that I'm not interested in C string functions or that kind of character manipulation/access. Also, please give…
Ashwin Nanjappa
  • 72,576
  • 76
  • 202
  • 288
3251
votes
29 answers

Case insensitive 'Contains(string)'

Is there a way to make the following return true? string title = "ASTRINGTOTEST"; title.Contains("string"); There doesn't seem to be an overload that allows me to set the case sensitivity. Currently I UPPERCASE them both, but that's just silly (by…
Boris Callens
  • 86,820
  • 84
  • 205
  • 301
3247
votes
31 answers

How do I concatenate two lists in Python?

How do I concatenate two lists in Python? Example: listone = [1, 2, 3] listtwo = [4, 5, 6] Expected outcome: >>> joinedlist [1, 2, 3, 4, 5, 6]
y2k
  • 64,108
  • 26
  • 59
  • 85
3231
votes
27 answers

How do I check if a list is empty?

For example, if passed the following: a = [] How do I check to see if a is empty?
Ray
  • 179,335
  • 97
  • 219
  • 202
3216
votes
51 answers

How can I check if an object is an array?

I'm trying to write a function that either accepts a list of strings, or a single string. If it's a string, then I want to convert it to an array with just the one item so I can loop over it without fear of an error. So how do I check if the…
mpen
  • 256,080
  • 255
  • 805
  • 1,172
3215
votes
89 answers

What is the JavaScript version of sleep()?

Is there a better way to engineer a sleep in JavaScript than the following pausecomp function (taken from here)? function pausecomp(millis) { var date = new Date(); var curDate = null; do { curDate = new Date(); } while(curDate-date…
fmsf
  • 35,134
  • 48
  • 145
  • 193
3213
votes
11 answers

Improve INSERT-per-second performance of SQLite

Optimizing SQLite is tricky. Bulk-insert performance of a C application can vary from 85 inserts per second to over 96,000 inserts per second! Background: We are using SQLite as part of a desktop application. We have large amounts of configuration…
Mike Willekes
  • 5,820
  • 10
  • 31
  • 33
3198
votes
13 answers

What is __init__.py for?

What is __init__.py for in a Python source directory?
Mat
  • 75,272
  • 33
  • 86
  • 107
3197
votes
33 answers

How can I change an element's class with JavaScript?

How can I change the class of an HTML element in response to an onclick or any other events using JavaScript?
Nathan Smith
  • 35,009
  • 6
  • 27
  • 25
3187
votes
28 answers

How to check if a string contains a substring in Bash

I have a string in Bash: string="My string" How can I test if it contains another string? if [ $string ?? 'foo' ]; then echo "It's there!" fi Where ?? is my unknown operator. Do I use echo and grep? if echo "$string" | grep 'foo'; then echo…
davidsheldon
  • 35,425
  • 4
  • 26
  • 27
3182
votes
98 answers

How can I convert a string to boolean in JavaScript?

Can I convert a string representing a boolean value (e.g., 'true', 'false') into a intrinsic type in JavaScript? I have a hidden form in HTML that is updated based upon a user's selection within a list. This form contains some fields which represent…
Kevin
  • 7,816
  • 11
  • 34
  • 39
3174
votes
43 answers

Creating multiline strings in JavaScript

I have the following code in Ruby. I want to convert this code into JavaScript. What is the equivalent code in JS? text = <<"HERE" This Is A Multiline String HERE
Newy
  • 36,597
  • 9
  • 42
  • 55