Check whether an array is empty
I have the following code ``` <?php $error = array(); $error['something'] = false; $error['somethingelse'] = false; if (!empty($error)) { echo 'Error'; } else { echo 'No errors'; } ?> ``` ...
Getting values from JSON using Python
While I am trying to retrieve values from JSON string, it gives me an error: ``` data = json.loads('{"lat":444, "lon":555}') return data["lat"] ``` But, if I iterate over the data, it gives me the ...
- Modified
- 10 Jan at 16:45
Replace all elements of Python NumPy Array that are greater than some value
I have a 2D NumPy array and would like to replace all values in it greater than or equal to a threshold T with 255.0. To my knowledge, the most fundamental way would be: ``` shape = arr.shape result ...
- Modified
- 29 Oct at 19:47
Turning off auto indent when pasting text into vim
I am making the effort to learn Vim. When I paste code into my document from the clipboard, I get extra spaces at the start of each new line: ``` line line line ``` I know you can turn off a...
- Modified
- 3 May at 14:57
What happens when a duplicate key is put into a HashMap?
If I pass the same key multiple times to `HashMap`’s `put` method, what happens to the original value? And what if even the value repeats? I didn’t find any documentation on this. Case 1: Overwritten...
Export query result to .csv file in SQL Server 2008
How can I export a query result to a .csv file in SQL Server 2008?
- Modified
- 24 Jul at 12:50
AngularJS ng-class if-else expression
With `AngularJS` I'm using `ng-class` the following way: ``` <div class="bigIcon" data-ng-click="PickUp()" ng-class="{first:'classA', second:'classB', third:'classC', fourth:'classC'}[call.State]"/>...
git pull remote branch cannot find remote ref
I'm not sure why this doesn't work. When I do `git branch -a`, this is what I see: ![enter image description here](https://i.stack.imgur.com/E2Lxn.png) I'm trying to pull from the DownloadManager on ...
- Modified
- 19 Dec at 21:35
How to remove last n characters from a string in Bash?
I have a variable `var` in a Bash script holding a string: ``` echo $var "some string.rtf" ``` I want to remove the last four characters of this string and assign the result to a new variable `var2`,...
- Modified
- 29 Jul at 10:38
How to convert List to Map?
Recently I have conversation with a colleague about what would be the optimal way to convert `List` to `Map` in Java and if there any specific benefits of doing so. I want to know optimal conversion a...
- Modified
- 21 Feb at 12:56
How do I get the output of a shell command executed using into a variable from Jenkinsfile (groovy)?
I have something like this on a Jenkinsfile (Groovy) and I want to record the stdout and the exit code in a variable in order to use the information later. ``` sh "ls -l" ``` How can I do this, es...
- Modified
- 27 Oct at 20:22
How to pass multiple parameters in a querystring
I have three values which I have to pass as parameters for e.g., `strID`, `strName` and `strDate`. I want to redirect these three parameters to another page in `Response.Redirect()`.Can anybody provi...
- Modified
- 7 Apr at 08:2
Simplest SOAP example
What is the simplest SOAP example using Javascript? To be as useful as possible, the answer should: - - - - -
- Modified
- 15 Feb at 04:2
How can I output only captured groups with sed?
Is there a way to tell `sed` to output only captured groups? For example, given the input: ``` This is a sample 123 text and some 987 numbers ``` And pattern: ``` /([\d]+)/ ``` Could I get only 123 ...
Table scroll with HTML and CSS
I have a table like that which i fill with a data ``` <table id="products-table" style="overflow-y:scroll" > <thead> <tr> <th>Product (Parent Product)</th> <th>...
- Modified
- 12 Feb at 13:55
ssh: connect to host github.com port 22: Connection timed out
I am under a proxy and I am pushing in to git successfully for quite a while. Now I am not able to push into git all of a sudden. I have set the RSA key and the proxy and double checked them, with no ...
How do I load the contents of a text file into a javascript variable?
I have a text file in the root of my web app [http://localhost/foo.txt](http://localhost/foo.txt) and I'd like to load it into a variable in javascript.. in groovy I would do this: ``` def fileConten...
- Modified
- 13 Oct at 01:57
How to convert float to varchar in SQL Server
I have a float column with numbers of different length and I'm trying to convert them to varchar. Some values exceed bigint max size, so I can't do something like this ``` cast(cast(float_field as b...
- Modified
- 15 Sep at 09:13
Calculate text width with JavaScript
I'd like to use JavaScript to calculate the width of a string. Is this possible without having to use a monospace typeface? If it's not built-in, my only idea is to create a table of widths for each ...
- Modified
- 3 Feb at 13:31
What are C++ functors and their uses?
I keep hearing a lot about functors in C++. Can someone give me an overview as to what they are and in what cases they would be useful?
- Modified
- 29 Jun at 10:41
How do I capture SIGINT in Python?
I'm working on a python script that starts several processes and database connections. Every now and then I want to kill the script with a + signal, and I'd like to do some cleanup. In Perl I'd do th...
Node.js Error: connect ECONNREFUSED
I am new to node and running into this error on a simple tutorial. I am on the OS X 10.8.2 trying this from CodeRunner and the Terminal. I have also tried putting my module in the `node_modules` fold...
- Modified
- 5 Jan at 03:59
Why is my asynchronous function returning Promise { <pending> } instead of a value?
My code: ``` let AuthUser = data => { return google.login(data.username, data.password).then(token => { return token } ) } ``` And when i try to run something like this: ``` let userToken = Auth...
- Modified
- 27 Apr at 08:21
What is the point of "final class" in Java?
I am reading a book about Java and it says that you can declare the whole class as `final`. I cannot think of anything where I'd use this. I am just new to programming and I am wondering . If they d...