Useful online font identification tools

https://www.myfonts.com/WhatTheFont/

https://www.fontsquirrel.com/matcherator

One of them will probably get you to the font you are in need of.

Advertisements
Posted in Uncategorized | Leave a comment

Rubygems: Rebuild native extensions

Reposted after “makandropedia”:

Rarely, you might want to rebuild all gems with native extensions, because they might be compiled against outdated system libraries, resulting in some warnings or even segfaults or other ruby errors.

You can do that using

gem pristine --all

This will reset all gems to a pristine state as if you’d reinstall them, and as a side effect, rebuild all native extensions.

The above command will also help you sorting out errors like this after a distribution upgrade:

libmysqlclient_r.so.16: cannot open shared object file: No such file or directory - /home/henning/.rvm/gems/ruby-1.8.7-p358/gems/mysql2-0.3.11/lib/mysql2/mysql2.so

(Because the library which is used to compile the gem doesn’t exist anymore and you have to recompile it.)

Posted in Coding, Rails | Tagged , | Leave a comment

One – liner to batch rename files with regex-remove part of the filename

Don’t read this post. It’s only for me so that I don’t forget it ūüėČ

After a long fight with bash, find, sed, … Here is the one – liner:

for i in $(find -E . -regex '(.*[a-zA-Z]{3}[0-9]{3}[a-zA-Z]{3}_[0-9]{9})(\.[0-9])(\.[jJ][pP]([eE])*[gG])') ; do mv -v $i $(echo $i | sed -E 's/(.*[a-zA-Z]{3}[0-9]{3}[a-zA-Z]{3}_[0-9]{9})(\.[0-9])(\.[jJ][pP]([eE])*[gG])/\1\3/') ; done

Given a set of JPEG files, which contained duplicates with .1¬†thrown-in before the final dot and the ending of the filename, replacing the original with the newer ones (those with .1‘s) seemed like a trivial task‚Ķ until I tried to actually do this. In the end it came to using “modern regex” with matching groups and refer to those groups I wanted to retain. These are \1¬†and \3¬†concatenated in the \1\3¬†part of the sed¬†replace pattern. Group \2¬†(the .1) didn’t make it there.

 

Posted in bash, Coding | Tagged , , , , | Leave a comment

One-bash-liner to get rid of .WMV container

For reasons known probably to only a very few, selected ones – videos contained in the “.WMV” container seem to have occasional problems with seeking and positioning when played back with XBMC (or “Kodi” if you adapted to the brave new name). To alleviate the problem I eventually wrote a one-liner that copies all video and audio streams from “.WMV” files into Matroska containers:

SAVEIFS=$IFS; IFS=$(echo -en "\n\b"); for i in $( ls *.wmv ) ; do ffmpeg -i "$i" -c copy "${i%.*}".mkv ; done ; IFS=$SAVEIFS

CD into the directory with the video files you want to process and go. Obviously you need to have a working ffmpeg installation first.

Posted in Video | Tagged , , , | Leave a comment

Rails derailed again (and again)

Executive summary (aka TL;DR)

  1. Rails docs suck… erm, no. I mean they are great but most probably written by people who never actually had to use them.
  2. If you want to follow Rails Guides and install a fresh Rails environment on a vanilla Ubuntu 16.04LTS you need at least the following dependencies installed before you start:
    • ruby-dev
    • zlib1g-dev
    • libsqlite3-dev
    • gcc
    • make
    • g++

Continue reading

Posted in Rails, Rants | Tagged , , , , | 4 Comments

PHP’s “associative array”: removing blacklisted or keeping whitelisted keys

Yup, if there is one language I loathe more than PHP, it’s Javascript‚Ķ but this here is about PHP and how to either remove unwanted keys from an “associative array” (as they call it in PHP world) or leave only those, which you want to stay – in one shot.

Remove unwanted keys:

$my_cleaned_array = array_diff_key($my_dirty_array, array_flip($array_of_blacklisted_keys));

Keep welcome keys:

$my_cleaned_array = array_intersect_key($my_dirty_array, array_flip($array_of_whitelisted_keys));
Posted in Coding, php | Tagged , | Leave a comment

openvpn inactivity timeout (–ping-restart) restarting

So, there’s a nicely configured OpenVPN server, there is the client config that is proven to work with all your colleagues around and everything “just works” … or maybe, rather “just needs more work”? was it?

If you happen to suffer from irregular but painful unreliability of your OpenVPN connection on a perfectly reliable network link and in the logs you regularly happen to see something like:

 [server] Inactivity timeout (--ping-restart), restarting

chances are that you have fallen into the same trap as me, and another OpenVPN user. What trap? I happily tried to use the same config (including my certificate) on three¬†machines… nothing wrong you say? Sure, I can use it on both my desktop and laptop and everything should be fine! True, I thought so too. Until I left my work desktop on and connected in the office, I connected my desktop at home and then, since thing didn’t look nicely I tried on the laptop too… then I went to the office to check how it works there (hint: stopped working too) and…

Yes, as one user called ‘krzee’ wrote:

your clients are fighting each other for the right to be [your CN]
there is a command to let the same cert connect multiple times… but it was only intended for testing purposes, or when using username auth in addition to certs. making certs for each client will fix your problem

So – if you use the same certificate on multiple clients, be sure to disconnect before leaving the machine unattended. Or – better – create and sign different certificates for every client / machine you intend to connect from.

Posted in Coding, DevOps | Tagged | Leave a comment