How to use Epson POS printer TM-T20II under linux

Getting an epson pos printer up and running under linux is very easy:

# add current user to lp group (requires relogin to work properly)
sudo usermod -a -G lp $USER

# for TM-T20II add udev rule (optional in my case):
echo 'SUBSYSTEM=="usb", ATTRS{idVendor}=="04b8", ATTRS{idProduct}=="0e15", MODE="0664", GROUP="lp"' > sudo tee -a /etc/udev/rules.d/99-escpos.rules
sudo service udev restart

# install pip and pipenv
sudo apt install python-pip
pip install --user pipenv

# install download python-escpos and submodules
git clone https://github.com/python-escpos/python-escpos.git
cd python-escpo
git submodule update --init --recursive

# install including deps
pipenv install -e .

Now you should be ready to use the installation. From your installation repository run a pipenv shell by using “pipenv shell” or simply run “pipenv run python _your-script_.py” to run a script directly.

Here is an example script:

from escpos.printer import Usb

# see https://github.com/python-escpos/python-escpos/blob/development/src/escpos/escpos.py

""" Seiko Epson Corp. Receipt Printer (EPSON TM-T20II) """
p = Usb(0x04b8, 0x0e15, 0, profile="TM-T88II")

p.set(bold=True, underline=1, align='center', custom_size=True, width=2, height=2)
p.textln("Hello world")
p.ln(count=1)
p.set()
p.textln("this is a test")

p.set(align='center')
p.image("examples/graphics/climacons/rain.png")
p.qr("Dies ist ein Test", size=8)
p.set()

p.barcode('1324354657687', 'EAN13', width=3)
p.barcode('123456', 'CODE39', width=3)

p.block_text("Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.", font='a', columns=None)

p.cut()

redis-server on ubuntu 18.04

After installing redis on my machine I received the following error message:

redis-server.service: Can’t open PID file /var/run/redis/redis-server.pid (yet?) after start: No such file or directory

This message comes because redis refuses to start with disabled ipv6. To get it running you have to remove “::1” from “bind 127.0.0.1 ::1” in /etc/redis/redis.conf. Then redis starts as expected.

Add charles certificate to JVM

This is an example how to do that on a Mac:

sudo keytool -import -noprompt -alias charles-$(date +%Y%m%d%H%M%S) -file "Downloads/charles-ssl-proxying-certificate.pem" -keystore "/Library/Java/JavaVirtualMachines/jdk-10.0.2.jdk/Contents/Home/lib/security/cacerts" -storepass changeit

 

Add charles ssl proxy certificates to JDK on a mac

First you need to run charles and enable SSL proxying. The see which JDK is used by your application and add the certificate to the cacerts file:

curl -s http://ssl.charles/ --proxy 127.0.0.1:8888 > cert_file
sudo keytool -import -noprompt -alias charles-$(date +%Y%m%d%H%M%S) \
  -file cert_file \
  -keystore /Library/Java/JavaVirtualMachines/jdk-10.0.2.jdk/Contents/Home/lib/security/cacerts \
  -storepass changeit
rm cert_file

 

Access Ubuntu 18.04 via VNC from Mac

Ubuntu

First prepare the ubuntu machine by installing vino:

sudo apt install vino

Then hit windows button and look for sharing. Configure the system to allow remote connections with given password.

You also need to disable encryption with:

gsettings set org.gnome.Vino require-encryption false

MAC

Then you can access the machine from your Mac with Screen Sharing app with the url

vnc://<IP>:5900

 

Add network bridge with ubuntu 18.04

To create a network bridge with netplan you have to create a file

network:
  version: 2
  ethernets:
     enp6s0:
        dhcp4: true
  bridges:
     br0:
       interfaces: [enp6s0]
       dhcp4: true
       optional: false
       macaddress: <some mac>

Make sure to place a mac address in and replace the interface name enp6s0 with yours.

Then run sudo netplan apply.

The machine gets a new IP from dhcp so make sure you have it configured in your dhcp before or have a local console 😉

run kong with compose

Here a simple docker-compose.yml file to get kong community up and running. It is configured to use postgresql that persists data to a local docker volume. All ports are mapped to localhost only and log goes to stdout/stderr.

version: '3.4'
services:
  kong-db:
    image: 'postgres:10.1'
    ports:
      - 127.0.0.1:5432:5432
    environment:
      POSTGRES_USER: kong
      POSTGRES_PASSWORD: kong
      POSTGRES_DB: kong
      PGDATA: /var/lib/postgresql/data/pgdata
    volumes:
      - db-volume:/var/lib/postgresql/data/pgdata
    healthcheck:
      test: 'echo "select 1" | psql -U kong kong || exit 1'
      interval: 1m
      timeout: 3s
      retries: 3
    restart: unless-stopped

  kong:
    image: 'kong:0.11.2'
    ports:
      - 127.0.0.1:8000:8000
      - 127.0.0.1:8443:8443
      - 127.0.0.1:8001:8001
      - 127.0.0.1:8444:8444
    environment:
      KONG_DATABASE: postgres
      KONG_PG_HOST: kong-db
      KONG_PG_DATABASE: kong
      KONG_PG_USER: kong
      KONG_PG_PASSWORD: kong
      KONG_PROXY_ACCESS_LOG: /dev/stdout
      KONG_ADMIN_ACCESS_LOG: /dev/stdout
      KONG_PROXY_ERROR_LOG: /dev/stderr
      KONG_ADMIN_ERROR_LOG: /dev/stderr
    links:
      - kong-db
# uncomment following line to run migrations for a new database
#    command: kong migrations up -v
    depends_on:
      - kong-db
    healthcheck:
      test: 'curl -f http://localhost:8001/status || exit 1'
      interval: 1m
      timeout: 3s
      retries: 3
    restart: unless-stopped

volumes:
  db-volume:

Attention: The kong container fails to start unless migrations are not run on the connected database. To do this simply uncomment the marked line and start the containers. With the command set the container will execute database migrations and stop with exit code 0. After that the line can be commented out again. Then you can start kong with the given file.

IntelliJ IDEA on Mac OS

When using IntelliJ IDEA with Spring Boot on a Mac make sure you have the entry

127.0.0.1 <hostname>.local

in your /etc/hosts file. Replace <hostname> with your Mac’s name. Also make sure that the result of the command ‘hostname’ is in your /etc/hosts file as well pointing to your local address.

Java 9 released

After years of development Oracle has released Java 9. It is available to download from the Oracle page as usual. Here is the EOL message for Java 8:

End of Public Updates for Oracle JDK 8

Oracle will not post further updates of Java SE 8 to its public download sites for commercial use after September 2018. Customers who need continued access to critical bug fixes and security fixes as well as general maintenance for Java SE 8 or previous versions can get long term support through Oracle Java SE Advanced, Oracle Java SE Advanced Desktop, or Oracle Java SE Suite. For more information, and details on how to receive longer term support for Oracle JDK 8, please see the Oracle Java SE Support Roadmap.