Monday, January 17, 2011

getting Skype to work on opensuse as a user

Skype is still only provided as a 32 bit binary and that is rather upsetting, because opensuse doesn't ship libXv as a 32 bit build by default. So if it fails because of that install xorg-x11-libXv-32bit (and any other stuff it wants).

If however you aren't root, then you are a little on your own. I got it working with the following
  1. Grab a 32 bit libXv from somwehere, e.g. here
  2. Unpack it. In my case like this: rpm2cpio xorg-x11-libXv-32bit-7.5-1.8.x86_64.rpm | cpio -idmv
  3. Now push that libXv.so.1 some place sensible (I recommend ~/.local/lib)
  4. Export LD_LIBRARY_PATH="$HOME/.local/lib/" or appropriate
  5. Start skype from within the reach of that export e.g. the same shell
Steps 4 and 5 have to be redone every time, so you might as well make a script out of it
All of this can be automated of course and is just a pointer for poor souls like me that take longer than 10 minutes to figure this out.

Thursday, January 13, 2011

Tex Font Catalogue

This is a most excellent find:

http://www.tug.dk/FontCatalogue/

Saturday, January 8, 2011

Latex Wrapperclass

When you define a new class in latex you most unlikely want to start from scratch. This is of course not a problem, you can easily inherit another documentclass. Problems tend to start if you also need to react on an option of the class as well. The example shows the easiest way i know of:

\NeedsTeXFormat{LaTeX2e} 
\ProvidesClass{myartcl}[2010/01/06 This is so 2010!]
\RequirePackage[unknownkeysallowed]{keyval} 
%set up the function for finding doublesided as an argument 
\define@key{keygroup}{doublesided}[true]{% 
  % Do whatever you need to here 
  \PackageWarning{myartcl}{Found doublesided #1}% 
} 
% and we pass it on to the keyval parsing algo 
\DeclareOption*{% 
  \edef\act{\noexpand\setkeys{keygroup}{\CurrentOption}}\act% 
  \PassOptionsToClass{\CurrentOption}{article}% 
} 
\ProcessOptions\relax 
\LoadClass{article} 

Saturday, January 1, 2011

Optional Arguments in Latex Functions, Style and Class Files

I just wrote my first own latex package and as usual i was rather aiming for the stars than KISS.
The last big issue was finding out how to have optional package arguments that take a value (think geometry's left).

First: 
How to have functions with more than one optional argument or named optional arguments: Turns out not to be too complicated in the end. First you need the package keyval which enables you to parse key=value style arguments and then you need to understand how it works (the doc is aweful imho). Set up your parsing functions with something like

\define@key{keygroup}{keyname}{\dostuff{#1}}

this defines an option keyname that takes an argument, that has to be provided if the key is used.
Example: 
\define@key{keygroup}{color}{\domorestuff{#1}}

You can also define an optional argument that has an optional value that gets used when none is provided with the following syntax

\define@key{keygroup}{keyname}[default]{\dostuff{#1}}

 This lets you for example define a length type argument like follows:

\define@key{head}{width}[\textwidth]{\def\@bannerwidth{#1}}

This would set \@bannerwidth to 5cm for width=5cm and to the width of the text otherwise.
 Now to parse an optionstring you need to pass it to \setkeys like this:

\setkeys{keygroup}{optstring}

So now in order to have a command with more than one optional argument (beware syntax is different though!)

\newcommand{\printbanner}[2][]{
    \setkeys{keygroup}{#1} 
    ....
}
and call it like so: 

\printbanner[width=18cm,color = red]{Other Arg}
 
Second:
I think keyval was written with functions in mind but that shan't stop us from abusing it for package options. Declare all your options that don't need keyval syntax first (it's easier than going through keyval). Afterwards set up the catchall handler with 

\DeclareOption*{\edef\@act{\noexpand\setkeys{keygroup}{\CurrentOption}}\@act}

The reason you need this is so you can delay the expansion of the arguments. This should be enough so you can 

\includepackage[width=18cm]{package}

Further Notes:
If you want a switch case like option have a look at the package ifthen.
A complete, minimal, working example is available here.

Friday, December 31, 2010

Auberginen, Radiccio, Weißwein sauce

Was:
2 kleine Auberginen
1 Kopf Radiccio
1 mittelgroße Zwiebel feingeschnitten
2-3 Knoblauchzehen
4 gehackte Tomaten
Ziegenweichkäse (Alter nach Vorliebe, frischkäse geht auch ist aber etwas fader)
ein wenig Brühe
\frac{1}{8}l Weißwein (nach Belieben, mir beliebt trocken)
Olivenöl
(roten) Pfeffer
1 Handvoll gehacktes (frisches) Basilikum
Thymian
Dazu: Pasta oder Gnocchi

Wie:
Auberginen halbieren und dann orthogonal dazu in relativ dünne (4mm) Scheiben schneiden. Mit Salz bestreuen und eine Weile weinen lassen (halbe Stunde wäre gut ich bin dafür meist zu ungeduldig. Auberginen mit Olivenöl grillen (oder braten) bis sie zart sind (2-4 min pro Seite je nach Hitze). Radiccio ebenfalls erhitzen bis er welk wird (1-2 min pro seite).
 Ein wenig Öl in einer ausreichend großen Pfanne erhitzen, Zwiebeln und Knoblauch zugeben zwei Minuten erhitzen, Thymian und Petersilie zugeben und rühren bis Zwiebel weich und glasig ist.
Nun Thomaten, Brühe, Weißwein, Pfeffer und Basilikum zugeben und ein paar Minuten simmern lassen.
Auberginen und Radiccio zugeben und abschmecken.
Pasta/Gnocchi in Teller füllen mit Sauce bedecken und zerkrümelten Ziegenkäse darüber streuen. Als Deko eignet sich das obligatorische Blättchen Basilikum.

Warum:
Lecker

Vegetarische Quiche

Ein simples Rezept, das ich sehr schätze:

Teig:
200g Mehl
100g Butter
1 Prise Salz
bis zu 50 ml Wasser
Butter kneten (Küchenmaschine empfiehlt sich), Mehl und Salz einbauen und kneten bis keine Klümpchen mehr existieren, Wasser dazu, kneten und kaltstellen.
In eine (gefettete) Backform packen, mit der Gabel ein Paar Mal einstechen und bei auf 170 Grad vorgeheiztem Backofen etwa 15 min vorbacken.

Füllung:
2 Spitzpaprika
1 Stange Lauch
1 Zwiebel
1 Zehe Knoblauch
 [Chili|Muskat|Paprika], Salz, Pfeffer je nach Vorlieben
Zwiebel und Knoblauch in Fett (Butter,öl) erhitzen, Lauch dazu. Wenns einigermaßen glasig aussieht Paprika dazu. Nach ein, zwei Minuten würzen, fertig! Wein würde sich sicher auch gut darin machen. 
Anschließen in die Form mit dem vorgebackenen Teig füllen.  

Überbackung:
150g Gry\'ere
1 Becher saure Sahne
Zusammen rühren über die Füllung verstreichen und alles in den Backofen bei 170Grad und backen bis es lecker aussieht (15 min?) 

Monday, November 8, 2010

MacOS and package management

This is priceless:

The following 240 additional packages will be installed: a52dec a52dec-dev a52dec-shlibs amrnb amrnb-dev amrnb-shlibs atk1 atk1-shlibs audiofile audiofile-bin audiofile-shlibs autoconf autoconf2.6 automake1.11 automake1.9 avahi avahi-dev bison cairo cairo-shlibs cloog cloog-shlibs compress-raw-bzip2-pm5100 compress-raw-zlib-pm5100 crypt-ssleay-pm5100 daemonic db48-aes db48-aes-shlibs dbus dbus1.3-dev dbus1.3-shlibs docbook-dsssl-nwalsh docbook-dtd docbook-utils docbook-xsl doxygen elinks encode-pm5100 esound esound-bin esound-common esound-shlibs faac faac-dev faac-shlibs faad ffmpeg-dev fftw3 fftw3-shlibs fink-package-precedence fontconfig-config fontconfig2-dev fontconfig2-shlibs freeglut freeglut-shlibs freetype219 freetype219-shlibs gawk gcc45 gcc45-compiler gcc45-shlibs gd2 gd2-shlibs getoptbin gettext gettext-dev ghostscript-fonts ghostscript6 giflib giflib-bin giflib-shlibs glib glib-shlibs glib2-dev glib2-shlibs glitz glitz-shlibs gmp gmp-shlibs gnome-doc-utils gsm gtk+ gtk+-data gtk+-shlibs gtk+2 gtk+2-dev gtk+2-shlibs gtk-doc html-parser-pm5100 html-tagset-pm id3lib4-dev id3lib4-shlibs imlib2 imlib2-shlibs intltool40 io-compress-pm5100 jack-dev jack-shlibs jadetex lame lame-dev lame-shlibs libao2-shlibs libavahi-client3-shlibs libavahi-common3-shlibs libavahi-core6-shlibs libavahi-glib1-shlibs libavcodec-dev libavcodec51-shlibs libavformat-dev libavformat52-shlibs libavutil-dev libavutil49-shlibs libdaemon libdaemon-shlibs libdatrie1 libdatrie1-shlibs libfaad1-dev libfaad1-shlibs libfaad2-shlibs libflac8 libflac8-dev libgettext8-dev libgmpxx-shlibs libgnugetopt libgnugetopt-shlibs libid3tag libid3tag-shlibs libidn libidn-shlibs libjasper.1 libjasper.1-shlibs libjpeg8 libkpathsea4 libkpathsea4-shlibs liblzma5-shlibs libmad libmad-shlibs libmikmod3 libmikmod3-shlibs libmodplug libmodplug-shlibs libmpc2 libmpc2-shlibs libmpcdec3 libmpcdec3-shlibs libmpfr1 libmpfr1-shlibs libogg libogg-shlibs libpng14 libpng14-shlibs libpng3 libpng3-shlibs librarian.08-shlibs libsamplerate0-dev libsamplerate0-shlibs libshout4 libshout4-shlibs libsndfile1-dev libsndfile1-shlibs libthai libthai-dev libthai-shlibs libtheora0 libtheora0-shlibs libtheoradec1-shlibs libtheoraenc1-shlibs libtiff libtiff-bin libtiff-shlibs libtool14 libtool14-shlibs libtool2 libtool2-shlibs libvorbis0 libvorbis0-shlibs libwww libwww-bin libwww-pm5100 libwww-shlibs libx264-57-shlibs libx264-dev libxml libxml-shlibs libxml2 libxml2-bin libxml2-py26 libxml2-shlibs libxslt libxslt-bin libxslt-shlibs m4 make ocaml openjade openmotif3 openmotif3-shlibs opensp4 opensp4-dev opensp4-shlibs pango1-xft2-ft219 pango1-xft2-ft219-dev pango1-xft2-ft219-shlibs passwd pixman pixman-shlibs ppl ppl-shlibs python26 python26-shlibs rarian rarian-compat sdl sdl-shlibs sgml-entities-iso8879 sgmls-pm shared-mime-info t1lib5-nox t1lib5-nox-shlibs t1lib5-x11 t1lib5-x11-shlibs tetex-base tetex-texmf texi2html uri-pm5100 wavpack1-dev wavpack1-shlibs xdg-base xft2-dev xft2-shlibs xinitrc xmkmf xml-parser-pm5100 xmms xmms-bin xmms-shlibs xvidcore xvidcore-shlibs xz 

Guess what package I was installing. Unbelievably mpd! 

I have now tried macports, homebrew and fink and they all suck. It's unbelievable how bad of a copy of most linux package managers they all are.

First of all why do i have to compile every package on all three of these tools. I know it is a lot of work and fink are working on it but it's been a year since snow leopard is out. Being forced to compile is the thing that most people erroneously make fun of when talking about linux. It is ridiculous that this troll is actually true when considering mac, and no even though most packages are more for convenience I don't think an OS without wget is to be considered complete.

 Macports really duplicates a lot of stuff unneccessarily and some packages break for me, Homebrew also broke on two packages and plain didn't have formulas for a lot of other (although it hast the rather sane policy of not duplicating anything already in MacOS, which is a big plus) and fink just sucks for the reasons above.

I don't think gentoo prefix would make the situation any better. I guess i will try to live with homebrew and write patches for it. :( I had a thought the other how i hardly ever had the urge to write a program on linux since somebody almost surely has done it before. Maybe I am not compatible to Macs, but i have never programmed as much as on Mac and that out of pure need!