Questions

Age from birthdate in python

How can I find an age in python from today's date and a persons birthdate? The birthdate is a from a DateField in a Django model.

11 Mar at 15:4

Pick a random value from an enum?

If I have an enum like this: ``` public enum Letter { A, B, C, //... } ``` What is the best way to pick one randomly? It doesn't need to be production quality bulletproof, but a fai...

14 Aug at 16:42

Checking if a SQL Server login already exists

I need to check if a specific login already exists on the SQL Server, and if it doesn't, then I need to add it. I have found the following code to actually add the login to the database, but I want t...

8 May at 15:8

How can I apply a border only inside a table?

I am trying to figure out how to add border only inside the table. When I do: ``` table { border: 0; } table td, table th { border: 1px solid black; } ``` The border is around the whole tab...

9 Dec at 14:27

Why are empty catch blocks a bad idea?

I've just seen a [question on try-catch](https://stackoverflow.com/questions/1234278/good-ratio-of-catch-statements-to-lines-of-code), which people (including Jon Skeet) say empty catch blocks are a r...

23 May at 11:47

Android selector & text color

I want a simple `TextView` to behave the way `simple_list_item_1` in a `ListView` does. Here's the XML: ``` <TextView xmlns:android="http://schemas.android.com/apk/res/android" android:layout_hei...

15 Oct at 12:16

Rename a file using Java

Can we rename a file say `test.txt` to `test1.txt` ? If `test1.txt` exists will it rename ? How do I rename it to the already existing test1.txt file so the new contents of test.txt are added to it...

3 May at 14:21

Code equivalent to the 'let' keyword in chained LINQ extension method calls

Using the C# compilers query comprehension features, you can write code like: ``` var names = new string[] { "Dog", "Cat", "Giraffe", "Monkey", "Tortoise" }; var result = from animalName in names...

What's the difference between dynamic (C# 4) and var?

I had read a ton of articles about that new keyword that is shipping with C# v4, but I couldn't make out the difference between a "dynamic" and "var". [This article](http://www.hanselman.com/blog/C4A...

21 Jul at 17:44

How to make a DIV not wrap?

I need to create a container DIV style that contains multiple other DIV's. It is asked that these DIV's wouldn't wrap if the browser window is resized to be narrow. I tried to make it work like below...

17 Apr at 22:12

How to check which locks are held on a table

How can we check which database locks are applied on which rows against a query batch? Any tool that highlights table row level locking in real time? DB: SQL Server 2005

How do I get ruby to print a full backtrace instead of a truncated one?

When I get exceptions, it is often from deep within the call stack. When this happens, more often than not, the actual offending line of code is hidden from me: ``` tmp.rb:7:in `t': undefined method...

20 Jun at 00:18

CSS div element - how to show horizontal scroll bars only?

I have a div container and have defined its style as follows: ``` div#tbl-container { width: 600px; overflow: auto; scrollbar-base-color:#ffeaff } ``` This gives me both horizon...

3 Nov at 11:24

Find where java class is loaded from

Does anyone know how to programmaticly find out where the java classloader actually loads the class from? I often work on large projects where the classpath gets very long and manual searching is n...

20 Sep at 14:5

Check if option is selected with jQuery, if not select a default

Using jQuery, how do you check if there is an option selected in a select menu, and if not, assign one of the options as selected. (The select is generated with a maze of PHP functions in an app I ju...

Visual Studio: How to break on handled exceptions?

I would like Visual Studio to break when a handled exception happens (i.e. I don't just want to see a "First chance" message, I want to debug the actual exception). e.g. I want the debugger to break ...

22 Oct at 15:36

How do I change the number of open files limit in Linux?

When running my application I sometimes get an error about `too many files open`. Running `ulimit -a` reports that the limit is 1024. How do I increase the limit above 1024? `ulimit -n 2048` res...

25 Apr at 23:0

Round corner for BottomSheetDialogFragment

I have a custom BttomSheetDialogFragment and I want to have round corners in top of Bottom View This is my Custom class that inflates my layout that I want to appear from bottom ``` View mView; @Over...

Using List/Tuple/etc. from typing vs directly referring type as list/tuple/etc

What's the difference of using `List`, `Tuple`, etc. from `typing` module: ``` from typing import Tuple def f(points: Tuple): return map(do_stuff, points) ``` As opposed to referring to Python...

6 Oct at 13:55

Default property value in React component using TypeScript

I can't figure out how to set default property values for my components using Typescript. This is the source code: ``` class PageState { } export class PageProps { foo: string = "bar"; } expor...

17 May at 16:52

Build and Install unsigned apk on device without the development server?

As I am new in react-native so if there is anything wrong in steps let me know. I have build a react native android app using the command as per documentation > react-native android while running o...

19 Jan at 14:21

PostgreSQL: role is not permitted to log in

I have trouble connecting to my own postgres db on a local server. I googled some similar problems and came up with this manual [https://help.ubuntu.com/stable/serverguide/postgresql.html](https://hel...

4 Jun at 18:45

How to programmatically skip a test in mocha?

I have a code where certain tests will always fail in CI environment. I would like to disable them based on an environment condition. How to programmatically skip a test in mocha during the runtime e...

22 Sep at 17:26

Android Studio was unable to find a valid Jvm (Related to MAC OS)

I am unable to start my Android Studio for Android development on Mac OS (10.10.1 - Yosemite)

13 Jun at 16:33

How to delete the last row of data of a pandas dataframe

I think this should be simple, but I tried a few ideas and none of them worked: ``` last_row = len(DF) DF = DF.drop(DF.index[last_row]) #<-- fail! ``` I tried using negative indices but that also ...

14 Feb at 05:28