Questions

Stop on first error

> [Automatic exit from bash shell script on error](https://stackoverflow.com/questions/2870992/automatic-exit-from-bash-shell-script-on-error) How can I have bash stop on the first command fai...

23 May at 12:10

Extract file basename without path and extension in bash

Given file names like these: ``` /the/path/foo.txt bar.txt ``` I hope to get: ``` foo bar ``` Why this doesn't work? ``` #!/bin/bash fullfile=$1 fname=$(basename $fullfile) fbname=${fname%.*} ...

16 Nov at 20:2

How to exit a 'git status' list in a terminal?

How can I exit a terminal listing mode generated by the `git status` command?

29 Dec at 00:37

JUnit test for System.out.println()

I need to write JUnit tests for an old application that's poorly designed and is writing a lot of error messages to standard output. When the `getResponse(String request)` method behaves correctly it ...

19 Apr at 23:28

Why can't I make a vector of references?

When I do this: ``` std::vector<int> hello; ``` Everything works great. However, when I make it a vector of references instead: ``` std::vector<int &> hello; ``` I get horrible errors like > e...

In C#, why is String a reference type that behaves like a value type?

A String is a reference type even though it has most of the characteristics of a value type such as being immutable and having == overloaded to compare the text rather than making sure they reference ...

How to run Rake tasks from within Rake tasks?

I have a Rakefile that compiles the project in two ways, according to the global variable `$build_type`, which can be `:debug` or `:release` (the results go in separate directories): ``` task :build ...

20 Jun at 15:40

How to combine paths in Java?

Is there a Java equivalent for [System.IO.Path.Combine()](http://msdn.microsoft.com/en-us/library/system.io.path.combine.aspx) in C#/.NET? Or any code to accomplish this? This static method combines ...

22 Aug at 08:53

How to make an image center (vertically & horizontally) inside a bigger div

I have a div 200 x 200 px. I want to place a 50 x 50 px image right in the middle of the div. How can it be done? I am able to get it centered horizontally by using `text-align: center` for the div...

21 Jul at 13:0

REST / SOAP endpoints for a WCF service

I have a WCF service and I want to expose it as both a RESTfull service and as a SOAP service. Anyone has done something like this before?

4 Jan at 02:28

Changing Vim indentation behavior by file type

Could someone explain to me in simple terms the easiest way to change the indentation behavior of Vim based on the file type? For instance, if I open a Python file it should indent with 2 spaces, but ...

31 Oct at 09:41

How can I decode HTML characters in C#?

I have email addresses encoded with HTML character entities. Is there anything in .NET that can convert them to plain strings?

5 Nov at 21:23

Using jq to parse and display multiple fields in a json serially

I have this Json ``` { "users": [ { "first": "Stevie", "last": "Wonder" }, { "first": "Michael", "last": "Jackson" }...

27 Mar at 10:29

Correct way to detach from a container without stopping it

In Docker 1.1.2 (latest), what's the correct way to detach from a container without stopping it? So for example, if I try: - `docker run -i -t foo /bin/bash`- `docker attach foo` both of which get ...

12 Aug at 14:48

Get file name from absolute path in Nodejs?

How can I get the file name from an absolute path in Nodejs? e.g. `"foo.txt"` from `"/var/www/foo.txt"` I know it works with a string operation, like `fullpath.replace(/.+\//, '')`, but I want to know...

8 Apr at 08:12

What is http multipart request?

I have been writing iPhone applications for some time now, sending data to server, receiving data (via HTTP protocol), without thinking too much about it. Mostly I am theoretically familiar with proce...

4 Feb at 14:7

Way to ng-repeat defined number of times instead of repeating over array?

Is there a way to `ng-repeat` a defined number of times instead of always having to iterate over an array? For example, below I want the list item to show up 5 times assuming `$scope.number` equal to...

Is there an AddRange equivalent for a HashSet in C#

With a list you can do: ``` list.AddRange(otherCollection); ``` There is no add range method in a `HashSet`. What is the best way to add another `ICollection` to a `HashSet`?

13 Aug at 18:19

Accessing bash command line args $@ vs $*

In many SO questions and bash tutorials I see that I can access command line args in bash scripts in two ways: ``` $ ~ >cat testargs.sh #!/bin/bash echo "you passed me" $* echo "you passed me" $@ `...

3 Nov at 07:9

Vim: insert the same characters across multiple lines

Sometimes I want to edit a certain visual block of text across multiple lines. For example, I would take a text that looks like this: ``` name comment phone email ``` And make it look like this `...

18 Jan at 17:24

Get connection string from App.config

``` var connection = ConnectionFactory.GetConnection( ConfigurationManager.ConnectionStrings["Test"] .ConnectionString, DataBaseProvider); ``` And this is my App.config: ``` <?xml version=...

Getting the closest string match

I need a way to compare multiple strings to a test string and return the string that closely resembles it: ``` TEST STRING: THE BROWN FOX JUMPED OVER THE RED COW CHOICE A : THE RED COW JUMPED OVER...

Difference between "process.stdout.write" and "console.log" in node.js?

What is the difference between "process.stdout.write" and "console.log" in node.js? EDIT: Using console.log for a variable showed a lot of unreadable characters while using process.stdout.write showe...

13 Feb at 22:59

Remove the last line from a file in Bash

I have a file, `foo.txt`, containing the following lines: ``` a b c ``` I want a simple command that results in the contents of `foo.txt` being: ``` a b ```

Understanding the difference between Object.create() and new SomeFunction()

I recently stumbled upon the `Object.create()` method in JavaScript, and am trying to deduce how it is different from creating a new instance of an object with `new SomeFunction()`, and when you would...

24 Jun at 18:45