Questions

How to set JAVA_HOME environment variable on Mac OS X 10.9?

I just purchased a brand new MacBook Pro. This is my first MAC ever and I'm still trying to get the hang of navigating my way around. Anyway, I'm also new to Java and I've been practicing on my Wi...

14 Apr at 09:55

How to check if a service that I don't know the name of is running on Ubuntu

I do not know the service's name, but would like to stop the service by checking its status. For example, if I want to check if the [PostgreSQL](http://en.wikipedia.org/wiki/PostgreSQL) service is r...

23 Dec at 12:50

Jackson enum Serializing and DeSerializer

I'm using JAVA 1.6 and Jackson 1.9.9 I've got an enum ``` public enum Event { FORGOT_PASSWORD("forgot password"); private final String value; private Event(final String description) { ...

22 Oct at 05:20

Check if value exists in Postgres array

Using Postgres 9.0, I need a way to test if a value exists in a given array. So far I came up with something like this: ``` select '{1,2,3}'::int[] @> (ARRAY[]::int[] || value_variable::int) ``` Bu...

15 May at 16:4

How To Accept a File POST

I'm using asp.net mvc 4 webapi beta to build a rest service. I need to be able to accept POSTed images/files from client applications. Is this possible using the webapi? Below is how action I am cu...

3 Jul at 05:57

How to add parameters to HttpURLConnection using POST using NameValuePair

I am trying to do with `HttpURLConnection`(I need to use it this way, can't use `HttpPost`) and I'd like to add parameters to that connection such as ``` post.setEntity(new UrlEncodedFormEntity(nvp)...

How to have click event ONLY fire on parent DIV, not children?

I have a DIV with a classed `foobar`, and a few DIVs inside that DIV that are unclassed, but I suppose they are inheriting the `foobar` class: ``` $('.foobar').on('click', function() { /*...do stuff....

6 Dec at 16:49

In JavaScript, why is "0" equal to false, but when tested by 'if' it is not false by itself?

The following shows that `"0"` is false in Javascript: ``` >>> "0" == false true >>> false == "0" true ``` So why does the following print `"ha"`? ``` >>> if ("0") console.log("ha") ha ```

13 Jul at 02:36

Asserting successive calls to a mock method

Mock has a [helpful assert_called_with() method](https://docs.python.org/3/library/unittest.mock.html#unittest.mock.Mock.assert_called_with). However, as far as I understand this only checks the call...

18 Apr at 17:24

What does principal end of an association means in 1:1 relationship in Entity framework

``` public class Foo { public string FooId{get;set;} public Boo Boo{get;set;} } public class Boo { public string BooId{get;set;} public Foo Foo{get;set;} } ``` I was trying to do t...

String variable interpolation Java

String building in Java confounds me. I abhore doing things like: ``` url += "u1=" + u1 + ";u2=" + u2 + ";u3=" + u3 + ";u4=" + u4 + ";"; url += "x=" + u1 + ";y=" + u2 + ";z=" + u3 + ";da1=" + u4 + ";...

26 Feb at 22:15

Execution time of C program

I have a C program that aims to be run in parallel on several processors. I need to be able to record the execution time (which could be anywhere from 1 second to several minutes). I have searched for...

21 Nov at 06:37

Difference between fprintf, printf and sprintf?

Can anyone explain in simple English about the differences between `printf`, `fprintf`, and `sprintf` with examples? What stream is it in? I'm really confused between the three of these while readi...

16 Jan at 20:59

Creating PHP class instance with a string

I have two classes, `class ClassOne { }` and `class ClassTwo {}`. I am getting a string which can be either `"One"` or `"Two"`. Instead of using a long `switch` statement such as: ``` switch ($str) ...

19 Sep at 11:3

Aligning text and image on UIButton with imageEdgeInsets and titleEdgeInsets

I would like to place an icon left of the two lines of text such that there's about 2-3 pixels of space between the image and the start of text. The control itself is Center aligned horizontally (set ...

23 May at 11:47

Orchestration vs. Choreography

What are the differences between service orchestration and service choreography from an intra-organization point of view.

7 Dec at 03:44

Adding days to $Date in PHP

I have a date returned as part of a MySQL query in the form `2010-09-17`. I would like to set the variables $Date2 to $Date5 as follows: `$Date2 = $Date + 1` `$Date3 = $Date + 2` etc., so that it retu...

26 Jan at 14:22

Rails: Default sort order for a rails model?

I would like to specify a default sort order in my model. So that when I do a `.where()` without specifying an `.order()` it uses the default sort. But if I specify an `.order()`, it overrides the d...

5 Sep at 09:7

Best way to load module/class from lib folder in Rails 3?

Since the latest Rails 3 release is not auto-loading modules and classes from lib anymore, what would be the best way to load them? From github: > ``` A few changes were done in this commit: Do not...

Why can I not push_back a unique_ptr into a vector?

What is wrong with this program? ``` #include <memory> #include <vector> int main() { std::vector<std::unique_ptr<int>> vec; int x(1); std::unique_ptr<int> ptr2x(&x); vec.push_back(...

How to add an auto-incrementing primary key to an existing table, in PostgreSQL?

I have a table with existing data. Is there a way to add a primary key without deleting and re-creating the table?

What is the 'dynamic' type in C# 4.0 used for?

C# 4.0 introduced a new type called 'dynamic'. It all sounds good, but what would a programmer use it for? Is there a situation where it can save the day?

28 Nov at 09:0

Android: How to create a Dialog without a title?

I'm trying to generate a custom dialog in Android. I create my Dialog like this: ``` dialog = new Dialog(this); dialog.setContentView(R.layout.my_dialog); ``` Everythings works fine except for the...

5 Feb at 13:9

Android Activity as a dialog

I have an Activity named `whereActity` which has child dialogs as well. Now, I want to display this activity as a dialog for another activity. How can I do that? ![enter image description here](http...

Is Ruby pass by reference or by value?

``` @user.update_languages(params[:language][:language1], params[:language][:language2], params[:language][:language3]) lang_errors = @user.errors logge...