Showing posts with label Tips. Show all posts
Showing posts with label Tips. Show all posts

Monday, October 18, 2010

Making great ER diagrams without drawing


This one will be short :-)

I needed to draw a decent looking Entity Relationship diagram for an academic assignment --BORING. This is the kind of thing that makes me wonder why I surrendered my soul to this degree hunting battle. Anyway, there are two utilities (Maybe more, who knows) that might help the candidate ER Michelangelo: Dia and kivio. Now, if you are into buttons and mousing that's all you should need; pick one, search for some online examples and you will be done in no time. Chances are your drawing will look like shit but then again, you'd be an artist you proly wouldn't be reading this anyway. Now, I'm not really into WYSIWYG so I searched a little more and discovered a life savior: The Tikz-er2 LaTeX package.

Not wanting to bore you more than what's strictly needed to communicate my joy, here is a complete example almost right from the documentation.



Neat isn't it?

Well, If you are still interested you should take a look at the
package documentation. It's quite short, just a few pages
long. For the time being and to aid your experiments here
is the LaTeX source for the above displayed diagram:

\documentclass[a4paper,10pt]{report}
\usepackage{ucs}
\usepackage[utf8]{inputenc}
\usepackage[spanish]{babel}
\usepackage{tikz-er2}

\usetikzlibrary{positioning}
\usetikzlibrary{shadows}

\tikzstyle{every entity} = [top color=white, bottom color=blue!30,
draw=blue!50!black!100, drop shadow]
\tikzstyle{every weak entity} = [drop shadow={shadow xshift=.7ex,
shadow yshift=-.7ex}]
\tikzstyle{every attribute} = [top color=white, bottom color=yellow!20,
draw=yellow, node distance=7em, drop shadow]
\tikzstyle{every relationship} = [top color=white, bottom color=red!20,
draw=red!50!black!100, drop shadow]
\tikzstyle{every isa} = [top color=white, bottom color=green!20,
draw=green!50!black!100, drop shadow]

\begin{document}
\begin{tikzpicture}[node distance=8em, every edge/.style={link}]
\node[entity] (persona) {Persona};
\node[attribute] (pid) [left of=persona] {\key{id\_persona}} edge (persona);
\node[attribute] (name) [below left of=persona] {nombre} edge (persona);
\node[multi attribute] (fono) [above of=persona] {fono} edge (persona);
\node[attribute] (anex) [right of=fono] {anexo} edge (fono);
\node[attribute] (number) [below left of=fono, node distance=5em] {number} edge (fono);
\node[attribute] (email) [above right of=persona] {email} edge (persona);
\node[relationship] (pertenece) [right of=persona] {Pertenece} edge node[auto,swap] {1:1} (persona);

\node[entity] (depto) [right of=pertenece] {Depto} edge node[auto,swap] {0:N} (pertenece);
\node[attribute] (iddepto) [above of=depto] {\key{id\_depto}} edge (depto);
\node[attribute] (dname) [above right of=depto] {d\_name} edge (depto);
\node[rectangle, draw=black, fit=(pertenece), inner sep=0em] (ipertenece) {};
\node[relationship] (tieneun) [below of=pertenece] {Ocupa} edge node[auto,swap] {1:1} (pertenece);

\node[entity] (cargo) [right of=tieneun] {Cargo} edge node[auto,swap] {0:N} (tieneun);
\node[attribute] (idcargo) [right of=cargo] {\key{id\_cargo}} edge (cargo);
\node[attribute] (cname) [above right of=cargo] {c\_name} edge (cargo);
\node[attribute] (plevel) [below right of=cargo] {nivel} edge (cargo);

\node[relationship] (responde) [below of=persona] {Responde} edge node[auto,swap] {1:N} (ipertenece);

\node[entity] (pregunta) [below of=tieneun] {Pregunta};
\node[attribute] (idpreg) [below of=pregunta] {\key{id\_preg}} edge (pregunta);
\node[attribute] (ptexto) [below right of=pregunta] {p\_texto} edge (pregunta);
\node[attribute] (pnumber) [right of=pregunta] {p\_numero} edge (pregunta);

\node[relationship] (tiene) [below of=responde] {Tiene} edge node[auto,swap] {1:N} (pregunta) edge node[auto,swap] {0:N} (responde);
\node[rectangle, draw=black, fit=(tiene), inner sep=0em] (itiene) {};

\node[entity] (alternativa) [left of=tiene] {Alternativa} edge node[auto,swap] {1:1} (tiene);
\node[attribute] (idalt) [above of=alternativa] {\key{id\_altern}} edge (alternativa);
\node[attribute] (atexto) [below of=alternativa] {a\_texto} edge (alternativa);
\node[attribute] (anumber) [below right of=alternativa] {a\_numero} edge (alternativa);
\end{tikzpicture}
\end{document}


Hope it helps.

Wednesday, March 11, 2009

Quick tip on transfering files from your phone to your gnome-ill computer

So, I just hate when things that are supposed to work
right out of the box just doesn't..., Anyway, 4 steps
recipe to get this working under debian/sid:

1.- Install gnome-bluetooth and bluez-gnome: (as root) apt-get install gnome-bluetooth bluez-gnome
2.- Run bluetooth-applet if its not running already: bluetooth-applet
3.- Make your adapter discoverable and connectable: Right click on bluetooth-applet, then preferences, then choose 'Visible and connectable for other devices' under 'Mode of operation'.
4.- run gnome-obex-server from the console, an small icon should pop up on your pannel.

Now do what you need to do on your phone to select and send your files.

Not saying this is the right way to do it but what the hell, this should get you going.

Wednesday, June 4, 2008

Quick tip on encoding video for your iriver E100


So you bought one of these players just to find out that

  • It supports just a subset of MPEG4 SP (strictly speaking it is NOT MPEG4 SP complaint).
  • The bundled movie converter, while based on MPlayer and FFmpeg does not work on Linux.

Let alone the blatant GPL violation (friends at MPlayer/FFmpeg fame says a team of assassins was already dispatched iriver's way. Rumor has it includes members of the Project From Hell age -- you have been warned).

I thought about quickly drafting a better and cross plataform movie converter but then realized I should maybe give you a working encoding recipe first (not to mention I have a lot on my TODO already), so, here it is:

  • Install MPlayer. If the one you installed has support for XviD in mencoder you are golden, otherwise you might have to build and install a custom one (If you use debian and maybe in ubuntu too, installing libxvidcore4-dev before building MPlayer from svn should be enough).

  • Proceed to encode your video with this cmd line:

    mencoder INFILE.SOMETHING -vf scale=320,expand=320:240 -oac mp3lame -lameopts abr=128 -ovc xvid -xvidencopts bitrate=600:max_bframes=0:vhq=4 -of avi -o OUTFILE.AVI


Of course you can customize this, specially the -vf part. I myself have to try other codecs yet.

Special thanks go to Robert Swain who helped figuring this
out yesterday. The dude has a lot of talent encoding with constrained/crippled neat gadgets as targets. Go read his blog and send him my regards.



Shame on you Iriver..., Shame on you.