Questions

Check if list is empty in C#

I have a generic list object. I need to check if the list is empty. How do I check if a `List<T>` is empty in C#?

25 Aug at 19:38

Specifying a custom DateTime format when serializing with Json.Net

I am developing an API to expose some data using ASP.NET Web API. In one of the API, the client wants us to expose the date in `yyyy-MM-dd` format. I don't want to change the global settings (e.g. `G...

23 May at 19:29

How to declare a constant map in Golang?

I am trying to declare to constant in Go, but it is throwing an error. This is my code: ``` const myMap = map[int]string{ 1: "one", 2: "two", 3: "three", } ``` This is the error ``` map[i...

23 Dec at 08:29

How to store arrays in MySQL?

I have two tables in MySQL. Table Person has the following columns: | id | name | fruits | | -- | ---- | ------ | The `fruits` column may hold null or an array of strings like ('apple', 'orange',...

15 Jun at 23:32

Missing return statement in a non-void method compiles

I encountered a situation where a is missing a statement and the code still compiles. I know that the statements after the while loop are (dead code) and would never be executed. But why doesn't th...

2 Nov at 07:31

Value cannot be null. Parameter name: source

This is probably the biggest waste of time problem I have spent hours on solving for a long time. ``` var db = new hublisherEntities(); establishment_brands est = new establishment_brands(); est.bra...

What is the minimum length of a valid international phone number?

I need to validate user input of an international phone number. According to [E.164](https://en.wikipedia.org/wiki/E.164), the maximum length is 15 digits, but I was unable to find any information abo...

3 Oct at 23:9

Node.js: Difference between req.query[] and req.params

Is there a difference between obtaining QUERY_STRING arguments via `req.query[myParam]` and `req.params.myParam`? If so, when should I use which?

3 Oct at 07:15

Add a common Legend for combined ggplots

I have two ggplots which I align horizontally with `grid.arrange`. I have looked through a lot of forum posts, but everything I try seem to be commands that are now updated and named something else. ...

16 Jul at 13:0

How to crop an image using PIL?

I want to crop image in the way by removing first 30 rows and last 30 rows from the given image. I have searched but did not get the exact solution. Does somebody have some suggestions?

22 May at 09:13

Merge 2 arrays of objects

Lets have a look at an example. ``` var arr1 = new Array({name: "lang", value: "English"}, {name: "age", value: "18"}); var arr2 = new Array({name : "childs", value: '5'}, ...

BigDecimal equals() versus compareTo()

Consider the simple test class: ``` import java.math.BigDecimal; /** * @author The Elite Gentleman * */ public class Main { /** * @param args */ public static void main(String[...

22 Jul at 08:52

How to get a substring between two strings in PHP?

I need a function that returns the substring between two words (or two characters). I'm wondering whether there is a php function that achieves that. I do not want to think about regex (well, I could ...

11 Aug at 23:31

Stretch background image css?

``` <td class="style1" align='center' height='35'> <div style='overflow: hidden; width: 230px;'> <a class='link' herf='' onclick='topic(<?=$key;?>)'> <span id='name<?=$key;?>'><?=$name;?><...

20 Apr at 10:46

In Python, how does one catch warnings as if they were exceptions?

A third-party library (written in C) that I use in my python code is issuing warnings. I want to be able to use the `try` `except` syntax to properly handle these warnings. Is there a way to do this? ...

20 Jun at 09:38

How to pass table value parameters to stored procedure from .net code

I have a SQL Server 2005 database. In a few procedures I have table parameters that I pass to a stored proc as an `nvarchar` (separated by commas) and internally divide into single values. I add it to...

How to use WPF Background Worker

In my application I need to perform a series of initialization steps, these take 7-8 seconds to complete during which my UI becomes unresponsive. To resolve this I perform the initialization in a sepa...

Use JAXB to create Object from XML String

How can I use the below code to unmarshal a XML string an map it to the JAXB object below? ``` JAXBContext jaxbContext = JAXBContext.newInstance(Person.class); Unmarshaller unmarshaller = jaxbContext...

28 Mar at 12:16

$(window).scrollTop() vs. $(document).scrollTop()

What's the difference between: ``` $(window).scrollTop() ``` and ``` $(document).scrollTop() ``` Thanks.

Rename Files and Directories (Add Prefix)

I would like to add prefix on all folders and directories. Example: I have ``` Hi.jpg 1.txt folder/ this.file_is.here.png another_folder.ok/ ``` I would like to add prefix "PRE_" ``` PRE_Hi.jpg PRE_1...

30 Dec at 12:46

How to get datetime in JavaScript?

How to get date time in JavaScript with format 31/12/2010 03:55 AM?

23 Jul at 14:57

Find indices of elements equal to zero in a NumPy array

NumPy has the efficient function/method [nonzero()](http://docs.scipy.org/doc/numpy/reference/generated/numpy.nonzero.html) to identify the indices of non-zero elements in an `ndarray` object. What is...

9 Jan at 22:29

What does this square bracket and parenthesis bracket notation mean [first1,last1)?

I have seen number ranges represented as `[first1,last1)` and `[first2,last2)`. I would like to know what such a notation means.

26 Apr at 17:37

Fixed Table Cell Width

A lot of people still use tables to layout controls, data etc. - one example of this is the popular jqGrid. However, there is some magic happening that I cant seem to fathom (its tables for crying out...

10 Dec at 18:21

JavaScript: How to join / combine two arrays to concatenate into one array?

I'm trying to combine 2 arrays in javascript into one. ``` var lines = new Array("a","b","c"); lines = new Array("d","e","f"); ``` This is a quick example, i want to be able to combine them so that...

12 Jul at 12:27