Questions

Remove file extension from a file name string

If I have a string saying `"abc.txt"`, is there a quick way to get a substring that is just `"abc"`? I can't do an `fileName.IndexOf('.')` because the file name could be `"abc.123.txt"` or something ...

12 Jan at 10:11

Semaphore vs. Monitors - what's the difference?

What are the major differences between a and a ?

7 Sep at 14:52

How to serialize an Object into a list of URL query parameters?

Without knowing the keys of a JavaScript `Object`, how can I turn something like... ``` var obj = { param1: 'something', param2: 'somethingelse', param3: 'another' } obj[param4] = 'yetanoth...

13 Jun at 08:48

TypeError: 'str' does not support the buffer interface

``` plaintext = input("Please enter the text you want to compress") filename = input("Please enter the desired filename") with gzip.open(filename + ".gz", "wb") as outfile: outfile.write(plaintext...

5 Oct at 00:0

How do I use brew installed Python as the default Python?

I try to switch to Homebrew (after using fink and macport) on Mac OS X 10.6.2. I have installed python 2.7 with ``` brew install python ``` The problem is that, contrary to Macport, it seems that ...

30 Aug at 14:10

How can I check in a Bash script if my local Git repository has changes?

There are some scripts that do not work correctly if they check for changes. I tried it like this: ``` VN=$(git describe --abbrev=7 HEAD 2>/dev/null) git update-index -q --refresh CHANGED=$(git dif...

31 Dec at 13:54

Markdown and including multiple files

Is there any markdown fork that allows you to reference other files, something like an includes file? Specifically, I want to create a separate markdown file with links that I call often but not alway...

28 Oct at 17:59

How to order by with union in SQL?

Is it possible to order when the data is come from many select and union it together? Such as ``` Select id,name,age From Student Where age < 15 Union Select id,name,age From Student Where Name like "...

25 Nov at 16:42

What is the meaning of CTOR?

In a lot of C# files I see regions tags(?) that are named CTOR or ctor. What's the meaning of ctor? Why is such a region called ctor?

3 Feb at 11:56

Difference between Activity Context and Application Context

This has me stumped, I was using this in Android 2.1-r8 SDK: ``` ProgressDialog.show(getApplicationContext(), ....); ``` and also in ``` Toast t = Toast.makeText(getApplicationContext(),....); ``...

8 Jun at 14:52

How to get Maven project version to the bash command line

Previous I issued a question on [how to change Maven project vesion from command line](https://stackoverflow.com/questions/3519005/update-a-maven-project-version-from-script) which lead me to a new is...

30 Aug at 11:56

JavaScript/jQuery to download file via POST with JSON data

I have a jquery-based single-page webapp. It communicates with a RESTful web service via AJAX calls. I'm trying to accomplish the following: 1. Submit a POST that contains JSON data to a REST url....

12 May at 13:33

Define an alias in fish shell

I would like to define some aliases in fish. Apparently it should be possible to define them in ``` ~/.config/fish/functions ``` but they don't get auto loaded when I restart the shell. Any ideas?...

9 Dec at 04:30

How to get the caller's method name in the called method?

Python: How to get the caller's method name in the called method? Assume I have 2 methods: ``` def method1(self): ... a = A.method2() def method2(self): ... ``` If I don't want to do ...

24 Sep at 22:30

Why can't C# interfaces contain fields?

For example, suppose I want an `ICar` interface and that all implementations will contain the field `Year`. Does this mean that every implementation has to separately declare `Year`? Wouldn't it be ...

19 Dec at 22:15

Add new value to an existing array in JavaScript

In PHP, I'd do something like: ``` $array = array(); $array[] = "value1"; $array[] = "value2"; $array[] = "value3"; ``` How would I do the same thing in JavaScript?

15 Nov at 10:9

How can I define colors as variables in CSS?

I’m working on a CSS file that is quite long. I know that the client could ask for changes to the color scheme, and was wondering: is it possible to assign colors to variables, so that I can just chan...

23 Jul at 02:22

How to assign from a function which returns more than one value?

Still trying to get into the R logic... what is the "best" way to unpack (on LHS) the results from a function returning multiple values? I can't do this apparently: ``` R> functionReturningTwoValue...

C++ sorting and keeping track of indexes

Using C++, and hopefully the standard library, I want to sort a sequence of samples in ascending order, but I also want to remember the original indexes of the new samples. For example, I have a set, ...

18 Jul at 16:49

Function to Calculate Median in SQL Server

According to [MSDN](http://msdn.microsoft.com/en-us/library/ms173454.aspx), Median is not available as an aggregate function in Transact-SQL. However, I would like to find out whether it is possible t...

Function passed as template argument

I'm looking for the rules involving passing C++ templates functions as arguments. This is supported by C++ as shown by an example here: ``` void add1(int &v) { v += 1 } void add2(int &v) { v += 2 } ...

Python: access class property from string

I have a class like the following: ``` class User: def __init__(self): self.data = [] self.other_data = [] def doSomething(self, source): // if source = 'other_data' ...

22 Jul at 20:40

How to ignore files/directories in TFS for avoiding them to go to central source repository?

Is it possible to set up files/folders to ignore on a per-project basis in TFS source control? For example, I've a website with an assets folder that I do not want to go in to source control. These a...

21 Jul at 23:20

Getting a list of associative array keys

I have an associative array in JavaScript: ``` var dictionary = { "cats": [1,2,3,4,5], "dogs": [6,7,8,9,10] }; ``` How do I get this dictionary's keys? I.e., I want ``` var keys = ["cats", "d...

15 Jul at 00:39

How can you strip non-ASCII characters from a string? (in C#)

How can you strip non-ASCII characters from a string? (in C#)

5 Jun at 13:46