Questions

Verify a method call using Moq

I am fairly new to unit testing in C# and learning to use Moq. Below is the class that I am trying to test. ``` class MyClass { SomeClass someClass; public MyClass(SomeClass someClass) { ...

24 Nov at 10:43

jQuery .live() vs .on() method for adding a click event after loading dynamic html

I am using jQuery v.1.7.1 where the .live() method is apparently deprecated. The problem I am having is that when dynamically loading html into an element using: ``` $('#parent').load("http://...")...

6 Jan at 01:48

Spring MVC - How to get all request params in a map in Spring controller?

Sample URL: ``` ../search/?attr1=value1&attr2=value2&attr4=value4 ``` I do not know the names of attr1, att2, and attr4. I would like to be able to do something like that (or similar, don't care, ...

6 Dec at 13:39

How to set a cookie for another domain

Say I have a website called `a.com`, and when a specific page of this site is loaded, say page link, I like to set a cookie for another site called `b.com`, then redirect the user to `b.com`. I mean...

26 Jul at 06:18

Converting a Date object to a calendar object

So I get a date attribute from an incoming object in the form: ``` Tue May 24 05:05:16 EDT 2011 ``` I am writing a simple helper method to convert it to a calendar method, I was using the following...

Where is Xcode's build folder?

Before Xcode 4 the build used to be created in the root folder of my project. I can no longer find it. Where can i find the build folder?

20 Jan at 20:41

How do I install a module globally using npm?

I recently installed Node.js and npm module on OSX and have a problem with the settings I think: ``` npm install [MODULE] is not installing the node.js module to the default path which is /usr/local...

26 Jul at 19:29

Is there a CSS selector for text nodes?

What I would like to do (not in IE obviously) is: ``` p:not(.list):last-child + :text { margin-bottom: 10px; } ``` Which would give a text node a margin. (Is that even possible?) How would I get ...

30 Mar at 06:39

Size-limited queue that holds last N elements in Java

A very simple & quick question on Java libraries: is there a ready-made class that implements a `Queue` with a fixed maximum size - i.e. it always allows addition of elements, but it will silently rem...

21 Aug at 21:42

How to run a class from Jar which is not the Main-Class in its Manifest file

I have a JAR with 4 classes, each one has Main method. I want to be able to run each one of those as per the need. I am trying to run it from command-line on Linux box. ``` E.g. The name of my JAR is...

29 Mar at 15:2

Parse string to DateTime in C#

I have in a string formatted like that one: ``` "2011-03-21 13:26" //year-month-day hour:minute ``` How can I parse it to `System.DateTime`? I want to use functions like `DateTime.Parse()` or `Da...

20 Jun at 07:18

How to subtract date/time in JavaScript?

I have a field at a grid containing date/time and I need to know the difference between that and the current date/time. What could be the best way of doing so? The dates are stored like `"2011-02-07 ...

14 Aug at 13:59

How do I use the lines of a file as arguments of a command?

Say, I have a file `foo.txt` specifying `N` arguments ``` arg1 arg2 ... argN ``` which I need to pass to the command `my_command` How do I use the lines of a file as arguments of a command?

how to mysqldump remote db from local machine

I need to do a mysqldump of a database on a remote server, but the server does not have mysqldump installed. I would like to use the mysqldump on my machine to connect to the remote database and do th...

21 Feb at 00:23

is of a type that is invalid for use as a key column in an index

I have an error at ``` Column 'key' in table 'misc_info' is of a type that is invalid for use as a key column in an index. ``` where key is a nvarchar(max). A quick google search finds that the maxim...

15 Oct at 23:25

How can I tell how many objects I've stored in an S3 bucket?

Unless I'm missing something, it seems that none of the APIs I've looked at will tell you how many objects are in an `<S3 bucket>/<folder>`. Is there any way to get a count?

Curly braces in string in PHP

What is the meaning of `{ }` (curly braces) in string literals in PHP?

17 Oct at 12:48

How can I escape a single quote?

How can I escape a `'` (single quote) in HTML? This is where I'm trying to use it: ``` <input type='text' id='abc' value='hel'lo'> ``` The result for the above code is "hel" populated in the text box...

19 Jan at 10:14

Difference between File.separator and slash in paths

What is the difference between using `File.separator` and a normal `/` in a Java Path-String? In contrast to double backslash `\\` platform independence seems not to be the reason, since both version...

21 Aug at 07:29

Return positions of a regex match() in Javascript?

Is there a way to retrieve the (starting) character positions inside a string of the results of a regex match() in Javascript?

How to format a DateTime in PowerShell

I can format the [Get-Date](https://technet.microsoft.com/en-us/library/hh849887.aspx) cmdlet no problem like this: ``` $date = Get-Date -format "yyyyMMdd" ``` But once I've got [a date](https://ms...

14 Jan at 06:6

How to increase storage for Android Emulator? (INSTALL_FAILED_INSUFFICIENT_STORAGE)

I get this sometimes(not often) for one of my projects, couple of classes only `Installation error: INSTALL_FAILED_INSUFFICIENT_STORAGE` How do I increase emulator's storage?

What is the difference between conversion specifiers %i and %d in formatted IO functions (*printf / *scanf)

What is the difference between `%d` and `%i` when used as format specifiers in `printf` and `scanf`?

14 Oct at 14:54

Can you create nested WITH clauses for Common Table Expressions?

``` WITH y AS ( WITH x AS ( SELECT * FROM MyTable ) SELECT * FROM x ) SELECT * FROM y ``` Does something like this work? I tried it earlier but I couldn't get it to work.

Extract part of a regex match

I want a regular expression to extract the title from a HTML page. Currently I have this: ``` title = re.search('<title>.*</title>', html, re.IGNORECASE).group() if title: title = title.replace('...