Most Popular
1500 questions
1381
votes
25 answers
How do I determine the size of my array in C?
How do I determine the size of my array in C?
That is, the number of elements the array can hold?
Mark Harrison
- 297,451
- 125
- 333
- 465
1381
votes
25 answers
How to escape single quotes within single quoted strings
Let's say, you have a Bash alias like:
alias rxvt='urxvt'
which works fine.
However:
alias rxvt='urxvt -fg '#111111' -bg '#111111''
won't work, and neither will:
alias rxvt='urxvt -fg \'#111111\' -bg \'#111111\''
So how do you end up matching up…
cons
- 14,423
- 4
- 20
- 14
1379
votes
14 answers
How do I terminate a script?
How do I exit a script early, like the die() command in PHP?
Teifion
- 108,121
- 75
- 161
- 195
1379
votes
17 answers
How to Sort a Multi-dimensional Array by Value
How can I sort this array by the value of the "order" key?
Even though the values are currently sequential, they will not always be.
Array
(
[0] => Array
(
[hashtag] => a7e87329b5eab8578f4f1098a152d6f4
[title] =>…
stef
- 26,771
- 31
- 105
- 143
1379
votes
21 answers
What is the difference between visibility:hidden and display:none?
The CSS rules visibility:hidden and display:none both result in the element not being visible. Are these synonyms?
Chris Noe
- 36,411
- 22
- 71
- 92
1378
votes
45 answers
What is the maximum value for an int32?
I can never remember the number. I need a memory rule.
Flinkman
- 17,732
- 8
- 32
- 53
1378
votes
20 answers
What characters can be used for up/down triangle (arrow without stem) for display in HTML?
I'm looking for a HTML or ASCII character which is a triangle pointing up or down so that I can use it as a toggle switch.
I found ↑ (↑), and ↓ (↓) - but those have a narrow stem. I'm looking just for the HTML arrow "head".
Timj
- 13,937
- 3
- 18
- 9
1378
votes
23 answers
Sending command line arguments to npm script
The scripts portion of my package.json currently looks like this:
"scripts": {
"start": "node ./script.js server"
}
...which means I can run npm start to start the server. So far so good.
However, I would like to be able to run something like…
arnemart
- 14,180
- 3
- 17
- 11
1375
votes
29 answers
Getting key with maximum value in dictionary?
I have a dictionary where keys are strings, and values are integers.
stats = {'a': 1, 'b': 3000, 'c': 0}
How do I get the key with the maximum value? In this case, it is 'b'.
Is there a nicer approach than using an intermediate list with reversed…
ricafeal
- 14,169
- 4
- 19
- 10
1374
votes
46 answers
How to check if element is visible after scrolling?
I'm loading elements via AJAX. Some of them are only visible if you scroll down the page. Is there any way I can know if an element is now in the visible part of the page?
yoavf
- 20,945
- 9
- 37
- 38
1374
votes
22 answers
How do I find the location of my Python site-packages directory?
How do I find the location of my site-packages directory?
Daryl Spitzer
- 143,156
- 76
- 154
- 173
1373
votes
19 answers
Display number with leading zeros
How do I display a leading zero for all numbers with less than two digits?
1 → 01
10 → 10
100 → 100
ashchristopher
- 25,143
- 18
- 48
- 49
1372
votes
23 answers
Convert JS object to JSON string
If I defined an object in JS with:
var j={"name":"binchen"};
How can I convert the object to JSON? The output string should be:
'{"name":"binchen"}'
Bin Chen
- 61,507
- 53
- 142
- 183
1372
votes
19 answers
Catch and print full Python exception traceback without halting/exiting the program
I want to catch and log exceptions without exiting, e.g.,
try:
do_stuff()
except Exception as err:
print(Exception, err)
# I want to print the entire traceback here,
# not just the exception name and details
I want to print the…
chriscauley
- 19,015
- 9
- 33
- 33
1372
votes
13 answers
Which MySQL data type to use for storing boolean values
Since MySQL doesn't seem to have any 'boolean' data type, which data type do you 'abuse' for storing true/false information in MySQL?
Especially in the context of writing and reading from/to a PHP script.
Over time I have used and seen several…
Beat