Questions

How to print a dictionary line by line in Python?

This is the dictionary ``` cars = {'A':{'speed':70, 'color':2}, 'B':{'speed':60, 'color':3}} ``` Using this `for loop` ``` for keys,values in cars.items(): print(keys) ...

3 Apr at 11:10

Access nested dictionary items via a list of keys?

I have a complex dictionary structure which I would like to access via a list of keys to address the correct item. ``` dataDict = { "a":{ "r": 1, "s": 2, "t": 3 },...

29 Dec at 03:4

How to configure slf4j-simple

api 1.7 and slf4j-simple as implementation. I just can't find how to configure the logging level with this combination. Can anyone help out?

27 Jan at 06:21

What's the difference between “mod” and “remainder”?

My friend said that there are differences between "mod" and "remainder". If so, what are those differences in C and C++? Does '%' mean either "mod" or "rem" in C?

1 Jul at 11:54

C# Thread safe fast(est) counter

What is the way to obtain a thread safe counter in C# with best possible performance? This is as simple as it gets: ``` public static long GetNextValue() { long result; lock (LOCK) { ...

How to add column if not exists on PostgreSQL?

Question is simple. How to add column `x` to table `y`, but only when `x` column doesn't exist ? I found only solution [here](https://stackoverflow.com/questions/9991043/how-can-i-test-if-a-column-ex...

23 May at 12:10

How can I convert this foreach code to Parallel.ForEach?

I am a bit of confused about `Parallel.ForEach`. What is `Parallel.ForEach` and what does it exactly do? Please don't reference any MSDN link. Here's a simple example : ``` string[] lines = File....

How to check if DST (Daylight Saving Time) is in effect, and if so, the offset?

This is a bit of my JS code for which this is needed: ``` var secDiff = Math.abs(Math.round((utc_date-this.premiere_date)/1000)); this.years = this.calculateUnit(secDiff,(86400*365)); this.days = thi...

AppSettings get value from .config file

I'm not able to access values in configuration file. ``` Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None); var clientsFilePath = config.AppSettings.Settin...

Converting a list to a set changes element order

Recently I noticed that when I am converting a `list` to `set` the order of elements is changed and is sorted by character. Consider this example: ``` x=[1,2,20,6,210] print(x) # [1, 2, 20, 6, 210] # ...

17 May at 03:37

How can I select the element prior to a last child?

I am looking for a CSS selector that lets me select the penultimate child of a list. ``` <ul> <li>1</li> <li>2</li> <li>3</li> <li>4</li> <li>5</li> <!-- select the pre last ...

22 Jun at 18:51

what exactly is device pixel ratio?

this is mentioned every article about mobile web, but nowhere I can found an explanation of what exactly does this attribute measure. Can anyone please elaborate what does queries like this check? ``...

9 Jan at 08:34

__FILE__ macro shows full path

The standard predefined macro `__FILE__` available in C shows the full path to the file. Is there any way to short the path? I mean instead of ``` /full/path/to/file.c ``` I see ``` to/file.c ``` ...

30 Mar at 16:39

How to get current date in jQuery?

I want to know how to use the Date() function in jQuery to get the current date in a `yyyy/mm/dd` format.

3 Apr at 08:39

How to create a file in Ruby

I'm trying to create a new file and things don't seem to be working as I expect them too. Here's what I've tried: ``` File.new "out.txt" File.open "out.txt" File.new "out.txt","w" File.open "out.txt"...

6 Dec at 19:27

Generate model in Rails using user_id:integer vs user:references

I'm confused on how to generate a model that belongs_to another model. My book uses this syntax to associate Micropost with User: ``` rails generate model Micropost user_id:integer ``` but [https://g...

21 Jul at 09:23

How to change Git log date formats

I am trying to display the last commit within Git, but I need the date in a special format. I know that the log pretty format `%ad` respects the `--date` format, but the only `--date` format I can fi...

19 Jul at 20:18

How to perform runtime type checking in Dart?

Dart specification states: > Reified type information reflects the types of objects at runtime and may always be queried by dynamic typechecking constructs (the analogs of instanceOf, casts, typeca...

18 Feb at 11:49

Detect If Browser Tab Has Focus

Is there a reliable cross-browser way to detect that a tab has focus. The scenario is that we have an application that polls regularly for stock prices, and if the page doesn't have focus we could st...

12 Sep at 14:26

range() for floats

Is there a `range()` equivalent for floats in Python? ``` >>> range(0.5,5,1.5) [0, 1, 2, 3, 4] >>> range(0.5,5,0.5) Traceback (most recent call last): File "<pyshell#10>", line 1, in <module> ...

1 Sep at 07:30

What do hjust and vjust do when making a plot using ggplot?

Every time I make a plot using ggplot, I spend a little while trying different values for hjust and vjust in a line like ``` + opts(axis.text.x = theme_text(hjust = 0.5)) ``` to get the axis label...

1 Sep at 21:12

How to convert List<string> to List<int>?

My question is part of this problem: I recieve a collection of id's from a form. I need to get the keys, convert them to integers and select the matching records from the DB. ``` [HttpPost] publ...

1 Jun at 12:46

Gradle proxy configuration

I need web access from Gradle through a proxy server to use the Gradle/Artifactory integration for Jenkins. To reduce possible causes for issues, I manually add the Artifactory plugin in build.gradle ...

Load HTML file into WebView

I have a local html page along with several other resources pointed by it (css files and Javascript libraries) that I would like to load into a WebView . How could this be achieved ? Perhaps not the ...

22 Mar at 17:19

How to make a class property?

In python I can add a method to a class with the `@classmethod` decorator. Is there a similar decorator to add a property to a class? I can better show what I'm talking about. ``` class Example(obj...

25 Mar at 15:29