Questions

How to request a random row in SQL?

How can I request a random row (or as close to truly random as is possible) in pure SQL?

7 Jul at 13:26

Create new column based on values from other columns / apply a function of multiple columns, row-wise in Pandas

I want to apply my custom function (it uses an if-else ladder) to these six columns (`ERI_Hispanic`, `ERI_AmerInd_AKNatv`, `ERI_Asian`, `ERI_Black_Afr.Amer`, `ERI_HI_PacIsl`, `ERI_White`) in each row ...

20 Dec at 13:4

What is the difference among col-lg-*, col-md-* and col-sm-* in Bootstrap?

What is the difference among `col-lg-*` , `col-md-*` and `col-sm-*` in Twitter Bootstrap?

Is there a way to follow redirects with command line cURL?

I know that in a php script: ``` curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); ``` will follow redirects. Is there a way to follow redirects with command line cURL?

31 Aug at 20:37

What is the difference between `throw new Error` and `throw someObject`?

I want to write a common error handler which will catch custom errors thrown on purpose at any instance of the code. When I did `throw new Error('sample')` like in the following code ``` try { t...

Convert Set to List without creating new List

I am using this code to convert a `Set` to a `List`: ``` Map<String, List<String>> mainMap = new HashMap<>(); for (int i=0; i < something.size(); i++) { Set<String> set = getSet(...); //returns di...

8 May at 12:48

How to disable the resize grabber of <textarea>?

How to disable the grabber in the `<textarea>`? I mean that triangle thing which appears in the right-bottom corner of the `<textarea>`.

24 Jun at 20:16

How to scale an Image in ImageView to keep the aspect ratio

In Android, I defined an `ImageView`'s `layout_width` to be `fill_parent` (which takes up the full width of the phone). If the image I put to `ImageView` is bigger than the `layout_width`, Android wi...

Can enums be subclassed to add new elements?

I want to take an existing enum and add more elements to it as follows: ``` enum A {a,b,c} enum B extends A {d} /*B is {a,b,c,d}*/ ``` Is this possible in Java?

14 Jun at 12:33

How to prevent line breaks in list items using CSS

I'm trying to put a link called in a menu using a `li` tag. Because of the whitespace between the two words it wraps to two lines. How to prevent this wrapping with CSS?

29 Aug at 09:21

How to build a query string for a URL in C#?

A common task when calling web resources from a code is building a query string to including all the necessary parameters. While by all means no rocket science, there are some nifty details you need t...

13 Mar at 17:30

ERROR 1698 (28000): Access denied for user 'root'@'localhost'

I'm setting up a new server and keep running into this problem. When I try to log into the MySQL database with the root user, I get the error: > ERROR 1698 (28000): Access denied for user 'root'@'loca...

21 Sep at 14:48

What are the advantages of list initialization (using curly braces)?

``` MyClass a1 {a}; // clearer and less error-prone than the other three MyClass a2 = {a}; MyClass a3 = a; MyClass a4(a); ```

UPDATE and REPLACE part of a string

I've got a table with two columns, `ID` and `Value`. I want to change a part of some strings in the second column. Example of Table: ``` ID Value --------------------------------- 1 ...

'password authentication failed for user "postgres"'

I have installed PostgreSQL 8.4, Postgres client and Pgadmin 3. Authentication failed for user "postgres" for both console client and Pgadmin. I have typed user as "postgres" and password "postgres", ...

10 Jun at 14:58

How does OAuth 2 protect against things like replay attacks using the Security Token?

As I understand it, the following chain of events occurs in OAuth 2 in order for `Site-A` to access information from `Site-B`. 1. Site-A registers on Site-B, and obtains a Secret and an ID. 2. When...

27 Jun at 15:33

Programmatic equivalent of default(Type)

I'm using reflection to loop through a `Type`'s properties and set certain types to their default. Now, I could do a switch on the type and set the `default(Type)` explicitly, but I'd rather do it in...

3 Sep at 06:37

How do I programmatically set the value of a select box element using JavaScript?

I have the following HTML `<select>` element: ``` <select id="leaveCode" name="leaveCode"> <option value="10">Annual Leave</option> <option value="11">Medical Leave</option> <option value="14">...

23 Jul at 11:41

How do you detect Credit card type based on number?

I'm trying to figure out how to detect the type of credit card based purely on its number. Does anyone know of a definitive, reliable way to find this?

How to open link in a new tab in HTML?

I'm working on an HTML project, and I can't find out how to open a link in a new tab without JavaScript. I already know that `<a href="http://www.WEBSITE_NAME.com"></a>` opens the link in the same tab...

11 Mar at 01:2

How to view method information in Android Studio

In Eclipse, when you hover your mouse over a method, a window would appear with a description of what the method does, what the parameters mean and what it returns. Is there a way to get Android Studi...

8 Jul at 17:1

How do you get centered content using Twitter Bootstrap?

I'm trying to follow a very basic example. Using the [starter page and the grid system](http://getbootstrap.com/css/#grid), I was hoping the following: ``` <div class="row"> <div class="span12"> ...

28 Oct at 10:9

Import regular CSS file in SCSS file?

Is there anyway to import a regular CSS file with Sass's `@import` command? While I'm not using all of the SCSS syntax from sass, I do still enjoy it's combining/compressing features, and would like t...

7 Jan at 07:31

How to get the return value from a thread?

The function `foo` below returns a string `'foo'`. How can I get the value `'foo'` which is returned from the thread's target? ``` from threading import Thread def foo(bar): print('hello {}'.form...

Hibernate throws MultipleBagFetchException - cannot simultaneously fetch multiple bags

Hibernate throws this exception during SessionFactory creation: > org.hibernate.loader.MultipleBagFetchException: cannot simultaneously fetch multiple bags This is my test case: ``` @Entity publi...

29 Apr at 16:42