Archive for the ‘Python’ Category
Posted by jpluimers on 2022/11/22
I have been into more and more Mojibake example pages like [Wayback] Mojibake: Question Marks, Strange Characters and Other Issues | GPI
Have you ever found strange characters like these ��� when viewing content in applications or websites in other languages?
They made me realise that all these (including the Mojibake examples on my blog) are just artifacts, but the real list of examples is the set of ftfy test cases at [Wayback/Archive.is] python-ftfy/test_cases.json at master · LuminosoInsight/python-ftfy
I got reminded when Waternet moved from paper mail using “Pyreneeën” to email using “Pyreneeën“. Not as bad as Waterschap AGV did earlier: they took it one level further and made “Pyreneeën” out of it, see Last year, a classic Mojibake was introduced when Waterschap Amstel, Gooi en Vecht redesigned their IT systems.
This seems like a trend where newer systems perform worse than older systems. I wonder why that is.
BTW: the trick on the [Wayback/Archive] Python.org shell to run ftfy (which is not installed by default) is first dropping to the shell (see my post How do I drop a bash shell from within Python? – Stack Overflow), then starting python again:
Read the rest of this entry »
Posted in CP850, Development, Encoding, ftfy, ISO-8859, Mojibake, Python, Scripting, Software Development, Unicode, UTF-8, UTF8 | Leave a Comment »
Posted by jpluimers on 2022/10/06
An interesting thread by Kristian Köhntopp last year:
[Archive.is] Kristian Köhntopp on Twitter: “Python: >>> print(1+2+” = “+2+1) Traceback (most recent call last): File “”, line 1, in TypeError: unsupported operand type(s) for +: ‘int’ and ‘str’ Java: System.out.println(1+2+” = “+1+2); 3=12”
The examples from him and others in the thread:
Python:
>>> print(1+2+" = "+2+1)
Traceback (most recent call last):
File "", line 1, in
TypeError: unsupported operand type(s) for +: 'int' and 'str'
Java:
System.out.println(1+2+" = "+1+2);
3=12
php8.1 -r 'print 1+2+" = "+2+1;'
PHP Fatal error: Uncaught TypeError: Unsupported operand types: int + string in Command line code:1
Stack trace:
#0 {main}
thrown in Command line code on line 1
php7.3 -r 'print 1+2+" = "+2+1;'
PHP Warning: A non-numeric value encountered in Command line code on line 1
Node?
Chrome & FF dev console:
window.alert(1+2+" = "+1+2)
3 = 12
Sind ja immerhin verschiedene Sprachen.
SELECT Wert1
FROM table1
WHERE Wert1 < AVG(Wert1);
DB2 vs. Oracle vs. MSSQL vs. ....
The joke is that Python actually does better than Java.
But in practice, this is a problem on many platforms, so it deserves constant attention, that’s why Kristian pointed to [Archive] Anna “Legacy Archaeologist” Filina on Twitter: “My annotated slides “Fantastic Bugs and How to Avoid Them” from @LonghornPHP: #LonghornPHP”
[Wayback/Archive] Fantastic Bugs and How to Avoid Them – Speaker Deck
I’ve expanded the examples from the thread below. The results are interesting and consistent over versions of the various languages.
–jeroen
Read the rest of this entry »
Posted in Development, Java, Java Platform, JavaScript/ECMAScript, Node.js, PHP, Python, Scripting, Software Development | Leave a Comment »
Posted by jpluimers on 2022/09/20

If you ever want a good visual representation to compare the breaking distance for a car at two different speeds, and see at what speed you will hit the human “obstacle”, then use the Python script mkbremsweg.py.
Git repository: [Wayback/Archive.is] joschtl / bremsweg · GitLab.
The image is generated in the current directory
It probably won’t work on Windows as it dynamically builds a very long command-line calling ImageMagick tool [Wayback/Archive.is] convert once to do all the drawing.
The text in the picture for now is hardcoded in German, but would be easy to adopt.
The fonts used are and FreeSans and [Wayback/Archive.is] Alte DIN 1451 Mittelschrift Font Family · 1001 Fonts (which the Germans use for Traffic Signage and is very similar to fonts used in other countries).
Calculations are based on [Wayback/Archive.is] Bremsweg-Rechner für Anhalteweg & Bremsweg – Johannes Strommer.
Via:
–jeroen
Posted in *nix, *nix-tools, cars, Development, ImageMagick, LifeHacker, Power User, Python, Scripting, Software Development, Traffic, Windows | Leave a Comment »
Posted by jpluimers on 2022/07/11
After yesterdays post (which I will be editing to add some more pictures) MCH2022 badge sneak previews from tweeps that attended the Bitlair 20220709 Sweatshop (@MCH2022Camp) now a call for help:
The Badge Team needs volunteers helping them on the software side.
At the badge event, the version 1.0 firmware was flashed so the badge will function perfectly fine during the event, but it would be cool if more features are available that attendees can get when upgrading at the event or downloading from the hatchery.
There is a virtual environment to test and a GitHub projects page with open issues to get started.
See the links below on how you can help:
Read the rest of this entry »
Posted in Development, ESP32, Hardware Development, Python, Raspberry Pi, RP2040, Scripting, Software Development | Leave a Comment »
Posted by jpluimers on 2022/05/27
Posted in Chrome, Configuration Management, Development, DevOps, Firefox, History, IaC - Infrastructure as Code, Infocom and Z-machine, Infrastructure, KVM Kernel-based Virtual Machine, LSI/3ware, Open Source, PDP-11, Power User, PowerShell, Puppet, Python, Qemu, Rust, Safari, Scripting, Software Development, UCSD Pascal, Vagrant, Veewee, Virtualization, Web Browsers, Xen | Leave a Comment »
Posted by jpluimers on 2022/03/16
Last year, Waterschap Amstel, Gooi en Vecht sent me a paper letter notifying the yearly water bill was going to be late as they were redesigning their IT systems.
Their letter introduced a classic Mojibake that had not been present in all their older paper letter communication.
- Street name on a letter via the old IT systems is
"Pyreneeën":

- Street name on a letter via the new IT systems is
"Pyreneeën":

Read the rest of this entry »
Posted in Development, Encoding, ftfy, Mojibake, Python, Software Development, Unicode, UTF-8, UTF8 | Leave a Comment »
Posted by jpluimers on 2022/03/10
When writing this, [Wayback/Archive.is] ftfy · PyPI:history indicates ftfy was already at 6.0.3.
It is still my goto tool for figuring out the cause of Mojibake. I remember writing about it the first time in 2016 (see the ftfy category) when it was already at version 3.0, discovering it after a few Mojibake posts.
By now it even understands right-to-left Mojibake garbage:
[Archive.is] Elia Robyn Speer on Twitter: “ftfy 5.8 is out! … A user reported that Hebrew text wasn’t being fixed, and this made me think about how to expand some of the trickier cases to non-Latin alphabets.”
Mojibake mishaps still happen a lot, so by now I hope I will have done a Mojibake themed Delphi talk at one or more conferences.
Read the rest of this entry »
Posted in !!con (bangbangcon), About, Autistic Spectrum/Autism, Cancer, Conference Topics, Conferences, Development, Encoding, Event, ftfy, Mojibake, Personal, Python, Rectum cancer, Scripting, Software Development, Unicode | Leave a Comment »
Posted by jpluimers on 2022/03/09
I needed this for my blog post tomorrow:
import os
os.system('sh') # or bash, tcsh, zsh, whatever. :-P
[Wayback] How do I drop a bash shell from within Python? – Stack Overflow
Thanks [Wayback] Chris Jester-Young!
This trick works at the Python shell.
–jeroen
Posted in Development, Python, Scripting, Software Development | Leave a Comment »
Posted by jpluimers on 2022/02/23
A follow-up on Source: Some links with notes on WoonVeilig/Egardia security system communications, protocols and support by 3rd party home automation apps:
Notes on the Woonveilig/Egardia GATE-03 model alarm hub (where 192.168.x.y is the IPv4 address that hub):
- It still uses the plain-text insecure http to communicate, so it is wise to try and put it in a separate LAN apart from other systems.
- Logon is done using HTTP Basic access authentication.
- Woonveilig/Egardia by now prefers the XMPP prototol over the CID protocol (the CID protocol is still used by jeroenterheerdt/python-egardia.
- You can find the configuration at
http://192.168.x.y/setting/xmpp.htm.
- XMPP protocol uses
xmpp01.egardia.com as primary and xmpp01.alt.egardia.com as secondary server on port 443.
arg-####-auth where ###### are the last 6 *lowercase* hexadecimal digits of the MAC address of the GATE-03.
- a long password you can find in the plain-text of the
http://192.168.x.y/action/xmppGet http GET request fired by http://192.168.x.y/setting/xmpp.htm.
- CID protocol address is
ip://######@ics.alt.egardia.com:52010/CID where ###### are the last 6 *uppercase* hexadecimal digits of the MAC address of the GATE-03.
- User PIN-codes are not visible at the Woonveilig/Egardia alarm site, but they are at
http://192.168.x.y/setting/userCode.htm together with their user names.
- Special PIN codes for Installer/Duress/Guard/Master/Temporary are at
http://192.168.x.y/setting/codeSetting.htm and obtained via http://192.168.x.y/action/areaListGet and http://192.168.x.y/action/codeSettingGet
- On the CID protocol:
I got all of the above via: [Wayback/Archive.is] GATE-03 system does not report to Egardiaserver · Issue #26 · jeroenterheerdt/python-egardia (which by coincidence used the same firmware I had: HSGW 0.0.2.18.1 HPGW-L2-XA35H).
Which brings me to some Google search with some remarkable results:
So I did a quick look at LUPUS XT* based products:
Then at the Woonveilig/Egardia and Climax shops:
Conclusions:
- Egardia/Woonveilig sensors look remarkably similar to the LUPUS ones
- LUPUS is a re-brand of Climax with slightly different firmware
Side note on open ports
- Open ports on the [Wayback] GATE-03 alarm device:
PORT STATE SERVICE VERSION
9/tcp filtered discard
25/tcp filtered smtp
80/tcp open http
445/tcp filtered microsoft-ds
- Open ports on the [Wayback] CAM-06 outdoor camera:
PORT STATE SERVICE VERSION
9/tcp filtered discard
21/tcp open ftp oftpd
25/tcp filtered smtp
80/tcp open tcpwrapped
445/tcp filtered microsoft-ds
554/tcp open rtsp
711/tcp open cisco-tdp?
1935/tcp open rtmp?
6000/tcp open X11?
49152/tcp open upnp Portable SDK for UPnP devices 1.6.17 (Linux 3.4.35; UPnP 1.0)
––jeroen
Posted in Communications Development, Development, Python, Scripting, Software Development | Leave a Comment »
Posted by jpluimers on 2021/12/01
Wanting a simple way on the console to convert a .pcap file to a .wav file, I searched for [Wayback] console convert pcap to wav – Google Search.
The reason is that [Wayback] fritzcap (written in Python) sometimes crashes while doing the conversion of a phone recording, so then only the .pcap file is available. I still want to figure this out, but given my health situation, I might not be able to in time.
Read the rest of this entry »
Posted in *nix, *nix-tools, Audio, Development, ffmpeg, Fritz!, Fritz!Box, fritzcap, Hardware, Media, Network-and-equipment, Power User, Python, Scripting, Software Development, Wireshark | Leave a Comment »