A Tiny Little Rant

lokakuu 31, 2008

Oh why, oh why do the LINQ sorting extension methods have to be OrderBy(Func) and OrderByDescending(Func)?

I’d find it so much less confusing if they were even OrderByAscending(Func) and OrderByDescending(Func), or OrderBy(Func, SortOrder), or the like.

Now I have to actually think every time I sort, “Okay, OrderBy was the one that sorts, um, descending? Was that, with small values first?” All in all, calling sort orders ‘ascending’ or ‘descending’ is the daftest thing in the world to do; the numbers don’t suddenly rise anywhere or go downwards, they get bigger and smaller. Or maybe it’s just me and my limited cognitive capabilities :P

Illustrator, EPS and LaTeX

lokakuu 30, 2008

Ironically, Adobe Illustrator creates malformed files when you save your illustrations as EPS, and of course LaTeX, ghostscript and thus pdflatex choke on them. There’s however a simple remedy: the eps2eps “distiller” strips all non-essential parts away from EPS files thus fixing also malformed AI EPS files.

For reference, here’s the gist of my (unoptimized) eps2pdf script I use before I run pdflatex:

#!/bin/bash
mkdir temp-eps-eps
for file in *.eps; do
    echo -e "$file";
    eps2eps $file temp-eps-eps/$file;
    cd temp-eps-eps;
    epstopdf $file --outfile=`echo -e $file | sed -e "s/\.eps/\.pdf/g"`;
    mv `echo -e $file | sed -e "s/\.eps/\.pdf/g"` ..;
    rm $file;
    cd ..;
done
rmdir temp-eps-eps

This should be called in the directory whose EPS files you wish to convert to PDF.

And why do I use EPS? Pretty much any vector graphics application supports it. Pretty often, saving your illustrations directly as well-behaving PDFs can be much more difficult than using EPS.

To modify citation styles for basic bibitem citations, use the following lines in the preamble:

\makeatletter
\renewcommand*{\@biblabel}[1]{/#1/}
\renewcommand*{\@cite}[1]{/#1/}
\makeatother

The code above changes the citation marker from [n] to /n/.

To change the bibliography title, use (right before \begin{thebibliography}, especially if you’re using babel):

\renewcommand\refname{New Title}   % for article, or
\renewcommand\bibname{New Title}   % for other types

This needs to be done whenever a new kernel is installed. (Sometimes a newer version of VBox is needed as well, if the current one does not support the new kernel.)

sudo /etc/init.d/vboxdrv setup

Just run:

iconv -f from -t to < input > output

where for example from=ISO88591 and to=UTF8

Coding Horrorissa oli tänään juttu ASCII-merkkien ääntämisestä koodia luettaessa. Ajattelinpa laittaa tähän sitten omat lukutapani suomeksi ja englanniksi. Sulut ja lainaukset luen joko “sulut auki/sulku kiinni” tai “suluissa”, englanniksi “opening/closing parenthesis” tai “in parentheses”. Lopussa on vielä lista useamman merkin yhdistelmistä.

!
not, huutomerkki, ei, kertoma (matikkayhteyksissä)
not, exclamation point, factorial

"
lainausmerkki, lainaus
quote

#
risuaita
hash

$
dollari, äs (muuttujien nimissä)
dollar

%
prosentti, modulo
percent, mod

&
änd, ja, et (xml)
and, amp (xml)

'
heittomerkki, heitto
single quote, char quote

( )
sulut
parentheses

[ ]
hakasulut, laatikkosulut
brackets, at index

{ }
aaltosulut, lohkosulut
(curly) braces, block

< >
pienempi/suurempi kuin, kulmasulut (xml)
less/greater than, angle brackets

*
tähti, kertaa
star, pointer (c), times

+
plus
plus

,
pilkku
comma

-
miinus, viiva
minus, dash

.
piste
dot, period (at least in Pascal "end.")

/
kautta, kauttaviiva, per (matikka)
slash, over

\
keno, kenoviiva
backslash

:
kaksoipiste
colon, as (Pascal type), in (Java foreach)

;
puolipiste
semicolon

=
on
equals

?
kysymysmerkki
question mark

@
ät
at

^
hattu, ksor
hat, xor

_
alaviiva
underscore

`
yläpilkku
grave

|
or, tai, putki (asiayhteydestä riippuen)
or, pipe

~
tilde, ei
tilde, not

Ja sitten monimerkkiset:

==
on on, tupla-on
equals, is, double equals

===
on on on, tripla-on
really equals, triple equals

=< =>
pienempi/suurempi tai yhtä suuri kuin
less/greater than or equal

:=
kaksoispiste-on
is

!= <>
ei ole, erisuuri kuin
not equals, is not

::
tuplakaksoispiste
double colon

=>
jolle (C#), nuoli (PHP)
for which, arrow

+= -= /= *= &= |= ^= %= .=
plus on, miinus on, kautta on, tähti on, ja on, tai on, hattu on, prosentti on, piste on
plus equals, minus equals, slash equals, times equals, and equals, or equals, ex-or-equals, mod equals, dot equals

...
piste piste piste
ellipsis

->
nuoli
arrow

..
-sta -een, piste piste
from to, dot dot

<>
oikealle
right, shift right

<<<
kolmoisnuoli
triple arrow

++ --
plus plus, miinus miinus
plus plus, minus minus

**
tähti tähti
star star

@"
ät lainaus
at quote

<< >>
vasemmalle/oikealle
left/right, shift left/right

..
-sta -een, piste piste
from to, dot dot

->
nuoli
arrow

<<<
kolmoisnuoli
triple arrow

This guide saved my day: Pulseaudio Fedora 8 Howto. Now I can play MIDI music with TiMidity++ and sounds at the same time, which is good for playing DOS games :)

Due to a known bug, setup projects fail to build in Visual Studio 2008 if LINQ assemblies are referenced in any of the projects in the setup. VS will show “Build failed” on the status bar, but no errors are displayed in the Output pane.

There’s no need to worry, though: the project actually builds successfully, the compiler just happens to return an error code.

N2S: texhash

toukokuu 13, 2008

If you have installed a LaTeX package by copying it to /usr/share/texmf/tex/latex, run texhash afterwards.

Launchy

maaliskuu 12, 2008

I installed Launchy about a week ago, and it has been working like a charm.

This great little piece of software brings the functionality to your Windows desktop that users of Quicksilver have been enjoying on their Macs for quite a while. In all simplicity, it enables you to operate your computer much more efficiently by popping up a command box upon pressing a chosen keystroke (I prefer Win+Space).

Launchy’s built-in functionality includes launching applications by typing in a part of their name (and it also learns: after a few runs, I can start Firefox with just Win+Space, F, Enter), and opening folders and web pages. It also includes a basic calculator, and the ability to create custom commands.

As an example of custom commands, I have created a command called shutdown that just launches the command “shutdown -s -f -t 0” to quickly shut down the computer.

As a slight downside, as the application has recently reached its 2.0 version, most of its extensions (integrated Windows desktop search, window changing by typing their names, etc.) are not yet compatible with the newest version. However, I hope that most extensions will be available soon as well.