The Wiert Corner – irregular stream of stuff

Jeroen W. Pluimers on .NET, C#, Delphi, databases, and personal interests

  • My badges

  • Twitter Updates

  • My Flickr Stream

  • Pages

  • All categories

  • Enter your email address to subscribe to this blog and receive notifications of new posts by email.

    Join 1,854 other subscribers

Archive for 2020

GitHub – facebook/osquery: SQL powered operating system instrumentation, monitoring, and analytics.

Posted by jpluimers on 2020/03/09

Boy, I wish I had found this years ago: [WayBack] GitHub – facebook/osquery: SQL powered operating system instrumentation, monitoring, and analytics.

No more remembering all those nifty configuration and log file details by heart, just install and query using SQL.

Now you need to learn a “database” schema, however that’s the same for all supported operating systems.

Example installation steps:

Run interactively through osqueryi, then perform .help or .schema to get an impression of what is possible.

There is lots of documentation at [WayBack] osquery.

–jeroen

Posted in *nix, *nix-tools, Apple, Mac, Mac OS X / OS X / MacOS, Power User | Leave a Comment »

🔎Julia Evans🔍 on Twitter: “the ip command… “

Posted by jpluimers on 2020/03/06

[Archive.is] 🔎Julia Evans🔍 on Twitter: “the ip command… “

Larger image below the fold; thanks Julia!

Shortened transcript:

  • ip
    • lets you view and change network configuration
    • ip OBJECT COMMAND
    • object: addr, link, neigh, etc
    • command: add, show, delete, etc
  • ip addr list
    • shows IP addresses
  • ip route list
    • displays the route table
    • ip route list table all
  • ip netsh
    • manage network namespaces
  • ip link
    • network devices (like eth0)
  • ip neigh
    • view/edit the ARP table
  • ip xfrm
  • ip -s link
    • s is for statistics
    • shows transmitted/received packets for each device

Lots of additions in the Twitter Thread too, including (and some of them I still need to figure out):

Read the rest of this entry »

Posted in *nix, *nix-tools, Power User | Leave a Comment »

In Unix, what are some common dot files?

Posted by jpluimers on 2020/03/06

I came across some 20 year old Unix stuff a while ago, so I needed an historic reference of filenames starting with a dot (like .newsrc).

This is a pretty good one: [WayBackIn Unix, what are some common dot files?

–jeroen

Posted in *nix, *nix-tools, History, Power User | Leave a Comment »

Mac OS X / macOS / …: quit screen or window when using it for a serial port

Posted by jpluimers on 2020/03/06

I wrote a bit on using screen from my Mac in The woods and trees of OpenSuSE on single-board computers – image abbreviations – and getting it installed using OS X.

The coverage was way too brief and also buried in large post.

Today, I want to focus on some things related to properly terminating a a screen window, session or screen by itself from a Mac which somehow is one of the harder things for me to do.

I’m talking about sessions and windows, because screen is a terminal multiplexer, which can also put a serial link in a window on a session. So screen is not “just” a serial console terminal application by itself.

Part of being hard is probably that even on for instance 10.12 Sierra, Apple ships a fairly old version: screen --version returns Screen version 4.00.03 (FAU) 23-Oct-06 whereas after 2014 (before that, screen development was pretty stalled) many new versions appeared: [WayBack] screen.git.

It makes it less hard that it hardly reproduces, and seems to reproduce less with the screen version I installed through homebrew: Screen version 4.06.02 (GNU) 23-Oct-17.

Time to make some notes so I can hopefully amend them later with solutions.

The screen magic key

When screen gives you a session to a terminal, all but one key are being routed through on a 1-on-1 base except for a “magic” key combination: Ctrla (which the documentation abbreviates as C-a).

Following the Ctrla combination, you can type a character (sometimes that needs Ctrl too) for a lot screen functionality (for a start, see the “Getting help” below).

Listing existing screen sessions and windows

Each screen process has one session

You list screen sessions from the command-line. I usually combine the latter with getting a process list as well using this command because the process list will show you parameters passed to screen:

ps -ax | grep screen && screen -list

which gets you output like this:

31992 ttys019    0:00.01 screen
29040 ttys020    0:00.04 screen /dev/cu.usbserial 115200
31898 ttys021    0:00.01 screen
32503 ttys025    0:00.00 grep screen
There are screens on:
    29041.ttys020.RMBPro1TBJWP  (Attached)
    31899.ttys021.RMBPro1TBJWP  (Attached)
    31993.ttys019.RMBPro1TBJWP  (Attached)
3 Sockets in /var/folders/zr/dsp77fhs6zq179n72lykjrjw0000gq/T/.screen.

Many people abbreviate screen -list as screen -ls, but I like descriptive commands over cryptic ones.

What you see is that:

  • there are three screen sessions of which one is using a USB serial device.
  • there is one session per screen session

Windows are within sessions

From within each session, you can use the Ctrl* combination to list the Windows. For the both non-serial sessions – looked like this on my machine:

term-type   size         user interface           window
---------- ------- ---------- ----------------- ----------
xterm-256c  84x28     jeroenp@/dev/ttys019        0(bash)       rwx

and

term-type   size         user interface           window
---------- ------- ---------- ----------------- ----------
xterm-256c  84x28     jeroenp@/dev/ttys021        1(bash)       rwx

The first was for session 31899.ttys021.RMBPro1TBJWP, the second for 31993.ttys019.RMBPro1TBJWP.

Attaching (or re-attaching) to an existing session

The -x parameter can attach to both an Attached or a Detached screen session. This allows for:

  • multiple Mac terminal tabs to see the same content
  • getting access to a detached session (because you – maybe by accident – closed terminal,  or detached the session)

Detached sessions keep their windows and the commands running in those windows. This allows you to have long-running scripts starting from the terminal but not terminated when the terminal closes.

So in my case, this command attaches to the second session not matter if it is attached or detached.

screen -x 31993.ttys019.RMBPro1TBJWP

Killing an existing window

When killing a window, all the processes in that window will be killed too.

Typing Ctrla followed by k or Ctrlk will kill the current window.

Killing a session with all windows

When killing a session, it will kill all the windows with all the processes in those windows.

Typing Ctrla followed by Ctrl\ will kill the current session with all the windows in it. On some Linux systems, you can replace Ctrl\ with just \.

I’ve not run into dead sessions yet, but if I do, I should try the -wipe command line option as shown in [WayBack] How to kill a dead screen session? – Stack Overflow (which also shows this can fail if you run out of disk space, but then you have bigger issues).

TODO: Killing a session that seems attached but isn’t

I still need to research this further, as every now and then I run into this:

# ps -ax | grep -w screen && screen -list
29040 ?? 0:00.04 screen /dev/cu.usbserial 115200
35724 ttys025 0:00.00 grep -w screen
There is a screen on:
 29041.ttys020.RMBPro1TBJWP (Attached)
1 Socket in /var/folders/zr/dsp77fhs6zq179n72lykjrjw0000gq/T/.screen.

Wiping it fails:

# screen -wipe 29041.ttys020.RMBPro1TBJWP
There is a screen on:
 29041.ttys020.RMBPro1TBJWP (Attached)
1 Socket in /var/folders/zr/dsp77fhs6zq179n72lykjrjw0000gq/T/.screen.

Attaching however times out:

# screen -x 29041.ttys020.RMBPro1TBJWP

For now, the only option is to reboot my system.

I’ve seen this happening mostly with cables that present themselves as prolific PL2303HX chipset.

So I will get some TTL debug cables based on other chipsets.

These posts will help finding about the available serial cables:

Getting help

It is daunting, but the man screen page [WayBack] has a truckload of information, for instance on the command-line options, key bindings and much more.

If you like on-line lists of tips more, then follow these:

The man page will get you most of that information:

Start screen

Screen version 4.00.03 (FAU) 23-Oct-06

Copyright (c) 1993-2002 Juergen Weigert, Michael Schroeder
Copyright (c) 1987 Oliver Laumann

This program is free software; you can redistribute it and/or modify it under the
terms of the GNU General Public License as published by the Free Software
Foundation; either version 2, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this
program (see the file COPYING); if not, write to the Free Software Foundation,
Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.

Send bugreports, fixes, enhancements, t-shirts, money, beer & pizza to
screen@uni-erlangen.de


                          [Press Space or Return to end.]

Here you can press Ctrl-A followed by : to get a prompt where you can type help:

[Press Space or Return to end.]
:help

There you get one or two (depending on your terminal size) pages of help:

                         Screen key bindings, page 1 of 2.

                         Command key:  ^A   Literal ^A:  a

   break       ^B b          license     ,             reset       Z         
   clear       C             lockscreen  ^X x          screen      ^C c      
   colon       :             log         H             select      '         
   copy        ^[ [          meta        a             silence     _         
   detach      ^D d          monitor     M             split       S         
   digraph     ^V            next        ^@ ^N sp n    suspend     ^Z z      
   displays    *             number      N             time        ^T t      
   dumptermcap .             only        Q             title       A         
   fit         F             other       ^A            vbell       ^G        
   flow        ^F f          pow_break   B             version     v         
   focus       ^I            pow_detach  D             width       W         
   hardcopy    h             prev        ^H ^P p ^?    windows     ^W w      
   help        ?             quit        ^\            wrap        ^R r      
   history     { }           readbuf     < writebuf >         
   info        i             redisplay   ^L l          xoff        ^S s      
   kill        ^K k          remove      X             xon         ^Q q      
   lastmsg     ^M m          removebuf   =         

                    [Press Space for next page; Return to end.]

followed by:

                         Screen key bindings, page 2 of 2.

^]  paste .
"   windowlist -b
-   select -
0   select 0
1   select 1
2   select 2
3   select 3
4   select 4
5   select 5
6   select 6
7   select 7
8   select 8
9   select 9
]   paste .






                          [Press Space or Return to end.]

–jeroen

Partially based on: [WayBack] terminate screen monitoring serial port – Unix & Linux Stack Exchange.

Posted in *nix, *nix-tools, Apple, Mac, Mac OS X / OS X / MacOS, MacBook, MacBook Retina, MacBook-Air, MacBook-Pro, MacMini, macOS 10.12 Sierra, macOS 10.13 High Sierra, OS X 10.10 Yosemite, OS X 10.11 El Capitan, Power User, screen | Leave a Comment »

Some tools useful for analysing PDF documents

Posted by jpluimers on 2020/03/05

A while ago, I wanted to analyse the difference of some PDF documents: why they had suddenly grown to twice their size.

[WayBack] Jeroen Pluimers en Twitter: “dat genereren kun je overigens zien als je dezelfde downloads doet, maar dan een fikse periode uit elkaar.…”

There are quite a few tools on [WayBack] Browse Internal PDF Structure – Super User and [WayBack] Best tool for inspecting PDF files? – Stack Overflow, including:

They also made me discover [WayBack] GitHub – pipwerks/PDFObject: A lightweight JavaScript utility for dynamically embedding PDFs in HTML documents documented at [WayBack] PDFObject: A JavaScript utility for embedding PDFs 

This particular case

The quickest way to analyse these for me was [WayBack] PDF Object Browser based on [WayBack] GitHub – brendandahl/pdf.js.utils: PDF.js Utility Files which is also the foundation of [WayBack] Test PDF Creator.

It runs in your web browser as local JavaScript, so it is pretty OK to load a PDF file into it: it does no “phone home”.

In this case, for generating PDF files with the same content, ABN AMRO added five Type 3 fonts of which one font was not used at all, and two others used to be Type 1 fonts.

Type 1 fonts (wikipedia)

Type 1 (also known as PostScriptPostScript Type 1PS1T1or Adobe Type 1) is the font format for single-byte digital fonts for use with Adobe Type Manager software and with PostScript printers. It can support font hinting.

It was originally a proprietary specification, but Adobe released the specification to third-party font manufacturers provided that all Type 1 fonts adhere to it.

Type 1 fonts are natively supported in Mac OS X, and in Windows 2000 and later via the GDI API.[2] (They are not supported in the Windows GDI+, WPF or DirectWrite APIs.)

Type 3 fonts (wikipedia)

Type 3 font (also known as PostScript Type 3 or PS3T3 or Adobe Type 3) consists of glyphs defined using the full PostScript language, rather than just a subset. Because of this, a Type 3 font can do some things that Type 1 fonts cannot do, such as specify shading, color, and fill patterns. However, it does not support hinting. Adobe Type Manager did not support Type 3 fonts, and they are not supported as native WYSIWYG fonts on any version of Mac OS or Windows.

So far for optimised PDF rendering…

Being in software development for this long, I am constantly reminded that The inmates are running the asylum – Wikipedia. I can definitely recommend reading “The Inmates Are Running the Asylum: Why High Tech Products Drive Us Crazy and How to Restore the Sanity”, by Alan Cooper:

–jeroen

Posted in Development, EPS/PostScript, PDF, Power User, Software Development | Leave a Comment »

Multi-parameter FreeAndNil plus InitialiseNil methods – interesting code ceremony reduction by David Heffernan

Posted by jpluimers on 2020/03/05

I’m probably getting a truckload of anti-FreeAndNil folks over me, but there are cases this comes in useful, so having an overloaded version cutting down code ceremony makes sense: [WayBack] interface – Avoiding nested try…finally blocks in Delphi – Stack Overflow

Which means I need to update my type safe FreeAndNil one day.

This should be relatively straightforward, given that David published a python generator for his Delphi code [WayBack].

–jeroen

Via: [WayBack] Interesting approach by David Heffernan (*1) to the nested try..finally blocks because of multiple object creations: Overloaded InitializeNil and FreeA… – Thomas Mueller (dummzeuch) – Google+

Read the rest of this entry »

Posted in Delphi, Development, Software Development | Leave a Comment »

Abilities that makes you a better developer – Hacker Noon

Posted by jpluimers on 2020/03/05

If we have passion for what we do, why not try to be a better professional every day?

Source: [WayBackAbilities that makes you a better developer – Hacker Noon

That is an interesting, but very hard question which very few people around me are afraid of trying to answer.

I think the hardest part for most developer isn’t the tech/science bits as usually they have a natural feel for natural science and formal science related topics (which I’d rather not call STEM).

I’ve a hard time to remember the STEM acronym because it means “vote” or “voice” to since I’m Dutch, and equally hard the . Also I really dislike the term “hard science” as “soft sciences” are very hard for me. So lets stick with natural science and formal science.

So if you are a developer and trouble motivating yourself to learn new things in the mathematics, algorithms & data structures, databases, computer architecture, operating systems and networks, then you will have a really really hard time.

I can understand it is tougher to motivate learning about English (and other languages), paradigms & design patterns, teamwork, or to put it in a broader perspective the human side of affairs. Those however are the areas that do not come “natural” for most developers and are in effect the ones most developers need to work on most to improve.

Doing that will make it a lot easier to work with people around you.

For myself, I still have to grow a lot in those areas even though I already have. Having originated as nerd/geek/introvert or however you want to call that direction, my natural habitat is still a silent place with little distraction with some relatively quiet people around me that help me keep focus and force me in the rhythms that are good for me. But I’ve learned to speak for large groups, write (not just posts) and have many other nice social interactions.

That growth brings so much joy and makes work so much nicer, that the effort and persistence keeps being worth every minute I put in.

Via: [WayBack] Cesar Romero (@cesarliws) on Twitter: “Abilities that makes you a better developerhttps://t.co/svwn4CueNe”

–jeroen

 

Posted in About, Agile, Development, Personal, Software Development | Leave a Comment »

SMS Backup+ – Apps on Google Play

Posted by jpluimers on 2020/03/04

Simple but cool app: [Archive.isSMS Backup+ – Apps on Google Play:

Automatically backup your SMS, MMS and call history with a separate label in Gmail and Google Calendar.

Later you can restore the saved data (except MMS) back to the phone, especially useful when switching to a new device.

IMAP access needs to be manually enabled in Gmail, see the website and FAQ for more information. You can of course use your own IMAP server for backups, giving you full control over your data.

SMS Backup+ is a free open-source project which has been in active development since the early days of Android, completely ad and tracking-free, supported through voluntary donations.

Sourcecode: [WayBack] GitHub – jberkel/sms-backup-plus: Backup Android SMS, MMS and call log to Gmail / Gcal / IMAP

Via: [WayBack] Wirre Telefongespräche für 500. Ich kriege ja nicht mehr oft Anrufe auf der deutschen Telefonnummer, und so liegt das Telefon jetzt daheim und hängt am… – Kristian Köhntopp – Google+

–jeroen

Posted in Android, Development, Mobile Development, Software Development | Leave a Comment »

Entwicklertag 2016: How Agile and OO have lost their way together – James Coplien – YouTube

Posted by jpluimers on 2020/03/04

Still an interesting video, though I wish James Coplien would have a less shouting voice: that would be much easier on the ears.

–jeroen

Posted in Agile, Development, Software Development | Leave a Comment »

18650 Battery shield V3(RaspberryPi&Arduino) from lspoplove on Tindie

Posted by jpluimers on 2020/03/04

As you know Tesla has thousands of 18650 batteries. The 18650 battery is a strong existence. So we made this 18650 battery shield for maker.

Features:

  • Battery protection(Over charge or Over discharge)
  • Micro USB port Input
  • Type-A USB Output
  • 0.5A current charging
  • 1 switch control USB output
  • 5~8V Input Voltage
  • 3V & 1A Output
  • 5V & 2A Output
  • LED indicate(Green means full,Red means charging)
  • 3V output port x3
  • 5V output port x3

Charging can only be done at 0.5A, so using it as a sort of UPS seems not possible, but an interesting device nonetheless.

The other products referenced from the same page are interesting too and will undoubtedly bring me some new ideas for some projects.

Source: [WayBack18650 Battery shield V3(RaspberryPi&Arduino) from lspoplove on Tindie

Via:

–jeroen

 

Posted in 18650, Arduino, Batteries, Development, ESP8266, Hardware Development, Li-Ion, Odroid, Power User, Raspberry Pi | Leave a Comment »