Skip to content

Tag: Linux

Miojo Script

O pre-requisito é o notify-send, um utilitário de linha de comando do libnotify. No Ubuntu:

sudo aptitude install libnotify-bin

E aqui o script em si:

sleep 5m; notify-send "aviso" "tirar o miojo do fogo"

Pronto, depois de cinco minutos isso vai aparecer:

Congelando e Ressuscitando Processos

batman mr freeze

Nem só de morte vive o kill.

Suponha que você tem um processo chamado program e quer congelar seu funcionamento. Para congela-lo sem mata-lo você pode mandar um sinal SIGSTOP com:

kill -s stop `pidof program`

Para ressuscitar o mesmo processo:

kill -s cont `pidof program`

Twitter Bot @rudaufc versão 1

robô

Este aqui é um bot bem simples para Twitter.

Diariamente, as nove da manhã ele posta qual vai ser o cardápio do RU (Restaurante Universitário) da UFC naquele dia.

Assim, quando vai batendo a hora da fome, os alunos podem entrar no perfil @rudaufc e olhar qual vai ser o prato do dia, ou quem está seguindo ele no Twitter pode ter a agradável surpresa de ver todo dia o que vai ser servido hoje.

Aqui está o código fonte do arquivo rudaufc.sh:

#!/bin/sh
# Twitter bot @rudaufc
login="rudaufc"
senha="suasenhaaqui"
 
segunda="Picadinho com legumes ou bife na chapa. Salada de macarrão com cenoura. Arroz. Feijão com abóbora e batata doce."
terca="Franco guisado ou coxas de frango ao forno . Salada de acelga, cenoura e passas. Arroz. Feijão com abóbora e batata doce."
quarta="# Feijoada à moda RU ou bisteca . Salada de repolho branco, cenoura e abacaxi. Arroz. Feijão com abóbora e batata doce"
quinta="Frango à passarinho ou frango chinês. Salada de Alface, Tomate e Cebola. Arroz. Feijão com abóbora e batata doce."
sexta="# Isca ao molho ou maravilha de carne. Salada de acelga com cenoura. Arroz. Feijão com abóbora e batata doce."
 
dia=`(date +%w)`
log=`(date +%Y-%m-%d-%s)`"-$$.log"
dir="/home/silveiraneto/rudaufc"
msg=""
case "$dia" in
#	"0") msg=$domingo ;;
	"1") msg=$segunda ;;
	"2") msg=$terca ;;
	"3") msg=$quarta ;;
	"4") msg=$quinta ;;
	"5") msg=$sexta ;;
#	"6") msg=$sabado ;;
esac
 
curl -u $login:$senha -d status="$msg" http://twitter.com/statuses/update.xml > $dir/$log

A mágica toda está na capacidade do Curl de acessar facilmente a API do Twitter para enviar mensagens.

Para que o script execute diariamente as nove da manhã ele está alocado em um servidor com a crontab configurada da seguinte maneira:

0 5 * * *  . /caminho_para_onde_ele_esta/rudaufc.sh

ps: leve em conta que o servidor está em um fuso horário diferente do Brasil.

Nessa versão o prato de cada dia está hardcoded no script, o que não é o ideal e faz com que semanalmente eu tenha que atualizar o script inserindo os pratos da semana manualmente. Eu espero que a próxima versão seja capaz de descobrir esses pratos e se atualizar sem nenhuma interferência.

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.