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,860 other subscribers

Archive for June, 2020

Delphi AMQP links

Posted by jpluimers on 2020/06/11

Some links I found about Delphi and AMQP.

AMQP

Delphi and AMQP

Threads:

Tests

Other environments

–jeroen

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

LD_PRELOAD: preload a Linux library, for instance to obtain more information on a segmentation fault

Posted by jpluimers on 2020/06/11

Not being a proficient Linux programmer, I wondered what other means than learning gdb intrinsics I had to get more information about a segmentation fault.

A while back, pip list 2> /dev/null would cause a segmentation fault on my system (see [WayBack] Bug 1084812 – [aarch64] IPv4 DNS leading to segfaults).

It turns out that LD_PRELOAD was my friend (like TERM=xterm was a friend before):

LD_PRELOAD=libSegFault.so pip list 2> /dev/null

It indicated that the problem was in libc, which on opensuse is implemented by glibc.

This meant that the originally diagnosed problem was already accurately describing the symptoms.

Searching for glibc libSegFault.so didn’t reveal many useful links, so I’ve included the one making most sense to me here:

The cool thing: most of the links above come from [WayBack] segmentation fault – Can you get any program in Linux to print a stack trace if it segfaults? – Server Fault which I found when searching for linux find segmentation fault stack trace

That link explains both the LD_PRELOAD steps and gdb steps (:

An alternative is to use gdb directly: [WayBack] command line arguments – How do I run a program with commandline args using gdb within a bash script? – Stack Overflow:

gdb -ex=run --args pip list

--jeroen

Posted in *nix, C, Development, gcc, Linux, Power User, Software Development | Leave a Comment »

Don’t mix objects and interfaces

Posted by jpluimers on 2020/06/11

Worth repeating Dalija Prasnikar, because I bumped into sources of people not getting this concept: [WayBack]: Don’t mix objects and interfaces.

You should not, but sometimes it is hard not to.

The rules in his article are very important as they indicate what’s safe and what’s not:

  1. object references are weak, interface references are strong
  2. reference counted object instances need at least one strong reference to keep them alive therefore you can’t use object reference as primary owning reference
  3. reference counted object instances can be safely accessed through temporary, short-lived (weak) object references, as long as there are strong reference(s) keeping the object alive

So basically:

  • ensure a reference counted instance has at least one strong reference to manage the lifetime
  • temporary (short-lived) weak references are OK as long as you are sure the strong reference lives longer

Note that unsafe will make interfaces references weak instead of strong; the same holds for pointer lists [WayBack] Using the [unsafe] attribute, it is possible to store the interface without reference counting. Is there any way for this behavior to be “transferred” … – Jacek Laskowski – Google+

–jeroen

via: [WayBack] Dalija Prasnikar – Google+

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

Squoosh: Compress and compare images with different codecs, right in your browser

Posted by jpluimers on 2020/06/10

Cool tool: [WayBack] Squoosh Compress and compare images with different codecs, right in your browser

Source at [WayBack] GitHub – GoogleChromeLabs/squoosh: Make images smaller using best-in-class codecs, right in the browser.

Via: [WayBack] Google releases an easy way to shrink and convert images for the internet — Mike Elgan

–jeroen

Posted in Development, Power User, Software Development, Web Browsers, Web Development | Leave a Comment »

When you are stuck, use “Oblique strategies – defeat creative block”

Posted by jpluimers on 2020/06/10

Sometimes you are stuck. Then this often helps, even outside the music industry:

[WayBack] Oblique strategies – defeat creative block: Draw random Oblique Strategy cards to break through creative block.

These are disruptive which is the whole point being stuck.

Obey the first and only rule: pick the first card and apply what it says.

  • Do NOT fall for the urge to draw multiple cards.
  • Do NOT make a list of all cards then choose from it.

Both above failures kill the randomness of the above strategy.

More on them at [WayBack] Oblique Strategies – Wikipedia

Via:

–jeroen

Read the rest of this entry »

Posted in Agile, Development, LifeHacker, Power User, Software Development | Leave a Comment »

One day I will dig in the various ways that bash can do evaluation, for now: there is eval, “ and $() and I’m not sure when to choose which.

Posted by jpluimers on 2020/06/10

A while ago, I had to execute a series of aliases of which the names were stored in an array. A simple for loop with en eval call did the job.

Then I found out there are at least two more ways of evaluation in bash, so here are just a few links giving me a head start if I ever dig this up again:

Note that looping over parameters is different than over an array: [WayBack] Loop through an array of strings in Bash? – Stack Overflow

ou can use it like this:

## declare an array variable
declare -a arr=("element1" "element2" "element3")

## now loop through the above array
for i in "${arr[@]}"
do
   echo "$i"
   # or do whatever with individual element of the array
done

# You can access them using echo "${arr[0]}", "${arr[1]}" also

Also works for multi-line array declaration

declare -a arr=("element1" 
                "element2" "element3"
                "element4"
                )

–jeroen

Posted in *nix, *nix-tools, bash, bash, Development, Power User, Scripting, Software Development | Leave a Comment »

Configuration files – Installation and configuration – Plastic SCM Community

Posted by jpluimers on 2020/06/09

The PlasticSCM GUI does not allow you to edit the paths of Workspaces (you can either rename a workspace or delete edit; no other editing options are available).

Luckily you can do this by hand editing the configuration files in %LocalAppData%\plastic4, though this is largely undocumented

Some of those configuration files are explained in [WayBack] Configuration files – Installation and configuration – Plastic SCM Community, but plastic.workspaces is not, so here are the steps:

Read the rest of this entry »

Posted in Development, PlasticSCM, Software Development, Source Code Management | Leave a Comment »

pip install –user and your path

Posted by jpluimers on 2020/06/09

I’ve added this to my ~/.bashrc to stuff installed by pip install --user is accessible from interactive shells:

# set PATH so it includes user's private python "pip --user" bin if it exists
if [ -d "$HOME/.local/bin" ] ; then
    PATH="$PATH:$HOME/.local/bin"
fi

The addition is at the end of the path. It is a choice: it means machine installs take prevalence over user installs. That’s usually what I want. For more considerations (including non-interactive shells), see [WayBack] bash – How to correctly add a path to PATH? – Unix & Linux Stack Exchange.

The --user installs do not affect the full system, nor other users.

Further reading:

–jeroen

Posted in Development, Python, Scripting, Software Development | Leave a Comment »

bash + sed: quadruple backslash for proper escaping within an alias

Posted by jpluimers on 2020/06/09

This is part of a bash alias where I had to use quadruple backslash in order to escape it for sed:

# The sed with quad //// is to prevent 'unterminated substitute in regular expression':
alias x='... | sed "s/=.*/ \\\\/"'

This is needed because bash will escape \\\\ into \\ which sed then escapes to \.

The easiest way to find this is to replace the sed with echo to see the expansion.

References:

–jeroen

Posted in *nix, *nix-tools, bash, bash, Development, Power User, Scripting, sed, Software Development | 2 Comments »

hardlink – How can I find hard links on Windows? – Super User

Posted by jpluimers on 2020/06/08

Cool:

use command:

fsutil hardlink list MyFileName.txt

It lists all hardlinks to file with name MyFileName.txt.

Source: [WayBackhardlink – How can I find hard links on Windows? – Super User

More information at [WayBack] Fsutil hardlink | Microsoft Docs on

fsutil hardlink create <NewFileName> <ExistingFileName>
fsutil hardlink list <Filename>

–jeroen

Posted in Power User, Windows, Windows 10, Windows 7, Windows 8, Windows 8.1 | Leave a Comment »