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
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.
Modifying LaTeX citation styles
lokakuu 15, 2008
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
N2S: Rebuilding VirtualBox Kernel Module
syyskuu 1, 2008
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
Quickly Convert Text Encodings
kesäkuu 26, 2008
Just run:
iconv -f from -t to < input > output
where for example from=ISO88591 and to=UTF8
An Excellent Guide to Getting PulseAudio to Work in Fedora 8
kesäkuu 11, 2008
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
Bug in VS 2008: Setup Projects Fail to Build
kesäkuu 2, 2008
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.
ASP.NET, ObjectDataSource and DateTime Culture Problems
tammikuu 10, 2008
If you want to display and especially provide editing capabilities for DateTime data in ASP.NET applications, you’ll surely sooner or later run into problems.
Without any exact format specifiers, your DateTime data may display in a wrong format, but this can be corrected by providing your desired format string to the binding expression.
However, when you edit a DateTime value e.g. in a TextBox, you’ll soon start getting “Could Not Convert” exceptions. It turns out that, initially, ObjectDataSource uses the default Culture of the current thread to convert DateTimes to and from strings, and that Culture is the Culture of the server, not the user agent.
There are some commonly seen solutions to this that recommend forcing conversions in the right format in your data control’s Updating event handler.
A cleaner solution that also removes the need to specify explicit format strings is to adopt the user’s Culture as the server Thread’s Culture and UICulture. Here’s how:
- Add a Global class to your Web Client project by going to Add New Item and selecting Global Application Class. Global.asax will be created with its code-behind class Global.asax.cs.
- Add the following namespaces to use in the class: System.Globalization and System.Threading.
- Add the following to the Application_BeginRequest handler:
string lang = Request.UserLanguages != null ? (Request.UserLanguages[0] ?? string.Empty) : string.Empty; CultureInfo info = CultureInfo.CreateSpecificCulture(lang); Thread.CurrentThread.CurrentCulture = info; Thread.CurrentThread.CurrentUICulture = info;
2008-01-11 Fixed a possibility for ArgumentNullException in CreateSpecificCulture.