h1

Raspberry Pi setup for HDMI ready TV

April 19, 2015

If you get blurred or poor quality images when using your Raspberry PI on an HDMI TV then this article might help you. To fix this, we have to tell the PI to reduce the quality of the image being sent via the HDMI cable.

You should edit the file config.txt located at /boot/config.txt

Add the following lines – they may already be in the file and need the leading hash # sign removing:

hdmi_group=1
hdmi_mode=4
hdmi_drive=2
config_hdmi_boost=4

hdmi_group defines the HDMI type. With this not set the Pi tries to infer it from what the TV is telling it. With older HDMI ready TVs it seems this is wrong and you need to be specific. TVs are generally hdmi_group 1 (which is CEA) where as hdmi_group 2 is for monitors (DMT).

hdmi_mode gives the specific screen resolution for your TV. For my 720p TV I needed hdmi_mode 4. For a complete list of modes check the hdmi_mode section of this page: http://elinux.org/RPiconfig

hdmi_drive can be 1 (no sound sent over HDMI) or 2 (with sound over HDMI)

config_hdmi_boost sets the signal strength. Default is 0 but you can boost as high as 7. I found 4 overcame some interference issues.

Once edited, the Raspberry Pi needs to be restarted for the changes to take effect.

h1

Doctrine 2 and Symfony 2 – ORA-01861: literal does not match format string

June 26, 2014

I am using Doctrine 2 and Symfony2 in a PHP application which queries an Oracle database.

Operations which filter on DateTime columns caused the following Exception to be thrown

 [Doctrine\DBAL\DBALException]
An exception occurred while executing 'SELECT ... with params ["1970-01-01 01:00:01", "2014-06-26 15:43:18"]:
ORA-01861: literal does not match format string

This error is Oracle telling you that the datetime parameter is in an unexpected format.

The fix is to put the following code into your app/config/config.yml file

services:
    oracle.listener:
        class: Doctrine\DBAL\Event\Listeners\OracleSessionInit
        tags:
            - { name: doctrine.event_listener, event: postConnect }

This appears to tell Doctrine to use the OracleSessionInit class when connecting.

ref: http://www.doctrine-project.org/jira/browse/DDC-2731

h1

Useful freenode IRC commands

May 30, 2014

Just collecting together some useful IRC commands which were difficult to find how to do…

Asking ChanServ for help

    /msg ChanServ help op

Regaining OP after leaving your channel

    /msg ChanServ OP #channel username

Setting a channel password

    /msg ChanServ set #channel mlock +k mypassword

 

h1

Setting all line endings in a DOS file to UNIX

September 13, 2012

If you have a nasty DOS file and you wish to convert the it from any mixture of CRLF/LF-only line endings, so all lines end with LF only:

Save any changes.
:w

Edit file again, using dos file format (‘fileformats’ is ignored).
:e ++ff=dos

This buffer will use LF-only line endings when written.
:setlocal ff=unix

Write buffer using unix (LF-only) line endings.
:w

h1

IE6 ignores z-index on select elements – bgiframe plugin for jquery

July 8, 2012

IE6 ignores z-index on selects and puts it above everything else. This is annoying when you have a drop down mega menu that needs to cover a form and you need to support IE6.

There is this jquery plugin magically fixes this with some magic involving an iframe:
http://docs.jquery.com/Plugins/bgiframe

Include the jquery plugin and then target the floating div in the menu that needs to float over the select. e.g. jQuery(‘div.sub’).bgiframe();

h1

Getting PHP and MSSQL talking on Mac OSX

April 5, 2012

Here is what I had to do to get PHP talking to an MSSQL database on MAC OSX (Lion). Note that I am running Acquia dev desktop for PHP, you’ll have to change the paths to PHP if your setup is different.

Download Free TDS stable source from http://www.freetds.org/software.html and extract from the tarball.

Login as root with

sudo /usr/bin/bash

Go into freetds sources folder and configure freetds

CFLAGS="-arch i386" LDFLAGS="-arch i386" ./configure --prefix=/usr/local/freetds --enable-msdblib --with-tdsver=8.0

Compile freetds with

make && make install

Download and extract PHP sources for your version of PHP from http://php.net/downloads.php

Go into the php sources folder ext/mssql directory and configure

CFLAGS='-arch i386 -isysroot /Developer/SDKs/MacOSX10.7.sdk -mmacosx-version-min=10.7' ./configure --with-php-config=/Applications/acquia-drupal/php/bin/php-config --with-mssql=/usr/local/freetds

This will create a file called libtool

Go back to the freetds sources directory and run

make clean
CFLAGS="-arch i386" LDFLAGS="-arch i386" ./configure --prefix=/usr/local/freetds --enable-msdblib --with-tdsver=8.0

delete the freetds install
rm -rf /usr/local/freetds

copy the libtool file from the php sources ext/mssql directory to the freetds directory
cp /path/to/php-source/ext/mssql/libtool /path/to/freetds-source

Compile and install freetds again
make && make install

Go to the php-sources/ext/mssql directory and compile mssql
make

cp the so file to your php extensions dir
cp modules/mssql.so /Applications/acquia-drupal/php/ext

Edit your php.ini to include the mssql.so extension (e.g. with vim or nano)
vim /Applications/acquia-drupal/php/bin/php.ini

Add the following line in the Dynamic extensions section
extension=mssql.so

Tell the system where the FreeTDS config file is
echo "export FREETDSCONF=/usr/local/freetds/etc/freetds.conf" >> /etc/profile
echo "/usr/local/freetds/lib" >> /etc/ld.so.conf
ln -s /usr/local/freetds/bin/tds /usr/bin

and also run the followig (to save restarting your MAC)

export FREETDSCONF=/usr/local/freetds/etc/freetds.conf

Edit the freetds config file and set the freetds version to 8.0 (others dont seem to work with SQL server properly)
vim /usr/local/freetds/etc/freetds.conf
tds version = 8.0

Restart Web server

If you need help setting up SQLEXPRESS…

The basics…
http://codebetter.com/jefferypalermo/2005/11/04/how-to-use-sql-server-express-wheres-the-ui-level-200/

Setting up SQLEXPRESS for mixed login (windows authentication didn’t work for me from my remote PHP server)
http://eduzine.edujini-labs.com/archives/24-HOWTO-Configure-Microsoft-SQL-Server-for-Mixed-Mode-Authentication.html

Adding a new user account to sql express:
http://msdn.microsoft.com/en-us/library/aa337562.aspx

Let this new account access a db:
http://msdn.microsoft.com/en-us/library/aa337545.aspx

h1

PHP shell scripts stop working if PHP executable is symlinked

March 9, 2012

I do web development for PHP on a MAC. Recently I installed the Acquia Dev desktop which is quite handy. It installed its own version of PHP to /Applications/acquia-drupal/php/bin/php

I needed to use this PHP from the command line so put a symnlink from /usr/bin/php -> /Applications/acquia-drupal/php/bin/php

Now, I also had phpcs installed, but moving PHP from an executable to a symmlink really upset it and it stopped working. Indeed, no shell script with the following shebang starting line would work anymore.

#!/usr/bin/php

The solution is to instead use the following line at the top of those shell scripts instead:

#!/usr/bin/env php

So to make phpcs work again I had to edit /usr/bin/phpcs

Ref:
http://www.cyberciti.biz/tips/finding-bash-perl-python-portably-using-env.html