How to install and package Frei0r plugins using FPM

To get the Alpha Shapes effect in Kdenlive you need install the Frei0r alphaspot filter.

This filter is experimental and not included in older Ubuntu release of the Frei0r plugin (recent versions of Ubuntu do contain these plugins). So the plugin needs to be compiled from source.

I decided to make a deb package with FPM as well, so I wouldn’t have to repeat the process. This post documents entire process if I ever do need to do it again.

If you just want the deb package it is linked at the bottom of this post.

Compiling

Following the instructions to compile Frei0r off the Kdenlive site.

First, we need to make sure the plugins from the repositories are not installed, then we need to install the libraries required compile Frei0r.

$ sudo aptitude purge frei0r-plugins frei0r-plugins-dev frei0r-plugins-doc
$ sudo aptitude install libcv-dev libgavl-dev libhighgui-dev libcvaux-dev cmake

Now we are ready to check out and compile.

$ mkdir compile
$ cd compile
$ mkdir bin
$ git clone git://git.dyne.org/frei0r.git
$ cd frei0r
$ mkdir build
$ cd build && cmake .. -DCMAKE_INSTALL_PREFIX=/usr && make -j3

Here we stop, instead of just plain make install we want to install the plugins to the bin directory we created earlier so we can package them.

Packaging

This part follows the FPM instructions on PackageMakeInstall.

We also strip the debug symbols from the compiled plugins. It makes for a smaller, happier deb package. It also prevents the Lintian error “unstripped binary or object”.

Finally we go to directory where we want the create the deb package.

$ make install DESTDIR=/path/to/bin
$ cd /path/to/bin/usr/lib/frei0r-1/
$ strip *.so
$ cd /path/to/bin/..

Now we can create the deb package. I wrote this script to do it for me. The only thing you will need to change is the -C /home/krokodil/src/bin which should be the destination of your make install.

Download Package

You can download the deb package from the link below. If you are running a more recent version of Ubuntu (Utopic 14.10+) there is a good chance these plugins are already available in the repository version, so check that first.

Compiled on Linux Mint 16 Petra – Linux 3.11.0-12-generic #19-Ubuntu SMP Wed Oct 9 16:20:46 UTC 2013 x86_64. It works for me.

Use at own risk, I am not responsible for any damages caused by using this package or the plugins therein.

frei0rplugins-1.4_amd64.deb.

Postgresql Datatype mismatch default for column cannot be cast to type integer

When converting a table column from varchar to integer I ran into a problem.

[code lang=text]
SQLSTATE[42804]: Datatype mismatch: 7 ERROR: default for column "column_name" cannot be cast to type integer
[/code]

The solution I could find on (Stackoverflow)[http://stackoverflow.com/questions/13170570/change-type-of-varchar-field-to-integer-cannot-be-cast-automatically-to-type-i] was not working:

[code lang=sql]
ALTER TABLE the_table ALTER COLUMN col_name TYPE integer USING (col_name::integer);
[/code]

Looking closer at the error I realised – as is often the case – the error was indicating exactly what the problem was. The default of the column could not be converted.

Not knowing how to convert the default, I simply changed it to something that could be converted:

[code lang=sql]
ALTER TABLE the_table ALTER COLUMN col_name SET DEFAULT 0;
[/code]

Despite it being a varchar column, the integer value 0 was accepted. After which the earlier CAST worked.

Install Debian wheezy-backports repository

The Debian backports repository contain packages or newer versions of packages that did not make it into the original release. You can read more about backports on the Debian website.

To install wheezy-backports you need to either add the repository line:

deb http://http.debian.net/debian wheezy-backports main

to your /etc/apt/sources.list file.

Alternatively you can create a new sources list file with this command (run as root):

# echo 'deb http://http.debian.net/debian wheezy-backports main' > /etc/apt/sources.list.d/wheezy-backports.list

Once installed, run apt-get update:

# apt-get update

Select individual packages to install:

# apt-get -t wheezy-backports install "package"

Photo credit: Giulio Turetta

Installing CyanogenMod onto a Samsung Galaxy S3 (International) – SIII / i9300 using Linux Mint 16 Petra (Ubuntu Saucy 13.10)

DISCLAIMER: Modifying or replacing your device’s software may void your device’s warranty, lead to data loss, hair loss, financial loss, privacy loss, security breaches, or other damage, and therefore must be done entirely at your own risk. I am not responsible for your actions. Good luck.

The new CyanogenMod installer requires Windows. Most of the manual tutorials assume you’re running Windows. Hopefully my summarised experience below will help other Linux users.

Continue reading Installing CyanogenMod onto a Samsung Galaxy S3 (International) – SIII / i9300 using Linux Mint 16 Petra (Ubuntu Saucy 13.10)

PostgreSQL functions and triggers

It is desirable to avoid using database functions. They are black boxes which gift only night horrors to unwary developers. A system is difficult to understand, maintain and debug when chunks of it lurk unseen in the DB.

Despite this – for certain features – using them does make sense. Provided the database function’s code is source controlled and huge lumps of comments referring to both the location and function of said code is spread evenly throughout the associated application code.

For example, in order to bill Ekaya agents accurately we needed a log of show house status changes, from upcoming to active to past or cancelled. Most of these changes were implemented in sweeping SQL statements that, while efficient at their own task, made it difficult to track individual changes.

Continue reading PostgreSQL functions and triggers

Postgresql date formatting

Preamble

Formatting of data should only occur in the final steps of output. Until that point, and as a rule, internally data should remain in a base format that can easily be converted into many others – without being converted into another more basic format first.

For example Unix timestamp for dates or a floating point number for money. Both can readily be converted into more expressive formats without writing code to first parse or disassemble the initial format.

However in a situation where the flow is very specific and unlikely to ever be used to generate a different output it is permissible, even desirable, to generate data in the format it will be finally outputted.

Continue reading Postgresql date formatting