Apr 30 2009

Adding a codebox to your wordpress

Éverton Arruda

Adding a codebox to your wordpress blog is really simple, all you have to do is download the one you want, upload it to wp-content/plugins directory in your blog, then you’ll have to access the admin page of your blog and activate it in the plugins section. Just as any other plugin.

I recommend CodeColorer plugin, the one i use here in my blog. CodeColorer is developed by Dmytro Shteflyuk, you can find it at it’s homepage: http://kpumuk.info/projects/wordpress-plugins/codecolorer. This plugins supports more than 100 languages.

After some customizations, my codebox is like this:

1
2
3
4
5
6
7
#include <stdio.h>
/* Hello World in C */
int main()
{
    printf("Hello World!\n");
    return 0;
}

If you want to look for other highlight plugins you can find more at http://wordpress.org/extend/plugins/search.php?q=code+highlight.

:wq


Apr 24 2009

Linux Counter – Get counted too

Éverton Arruda
Linux Counter

Linux Counter

Surfing the web i found this project which intends to count linux users and computers running linux. Maybe you have already seen someone using “Linux User #1234567″ in his/her forum/e-mail signature, this is exactly what this project does, it counts you (if you register yourself) as a linux user.

The site shows some statistics about linux users and computers running linux, but it specifies that those statistics are not completely real, because there are many linux users not registered.

I got counted, and i’m

Linux User #489240

Linux User #489240

Get counted too!

Project Site: http://counter.li.org


Apr 16 2009

Autocompletion on VIM

Éverton Arruda

Some time ago i read, in Renato Carvalho’s Blog (http://www.renatocarvalho.net/autocompletando-no-vim-dicionario-php.html), a post about autocompletion on VIM.

Autocompletion is a method which consists of completing a word when you write part of it, for example you write lin and press a key, on the keyboard, which is programmed to execute the autocompletion and it completes the word for you, giving you linux. For me it’s very useful.

If you want it too, all you have to do is:

1 – Create plugin and doc directories in ~/.vim:

1
$ mkdir -p ~/.vim/doc ~/.vim/plugin

2 – Download and install SuperTab plugin for VIM:

This plugin enables <tab> to be used for completion.
SuperTab Link:  http://www.vim.org/scripts/script.php?script_id=1643

3 – Download functions list of a language and save it to ~/.vim/doc:

Using google you should be able to find the function list of a language.
For this tutorial i’ll use a PHP functions list, you can get it at: http://lerdorf.com/funclist.txt, save this file in ~/.vim/doc as php-funclist.txt

4 – Add a few lines inside /etc/vim/vimrc:

Edit /etc/vim/vimrc and add the following lines:

1
2
3
if has("autocmd")
    autocmd FileType php  set complete-=k/home/$USER/.vim/doc/php-funclist.txt complete+=k/home/$USER/.vim/doc/php-funclist.txt
endif

These lines tell VIM to read the php-funclist.txt file and load it for autocompletion.

You could use another language functions list, all you have to do is change the name of the functions list file from the lines above.

Now you can test it, open vim and write part of a php function, then press the <tab> key and see what happens.

This tutorial was written by Rodrigo Carvalho, i made some modifications and, with his permission, i posted here.


Apr 15 2009

Creating a simple repository for .deb packages

Éverton Arruda

A few days ago i had to create an internal repository for some deb packages. As there weren’t so many packages, i didn’t need to create a huge repository, like the official ones, so, after a little research, i managed to get it working, and that is what i will explain here, how to create a simple repository for deb packages.

We’ll need this packages before we can continue:
- apt-utils
- dpkg-dev
In debian-like systems you can install it by executing:

1
# aptitude install apt-utils dpkg-dev

And now the steps:

1 – Select the directory in which the repository will be:
I recommend you to use a direcotory in /var/www , like /var/www/repository, making it possible for everyone to see and access it without the need change apache configurations, but for this you’ll have to have apache installed.

For this tutorial we will take /var/www/repository as our repository directory.

1
# mkdir /var/www/repository

2 – Move packages to the repository directory:
Move all deb packages you want to be in the repository to the repository directory, in our case: /var/www/repository.

1
# mv *.deb /var/www/repository

3 – Create index files (Packages and Sources):
These files tell apt wich packages are available in the repository, their version, author and other informations. These files must be in the repository directory.

To create them you’ll have to run:

1
2
3
4
# dpkg-scanpackages /var/www/repository > /var/www/repository/Packages
# dpkg-scansources /var/www/repository > /var/www/repository/Sources
# dpkg-scanpackages /var/www/repository /dev/null | gzip -9c > /var/www/repository/Packages.gz
# dpkg-scansources /var/www/repository /dev/null | gzip -9c > /var/www/repository/Sources.gz

What there command do:
The first two commands scan the given directory for, repectively, .deb files and .dsc files and save their informations in, respectively, Packages and Sources.
The two last commands do the same thing, but instead of saving the files’ informations in a text file, it compresses the files’ informations and save it to a .gz file, which apt will also look for.
For more information about these commands check manpages for each one.

4 – Add repository uri to /var/apt/sources.list:
Now that you have a repository running you’ll, probably, want to access it, right?! To do that you’ll have to edit /etc/apt/sources.list .
If you want to access the repository from the same machine you’ll need to add the following lines:

1
2
3
4
# For binary files repository:
deb file:///var/www/ repository/
# For source files repository:
deb-src file:///var/www/ repository/

If you want other machines to access it you’ll have to have those machines in the same network and add the following lines in their /var/apt/sources.list file:

1
2
3
4
# For binary files repository:
deb http://repository's.machine.ip/ repository/
# For source files repository:
deb-src http://repository's.machine.ip/ repository/

5 – Check if the repository is up:
Now run:

1
# aptitude update

and see if everything is ok.

And that’s it, you should have your repository running.

TIP:
You can make a script to automatize the creation of index files, all you have to do is create a script in the /usr/bin/ directory and add the command lines for the dpkg-scanpackages and  dpkg-scansources commands:

1
2
3
4
5
6
7
# cd /usr/bin
# echo "#!/bin/bash \
dpkg-scanpackages . /dev/null | gzip -9c > Packages.gz \
dpkg-scansources . /dev/null | gzip -9c > Sources.gz  \
dpkg-scanpackages . > Packages \
dpkg-scansources . > Sources" > createrepo
# chmod +x createrepo

The script above will scan for packages and source files in the directory it’s going to be executed and you’ll have to run it as root, you could add ‘sudo’ before each dpkg-scan command so you could run it as a normal user, but it would ask you for the sudo password as well.

This tutorial was based on:
- http://ubuntuforums.org/showthread.php?t=42862
- http://www.debian.org/doc/manuals/repository-howto/repository-howto.en.html

:wq!


Apr 13 2009

Hello world!

Éverton Arruda

Finally, my own domain!

http://www.earruda.eti.br, or simply earruda.eti.br.

A good first (not so first) post will be comming soon.