JavaScript: dot vs bracket notation

During linting my code jshint gave me the “hint” that I should prefer dot notation over bracket notation.

"testcase": data.finding["testcase"], [‘testcase’] is better written in dot notation.

What is that?

  • Accessing members with “.” is called “dot notation”.
  • Accessing them with [] is called “bracket notation”.

 

The Normal Distribution

Diving deeper into data science I started to brush up my knowledge about math especially statistics.

The Mother of all Distributions

The normal distribution was formulated by Carl Friedrich Gauß in 18XX and can be implemented in Python like the following :

def normal_distribution(x, mu=0, sigma=1):
    sqrt_two_pi = math.sqrt(2*math.pi)
    return math.exp(-(x-mu)**2 / 2 / sigma**2) / sqrt_two_pi * sigma

Useful Outlook Settings

Being forced to use Outlook at work, I use the following configuration:

  • Disable Popups
    • Options -> Mail -> Message Arrival
  • Default Reminder -> 5mins
    • Options -> Calendar -> Calendar options -> Default reminders
  • Activate Week Number
    • Options -> Calendar -> Display options -> Show week numbers in the month view
  • Enable Calendar in Mail View
    • Mail View -> View -> ToDo-Bar -> Calendar

 

KnockoutJS: passing parameters to components

HTML

<my-component params='from: "foo"'></my-component>

JS

class MyViewModel {
    constructor(params) {
        console.log(params["from"]);
    }
}

ko.components.register('table-edit', {
    template:
        ``,

    viewModel: {
        createViewModel(params) {
            return new TableViewModel(params);
        },
    }
});

Distributing your own package on PyPi

In Regular Expressions Demystified I developed a little python package and distributed it via PyPi.

I wanted to publish my second self-written package as well, but coming back after almost a year, some things have changed in the world of PyPi, i.e. the old tutorials aren’t working anymore.

What You have to do is the following thing in a nutshell:

python setup.py sdist
twine upload dist/*

The complete guide can be found here.

pip optional dependencies

Sometimes you want to make your python package usable for different situations, e.g. flask or bottle or django.

If You want to minimize dependencies You can use an optional dependency in setup.py:

extras_require={
 'flask': ['Flask>=0.8', 'blinker>=1.1']
}

Now you can install the library with:

pip install raven[flask]

 

Add Vaadin Maven Archetype to IntelliJ

On Windows You can add the Maven archetype for Vaadin to IntelliJ IDEA the following way:

Open:

c:\Users\username\.IdeaIC2017.3\system\Maven\Indices\UserArchetypes.xml

and add the line:

<archetypes>
 <archetype groupId="com.vaadin" artifactId="vaadin-archetype-application" version="8.3.2" />
</archetypes

Now you can create a new Vaadin project via Maven