First Steps in Postgres

By default, postgres allow only local connections and and uses peer authentification to access the databases. In some cases this provoke the error message “

FATAL: Peer authentication failed for user "postgres"

This is an explanation how to configure postgres to ask for encrypted password and allow remote connections.

Change password for rootuser “postgres”

Connect to the default database with user postgres

sudo -u postgres psql template1

Set the password for user postgres

ALTER USER postgres with encrypted password 'yourpassword';

Exit (ctrl + d)

Config your postgres to allow remote access and to ask for passwords

Get your IP

curl ipinfo.io/ip

here 172.168.0.1

Find postgresql.conf

find / -name "postgresql.conf"

here /etc/postgresql/10/main/postgresql.conf

Edit the file

sudo vim /etc/postgresql/10/main/postgresql.conf

Replace

#listen_addresses = 'localhost'

With

listen_addresses = '*'

Find pg_hba.conf

sudo find / -name "pg_hba.conf

here /etc/postgres/10/main/pg_hba.conf

Edit the file

sudo vim /etc/postgresql/10/main/pg_hba.conf

Change lines

local    all    postgres              peer

local    all    all                   peer

To

local    all    postgress             md5

local    all    all                   md5

And add

host    all    all    172.168.0.1/32  md5

Restart the database

sudo /etc/init.d/postgresql restart

Check, if it worked

pql -U postgres

Exit (ctrl + d)

Create user and database

Create user with linuxusername

sudo createuser -U postgres -d -e -E -l -P -r -s $USER

Create database

createdb mynewdatabase

You can now remote connect to your database

 

Two Snakes and a Notebook

“The Jupyter Notebook is an open-source web application that allows you to create and share documents that contain live code, equations, visualizations and narrative text.”

A notebook consists mainly of markdown cells to build narratives around your code and code cells to define computional code respectively show output of executed code (see figure 1).

Cell Types
Figure 1: The main cell types

Jupyter offers the possibily to explain and run your code in blocks, which is quite nice – not only for data scientists, but for tutorial writers as well: you don’t have to do all the copy&paste stuff anymore. It supports code in many programming languages, Continue reading Two Snakes and a Notebook

Ubuntu in a Box

Linux is a wounderful operating system for coding and development, but Windows or Mac OS also have advantages. My favorite Linux distribution is Ubuntu (even if there are good reasons to use Linux Mint or Xubuntu). To combine the best of different operating systems, you don’t have to install them side by side: In many cases a virtual machine (VM) is sufficient, especially if your system has a SSD, 8 GB ram and an eight-core processor.

I’m using Oracle Virtual Box, because it’s free and together with an extension pack it delivers a bunch of useful options and features (like a shared clipboard or shared folders and so on). Continue reading Ubuntu in a Box

Ocropy OCR – good results for Gothic/Fraktur Typeface

Ocropy (also called ocropus) is not a standalone program for text recognition: it consists of several command line modules for

  • binarization (creates a binary raster graphic)
  • segmentation (splitting documents into lines)
  • optical character recognition (OCR)
  • controlling the recognised text and
  • training new character sets.

Continue reading Ocropy OCR – good results for Gothic/Fraktur Typeface