Questions

Can I set variables to undefined or pass undefined as an argument?

I’m a bit confused about JavaScript’s `undefined` and `null` values. What does `if (!testvar)` actually do? Does it test for `undefined` and `null` or just `undefined`? Once a variable is defined ca...

26 Sep at 01:11

How can I format a decimal to always show 2 decimal places?

I want to display: `49` as `49.00` and: `54.9` as `54.90` Regardless of the length of the decimal or whether there are are any decimal places, I would like to display a `Decimal` with 2 decimal places...

23 Sep at 14:0

Java: Get first item from a collection

If I have a collection, such as `Collection<String> strs`, how can I get the first item out? I could just call an `Iterator`, take its first `next()`, then throw the `Iterator` away. Is there a less w...

4 Nov at 02:22

Shuffle an array with python, randomize array item order with python

What's the easiest way to shuffle an array with python?

28 Aug at 17:58

What is the best (idiomatic) way to check the type of a Python variable?

I need to know if a variable in Python is a string or a dict. Is there anything wrong with the following code? ``` if type(x) == type(str()): do_something_with_a_string(x) elif type(x) == type(d...

2 Jul at 12:0

How to scale a UIImageView proportionally?

I have a UIImageView and the objective is to scale it down proportionally by giving it either a height or width. ``` UIImage *image = [[UIImage alloc] initWithData:[NSData dataWithContentsOfURL:[NSU...

7 Aug at 13:46

How to recursively download a folder via FTP on Linux

I'm trying to ftp a folder using the command line ftp client, but so far I've only been able to use 'get' to get individual files.

25 Aug at 09:47

How do you overcome the svn 'out of date' error?

I've been attempting move a directory structure from one location to another in Subversion, but I get an `Item '*' is out of date` commit error. I have the latest version checked out (so far as I c...

6 Mar at 23:0

What's the best mock framework for Java?

What's the best framework for creating mock objects in Java? Why? What are the pros and cons of each framework?

28 Jan at 20:5

INSTALL_FAILED_USER_RESTRICTED : android studio using redmi 4 device

[](https://i.stack.imgur.com/TsZ3Z.jpg) Got this freaky error ``` Installation failed with message Failed to finalize session : INSTALL_FAILED_USER_RESTRICTED: Install canceled by user. It is possible...

17 Aug at 14:18

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...

27 Oct at 20:22

Angular HTTP GET with TypeScript error http.get(...).map is not a function in [null]

I have a problem with HTTP in Angular. I just want to `GET` a `JSON` list and show it in the view. ## Service class ``` import {Injectable} from "angular2/core"; import {Hall} from "./hall"; i...

28 Nov at 04:20

Removing duplicate elements from an array in Swift

I might have an array that looks like the following: ``` [1, 4, 2, 2, 6, 24, 15, 2, 60, 15, 6] ``` Or, really, any sequence of like-typed portions of data. What I want to do is ensure that there is o...

24 Sep at 17:8

Proper way to wait for one function to finish before continuing?

I have two JS functions. One calls the other. Within the calling function, I'd like to call the other, wait for that function to finish, then continue on. So, for example/pseudo code: ``` function fi...

What are the Android SDK build-tools, platform-tools and tools? And which version should be used?

I know this is a very rudimentary question, but to my surprise, I could not find any document about Android SDK Build-tools. Besides Android SDK Tools and Android SDK Platform-tools, there are a bunch...

9 Aug at 06:51

Entity Framework. Delete all rows in table

How can I quickly remove all rows in the table using Entity Framework? I am currently using: ``` var rows = from o in dataDb.Table select o; foreach (var row in rows) { dataDb.Table.Rem...

13 Feb at 07:32

What does "|=" mean? (pipe equal operator)

I tried searching using Google Search and Stack Overflow, but it didn't show up any results. I have seen this in opensource library code: ``` Notification notification = new Notification(icon, ticker...

13 Jan at 19:58

Making HTTP Requests using Chrome Developer tools

Is there a way to make an HTTP request using the Chrome Developer tools without using a plugin like POSTER?

ValidateAntiForgeryToken purpose, explanation and example

Could you explain [ValidateAntiForgeryToken](http://msdn.microsoft.com/en-us/library/system.web.mvc.validateantiforgerytokenattribute%28v=vs.100%29.aspx) purpose and show me example about `ValidateAnt...

25 Feb at 09:37

library not found for -lPods

I got an error when archiving a project. This is my environment. - - - The project deployment target is: ``` IPHONEOS_DEPLOYMENT_TARGET 3.2 ``` The error shows: ``` ld: library not found for -l...

Check if two unordered lists are equal

I'm looking for an easy (and quick) way to determine if two lists contain the same elements: For example: ``` ['one', 'two', 'three'] == ['one', 'two', 'three'] : true ['one', 'two', 'three'] == [...

25 Jan at 13:7

Converting from IEnumerable to List

I want to convert from `IEnumerable<Contact>` to `List<Contact>`. How can I do this?

18 Aug at 21:49

Using PowerShell to write a file in UTF-8 without the BOM

`Out-File` seems to force the BOM when using UTF-8: ``` $MyFile = Get-Content $MyPath $MyFile | Out-File -Encoding "UTF8" $MyPath ``` How can I write a file in UTF-8 with no BOM using PowerShell? ##...

"webxml attribute is required" error in Maven

I am getting the following error: > Error assembling WAR: webxml attribute is required (or pre-existing WEB-INF/web.xml if executing in update mode) I have got `web.xml` in right place which is `pr...

19 Jun at 20:9

Remove all occurrences of char from string

I can use this: ``` String str = "TextX Xto modifyX"; str = str.replace('X','');//that does not work because there is no such character '' ``` Is there a way to remove all occurrences of character ...

11 Apr at 12:46