Install x265 codec on Ubuntu 14.04

x265 is here and we have to deal with its support.

So using these commands I was able to play a x265 encoded video in the latest Ubuntu:

sudo apt-add-repository ppa:strukturag/libde265
sudo apt-get update
sudo apt-get install gstreamer1.0-libde265

Source: Install x265 codec on Ubuntu 14.04

How to temporarily fix the message “TERM environment variable not set” while working with a Docker container

Sometimes at least these days with the current version of Docker you may stumble upon the message “TERM environment variable not set”.

This happened to me while being inside a container with “docker exec -ti”.

clear, top, etc. were not working and complaining about the not set variable.

If you execute this while inside the container:

export TERM=${TERM:-dumb}

The warnings will stop and you can have almost the real thing.

Open windows in center of screen – Ask Ubuntu

As a heavy Windows user I am used to have all not maximized windows to open somewhere in the center or where I put them last time. So I’ve decided to look around the Interwebz if I can do the same with Linux knowing that such things should already be discussed for Ubuntu Linux.

I’ve found this and will use it now to see if it makes the window placement like I am used to:

Open windows in center of screen – Ask Ubuntu.

Some PHP developer interview algorithms you must now

FizzBuzz:

http://3v4l.org/mIBmo

<?php

for ($i = 0; $i <= 30; $i++) {
    if ($i % 3 == 0 && $i % 5 == 0) {
        echo "$i: FizzBuzz; ";
    } elseif ($i % 3 == 0) {
        echo "$i: Fizz; ";
    } elseif ($i % 5 == 0) {
        echo "$i: Buzz; ";
    }
}

Swap 2 vars values without using a third one:

Numbers and strings with XOR:

http://3v4l.org/dsBvh

<?php

$a = 3;
$b = 5;

$a = $a+$b;
$b = $a-$b;
$a = $a-$b;

echo "a = $a; b = $b";

and:

http://3v4l.org/aqWcl

<?php

for ($i = 0; $i <= 30; $i++) {
    if ($i % 3 == 0 && $i % 5 == 0) {
        echo "$i: FizzBuzz; ";
    } elseif ($i % 3 == 0) {
        echo "$i: Fizz; ";
    } elseif ($i % 5 == 0) {
        echo "$i: Buzz; ";
    }
}

Swap 2 strings without using XOR:

http://3v4l.org/FDFDF

<?php
$a = 'texta';
$b = 'textb';
$a = $a . $b; //textatextb
$b = substr($a, 0, strlen($a) - strlen($b)); //texta
$a = substr($a, strlen($b)); //textb
echo "a = $a; b = $b";

Owncloud: How to change the admin password from the command line.

I’ve been playing with Owncloud in a Docker container today and something was not set right. The admin password was not the default one. So my options were to delete the sqlite db file or run some password generating commands and queries to update the password.

The first thing is to generate a new sha1 password:

echo -n "password" | sha1sum

Use the result from the command above as the new password.

The second thing is to open the sqlite database with the sqlite3 command and update the admin’s password:

cd /var/www/owncloud/data
sqlite3 owncloud.db
update oc_users set password = "newsha1password" where uid = "admin";
.quit

Now you can login normally with admin/newpassword and from there you can set up all of the rest.

The sources I used for this article: here and here.