Skip to content

Tag: Linux

The Fork Bomb Tattoo

I thought about these two problems my entire life.

Graphical arts have a significant role in everything I do. I always expressed my feelings thorough graphical drawings. First on paper, so notebooks, then walls and others surfaces like the computer screen. But the possibility of transform my body, my own skin in a art canvas always fascinated me. This was a natural step.

But the tattoo is an art that raises a tricky philosophical question, it’s something that you can not undo it. Once you did it, it’s done. You can change or add the meaning with others tattoos but you can not remove meaning of a draw in a negative way by erasing it like other forms of arts. Of course there’s some kinds of treatments with different approaches and variant results but I see no point on think about tattoos looking on how remove them. It seems obvious that doesn’t matter how cool and incredible something could appear or how sure I am about it, I could always change my mind and repent. This puzzle was around my mind for a long time until finally I saw way out.

The key is that the life you live itself is also a tattoo. You say words that cannot be unsaid. You see things that you can not unseen.You feel such strong emotions that you can not heal your scars. Every moment it’s also a tattoo in the thin skin of the time and there’s nothing you can do about that because the time flows only in one direction. Of course you don’t paint all your life with ink in your own skin but at least, you can choose some parts of it to express as a beautiful tattoo.

The second problem is witch draw do. There are hundred of drawings that I love and besides I also enjoy old school tattoo drawings, I choose a piece of programming code. More specifically the Jaromil most elegant forkbomb code ever written:

forkbomb_small

This small piece of code fork itself twice in parallel creating more processes that will be forked again and again until stop the entire system. You can read a more detailed explanation on its operation, history and variations on Wikipedia’s Fork bomb article.

It has several meanings to me, from the aesthetics from the computer science field to the shape and possibilities the draw allow. The exponential grow of the number of forked process it’s also another beautiful aspect of this code. From the viewer perspective, even a casual one, it has a beautiful as a puzzle to be decipher or a totem pole of different emoticons.

Blood and ink.

I tried for months several different fonts and styles to use on it, from mono space to stylized draws. In the end I choose the Bitstream Vera Sans by Jim Lyles. A free (as in freedom) font very common on GNU/Linux systems. I also did small change in the draw by reducing almost entirely the spacing between the braces. This made it look better when looking it by side creating a stronger emoticon illusion.

Blood stain

Blood stain in the paper towel after dry the finished tattoo.

The process almost doesn’t involve pain and hurt, in contrast with what I thought. It’s like a little cat scratch in your arm for almost 2 hours of painting. I did in the Freedom of Tattoo studio, from the well-known here tattoo artist Dereka, with Thiago, a very skilled artist.

My thanks to the studio, to Dereka, to Thiago and to my friend Silvio who took the pictures and accompanied me. There’s a photo album with all tattoo photos. I’m very happy with the final work.

JavaFX on Linux!

Yeah. No more workarounds. Download now JavaFX 1.2 for Windows, MacOS X, Linux and OpenSolaris!

bob sponja dancinha

\o/

There’s also a lots of improvements in the language and the API. For details on that read this document. Unfortunately, as a side effect of those great changes some JavaFX source codes posted here are now deprecated and need a few changes to compile again but the online preview of them as applet or Java Web Start will continue to work well.

Let’s code.

OGG com qualidade

Para o controle de qualidade quando encondando vídeos com o FFmpeg use o parâmetro -qscale seguido de um número. Os número podem ir de 1 (melhor qualidade) até 31 (pior qualidade), sendo que 13 já é uma qualidade bem ruim.

Convertendo pro exemplo um vídeo chamado exemplo.flv para um arquivo ogg com a melhor qualidade seria:

ffmpeg -i exemplo.flv -qscale 1 saida.ogg

Sem usar esse parâmetro os arquivos encodados em OGG ficam com uma qualidade mediana. Uma opção bem útil é usar a mesma qualidade do arquivo de entrada, já que não é possível melhorar a qualidade do vídeo mesmo. Para isso existe o parâmetro -sameq. No exemplo anterior bastaria:

ffmpeg -i exemplo.flv -sameq saida.ogg

Com isso eu tenho reduzido os vídeos da minha câmera para arquivos que só ocupam cerca de 1/5 do tamanho original e ainda assim mantém a mesma qualidade.

Arduino on Ubuntu

Arduinos

My Arduinos arrived yesterday. It’s a programmable open source and hardware device.

To install its software on my Ubuntu 8.10 I need Java installed and some tools that I could get by:

sudo apt-get install avrdude avrdude-doc avrp avrprog binutils-avr gcc-avr

Camera nova e fazendo ela trabalhar bem com o Cinelerra

A um tempo atrás eu comprei uma câmera nova pra mim.

Como eu não quero posso comprar uma câmera boa mesmo agora eu preferi comprar uma bem barata que fizesse o básico. Uma câmera de preço médio iria ter poucas funções e eu iria ficar pensando —  se eu tivesse comprado aquela outra. Além disso uma câmera custa um pouco mais trás também um maior zelo e o meu zelo é muito limitado e eu já gasto com outras coisas. Ou seja, cheguei a conclusão que pra mim o ideal seria uma câmera barata que pudesse estar absolutamente sempre comigo, esteja eu a pé, de ônibus ou de carro. Assim eu posso tirar muitas, muitas fotos, já que o meu fim principal pra ela é a documentação de eventos e atividades e não um trabalho artístico.

oregon scientific

Dentro disso e uma certa urgência em voltar a tirar fotos (Campus Party de 2009 chegando) eu comprei nas Americanas (a loja mesmo, não a ponto-com) uma Oregon Scientific (nome estranho) de 5.0 Megapixels com um cartão de 1Gb, por R$ 200.  Ela é bem básica pra fotos já que não tem zoom optico e não se dá bem com movimentos mas a qualidade da gravação dos vídeos, inclusive com aúdio me surpreendeu.

laboratório de metareciclagem
Uma típica foto com ela. Essa em um telecentro da Casa Brasil.

#cparty
Um macro de um robô do ITA durante o Campus Party

Erámos felizes até eu começar a fazer meus primeiros experimentos com os vídeos dela com o Cinelerra (software que eu ainda engatinho).

O vídeo tudo bem mas o aúdio dos vídeos dela (uns arquivos AVI com vídeo codificado e áudio cru) ficavam bichados no Cinelerra mas tocavam bem no Mplayer ou outros tocadores. Como o vídeo estava legal eu só precisava extrair os audios por fora que aí eu podia colocar eles como uma trilha de aúdio do Cinelerra e problema resolvido. O problema é que sempre que eu ia extrair esse aúdio dava algum problema. A solução veio em uma thread da lista de usuários do Mencoder usando a dupla Mplayer e Sox:

mplayer -vc null -vo null -ao pcm video_da_camera.AVI
sox audiodump.wav -i -b -r 48000 -c 2 audio_do_video.wav

No caso eu estou usando a taxa de amostragem em 48kHz e dois canais de áudio (stereo) para ficar compatível com outros formatos que eu estou usando no Cinelerra.

Pronto, voltamos a ser felizes juntos, eu, a câmera e o Cinelerra.

Cromakey no Cinelerra

cinelerra editando

Continuo minha epopéia para desvendar os segredos das complexas interfaces do Cinelerra. Dessa vez aprendi a usar o cromakey usando uma filmagem minha mesmo contra uma parede azul.

Os dois monitores ajudam muito. Essa máquina aqui é uma das máquinas que eu usei para editar. É uma das duas máquinas de edição multimídia na unidade da Casa Brasil do Vila União.

Cinelerra

O resultado. Ainda falta muito pra chegar no nível de excelência do cromakey do Chapolin mas a gente chega lá.

A imagem de fundo é de 1888 por James Valentine, vinda da Galeria Nacional da Escócia no Commons. O som é de um trecho da música La mort de Chloé por Xcyril.

Logo que eu tiver um maior domínio da técnica eu faço um tutorial explicando o procedimento. 😉

JavaFX SDK 1.0 on Linux

JavaFX 1.0 is out and is absolutely amazing. You guys did really a great work on it.

As I really need a working SDK on Linux to continue to study and I don’t have any Windows/Mac near me, I’m using the Weiqi Gao’s workaround. I tried to simplify a little bit more the process for those who need JavaFX SDK working on Linux right now.

Download javafxsdk_linux_unofficial.tar.bz2 (~18Mb).

And then

tar -xjvf javafxsdk_linux_unofficial.tar.bz2
sudo cp javafx /opt/javafx
echo “PATH=\$PATH:/opt/javafx/bin” >> ~/.profile
echo “JAVAFX_HOME=/opt/javafx” >> ~/.profile
source ~/.profile

Now you can call javafx, javafxc, javafxdoc and javafxpackager from your terminal. Don’t forget that you need Java 1.6 or greater installed.

Here’s a video showing the SDK working, I’m compiling and running two sample applications. Remeber that as a temporary unofficial port for Linux, there’s not native video support nor hardware acceleration.

[youtube]ENf5mXEIiD8[/youtube]

Short urls with Glassfish+MySQL


Pipes, Creative Commons photo by flattop341.

1. The Problem

Internet is full of long urls and meaningless.

Long urls are difficult to remember or print, usually full of redundancy and low semantic. With short and meaningful urls you can avoid thes problems and even achieve profitable goals with SEO
SEO (search engine optimization) technics.

There are services like Tiny URL, Fancy URL, Moo URL and others. Although they solve part of the problems, they bring several others. Another problem is if you have a web site like example.com and use a third-party service for short urls you are losing part of your mind-share with your users and clients.

As an example, if a example.com company wants to promote a open work position would be preferable spread a example.com/jobs instead of a tinyurl.com/examplejobs, or even worst, a tinyurl.com/3i4i592 (meaningless hash).

2. Solution Approach

I created a little program called xort that can be placed on your own server and provide you own short maintening your base url.

I use a pipe abstraction. Each pipe redirects from a key url to an output url.

The idea is that you have xort installed and associated into your domain (preferably on /x). A pipe inside example.com would be like example.com/x/jobs.

3. Tools

All those tools are multi platform, open source and free.

3.1 Glassfish Application Server

Glassfish is an open source application server project led by Sun Microsystems for the Java Enterprise Edition (Java EE) platform. It’s very easy to install and run and have a very nice administration web interface where you can do from simple tasks like deploy a application to more complexes like clustering.


Glassfish Admin Console

To develop the application I’m using NetBeans 6.5 Beta that comes with Glassfish V3 prelude b15b. Netbeans also provides a integration of project, database and web server.

Nevertheless, Glassfish has no dependencies with any IDE and perfectly works by alone. If you need I wrote this post explaining how to install and deploy a application on Glassfish from scratch.

3.2 MySQL Relational Database

MySQL is a relational database management system and probably the most used database on internet (has more than 11 million installations). It’s also very easy to install and administer, through command line or many gui interfaces.

To install MySQL and JDBC driver on Ubuntu just run as root:

# apt-get install mysql-server libmysql-java

After installing and configuring it you can test the jdbc driver throught this servlet code. You can optionally register the MySQL on NetBeans to have a easier access to it thought the service tab.

At the command line you can invoke mysql command line interface and use MySql commands or SQL queries. I’ll login and create a database called xort:

$ mysql -u username -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 13
Server version: 5.0.51a-3ubuntu5.3 (Ubuntu)

Type ‘help;’ or ‘\h’ for help. Type ‘\c’ to clear the buffer.

mysql> create database xort;
Query OK, 1 row affected (0.06 sec)

You could also create this database by an SQL statement:

CREATE DATABASE xort;

To select the database xort:

mysql> use xort;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed
mysql>

Now we create a database called pipes with fields pin (pipe in) and pout (pipe out). They represent the input url and the output url of our pipe abstraction.

CREATE TABLE pipes (
   pin varchar(255) NOT NULL,
   pout varchar(255)
);

As we expect a lot of searches queries on this table, we can optionally create a index for it on pin field. This can reduce ours searches from O(n) to O(logn) (because pin’s will be ordered so don’t need to look all pipes, we can use logn algorithms like binary search).

CREATE INDEX pinindex ON pipes (pin);

Another trick to improve our speed is recycling connections through connection pools.

Creating a pool of MySQL connections on Glassfish is very easy. There’re two good tutorials on this subject:

And now we populate the database with some initial pipes.

INSERT INTO pipes VALUES ('blog','http://silveiraneto.net');
INSERT INTO pipes VALUES ('cejug','http://cejug.org/display/cejug/Home');
INSERT INTO pipes VALUES ('orkut','http://www.orkut.com.br/Main#Profile.aspx?rl=ls&uid=12443310329436634134');
INSERT INTO pipes VALUES ('glassfish','http://glassfish.dev.java.net');
INSERT INTO pipes VALUES ('mysql','http://dev.mysql.org');
INSERT INTO pipes VALUES ('twitter','http://twitter.com/silveira');
INSERT INTO pipes VALUES ('lab', 'http://maps.google.com/maps?f=q&geocode=&q=campus+do+pici&g=Fortaleza,+Brazil&ie=UTF8&t=h&ll=-3.745978,-38.574023&spn=0.002452,0.004823&z=18');
INSERT INTO pipes VALUES ('videos', 'http://br.youtube.com/user/NetoSilveira');
INSERT INTO pipes VALUES ('photos', 'http://flickr.com/photos/silveiraneto/');

4. Program

Basically we have just a program that implement this simple behavior:

  1. separate the key from the url.
  2. if the key is a pin from a pipe then redirect to that pout.
  3. else provide a way to create a new pipe.
  4. list all pipes.
  5. provide a way to remove a pipe.

To get the key we need to separate the proper part of the request uri:

String uri = request.getRequestURI();
String key = uri.substring(request.getContextPath().length()+1);

After that we check if it matches with a pin of some pipe. In this case we redirect user for the correspondent pout:

response.sendRedirect(pout);

Notice that using this approach we can connect a url to a extern or intern url (even to another pipe).

5. Download

Check out the xort project and sources at xort.dev.java.net:

Or grab sources and the current build with:

svn checkout https://xort.dev.java.net/svn/xort/trunk xort

Parameters can be passed by the the web.xml file:

   Set if users can add new pipes using the web interface.
allowNewPipes
true

   JDBC driver to use
driver
com.mysql.jdbc.Driver

   Username to login on the database.
username
root

   Password for the given username.
password
yourpassword

   JDBC path to database.
database
jdbc:mysql://localhost:3306/xort

Xort up and running:

[youtube]b2Mrk8XfvKk[/youtube]