Fix ‘ERROR: column “spclocation” does not exist’ in phpPgAdmin

I was going to create a new database with phpPgAdmin and it crashed with this error:

ERROR:  column "spclocation" does not exist
LINE 1: ...pg_catalog.pg_get_userbyid(spcowner) AS spcowner, spclocatio...
                                                             ^

php-postgresql

We’ll have to add some code to phpPgAdmin to fix this. In my case this worked for phpPgAdmin 5.0.4 and PostgreSQL 9.3 but if you have for example PostgreSQL 9.2 just change the number. It should work.

  1. Open your phpPgAdmin location and change to /classes/database.
  2. Open Connection.php and add a case line for your PostgreSQL version:
    // Detect version and choose appropriate database driver
    switch (substr($version,0,3)) {
        case '9.3': return 'Postgres93'; break;
        case '8.4': return 'Postgres'; break;
        case '8.3': return 'Postgres83'; break;
        case '8.2': return 'Postgres82'; break;
        case '8.1': return 'Postgres81'; break;
        case '8.0':
        case '7.5': return 'Postgres80'; break;
        case '7.4': return 'Postgres74'; break;
    }
  3. Copy Postgres84.php to Postgres93.php.
  4. Open Postgres.php and copy functions getTablespaces and getTablespace.
  5. Open Postgres93.php and change class name to Postgres93 and $major_version variable value to 9.3.
  6. Also in Postgres93.php paste the functions you copied before inside the class.
  7. Replace ", spclocation," with ", pg_tablespace_location(oid) as spclocation," in both functions.

Ref: http://stackoverflow.com/questions/13467949/error-on-creating-database-in-phppgadmin

Fix date strings with percentage symbols in qtranslate

If you see dates with percentage symbols when using qtranslate in WordPress:

before

You can fix it by editing the qtranslate_utils.php file (line 151 more or less) and deleting one of the percentage symbols from:

$date_parameters[] = '#%#'; 			$strftime_parameters[] = '%%';

To this:

$date_parameters[] = '#%#'; 			$strftime_parameters[] = '%';

Then dates should look ok:

after

See CPU and harddrive temperature from the command line in Ubuntu

Install lm-sensors and then configure it. You’ll be asked to try different ways to interface with the hardware that interfaces with the temperature sensors.

sudo apt-get install lm-sensors
sudo sensors-detect
sudo service module-init-tools start

When finished run this to see the CPU temperatures:

sensors

And you’ll see something like this:

acpitz-virtual-0
Adapter: Virtual device
temp1:        +41.0°C  (crit = +110.0°C)

coretemp-isa-0000
Adapter: ISA adapter
Core 0:       +33.0°C  (high = +85.0°C, crit = +85.0°C)
Core 1:       +35.0°C  (high = +85.0°C, crit = +85.0°C)

To see the temperature of the hard drives:

sudo apt-get install hddtemp
sudo hddtemp /dev/sda

You’ll see something like this:

/dev/sda: HTS541060G9SA00: 38°C

Ref: http://askubuntu.com/questions/15832/how-do-i-get-the-cpu-temperature

Twig-extensions in Symfony2

Twig comes with multiple filters that provide functions like round, slice, sort, etc. In case you need more filters Twig-extensions becomes handy because it implements all those filters that are not available by default:

  • Debug: Provides tags and filters to ease template debugging.
  • Text: wordwrap, truncate and nl2br for Strings.
  • i18n: Adds internationalization support via the gettext library.
  • Intl: localizeddate provides localization of DateTime objects.
  • Array: shuffle filter.

First you have to check if these Twig-extensions are already installed. Open composer.json and look for this:

    "require": {
        ...
        "twig/extensions": "1.0.*",
        ...
    }

If you don’t have that, add it and run in the terminal:

composer update

Then you have to enable this extensions in config.yml:

services:
    twig.extension.text:
        class: Twig_Extensions_Extension_Text
        tags:
           - { name: twig.extension }

From now on you can use these extensions as usual in Twig templates:

    {{ name|truncate(10) }}

Ref: https://github.com/fabpot/Twig-extensions

Ubuntu: Fix “The disk drive for /tmp is not ready yet or not present”

Adding explicitly the /tmp to fstab solves the problem. Just add this to your /etc/fstab file:

tmpfs           /tmp            tmpfs   defaults            0       0

Before rebooting you could run this to delete everything from the /tmp folder:

sudo mv /tmp /tmp_old
sudo mkdir /tmp
sudo chmod -R 777 /tmp
sudo rm -Rf /tmp_old

tmp

Ref: http://elementaryos.org/answers/the-disk-drive-for-tmp-is-not-ready-yet-or-not-present
https://bugs.launchpad.net/ubuntu/+source/mountall/+bug/1091792/comments/15