Questions

Why doesn't list have safe "get" method like dictionary?

Why doesn't list have a safe "get" method like dictionary? ``` >>> d = {'a':'b'} >>> d['a'] 'b' >>> d['c'] KeyError: 'c' >>> d.get('c', 'fail') 'fail' >>> l = [1] >>> l[10] IndexError: list index ou...

Convert UTC Epoch to local date

I have been fighting with this for a bit now. I’m trying to convert epoch to a date object. The epoch is sent to me in UTC. Whenever you pass `new Date()` an epoch, it assumes it’s local epoch. I trie...

24 Oct at 10:23

What is the shortcut in IntelliJ IDEA to find method / functions?

I know that + is to find classes and it is very useful. But what about methods?

12 Apr at 10:34

A weighted version of random.choice

I needed to write a weighted version of random.choice (each element in the list has a different probability for being selected). This is what I came up with: ``` def weightedChoice(choices): """...

26 Jan at 12:31

jQuery change class name

I want to change the class of a td tag given the td tag's id: ``` <td id="td_id" class="change_me"> ... ``` I want to be able to do this while inside the click event of some other dom object. How ...

8 Apr at 06:3

How do I delete multiple rows in Entity Framework (without foreach)

I want to delete several items from a table using Entity Framework. There is no foreign key / parent object, so I can't handle this with `OnDeleteCascade`. Right now I'm doing this: ``` var widgets = ...

10 Feb at 16:12

How to sort a NSArray alphabetically?

How can I sort an array filled with `[UIFont familyNames]` into alphabetical order?

30 Nov at 11:42

Could not establish trust relationship for SSL/TLS secure channel -- SOAP

I have a simple web service call, generated by a .NET (C#) 2.0 Windows app, via the web service proxy generated by Visual Studio, for a web service also written in C# (2.0). This has worked for severa...

31 Dec at 21:16

How to load up CSS files using Javascript?

Is it possible to import css stylesheets into a html page using Javascript? If so, how can it be done? P.S the javascript will be hosted on my site, but I want users to be able to put in the `<head>`...

22 Feb at 13:48

Equivalent of typedef in C#

Is there a typedef equivalent in C#, or someway to get some sort of similar behaviour? I've done some googling, but everywhere I look seems to be negative. Currently I have a situation similar to the ...

23 Jun at 18:56

What are Java command line options to set to allow JVM to be remotely debugged?

I know there's some `JAVA_OPTS` to set to remotely debug a Java program. What are they and what do they mean ?

17 Apr at 10:55

In Angular, how do you determine the active route?

`[routerLinkActive]`[this answer](https://stackoverflow.com/a/37947435/1480995) In an Angular application (current in the 2.0.0-beta.0 release as I write this), how do you determine what the current...

How do I prevent the error "Index signature of object type implicitly has an 'any' type" when compiling typescript with noImplicitAny flag enabled?

I always compile TypeScript with the flag `--noImplicitAny`. This makes sense as I want my type checking to be as tight as possible. My problem is that with the following code I get the error: ``` Ind...

27 May at 04:19

How can I use environment variables in docker-compose?

I would like to be able to use environment variables inside , with values passed in at the time of `docker-compose up`. This is the example. I am doing this today with a basic `docker run` command, wh...

17 Feb at 01:30

react-router - pass props to handler component

I have the following structure for my React.js application using [React Router](https://github.com/ReactTraining/react-router): ``` var Dashboard = require('./Dashboard'); var Comments = require('./C...

"continue" in cursor.forEach()

I'm building an app using meteor.js and MongoDB and I have a question about `cursor.forEach()`. I want to check some conditions in the beginning of each `forEach` iteration and then skip the element i...

12 Dec at 15:50

Android - Launcher Icon Size

For `HDPI`, `XHDPI`, etc. what should be the ideal size of the launcher icon? Should I have to create `9-Patch` images for the icon to scale automatically, or would it be better to create separate ico...

8 Jul at 18:58

Objective-C ARC: strong vs retain and weak vs assign

There are two new memory management attributes for properties introduced by ARC, `strong` and `weak`. Apart from `copy`, which is obviously something completely different, `strong``retain``weak``assi...

Keyboard shortcut for Jump to Previous View Location (Navigate back/forward) in IntelliJ IDEA

I know ++ is used to go to the location of the last edit. But I want to jump to whichever location I was most recently at, not necessarily one where I edited anything. For example, if I jumped to a ...

3 May at 22:2

When should I use Lazy<T>?

I found this article about `Lazy`: [Laziness in C# 4.0 – Lazy](http://sankarsan.wordpress.com/2009/10/04/laziness-in-c-4-0-lazyt/) What is the best practice to have best performance using Lazy object...

7 Sep at 00:21

How to check if a string contains an element from a list in Python

I have something like this: ``` extensionsToCheck = ['.pdf', '.doc', '.xls'] for extension in extensionsToCheck: if extension in url_string: print(url_string) ``` I am wondering what w...

16 Jun at 09:53

How can I remove three characters at the end of a string in PHP?

How can I remove three characters at the end of a string in PHP? "abcabcabc" would become "abcabc"!

13 Oct at 18:2

What does LayoutInflater in Android do?

What is the use of [LayoutInflater](http://developer.android.com/reference/android/view/LayoutInflater.html) in Android?

Find string between two substrings

How do I find a string between two substrings (`'123STRINGabc' -> 'STRING'`)? My current method is like this: ``` >>> start = 'asdf=5;' >>> end = '123jasd' >>> s = 'asdf=5;iwantthis123jasd' >>> prin...

30 Jul at 06:1

How to use Boost in Visual Studio 2010

What is a good step by step explanation on how to use the Boost library in an empty project in Visual Studio?

6 Jun at 19:17