Roland's homepage

My random knot in the Web

Articles tagged with "python3"

  1. ImageMagick: convert vs Wand

    The ImageMagick suite has been in my software toolbox for years. It is my go-to tool for manipulating bitmap images. Over the years I have written several front-ends for specific tasks for in Python.

    In general, I have used the subprocess module to launch convert or mogrify from Python.

    With the release of Wand 0.5.0 which supports ImageMagick 7, I decided to try that by porting one of my scripts (foto4lb) to it. This turned out to be slower than using convert directly.

    But now it is 2021. Py-wand is at 0.6.7 and it is time to try again.

  2. Installing Pelican 4

    Pelican is the static site generator that I use for my website. This allows me to write my website posts in almost plain text (actually a light-weight markup language named reStructuredText), which are then translated into HTML. As someone who has written his webpages in HTML by hand, I can tell you that this is definitely an improvement.

    Although I use LaTeX for things that require high-quality typesetting, these days almost all my other writings are in reStructuredText.

    The previous pelican version 3.7 was basically the last Python 2.7 application that I use. So now that pelican supports Python 3, I’m switching. Since Pelican 4 is not in the FreeBSD ports tree yet, I’m installing it myself.

    Note

    As of 4.0.1, Pelican is now in the FreeBSD ports tree and I’m using the port www/py-pelican. At the moment I’m still installing typogrify and smartypants by hand.

  3. Using the FT232 with Python

    In this article I will try to document how to with with the FT232H using Python on FreeBSD. I will be using the Adafruit FT232H breakout board.

    Note that since I’m using FreeBSD, the library provided by FTDI doesn’t work. However, the library provided by Adafruit was written for Python 2, and doesn’t work with Python 3. I tried tinkering with it a bit to get it to work with Python 3, but that did not work out. In the end, I went with pyftdi since it doesn’t require a native library and it just works.

  4. Install ntpsec on FreeBSD

    A short article on how to install ntpsec on FreeBSD. Tested with 0.9.7 and 1.0.0.

    Note

    There is/was a bug in the ntpdate implementation that set the clock to a completely bogus value. So I’ve since written a simple script that runs from cron to fetch the time from a near NTP server.

    date: 2018-01-28
    modified: 2019-07-30
    reading time: 2 min.
    category: freebsd
    tags: ntp python3
  5. Database scheme for resin recipes

    This document explores how an SQLite database could be used to store data for the resin-calculator. Normally, the recipes are a dictionary keyed to the name of the resin. The value of each recipe is a list of (component, parts-by-weight) tuples. Since a database only contains tables, where each row has the same form, how do we store such infomation in a database?

  6. Doing calculations with Python

    As an engineer I do a lot of calculations. These can be done with pen and paper and a calculator, in an IPython notebook or in a throwaway spreadsheet. All of these methods have shortcomings, though.

    Pen and paper is hard to share and (in my case) hard for others to read. In IPython you can assign the results of calculations to a variable, but you have to perform a separate action to display them. And spreadsheets in general show you the results but not the calculations.

    So I wrote a simple function in Python to help me with that. Using this function I can print both simple assignments and relatively complex calculations. And it shows both the calculation and the result.

  7. Structures in Python

    Sometimes I miss the C’s plain old struct in Python.

    Of course Python has dictionaries, but I prefer to write a.b over a['b'].

    Here are several ways of doing something akin to a struct in Python.


←  Page 2 Page 3 / 6 Page 4 →