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

Getting your local IPv4 addresses, netmasks and CIDRs

Posted by jpluimers on 2017/04/11

In order to scan some local networks for unknown hosts (yes, on some sites you need to perform archeology), I needed the local IPv4 addresses, netmasks and CIDRs on my Mac running OS X.

Part of that is using ifconfig to get local inet information which however uses hexadecimal network masks and delivers no CIDRs.

SoI was a bit premature when I wrote about “This could be done by creating bash functions mask2cdr and cdr2mask, but that’s a bit too convoluted right now” in Getting the IP addresses of gmail MX servers – via Super User – dig isn’t enough.

netmask to CIDR and CIDR to netmask conversion

I need mask2cdr now, so lets start with these two bash functions and their aliases:

Read the rest of this entry »

Posted in *nix, *nix-tools, Apple, bash, Development, Mac OS X / OS X / MacOS, OS X 10.10 Yosemite, OS X 10.11 El Capitan, OS X 10.9 Mavericks, Power User, Scripting, Software Development | Leave a Comment »

version control – How can I run “git status” and just get the filenames – Stack Overflow

Posted by jpluimers on 2017/04/10

git status --porcelain | sed s/^...//

Source: version control – How can I run “git status” and just get the filenames – Stack Overflow [WayBack]

–jeroen

Posted in Development, DVCS - Distributed Version Control, git, Software Development, Source Code Management | Leave a Comment »

Ext2 File System Driver for Windows download | SourceForge.net

Posted by jpluimers on 2017/04/10

If I ever need it: Ext2 File System Driver for Windows download | SourceForge.net

Posted in *nix, Linux, Power User, Windows | Leave a Comment »

127.0.1.1 in /etc/hosts for your hostname?

Posted by jpluimers on 2017/04/07

Coming from an OpenSuSE background, I was a bit surprised to find 127.0.1.1 in the /etc/hosts file to point to the hostname in Raspbian distributions.

It means you have to change at least these files when altering the hostname:

/etc/hosts
/etc/hostname

In addition to those, I also changed these:

/etc/ssh/ssh_host_rsa_key.pub
/etc/ssh/ssh_host_ecdsa_key.pub
/etc/ssh/ssh_host_dsa_key.pub
/etc/ssh/ssh_host_ed25519_key.pub
/etc/.git/description

After altering these files, you want to run this (via: Pi Town: Change a Raspberry Pi’s Hostname without Rebooting [WayBack])

sudo /etc/init.d/hostname.sh start

This prevents In order to prevent messages like sudo: unable to resolve host raspberrypi without rebooting.

The 127.0.0.1 seems to be a Debian thing: Chapter 5. Network setup – 5.1.1. The hostname resolution [WayBack] has

The IP address 127.0.1.1 in the second line of this example may not be found on some other Unix-like systems. The Debian Installer creates this entry for a system without a permanent IP address as a workaround for some software (e.g., GNOME) as documented in the bug #719621.

The <host_name> matches the hostname defined in the “/etc/hostname“.

For a system with a permanent IP address, that permanent IP address should be used here instead of 127.0.1.1.

For a system with a permanent IP address and a fully qualified domain name (FQDN) provided by the Domain Name System (DNS), that canonical <host_name>.<domain_name> should be used instead of just <host_name>.

via: linux – Why does my hostname appear with the address 127.0.1.1 rather than 127.0.0.1 in /etc/hosts? – Server Fault [WayBack]

There isn’t a great deal of difference between the two; 127/8 (eg: 127.0.0.0 => 127.255.255.255) are all bound to the loopback interface.

The reason why is documented in the Debian manual here:http://www.debian.org/doc/manuals/debian-reference/ch05.en.html#_the_hostname_resolution

Ultimately, it is a bug workaround; the original report is here: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=316099

–jeroen

Posted in *nix, Development, Hardware Development, Linux, openSuSE, Power User, Raspberry Pi, SuSE Linux | Leave a Comment »

Starting a command with one more more spaces prevents it from going into the bash history…

Posted by jpluimers on 2017/04/07

Learned about the -www switch for ps: extra extra “unlimited” wide (a single -w gets you 132 columns).

ps auxwww

Actually, there is no need for www, ww just works:

ps auxww

–jeroen

Source: Starting a command with one more more spaces prevents it from going into the…

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

QCon London 2017: IoT insecurity, serverless computing, predicting technical debt, and why .NET Core depends on a 36,000 line C++ file « Tim Anderson’s ITWriting

Posted by jpluimers on 2017/04/07

A friend of mine is attending the QCon conference as well; I’m anxious to see his conference report and the future posts of Tim.

[WayBackQCon London 2017: IoT insecurity, serverless computing, predicting technical debt, and why .NET Core depends on a 36,000 line C++ file « Tim Anderson’s ITWriting

via [WayBack] QCon London 2017 day 1 – tim anderson – Google+

–jeroen

Posted in Development, Software Development | Leave a Comment »

Some great StackOverflow / StackExchange bash tips

Posted by jpluimers on 2017/04/06

Found these then trying to create a new feature for https://github.com/Hexxeh/rpi-update:

–jeroen

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

Hosting Grumpydev Imageflair locally

Posted by jpluimers on 2017/04/06

Even though StackOverflow and StackExchange now have implemented their own ImageFlair, I still like the original imageFlair that Grumpydev made at Stack Overflow – Share Your Flair – Now in PNG! | GrumpyDev

Grumpydev Imageflair

Stackoverflow imageflair

Stackoverflow imageflair

Alas, the Grumpydev site doesn’t properly support https and Grumpydev cannot change it because of shared hosting limitations, so I wanted to host ImageFlair locally and even see if I could make it StackExchange aware:

Stackexchange flair

Stackexchange flair

Well, I need to do that propertly another time as the first thing I bumped into was this:

PHP Fatal error: Call to undefined function imagecreatefrompng() in /srv/www/vhosts/pluimers.com-ssl/stackoverflow/imageFlair/imageFlair.php on line 42

For now I’ve fixed the first by installing php5-gd (although an SO answer suggests php-gd, openSuSE uses the php-version number for installing modules).

zypper install php5-gd
php -m
rcapache2 stop
rcapache2 start
rcapache2 status

This will install the module, check with php if it is indeed installed, then restart apache to let it use the updated module.

After that, I bumped into a second thing: the image is blank.

Blank imageFlair

Blank imageFlair

I also bumped into a third thing: the .htaccess file rewrite doesn’t work:

https://www.pluimers.com/stackoverflow/imageFlair/so/1.png gave me a 404 error whereas https://www.pluimers.com/stackoverflow/imageFlair/imageFlair.php?userid=1&mode=so “works” (i.e. generates a blank image).

That one was sort of easy to solve.

First of all, apparently I didn’t have all the required apache modules installed. The not-so-easy part is that apache uses two different aliases for modules: the ones listed by apache2ctl -M 2>&1 | sort are in a different format than the ones you mention in .htaccess and .conf files. Oh and of course the -M (nor the -t -D DUMP_MODULES) aren’t listed ore hinted in the apachectl documentation: that would be too easy. They are listed in the httpd2 documentation.

The .htaccess file needs mod_rewrite and mod_expires, but apache2ctl names them rewrite_module and expires_module.

Enabling these was easy, but you have to remember that a2enmod strips the prefix/suffix of the module name (I already had expires_module (shared) installed so this only shows how to enable mod_rewrite):

a2enmod rewrite
rcapache2 stop
rcapache2 start
rcapache2 status

NB: mod_rewrite wasn’t enable by default and before enabling it, read about the risks of mod_rewrite.

Then it still didn’t work, and then it occurred to me that likely I didn’t even have Apache2 allow for using .htaccess as the regexes in the .htaccess were fine. And indeed: .htaccess wasn’t enabled according to the steps at Making sure .htaccess and mod_rewrite are working as they should | Bolt Documentation. And indeed, the Apache documentation indicates when (not) to use .htaccess.

By setting the AllowOverride to both FileInfo as specified by RewriteRule and Indexes as specified by ExpiresActive (trying to refrain from AllowOverride All) for only this specific directory, I think I struck the right balance:


<Directory "/srv/www/vhosts/pluimers.com-ssl/stackoverflow/imageFlair">
# for .htaccess in that directory
AllowOverride FileInfo Indexes
</Directory>

And the final thing is that the logic around StackExchange flair is a tad more complex than I hoped for. And on that bombshell…

–jeroen

Posted in *nix, Apache2, Development, Linux, openSuSE, PHP, Power User, Scripting, Software Development, SuSE Linux | 1 Comment »

OpenSuSE Tumbleweed on Raspberry Pi: getting `vcgencmd version` to work to see which GPU firmware you have

Posted by jpluimers on 2017/04/05

When you search for raspberry pi firmware version check

Installing and running rpi-update will – besides updating the GPU firmware – also install vcgencmd, I got this result:

statler:~ # LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/opt/vc/lib/
statler:~ # export LD_LIBRARY_PATH
statler:~ # /opt/vc/bin/vcgencmd version
Jul 15 2016 17:50:10 
Copyright (c) 2012 Broadcom
version efa728fef77ea14ceb1500caf0146395fa282a0f (clean) (release)

But I wanted to be able to run vcgencmd before installing updates.

openmamba indicates it’s part of their raspberrypi-utils package with sources in the raspberrypi-userland package tracing back to git://github.com/raspberrypi/userland.git which is at https://github.com/raspberrypi/userland.

So I had two choices: compile https://github.com/raspberrypi/userland or find the binaries that rpi-update installs and are already runnable. I went for the second first by digging in https://github.com/Hexxeh/rpi-update/blob/master/rpi-update which on one of the first lines points to https://github.com/Hexxeh/rpi-firmware where the binaries are stored under https://github.com/Hexxeh/rpi-firmware/tree/master/vc/softfp/opt/vc.

The logic for copying the files is in the update_vc_libs function. The calling do_update function updates a lot more, including the firmware. So I wrote a quick pull request to just download the userland binaries:

Feature SKIP_FIRMWARE for #220: forces SKIP_KERNEL=1 and also skip the kernel.img files and the kernel modules: This effectively only installs the userland and SDK.

Source: #220 feature `SKIP_FIRMWARE` by jpluimers · Pull Request #221 · Hexxeh/rpi-update

Hopefully it gets merged in. When not, then you can always take a look at the commit: #220 feature SKIP_FIRMWARE · jpluimers/rpi-update@5a2ec0b

Run these commands to get going:

cd /root/bin
wget https://raw.githubusercontent.com/jpluimers/rpi-update/5a2ec0bc552436d58127cc20e3791cb5b90fd5ba/rpi-update
chmod +x rpi-update
SKIP_FIRMWARE=1 UPDATE_SELF=0 ./rpi-update

You should see this when updating:

 *** Raspberry Pi firmware updater by Hexxeh, enhanced by AndrewS and Dom
 *** We're running for the first time
 *** Backing up files (this will take a few minutes)
 *** Remove old firmware backup
 *** As requested, not updating firmware and kernel modules
This update bumps to rpi-4.4.y linux tree
Be aware there could be compatibility issues with some drivers
Discussion here:
https://www.raspberrypi.org/forums/viewtopic.php?f=29&t=144087
##############################################################
 *** Downloading specific firmware revision (this will take a few minutes)
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   168    0   168    0     0    361      0 --:--:-- --:--:-- --:--:--   362
100 51.2M  100 51.2M    0     0  1246k      0  0:00:42  0:00:42 --:--:-- 1446k
 *** As requested, not updating firmware and kernel
 *** As requested, not updating firmware and kernel modules
 *** Updating VideoCore libraries
 *** Using HardFP libraries
 *** Updating SDK
 *** Running ldconfig
 *** Storing current firmware revision
 *** Deleting downloaded files
 *** Syncing changes to disk
 *** If no errors appeared, your firmware was successfully updated to 818a860cf690d64c62d3227ad9c36d5867a671c2
 *** A reboot is needed to activate the new firmware

And the final goal of checking the firmware version now works:

# LD_LIBRARY_PATH=/opt/vc/lib /opt/vc/bin/vcgencmd version
Jul 15 2016 17:50:10 
Copyright (c) 2012 Broadcom
version efa728fef77ea14ceb1500caf0146395fa282a0f (clean) (release)

–jeroen

Posted in Development, Hardware Development, Linux, openSuSE, Raspberry Pi, SuSE Linux, Tumbleweed | Leave a Comment »

Recursively convert WMA files to MP3 using ffmeg on a Mac OS X bash shell

Posted by jpluimers on 2017/04/05

A friend of mine made the mistake to capture some CDs using WMA files and throwing away the CDs. His old Nokia could play them, but not his new iOS and Android devices.

ffmeg and bash to the rescue:

find . -iname "*.wma" -execdir bash -c 'NAME="{}" && ffmpeg -y -i "$NAME" -ab 192k "${NAME/.wma/.mp3}" -map_metadata 0:s:0 && rm "$NAME"' \;

Tricks used:

Read the rest of this entry »

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