PDF on the command line

jfbview is an excellent program to view pdf files on the commandline. The author, Chuan Ji, has an fine description how to compile it. The make file had to be edited to compile on Debian as kalpha2 described in the issues section on the github page.

When jfbview is compiled and put in the path it is as simple as:
$ jfbview filename.pdf

Python 3.7 on Debian Stretch

To install the latest python on Debian (python 3.7 in this case) we need to go through a few steps.
First install some dependencies.

sudo apt-get install -y libffi-dev libbz2-dev liblzma-dev libsqlite3-dev libncurses5-dev libgdbm-dev zlib1g-dev libreadline-dev libssl-dev tk-dev build-essential libncursesw5-dev libc6-dev openssl git

Next download python 3.7 and extract it.

wget https://www.python.org/ftp/python/3.7.0/Python-3.7.0.tar.xz
tar xvf Python-3.7.0.tar.xz
cd Python-3.7.0

Configure, make and make install

./configure --enable-optimizations --with-ensurepip=install
make -j8
sudo make altinstall

Update your update-alternatives
Use whereis python to find the location of your binaries

update-alternatives --install /usr/bin/python python /usr/local/bin/python3.7 50
update-alternatives --install /usr/bin/python python /usr/bin/python2.7 40
update-alternatives --install /usr/bin/python python /usr/bin/python3.5 30

sources:
unix.stackexchange.com
www.scivision.co
image is the logo of python.org

From twitter to rss

Yes, rss is still alive. To follow a twitter account in a rss reader you need a rss feed. Twitter does not provide it probably to encourage you to login to twitter.

Charlie Harvey wrote a nice script and hosts it on https://www.twitrss.me/.
Simply type in a twitter account or a twitter search and it will return an url of an rss feed. Paste that url in your favorite rss reader and Bob is your uncle.

Thank you Charlie, for writing this great script and thanks to Bytemark for hosting it.

ESP-32 config wifi in micropython

Make a file with the name ConnectWifi.py with the following code:

def do_connect():
    import network
    sta_if = network.WLAN(network.STA_IF)
    if not sta_if.isconnected():
        print('connecting to network...')
        sta_if.active(True)
        sta_if.connect('essd', 'password')
        while not sta_if.isconnected():
            pass
        print('network config:', sta_if.ifconfig())

Edit boot.py to:

import ConnectWifi
ConnectWifi.do_connect()

Upload both files with ampy to the esp-32

ampy -p /dev/ttyUSB0 put boot.py
ampy -p /dev/ttyUSB0 put ConnectWifi.py

Now when your micropython device boots up it will connect immediately connect to the configured wifi-network.

Micropython on the ESP-32

Some time ago i bought an esp-32 and now is the time to play with it. I like python so micropython will be flashed on it. I downloaded the latest firmware from micropython.org and installed the esptool to flash the firmware.

sudo pip3 install esptool

I attached the esp-32 to my computer with a micro-usbcable and looked for the port it got attached to.

 sudo dmesg

I this case it was /dev/ttyUSB0.
Because it is the first time I flash micropython on the chip it is recommended to erase the flash first

 esptool.py --port /dev/ttyUSB0 erase_flash

Then flashed micropython on the chip. (your version of the .bin file may differ)

esptool.py --chip esp32 --port /dev/ttyUSB0 write_flash -z 0x1000 esp32-20180403-v1.9.3-503-gbcfff4fc.bin

Did it work? Well, let’s connect with it to get a repl.

screen /dev/ttyUSB0 115200

Yeah, we got a repl: >>>

print("Hello World"

My version of the esp-32 has a led on pin 16 which is on if the pin is low and off if the pin is high.

import machine
led = machine.Pin(16, machine.Pin.OUT)
led.value(0) # led is on
led.value(1) # led is off

You can exit screen with Ctrl-a \ y. On the computer create a file called main.py with the following code

import machine
import time
led = machine.Pin(16, machine.Pin.OUT)
while True:
    led.value(0)
    time.sleep(0.5)
    led.value(1)
    time.sleep(0.5)

To ‘upload’ a file we need a tool called ampy.

sudo pip3 install ampy

Now ‘upload’ main.py to the esp-32 with ampy.

ampy -p /dev/ttyUSB0 put main.py

Powercycle the esp-32 and it will start main.py automaticly.
Yeah, we have blinky running!

ITunes podcast without an ITunes account

logo http://picklemonkey.net/feedflipper-home/
http://picklemonkey.net/feedflipper-home/

 

On superuser.com I found a link to FeedFlipper    (no https, shame on them!) to convert an ITunes podcast feed to a regular rss-feed. This way you can subscribe to the feed with your regular podcatcher without having to have an ITunes account.

 

Dump the ITunes url in the textbox and they return a regular rss.

For example:
https://itunes.apple.com/us/artist/ramsey-solutions/id834566130?snid=show.podcast-a

becomes:
http://daveramsey.ramsey.libsynpro.com/rss (no https, shame on them)

Great tool!