The Wiert Corner – irregular stream of stuff

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

  • My work

  • 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,310 other followers

Archive for the ‘bash’ Category

bash: `printf` supports `\e` just like `echo -e` does

Posted by jpluimers on 2017/11/07

Learned a few things when modifying https://github.com/gkotian/gautam_linux/blob/master/scripts/colours.sh

Note: `printf` supports emitting `ESC` (ASCII character `\033` aka `27` aka `0x1B`)as `\e` the same way that `echo` does

https://linux.die.net/man/1/printf
https://linux.die.net/man/1/echo

Format strings are at https://linux.die.net/man/3/printf
%-10s means left adjusted (aligned) string of length 10

–jeroen

via:

I was investigating how the colour definitions on my OpenSuSE system actually work internally so I added some extra output: ${TYPE} and ${COLOUR}.

Source: Show type and colour definition in addition to the rendered colour. by jpluimers · Pull Request #5 · gkotian/gautam_linux

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

nojhan/liquidprompt: A full-featured & carefully designed adaptive prompt for Bash & Zsh

Posted by jpluimers on 2017/10/05

Wow: nojhan/liquidprompt: A full-featured & carefully designed adaptive prompt for Bash & Zsh

This is really useful!

via:

Sort of tanslated from the first “via” (note that “mit Alles und Scharf” is hard to translate; it’s somewhere between “everything but the kitchen sink, but done right” and “right on the money”):

Bash Prompt Overkill: https://github.com/nojhan/liquidprompt is a Bash “Prompt doing it all right”-extension, which doesn’t care how much any feature costs as we have cores, gigabytes and SSD.

Liquid Prompt automagically recognises context and enables a plethora of features in the prompt when needed based on that context.

It’s like pixie dust for your prompt.

You can configure everything, but you don’t have to: the out of the box experience is already like pixie dust for your prompt.

It works on OS X too and is part of homebrew:

$ brew install liquidprompt
==> Using the sandbox
==> Downloading https://github.com/nojhan/liquidprompt/archive/v_1.11.tar.gz
==> Downloading from https://codeload.github.com/nojhan/liquidprompt/tar.gz/v_1.11
######################################################################## 100.0%
==> Caveats
Add the following lines to your bash or zsh config (e.g. ~/.bash_profile):
  if [ -f /usr/local/share/liquidprompt ]; then
    . /usr/local/share/liquidprompt
  fi
If you'd like to reconfigure options, you may do so in ~/.liquidpromptrc.
A sample file you may copy and modify has been installed to
  /usr/local/share/liquidpromptrc-dist
Don't modify the PROMPT_COMMAND variable elsewhere in your shell config;
that will break things.
==> Summary
🍺  /usr/local/Cellar/liquidprompt/1.11: 7 files, 125.6K, built in 3 seconds
[jeroenp:~/Versioned] 10s $

–jeroen

Read the rest of this entry »

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

youtube-dl – saving both audio and video without keeping intermediate files seems impossible

Posted by jpluimers on 2017/09/14

Just in case someone has a better alternative than youtube-dl alias:

alias youtube-dl-audio-and-video='youtube-dl --keep-video --extract-audio --audio-quality 0 --audio-format mp3'

It extracts the audio and keeps the video.

The result is that also all intermediate downloads are being kept.

So even after studying the README extensively the only alternative seems to be a double download like this:

youtube-dl-audio-and-video() { youtube-dl --extract-audio --audio-quality 0 --audio-format mp3 $1; youtube-dl $1; }

–jeroen

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

opensuse – How to run my script after SuSE finished booting up? – Unix & Linux Stack Exchange

Posted by jpluimers on 2017/04/21

For future research: opensuse – How to run my script after SuSE finished booting up? – Unix & Linux Stack Exchange

Reason? Want to show the output of this as the last boot sequence line:

hostname
ip route
echo
ip address | grep -w 'UP\|flags\|inet\|inet6'
echo more detailed info through "ip address" and "ip route"
cat /etc/resolv.conf | grep nameserver

–jeroen

Posted in *nix, *nix-tools, bash, Linux, openSuSE, Power User, SuSE Linux, Tumbleweed | Leave a Comment »

Hosting Grumpydev Imageflair locally – part 2 – trying to get the text and images to display

Posted by jpluimers on 2017/04/12

Blank imageFlair

Blank imageFlair

Hosting Grumpydev Imageflair locally ended with two issues left: an empty image and my wish to include more complete StackExchange bits like the current StackExchange flair does.

I thought fixing the empty image would take a rainy day. It actually took a few rainy hours.

No text

The culprit is that I didn’t have the Microsoft Core Fonts for the Web installed. Which was no coincidence as the free download of those from Microsoft terminated in 2002. The upside is that because of their licenses, they are available as open source and most linux distributions have a script package that will download these fonts. OpenSuSE has fetchmsttfonts for this.

Alternatively, you can use the web.archive.org to download manually, but that’s a tad tedious. But if you love tedious: Free downloads – TrueType core fonts for the Web.

zypper install fetchmsttfonts

That installs the fonts in:

/usr/share/fonts/truetype

The drawback of having fetchmsttfonts is that the original Microsoft versions of these fonts are downloaded from corefonts.sourceforge.net each time the fetchmsttfonts package is updated, potentially overwriting newer versions of the fonts in that directory. If you don’t want that, use the trick at  (not yet archived at the WayBack machine) font handling – install fetchmsttfonts, copy fonts, rpm -e fethmsttfonts, copy fonts back.

Having the fonts installed, I thought the only thing I needed to fix were the multiple references in config.php from that pointed to Arial.TTF. I took the poor man’s approach and just did this being in the directory of config.php:

cp /usr/share/fonts/truetype/arial.ttf Arial.TTF

Filled Imageflair

That didn’t work either: still no text showed.

So I decided to run imageFlair.php from the command line after setting $imageflair_debug = true; in config.php which then resulted in all sorts of warnings like

PHP Warning: imagettftext(): Could not find/open font

After reading I decided to build a small php-gd.tester.php script containing phpinfo(); and gd_info showing these portions for PHP GD (non-relevant bits stripped):

Additional .ini files parsed /etc/php5/conf.d/ctype.ini,
/etc/php5/conf.d/dom.ini,
/etc/php5/conf.d/gd.ini,
/etc/php5/conf.d/iconv.ini,
/etc/php5/conf.d/json.ini,
/etc/php5/conf.d/mysql.ini,
/etc/php5/conf.d/mysqli.ini,
/etc/php5/conf.d/pdo.ini,
/etc/php5/conf.d/pdo_mysql.ini,
/etc/php5/conf.d/pdo_sqlite.ini,
/etc/php5/conf.d/sqlite3.ini,
/etc/php5/conf.d/tokenizer.ini,
/etc/php5/conf.d/xmlreader.ini,
/etc/php5/conf.d/xmlwriter.ini

gd

GD Support enabled
GD headers Version 2.1.1
GD library Version 2.1.1
FreeType Support enabled
FreeType Linkage with freetype
FreeType Version 2.6.3
GIF Read Support enabled
GIF Create Support enabled
JPEG Support enabled
libJPEG Version 8
PNG Support enabled
libPNG Version 1.6.21
WBMP Support enabled
XPM Support enabled
libXpm Version 30411
XBM Support enabled
WebP Support enabled

And the gd_info dump:

GD Version 2.1.1
FreeType Support 1
FreeType Linkage with freetype
T1Lib Support
GIF Read Support 1
GIF Create Support 1
JPEG Support 1
PNG Support 1
WBMP Support 1
XPM Support 1
XBM Support 1
WebP Support 1
JIS-mapped Japanese Font Support

Too bad though: no information on where it sources the fonts from.

No image

Having no solution for the font rendering yet, I focussed at the lack of profile picture.

In the past, the images were generated with gravatar information in the JSON, but now that is empty. See for instance the output of http://superuser.com/users/flair/1.json versus his image http://superuser.com/users/flair/1.png

That reveals quite a change in the JSON that imageFlair expects. Actually there is a lot of HTML in there.

So decided to try http://superuser.com/users/flair/1 in addition to http://superuser.com/users/flair/1.json with this result:

Two downsides here:

  1. This doesn’t work for the combined stackexchange flair: http://stackexchange.com/users/flair/1.png works, but http://stackexchange.com/users/flair/1 gives a 404.
  2. Rendering HTML servers side to PNG requires a lot of work.

Time for another rainy day (:

–jeroen

Read the rest of this entry »

Posted in *nix, *nix-tools, bash, Development, Linux, openSuSE, PHP, Pingback, Power User, Scripting, Software Development, Stackoverflow, SuSE Linux | Leave a Comment »

 
%d bloggers like this: