Questions

Test if a vector contains a given element

How to check if a vector contains a given value?

9 May at 09:33

How do I get the directory from a file's full path?

What is the simplest way to get the directory that a file is in? I'm using this to set a working directory. ``` string filename = @"C:\MyDirectory\MyFile.bat"; ``` In this example, I should get "C:...

6 Feb at 16:25

Interface defining a constructor signature?

It's weird that this is the first time I've bumped into this problem, but: How do you define a constructor in a C# interface? Some people wanted an example (it's a free time project, so yes, it's a...

14 Jul at 19:52

Unnamed/anonymous namespaces vs. static functions

A feature of C++ is the ability to create unnamed (anonymous) namespaces, like so: ``` namespace { int cannotAccessOutsideThisFile() { ... } } // namespace ``` You would think that such a featu...

6 Dec at 18:57

*ngIf and *ngFor on same element causing error

I'm having a problem with trying to use Angular's `*ngFor` and `*ngIf` on the same element. When trying to loop through the collection in the `*ngFor`, the collection is seen as `null` and consequen...

1 Feb at 11:7

How to check if a dictionary is empty?

I am trying to check if a dictionary is empty but it doesn't behave properly. It just skips it and displays without anything aside from the display the message. Any ideas why ? ``` def isEmpty(self, ...

5 Jan at 13:9

What is a user agent stylesheet?

I'm working on a web page in Google Chrome. It displays correctly with the following styles. ``` table { display: table; border-collapse: separate; border-spacing: 2px; border-color: ...

26 Apr at 14:22

What does the ^M character mean in Vim?

I keep getting the `^M` character in my `.vimrc` and it breaks my configuration.

What is the equivalent of Java's final in C#?

What is the equivalent of Java's `final` in C#?

6 Mar at 10:48

Can I add extension methods to an existing static class?

I'm a fan of extension methods in C#, but haven't had any success adding an extension method to a static class, such as `Console`. For example, if I want to add an extension to `Console`, called '`Wri...

29 Jan at 09:45

How can I check if an element exists in the visible DOM?

How do you test an element for existence without the use of the `getElementById` method? I have set up a [live demo](http://jsbin.com/apawi5/3) for reference. I will also print the code on here as we...

What's the difference between HEAD, working tree and index, in Git?

Can someone tell me the difference between HEAD, working tree and index, in Git? From what I understand, they are all names for different branches. Is my assumption correct? I found this: > A single g...

11 Jan at 21:24

How can I create a "Please Wait, Loading..." animation using jQuery?

I would like to place a "please wait, loading" spinning circle animation on my site. How should I accomplish this using jQuery?

25 Oct at 16:43

How to convert Milliseconds to "X mins, x seconds" in Java?

I want to record the time using `System.currentTimeMillis()` when a user begins something in my program. When he finishes, I will subtract the current `System.currentTimeMillis()` from the `start` var...

9 Mar at 08:41

UTF-8, UTF-16, and UTF-32

What are the differences between UTF-8, UTF-16, and UTF-32? I understand that they will all store Unicode, and that each uses a different number of bytes to represent a character. Is there an advanta...

4 Jan at 18:22

Is there a NumPy function to return the first index of something in an array?

I know there is a method for a Python list to return the first index of something: ``` >>> xs = [1, 2, 3] >>> xs.index(2) 1 ``` Is there something like that for NumPy arrays?

6 Jun at 05:53

Looping through array and removing items, without breaking for loop

I have the following for loop, and when I use `splice()` to remove an item, I then get that 'seconds' is undefined. I could check if it's undefined, but I feel there's probably a more elegant way to ...

19 Sep at 19:8

How to make the first option of <select> selected with jQuery

How do I make the first option of selected with jQuery? ``` <select id="target"> <option value="1">...</option> <option value="2">...</option> </select> ```

8 Jan at 14:12

How to update the value stored in Dictionary in C#?

How to update value for a specific key in a dictionary `Dictionary<string, int>`?

1 Feb at 07:0

What is the difference between Integrated Security = True and Integrated Security = SSPI?

I have two apps that use Integrated Security. One assigns `Integrated Security = true` in the connection string, and the other sets `Integrated Security = SSPI`. What is the difference between `SSPI...

How can I indent multiple lines in Xcode?

When I select multiple lines of code and want to indent them as usual with key, it just deletes them all. I come from Eclipse where I always did it that way. How's that done in Xcode? I hope not line...

13 Mar at 20:46

What is the difference between 'it' and 'test' in Jest?

I have two tests in my test group. One of the tests use `it` and the other one uses `test`. Both of them seem to be working very similarly. What is the difference between them? ``` describe('updateAll...

28 Nov at 10:35

Smooth scrolling when clicking an anchor link

I have a couple of hyperlinks on my page. A FAQ that users will read when they visit my help section. Using Anchor links, I can make the page scroll towards the anchor and guide the users there. Is ...

OS X: equivalent of Linux's wget

How can I do an HTTP GET from a Un*x shell script on a stock OS X system? (installing third-party software is not an option, for this has to run on a lot of different systems which I don't have contro...

31 Dec at 20:19

Merging dictionaries in C#

What's the best way to merge 2 or more dictionaries (`Dictionary<TKey, TValue>`) in C#? (3.0 features like LINQ are fine). I'm thinking of a method signature along the lines of: ``` public static Dict...

19 Dec at 11:56