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

 

Numpy linspace function

To create e.g. x-axis indices you can use the linspace function from numpy.

You give it a range (e.g. 0 to 10) and the number of divisions and it will distribute the values evenly across that range. The stop values is included in the resulting value array by default.

Example:

>>import numpy as np
>>np.linspace(0, 10, num=9)
>>array([ 0. , 1.25, 2.5 , 3.75, 5. , 6.25, 7.5 , 8.75, 10. ]

Arduino PROGMEM

To save RAM on your Arduino You can annotate immutable variables like lookup tables or strings with the PROGMEM keyword. The data will be stored in program memory.

const dataType variableName[] PROGMEM = {data0, data1, data3…​};

Removing pyc files on server

Sometimes Python gives You a hard time when You deploy code to a server after you changed directory structures or simply moved files.
With the following command You can remove the pyc files in the working directory and subdirectories:

find . -name \*.pyc -delete

SQL-Basics: Create – Read – Update – Delete

This episode is about the basic statements needed to create, read, update and delete data in a database system.

Let’s assume we work as a data scientist for Knight Industries.  We want to help the Foundation of Law and Government to keep track of our operatives.

We decide to use a classic relational database management system or RDBMS. In order to explore Database Management Systems we can either install one locally or we can use an online tool like SQLFiddle.

To interact with RDBMS we use SQL – the Structured Query Language.

As the name says SQL (speak either S-Q-L or Sequel) is used to write structured queries. Think of “conversations” when You think of “queries”.

So, let’s fire up SQLFiddle. Continue reading “SQL-Basics: Create – Read – Update – Delete”