Yearly Archives: 2016


Murloc

This slideshow requires JavaScript.


The blue filter observed in this picture is the Electric filter from the Prisma application of Prisma Labs.

Prisma is a photo-editing application that utilizes a neural network and artificial intelligence to transform the image into an artistic effect.
— From Wikipedia: https://en.wikipedia.org/wiki/Prisma_(app)

The scary looking creature photographed is a fictional character from the Warcraft franchise and it is called a Murloc:

The murlocs are amphibious bipedal fish-like creatures, which dwell along the coastlines of the Eastern Kingdoms, and few other locations. Little is known about this species, although they seemingly have enough intellect to form societies and tribes, even having their own faith system. They have their own spoken language, although it is unpronounceable in the common tongue.
— From Wikipedia: https://en.wikipedia.org/wiki/Races_and_factions_of_Warcraft#Murlocs

Useful links:

In this gallery we added along with the original and the filtered pictures some more that use half of the original picture and half of the filtered picture to better show how the effect altered the original picture.

Notes:

  • Prisma only accepts square images and it will resize the produced result to 1080px if the input image is larger than that.
  • The creation of the mixed images was done manually using Gimp.
  • We added the text at the end of the images using the following set of commands on a GNU/Linux environment (specifically Fedora) using bash shell and the imagemagick suite:
folder="modified";
mkdir "$folder";
for img in *.jpg;
do
  width=`identify -format %w "$img"`;
  convert -background '#0008' -fill white -gravity center -size ${width}x30 caption:"© bytefreaks.net" "$img" +swap -gravity south -composite "./$folder/$img";
done

The filtered images were added to the sub-folder called “modified” while the original images were not changed at all.


NotePad++: Replace all content after delimiter on each line

We have a configuration file for Skype, that on each line it describes the translation for each element of Skype.

The format on each line is as VARIABLE=VALUE.

We decided to remove all values automatically, to do that we used NotePad++.

Skype - Language File - Dialog

We pressed Ctrl+H to open up the Replace dialog. In the ‘Find what’ field we wrote =[^\n]*$ and in the ‘Replace with’ we wrote =. In the ‘Search Mode’ option we selected ‘Regular expression’.

The tool looked as follows:
Skype - Language File - Before

Hitting the ‘Replace All’ button, removed all values from each line as it can be viewed below:
Skype - Language File - After
=[^\n]*$ instructs NotePad++ to match everything including the = symbol until the end of the line. [^\n]* means to match everything except the new line character. $ matches the end of the line.


Bash: Check if file is found and contains data

The following code will check if the file described by variable FILENAME exists and has data.

if [ ! -f "$FILENAME" ]; then

    echo "Error: '$FILENAME' file not found.";
else

    if [ ! -s "$FILENAME" ]; then

        echo "Error: '$FILENAME' file is empty.";
    else

        echo "Info: '$FILENAME' file found and contains data.";
    fi
fi

Convert a list of integers from MySQL to a Bash array

The following code will connect to a MySQL server, it will get a list of integers and convert the results to a bash array that will be iterated using a for loop and they will be printed using zero padding.


IDS_RAW=$(mysql --user="myuser" --password="mypass" --host="db.example.com" --database="mydb" --batch --compress --skip-column-names --execute="
  SELECT
    Id
  FROM
    Users
  WHERE
    Status = 0;
");

OLDIFS=$IFS;
IFS=$'\n' command eval;
'IDS=($IDS_RAW)';
IFS=$OLDIFS;

echo "Will process the following user IDs '${IDS[@]}'";

for ID in "${IDS[@]}"; do
  LEADING_ZERO=$(printf %08d $ID);
  echo "ID $LEADING_ZERO";
done;