Thursday, April 21, 2011

How to generate symfony 2 documentation

Symfony 2 is a PHP 5.3 Framework by Sensiolabs. As it's still in development stage and I want to be able to read about newest features, especially from other branches of documentation. I fall in doubt how to read an .rst docs. First what i found was a python-docutils. But it's utility rst2html converts only one rst file! Then I found that Fabien uses sphinx to generate docs.

Preparations

First of all you need to have git installed. I will use Ubuntu installation in this example. But I think everything should be almost same on other Linux.

git clone https://github.com/symfony/symfony-docs.git
git clone https://github.com/fabpot/sphinx-php.git

First line will clone a Symfony 2 documentation and second one will clone an extension for viewing different code snippets. You can use sphinx-builder as is. But you will not see some parts. Next you need a python-setuptools installed:

sudo apt-get install python-setuptools
sudo easy_install -U Sphinx

Second command will install Sphinx (sphinx-build, sphinx-quickstart and sphinx-autogen). You can use a default Ubuntu shinx-build but I found it's outdated.

Let's build it!

Now all is ready. Let's do it. Prepare to answer questions about how you want to have all documentation built. To just read documentation you can answer all questions as their defaults.

cd symfony-docs
cp index.rst index_.rst
sphinx-quickstart

You need to copy index.rst, as program assumes you are just starting with documentation.
After you have answered all questions you need to copy back an index.rst

mv index_.rst index.rst

Now you need to add an extension from sphinx-php repository. Just open config.py with your favorite editor and add after code import sys, os:

sys.path.append(os.path.abspath('../sphinx-php'))

And add extension to extensions hash:

#was before
extensions = ['sphinx.ext.autodoc', 'sphinx.ext.intersphinx', 'sphinx.ext.pngmath']
#after
extensions = ['sphinx.ext.autodoc', 'sphinx.ext.intersphinx', 'sphinx.ext.pngmath', 'configurationblock']

If you have selected to make a Makefile you are ready to go with building a doc with.

make html

This will generate a doc in _build/html/index.html If you choose not to make a Makefile:

sphinx-build -b html ./ ./_build/html

That's it!

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

References

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.

Limitations:

  • 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:

Configuration:

  • Biozshock.blogspotImages.render([thumb-size], [large-size], [yoxview-options]);
  • Image sizes:
    x-small
    small
    medium
    large
    x-large
  • 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!