How To Fix Encoding Error In Postgres

Here is an example error when trying to create a database in Postgres:

ERROR 22023 (invalid_parameter_value) encoding "UTF8" does not match locale 
The chosen LC_CTYPE setting requires encoding "LATIN1".

Such an error might come up if OS locale was not set while installing Postgres. It is fixable by shuffling templates or by reinstalling Postgres after locale is set, I prefer the latest, cause having a fresh install just gives me more peace of mind. To fix that, we must first configure locale, on Debian/Ubuntu it would be something like that (the command will trigger an interactive prompt):

Continue reading

Fix No Sound in Steam for Linux Problem

There is an issue with Steam for Linux that seem to be persistent on machines with HDMI enabled displays or similar unused HD audio inputs.

Steam for Linux seems to use these controllers despite them being ignored by the system, which results in weirdly muted games while YouTube as well as any sound tests are loud and clear.

To fix this issue open sound settings and select analog controller or (for pulseaudio sound server) install pulseaudio volume control

sudo apt-get install pavucontrol

under “Output Devices” check if it tries to use the HD audio controller to output sound, go to “Configuration” and disable the HD audio controller profile so that analog audio will always be used.

Update: Local Subdomains under Ubuntu 14.04 Linux and Apache 2.4

Here we went through the Ubuntu 13.10 process, Ubuntu 14.04, though using the same Apache 2.4, again has a small thing that have to be done differently:

Config files in sites-available have a .conf (and not .config) extension
gksudo gedit /etc/apache2/sites-available/project.conf

As for the rest, previous Ubuntu 13.10 Tutorial can be used for newer Ubuntu as well.

Local Subdomains under Ubuntu Linux and Apache 2.4 Tutorial

The whole process was described in this article, but there are few quirks to fix in newer Ubuntu (namely 13.10 / Apache 2.4).

  1. Every config file in sites-available has to have a .config extension now, so instead of
    sudo nano /etc/apache2/sites-available/project
    sudo nano /etc/apache2/sites-available/project.config
    if upgrading fist add the extension to the /etc/apache2/sites-available/project config file, then delete /etc/apache2/sites-enabled/project and re-run “sudo a2ensite project” / restart apache.
  2. If your project root is located in your home directory you might get a persistent 403 / Forbidden error, that (weird as it is) has nothing to do with Linux permissions. To fix it add “Require all granted” directory directive. Here is how the new config file might look:
    <VirtualHost *:80>
    DocumentRoot /home/user/project
    ServerName project.localhost
    <Directory /home/user/project>
    AllowOverride All
    Order allow,deny
    Allow from all
    Require all granted

So here are updated instructions for Ubuntu 13.10+ (and maybe some older versions). Continue reading

How To Fix a Broken NetBeans under Linux

Yesterday something awful happened to my NetBeans IDE (version 7.3 PHP Linux x64 under Ubuntu 12.4 LTS) – it started to do all kinds of weird stuff, along with few visual bugs it also froze on code completion and hanged while preparing an SVN commit. All of a sudden it wasn’t possible to work any more and of course there were quite a few urgent things that I had to do with it.

So I quickly tried to fix it:

  • Killed all processes, restarted NetBeans few times, logged out/in, restarted the system
  • Reinstalled NetBeans, reinstalled it without saving any settings, installed newer version (7.3.1), tried latest beta
  • Started it with all the smart parameters that I could google
  • Installed few alternatives, didn’t have much time to play with these though

None of the things above fixed the problem which is somewhat strange – it’s not every day that you find cross-version bugs that just come out of the blue and wouldn’t go away. So after installing PHPStorm and seeing its warning about Java I got another idea about the root of the problem – NetBeans as well as other IDEs uses Java, that under Linux comes in two flavors: OpenJDK and Oracle Java (well, there are other options but these are not that relevant).

At the moment I had OpenJDK and I think it was just updated (yeah I might have clicked “update” button) causing all the weird bugs. Since the problem had little to do with the software itself, it could not be fixed by fixing the software. Download and install of NetBeans with Oracle Java solved the problem for me so if you have similar problems you might want to give it a try.

Manually remove a broken package in Ubuntu/Debian

Recently I’ve had a problem with one of the packages (“deployment-daemon-zend-server”) that went broken after system upgrade, so that no updates or even new software could be installed. Here’s an error message I kept getting:
dpkg: error processing deployment-daemon-zend-server (--remove):
subprocess installed pre-removal script returned error exit status 127

That’s a nasty problem cause it has to be solved per hand – no automatic fixes via update manager and software center worked for me, I also tried the force removal of the package this way:
sudo dpkg --remove --force-remove-reinstreq PACKAGE_NAME
And it didn’t work either. So the solution here is to find all the package files, move them to a temporary directory and then force-remove the package. Following code did the job (replace PACKAGE_NAME with the name of the broken package):
sudo mv /var/lib/dpkg/info/PACKAGE_NAME.* /tmp/
sudo dpkg --remove --force-remove-reinstreq PACKAGE_NAME