Tuesday, November 9, 2010

Handlersocket for MySQL - ubuntu installation

Recently I've trapped on nice blog post of Yoshinori Matsunobu one of former developers of MySQL. He tells how to get a MySQL work as NoSQL. I've decided to compile that on my Ubuntu installation.

Getting sources

For building handlersocket under Ubuntu you will need to install
$ sudo aptitude install dpkg-dev libtool automake libssl-dev dpatch git-core
Create a directory where you will store all build files and get source of MySQL and handlersocket
$ mkdir build
$ cd build
$ sudo apt-get source mysql-server
$ git clone https://github.com/ahiguti/HandlerSocket-Plugin-for-MySQL.git handlersocket

That will download MySQL source into mysql-dfsg-5.1-5.1.41 and handlersocket project into handlersocket directory.

Before you start

You need to apply some Debian patches and edit MySQL configure.in
$ cd mysql-dfsg-5.1-5.1.41
$ sudo dpatch apply-all

and in file configure.in you need to add a line
#([MySQL Server], 5.1.41)
Be sure you will add your MySQL version.

Compile handlersocket

Now you are ready to compile. $ cd ../handlersocket
$ ./configure --with-mysql-source=/path/to/mysql-dfsg-5.1-5.1.41 --with-mysql-bindir=/usr/bin/ --with-mysql-plugindir=/usr/lib/mysql/plugin/
$ make
$ sudo make install

if all wend goo you should see handlersocket.so in /usr/lib/mysql/plugin/ directory

Install handlersocket MySQL plugin

to run handlersocket you need to install MySQL plugin. Login as root to MySQL and execute following SQL query:
mysql> install plugin handlersocket soname 'handlersocket.so';
Query OK, 0 rows affected (0.05 sec)

To be sure you are have installed plugin you should check show processlist; If you saw a message about permission denied or so - you need to turn off apparmor while installing plugin.
$ sudo invoke-rc.d apparmor stop


Github project page

Thursday, September 16, 2010

Linux version of chromium-browser crash fix

After yesterdays update of chromium-browser from PPA repository my chromium won't start. I have tried that from command line and got segmentation fault while chromium was staring. Googling of this problem didn't solve that. But i found and article Chromium debugging and posted a bug on launchpad. In an hour Fabien replied that it's a known bug. In few hours user vthomasset has found a quick solution on how to solve that problem while developers will fix that in code.

You need to edit a file ~/.config/chromium/Default/Preferences with your favourite editor. And remove a line
"inspector_settings": "lastActivePanel:string:console\n".
So the lines in your config:

   "webkit": {
      "webprefs": {
         "inspector_settings": "lastActivePanel:string:console\n"

after changes will look like:

   "webkit": {
      "webprefs": {

Thursday, April 8, 2010

Blogspot jQuery gallery

Today i'm going to create one thing with blogger.

Want to make a gallery for blogger.

First of all i've reviewed text which was generated by Blogger when i insert images. And then few hours of coding made rough, but useful gallery for Blogger. Anyway, due to limitations of blogger itself code looks like an in&*an one. Later i will check checked where i can host all of the plugins i've used here, together with library for user-friendly usage. Now i'm going to make same easy thing for Picasa.


  • It's for blogger only
  • After editing a page you need to put your JS code again.
  • You need to know basics of HTML. If you want to order your photos.
  • You need to know CSS. If you want to style your gallery.
  • You need to search for "change 'medium' to x-small, small, large or x-large to enlarge image" comment in javascript to change size of image

For now you need to do the following:

  1. Make an empty post and add images there.
  2. Write all text. you want to have in your blog post.
  3. If you want captions like you see in example below you need to add "alt" property to the image or "title" property to link around image.
  4. Add this huge small code:


  • Biozshock.blogspotImages.render([thumb-size], [large-size], [yoxview-options]);
  • Image sizes:
  • YoxView documentation is here
  • If you want to style image previews, just override CSS file

Libraries used:

Do hard work! Eat a little chease Eat more grass Hm, I think it's too bog for me Oh, yeah, it's and eden!

Wednesday, March 3, 2010

Codeigniter Crontab Library

Recently i've wrote a library for CodeIgniter framework that handles crontab jobs of the project. This library is very simple, but it's designed to be so.

What does it do

This library sets up cron to perform tasks from crontab file. When crontab file is written with this library. Almost all you need is set up config/crontab.php file.


  1. Download library from github repository git://github.com/biozshock/crontab.git
  2. If you are familiar with phpunit you can test library. Tests are located in tests subdirectory
  3. Copy config/crontab.php and libraries/crontab.php
  4. Setup config/crontab.php
  5. Use this library

Crontab library config file

Path to cronfile library will write all jobs
Path to PHP executable
Crontab library default format for date() function
PHP cli scripts path
This config variable can be used when your server has different timezone from timezone of tasks you want to be cheduled. e.g. server is in -5 timezone. backend in +1 timezone. in backend you setting cronjob for 00:00:00, but for server this would be 14:00:00

Library usage examples

Simple usage

To execute cli script every day at midnight n your controller you should put following code:

$this->crontab->add_job('0 0 * * *', 'cli_script.php');

This code will execute cli_script.php located in directory you've set up in config file at 0 minutes 0 hour

Advanced usage

Assuming you have in your $_POST['time'] time when scheduled action should be performed.

$time = $this->crontab->translate_timestamp(strtotime($this->input->post('time')), 's i G * *');
$this->crontab->add_job($time, 'cli_script.php');

If you want to perform an action every day after user submit a data:

$time = $this->crontab->translate_timestamp(time(), 's i G * *');
$this->crontab->add_job($time, 'cli_script.php');


Please make sure:
  • your php exec is enabled
  • your server user has access to crontab
  • you know what you are doing
This script will REPLACE ALL crontab jobs for user under which your server is running.

Thursday, February 4, 2010

phpsh - Great tool for commandline PHP

Recently i've found great tool phpsh. It was developed by Facebook programmer Daniel <dancor> Corson. phpsh was written in Python for PHP (irony). It allow you to run PHP scripts in a shell. Yeah, you can say "Just install php5-cli and run php -a". When i have phpsh? No, thanks.

phpsh features i've been searching for:

  • php autocomplete of native and included functions and classes

  • php manual/description of native functions and classes

  • good exception handling (in php -a shell is exiting)

  • Color highlighting for output type

How to install phpsh on Ubuntu Karmic

First of all you need to have git and python installed:

sudo apt-get install git python python-setuptools

Next you need to fetch phpsh git repository on github:

git clone git://github.com/facebook/phpsh.git phpsh

Then build and install phpsh:

cd phpsh/
python2.6 setup.py build
sudo python2.6 setup.py install

During install procedure i've encountered a problem: setuptools was unable to get pysqlite, so i've installed those from Ubuntu repo:

sudo aptitude install python2.6-pysqlite2

and repeated step with install command

First look on phpsh

To see what i can do with phpsh i've used following simple code:

 * Classs for testing phpsh
 * @author bumz
class Test
  * Variable holds all set foos
  * @var array
 private $_foos = array();
  * General empty constructor
  * @return void
 public function __construct()
  * General getter
  * @param string $fooName
  * @return mixed
  * @throws Exception if foo isn't set
 public function __get($fooName)
  if (isset($this->_foos[$fooName])) {
   return $this->_foos[$fooName];
  } else {
   throw new Exception('This foo isn\'t set');
  * General setter
  * @param string $fooName
  * @param mixed $fooValue
  * @return void
 public function __set($fooName, $fooValue)
  $this->_foos[$fooName] = $fooValue;
  * General magic isset function
  * @param string $fooName
  * @return bool
 public function __isset($fooName)
  return isset($this->_foos[$fooName]);
  * General magic unset function
  * @param string $fooName
  * @return bool
  * @throws Exception every time as foo can't be unset
 public function __unset($fooName)
  throw new Exception('You can\'t unset foos');
  * Test of autocomplete
  * @return void
 public function autocomplete()
  echo 'autocomplete works';

first of all you need to load phpsh itself and load Test class:

phpsh> r '/home/bumz/workspace/test/testsh.php'

Then i've done few simple operations:

php> $class = new Test();

php> $class->foo1 = 'I\'m foo 1';

php> $class->foo2 = 'Foo 2 here';

php> echo $class->foo2;
Foo 2 here
php> echo isset($class->foo2);
php> unset($class->foo2);
Uncaught exception: Exception: You can't unset foos

php> $class->autocom
autocommit autocomplete
php> $class->autocomplete();

Now i know i will use this tool.

Friday, January 22, 2010

Firefox 3.6 released, and i want it on Ubuntu Karmic

As web develops very fast (and i take part into it :)), I prefer newest technologies on my workstation under Ubuntu. In Ubuntu main repositories there are no Firefox 3.6 yet, and i believe it will be available in Ubuntu Lucid. To add FF 3.6 to Ubuntu Karmic use

sudo add-apt-repository ppa:ubuntu-mozilla-daily/ppa
sudo apt-get update && sudo apt-get install firefox-3.6

After this you will then find Firefox 3.6 (Namoroka) under Applications > Internet > Namoroka Web Browser.

Wednesday, January 13, 2010

Audio output streaming on Ubuntu linux

Developers also have fun.

Usually developers who are listening to music listen it in their headphones, as not all people in office like music they are listening to. After couple of month all music on hard drive becomes annoying. And then internet radio becomes helpful. But if more and more programmers listen to radio through internet it would lag a lot. For web developers it's more annoying than music on HD. And they must listen to it. I have couple of co-workers who like to listen to one internet radio station. The big problem that it's going through Adobe Flash interface and i can't re-stream it. I've googled a lot to find how to broadcast audio stream through LAN. First option i've got is a PulseAudio Ubuntu native driver. But output on other machines was like on old cassette audio player. Music sometimes accelerates. So that was not a solution. Mix of other broadcasting tools does not help. And i remembered one of my classmates had broadcasted video through VLC.


To stream output channel you must have to install:


Also you need to set up PulseAudio to play through Jack. Please refer this manual
After you have setup PulseAudio to play through jack and checked it's working you need to start qjackctl and start server if you are didn't set to start it automatically. Then start VLC with command:

vlc -vvv 'jack://channels=2:ports=.*' --sout '#transcode{acodec=mp3,ab=128,channels=2,samplerate=44100}:std{access=http,mux=raw,dst=}'

Please note you need to set your IP address instead of
if you want vlc to start without an UI change vlc to cvlc

After this you can hear any audio on other machines by typing


Finally you can write shell script to load all in one shot without interfaces

pulseaudio -k
/usr/bin/jackd -t2000 -dalsa -dhw:0 -r48000 -p1024 -n2&
sleep 15
pulseaudio -DnF ~/.pulse/pulsejack.pa
cvlc -vvv 'jack://channels=2:ports=.*' --sout '#transcode{acodec=mp3,ab=128,channels=2,samplerate=44100}:std{access=http,mux=raw,dst=}' && pulseaudio -k && killall jackd; pulse-session

Please note you need to set your IP address instead of

Good music for you