Most Popular
1500 questions
1418
votes
27 answers
How can I declare and use Boolean variables in a shell script?
I tried to declare a Boolean variable in a shell script using the following syntax:
variable=$false
variable=$true
Is this correct? Also, if I wanted to update that variable would I use the same syntax? Finally, is the following syntax for using…
hassaanm
- 14,539
- 4
- 21
- 20
1417
votes
40 answers
How can I output MySQL query results in CSV format?
Is there an easy way to run a MySQL query from the Linux command line and output the results in CSV format?
Here's what I'm doing now:
mysql -u uid -ppwd -D dbname << EOQ | sed -e 's/ /,/g' | tee list.csv
select id, concat("\"",name,"\"") as…
MCS
- 22,113
- 20
- 62
- 76
1416
votes
36 answers
How to get the client IP address in PHP
How can I get the client IP address using PHP?
I want to keep record of the user who logged into my website through his/her IP address.
Anup Prakash
- 14,406
- 4
- 17
- 12
1416
votes
191 answers
Hidden features of Python
What are the lesser-known but useful features of the Python programming language?
Try to limit answers to Python core.
One feature per answer.
Give an example and short description of the feature, not just a link to documentation.
Label the feature…
jelovirt
- 5,844
- 8
- 38
- 49
1415
votes
12 answers
How do I get the full path of the current file's directory?
How do I get the current file's directory path?
I tried:
>>> os.path.abspath(__file__)
'C:\\python27\\test.py'
But I want:
'C:\\python27\\'
Shubham
- 21,300
- 18
- 66
- 89
1415
votes
18 answers
Undo git pull, how to bring repos to old state
Is there any way to revert or undo git pull so that my source/repos will come to old state that was before doing git pull ?
I want to do this because it merged some files which I didn't want to do so, but only merge other remaining files. So, I want…
seg.server.fault
- 19,118
- 13
- 35
- 31
1414
votes
22 answers
Create Generic method constraining T to an Enum
I'm building a function to extend the Enum.Parse concept that
Allows a default value to be parsed in case that an Enum value is not found
Is case insensitive
So I wrote the following:
public static T GetEnumFromString(string value, T…
johnc
- 39,385
- 37
- 101
- 139
1412
votes
30 answers
Check if table exists in SQL Server
I would like this to be the ultimate discussion on how to check if a table exists in SQL Server 2000/2005 using SQL Statements.
Here are two possible ways of doing it. Which one is the standard/best way of doing it?
First way:
IF EXISTS (SELECT 1
…
Vincent
- 22,366
- 18
- 58
- 61
1411
votes
16 answers
Convert JavaScript String to be all lowercase
How can I convert a JavaScript string value to be in all lowercase letters?
Example: "Your Name" to "your name"
Derek
- 16,181
- 3
- 27
- 36
1410
votes
5 answers
What is the difference between the remap, noremap, nnoremap and vnoremap mapping commands in Vim?
What is the difference between the remap, noremap, nnoremap and vnoremap mapping commands in Vim?
Chetan
- 46,743
- 31
- 106
- 145
1410
votes
32 answers
How to pass props to {this.props.children}
I'm trying to find the proper way to define some components which could be used in a generic way:
There is a logic going on for rendering between parent and children components of course,…
plus-
- 45,453
- 15
- 60
- 73
1410
votes
23 answers
How to copy a dictionary and only edit the copy
I set dict2 = dict1. When I edit dict2, the original dict1 also changes. Why?
>>> dict1 = {"key1": "value1", "key2": "value2"}
>>> dict2 = dict1
>>> dict2["key2"] = "WHY?!"
>>> dict1
{'key2': 'WHY?!', 'key1': 'value1'}
MadSc13ntist
- 19,820
- 8
- 25
- 19
1409
votes
31 answers
JavaScriptSerializer - JSON serialization of enum as string
I have a class that contains an enum property, and upon serializing the object using JavaScriptSerializer, my json result contains the integer value of the enumeration rather than its string "name". Is there a way to get the enum as a string in my…
Omer Bokhari
- 57,458
- 12
- 44
- 58
1409
votes
12 answers
What are the differences between NP, NP-Complete and NP-Hard?
What are the differences between NP, NP-Complete and NP-Hard?
I am aware of many resources all over the web. I'd like to read your explanations, and the reason is they might be different from what's out there, or there is something that I'm not…
DarthVader
- 52,984
- 76
- 209
- 300
1409
votes
16 answers
How can I get a list of user accounts using the command line in MySQL?
I'm using the MySQL command-line utility and can navigate through a database. Now I need to see a list of user accounts. How can I do this?
I'm using MySQL version 5.4.1.
burntsugar
- 57,360
- 21
- 58
- 81