Creating screencast with audio on Linux

By screencast I don't mean slideshow, but real-time recording of
screen. I used the following software:

- recordmydesktop
- mencoder

Recordmydesktop is great program, it only has one subtle bug: it does
not allow X or Y coordinate to be zero, so I had to move all the
windows 1 pixel to the right. No big deal. I recorded on a 1024x768
area using 1680x1050 screen, so there was plenty of space off-camera
that I could use the stage content and record everything in a single
go.

I used mencoder to convert the video from Ogg/Theora to other formats.
Although I prefer Ogg, many hardware DVD players do not support it (in
fact, it's hard to find one that does).

I had problems with sound setup, although everything was at max in
KMix, it was not loud enough. I have same problems using Skype, so
this is some problem with my computer, not the software. Luckily,
mencoder can also manipulate volume, so I increased it during
conversion. I used a line like this one to invoke mencoder:

mencoder -ovc lavc -oac mp3lame -o video.avi -lameopts
abr:br=128:vol=9 -mc 0 video.ogv

At first I used -oac lavc, but audio and video were out of sync, so I
switched to lame.

Comments [0]

TweetMeme fail

I have an issue they described here:

http://help.tweetmeme.com/forum/topic/467

However, this is what really sucks:

"If you encounter the problem please could you report it in this
forum. We need a bit of information to help us, including your Twitter
username and the browser you are using."

I call that BS. As if they don't have that information available
already. My twitter username is sent in the request that fails.
Browser sends its UserAgent. Just log it, damn it!

Of course, to report the problem you have to log in to forum, and to
log in, you have to create another account. TweetMeme should be a
modern web 2.0 website, yet for their forums they use the
"username/password" concept from stone age. As if OpenID and all the
related technologies do not exists.

Now, I hope all the websites in the world read this and start using
some Twitter integration tools that actually work.

Comments [0]

CKEditor with dark background

I have a website with dark background and light colored text and
needed some WYSIWYG editor for on of the forms. Only special
requirement is support for smileys. I considered:

  • CKEditor
  • TinyMCE
  • openwysiwig
  • Xinha
  • wmd


wmd is not WYSIWYG, so that one was off. openwysiwig was easiest to
configure, but same as Xinha it did not have simleys. So, I was left
with "power" ones.

First I tried TinyMCE. It was rather easy to configure to be used with
dark background, but it's smileys have a few-pixel white border around
them and it looks really ugly. I guess I could have created my own
smileys or edited those provided, but I just wasn't ready to invest
that kind of effort.

So, I tried with CKEditor. Setting it up makes me never want to create
a dark website anymore :(

There are multiple problems that you need to tackle:

1. In contents.css, set something like this:

body
{
color: white;
background-color: black;
}

2. in config.js you could set: config.uiColor = '#000';
but then the dialogs (special character, smiley, link editor, etc.)
will look really ugly, and text of labels would not be readable (black
text on black background). To work around this, I left the default
uiColor (to make sure dialogs are ok) and added a style that .uiColor
setup would create (determined by Firebug). After your ckeditor
declaration in HTML file, add this:

<style>
.cke_editor_editor1 .cke_wrapper { background-color:#000 !important; }
.cke_editor_editor1_dialog a.cke_dialog_tab { background-color:#999
!important; }
</style>

I used #999 for dialog tabs, but this is really not needed (it looks
nice though)

3. the final obstacle was color of links. If you have A tag present in
your textarea it will be rendered as blue, which has almost no
contrast against black. To change this, I added the following to my
CSS file:

.myckeditor a { color: yellow; }


and forced CKEditor to use it via the following setting in config.js

config.bodyClass = 'myckeditor';

This made it work... well, sort of. If link was already present in
works in all browsers. But if you add a link using the "link" button,
it would work properly in IE and Opera, but not Firefox (tested with
Firefox 3.0). Interesting enough, debugging it with Firebug shows the
correct CSS color being used, although it is not shown on screen. The
trick is to add !important to CSS:

.myckeditor a { color: yellow !important; }

Another tip for the end: CKEditor has a context menu which replaces
the default menu so you cannot click some text inside the editor
control and use "Inspect element" opcion of Firebug. To work around
this, add the following to your config.js:

config.browserContextMenuOnCtrl = true;


now, you can invoke the default context menu by holding down Ctrl key
while pressing the right mouse button.

enjoy...

Comments [0]

PHP unserialize bug and CodeIgniter

Using PHP's serialize function to serialize and array or object where
some element is a string with UTF8 data creates the serialized string
properly. However, unserialize function fails to unpack that data.

I ran into this when setting session flashdata from my CodeIgniter application.

The solution I find to work (not sure if it's perfect though) is to
use mb_unserialize function (found in comments of PHP manual).

function mb_unserialize($serial_str)
{
$out = preg_replace('!s:(\d+):"(.*?)";!se',
"'s:'.strlen('$2').':\"$2\";'", $serial_str );
return @unserialize($out);
}

To use this with CodeIgniter's session, just change Session's
_unserialize($data) function to use mb_unserialize instead of PHP's
original function.

Grrr, I lost hours debugging this and finding a solution :(

Comments [1]

Printing from Windows machine to CUPS printer via Samba

I have a laser printer installed on a Linux box which is working from
Linux correctly. I can also print from other Linux machines in the
network via CUPS. One of the machines in the network runs Windows. I
shared the printer via Samba, so that Windows can "see" it via
standard Windows networking. Windows has driver for this printer
installed, but CUPS won't allow it to print. The trick is to configure
CUPS to allow "raw" data to be sent directly to printer. To do this,
edit the file /etc/cups/mime.convs and uncomment this line (it's near
the end of file):

application/octet-stream application/vnd.cups-raw 0 -

Depending on the default CUPS setup for your machine, you might also
need to edit the file /etc/cups/mime.types

After this, just restart CUPS and you can print from Windows box

/etc/rc.d/rc.cups stop
/etc/rc.d/rc.cups start

Comments [1]

A few useful Linux commands

...I learned listening to TuxRadar radio...

xxd - hexadecimal dump of a file, works both ways (you can edit the
dump and save back to file)

xinput list - list and set up input devices for X window system

Comments [0]

64bit PHP 5.2 and Firebird blobs

There's a bug introduced between PHP 5.2.1 and 5.2.2 that affects
handling of Firebird blobs on 64bit machines. Having moved some of my
servers to 64bit Slackware (Slamd64 to be more precise) I run into
this problem.

Unless you want to recompile the whole PHP to a newer version with the
fix (5.3 as I understand, although did not test), you can patch the
sources: Just open ibase_blobs.c file and modify this function:

_php_ibase_quad_to_string

char *result = (char *) emalloc(BLOB_ID_LEN+1);

/* shortcut for most common case */
if (sizeof(ISC_QUAD) == sizeof(ISC_UINT64)) {
sprintf(result, "0x%0*" LL_MASK "x", 16, *(ISC_UINT64*)(void *) &qd);
} else {
ISC_UINT64 res = ((ISC_UINT64) qd.gds_quad_high sprintf(result, "0x%0*" LL_MASK "x", 16, res);
}
result[BLOB_ID_LEN] = '\0';
return result;

Rebuild the interbase.so, copy to extension directory, restart Apache
and you're done.

Comments [0]

Close the tracker item and go home

What to do with average developers that do bad things without even
thinking about it?

Short answer: do NOT hire them.

Being an ISV owner I have a challenge of hiring developers to help me.
Most of them do help, but if their commitment to the development and
the company is not real, they will produce many errors. They simply do
not care: "just close the tracker item and go home" is the policy.

What prompted me to write this is anger I feel, after users reported a
huge bug I believed was fixed ages ago. In fact, it was fixed 17
months ago. I just found my commit (hash
2f51bc152d03e6efbfcb563c46519cc5872d971d in our Git tree). However,
our employee had a small fix on that file (changing a single line) a
few days later and he got a merge conflict.

Instead of going in and applying his change to my version (which changed some 50+ lines) he
decided to simply rewrite it with his own. He could, of course, ask
any other developer to do it, but I guess that was too much work. It's
easiest to screw things up, and not close your tracker item.

Anyway, he left the company some time ago, so it does not even make
sense to tell him about this. Somehow, I feel it's my own fault, maybe
I did not provide enough motivation? Experiences like this assure me
in thinking that you should never hire mediocre developers. Well,
unless it is not your company and you can leave tomorrow, careless
about any wreckage you leave behind you. Nobody is going to blame you
anyway.

Comments [0]

10 Years of Firebird DBMS

I have been using it since 2002. It's rock-solid, small-footprint,
lean and mean database. And it's completely free. No dual-licensing
crap like MySQL, no crippleware like Microsoft or Oracle Express
editions.

Not mention 2MB embedded engine with x-copy deployment (just copy a
few DLLs alongside your EXE and you're good to go). And, without any
changes to the applications, it scales to 10 GB databases (largest I
tried myself, reportedly, there are much larger ones out there).

Imagine a world where DBMS download is a few megabytes and install is
a few seconds...

Well, do not dream, try Firebird and see it for yourself. Once you get
used to that, other DBMS will look like bloatware.

Comments [3]

Reading between the lines

When I read a new software announcement like this:

"According to KDE's bug-tracking system, 7293 bugs have been fixed and
1433 new feature requests were implemented."

my brain actually receives this:

"According to KDE users' complaint system, 1433 new bugs were
introduced and 7293 features that had to work in previous version are
now actually working."

KDE is just the example, don't get me wrong. I'm using KDE as my main
DE and I like it a lot.

Comments [0]

About