<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"><channel><atom:link rel="hub" href="http://tumblr.superfeedr.com/" xmlns:atom="http://www.w3.org/2005/Atom"/><description>My name is Einar Lielmanis and this is my somewhat technical blog.
I immensely enjoy moving the bits and bytes around.


var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));

try {
var pageTracker = _gat._getTracker("UA-7409939-3");
pageTracker._trackPageview();
} catch(err) {}</description><title>Superb hand-made bugpipes</title><generator>Tumblr (3.0; @bugpipe)</generator><link>http://bugpipe.com/</link><item><title>SDL and OCaml</title><description>&lt;p&gt;In case you’re a minority like me and are working with OCaml (I don’t know why, but somehow I doubt that) and thinking about trying to play with OpenGL, you may be interested to know that I have forked &lt;a href="http://glcaml.sourceforge.net/"&gt;glcaml project&lt;/a&gt; and put that on the &lt;a href="http://github.com/einars/glcaml/"&gt;GitHub&lt;/a&gt;: &lt;a href="http://github.com/einars/glcaml/"&gt;&lt;a href="http://github.com/einars/glcaml/"&gt;http://github.com/einars/glcaml/&lt;/a&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Glcaml provides an interface to OpenGL and SDL libraries for OCaml in a nice cross-platform-compatible way. Until now, it didn’t support SDL_mixer (and some other SDL_* libraries), thus playing sounds and music was quite difficult. No more! — as I’ve added support for the mixer, and more changes will come, when my need arises.&lt;/p&gt;

&lt;p&gt;For your convenience, there’s an &lt;a href="http://github.com/einars/glcaml/blob/master/examples/mixer.ml"&gt;example of using the mixer interface&lt;/a&gt; available, showing various features of the library.&lt;/p&gt;

&lt;p&gt;And, most importantly: Have fun!&lt;/p&gt;</description><link>http://bugpipe.com/post/318984317</link><guid>http://bugpipe.com/post/318984317</guid><pubDate>Wed, 06 Jan 2010 04:10:00 +0200</pubDate></item><item><title>The New Turing Omnibus: A chapter on Gödel's Theorem</title><description>&lt;p&gt;&lt;a href="http://bugpipe.org/misc/goedel.txt"&gt;http://bugpipe.org/misc/goedel.txt&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This is a chapter which deals with the Gödel’s Theorem from the A. K. Dewdney’s most wonderful book “&lt;a href="http://books.google.com/books?id=XW7fICYtkg8C&amp;dq=&amp;pg=PP1&amp;ots=fWQL2tqxMH&amp;sig=xYri8q7TNdxEokZE0M5cfhT1TA8"&gt;The New Turing Omnibus&lt;/a&gt;”.&lt;/p&gt;

&lt;p&gt;I can’t recommend this book enough, the insight it gives into various topics through its short articles makes me feel omnipotent. I hope that the publishers won’t find^W object me publishing one of the articles.&lt;/p&gt;

&lt;p&gt;Fun fact: even though it’s XXI century, I typed the article in manually so that the owner of the book — who found a sudden surge of interest for this exact article — would let me keep it for a longer while.&lt;/p&gt;</description><link>http://bugpipe.com/post/295702931</link><guid>http://bugpipe.com/post/295702931</guid><pubDate>Wed, 23 Dec 2009 00:43:00 +0200</pubDate></item><item><title>In defense of slower calculations</title><description>&lt;p&gt;…or 2^64 should be enough for everyone.&lt;/p&gt;

&lt;h2&gt;Floating points&lt;/h2&gt;

&lt;pre&gt;&lt;code&gt;    % python
    &gt;&gt;&gt; 2.5 - 0.1
    2.39999999999999
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;The usual answer to complaints about such behaviour is mumbling about standards, traditional numerical representations and things like that.
That’s a cop out. It’s about time it would be treated as a bug.&lt;/p&gt;

&lt;p&gt;Nowadays computers are insanely fast and have huge amounts of memory. Still, it’s surprisingly hard to tell that by number “2,5” I really mean discrete 2,5. IEEE-754 is a premature optimization, and I feel that there is a need to search for new real number representations.&lt;/p&gt;

&lt;p&gt;There are algorithms, CPU support and long history of working with traditional, highly inexact floating points, and thus the calculations are very fast. Yet, as soon as you’d like to sacrifice some speed for the correctness, it turns out that you’re on your own. Multiplying 123456789 with 987654321 is possible, but as soon as it’s 123456789.01, you’re welcome to the land of huge errors and approximations.&lt;/p&gt;

&lt;h2&gt;Platform-specific integer representations&lt;/h2&gt;

&lt;p&gt;Even google’s new &lt;a href="http://golang.org"&gt;language Go&lt;/a&gt; is short-sighted with having fixed-size integers, forcing you to do the computer’s job of cherry-picking how much memory you’ll allocate to each of your integers. Will it be 8 bits, 16 bits, or maybe 32 bits? Oh, and then there are platform-dependant integers, which will work nicely on my 64-bit machine, but will overflow on your 32-bit, and no tests will catch that. It’s 2009 already! Just use for the integers as much you need!&lt;/p&gt;

&lt;h2&gt;Integer overflows&lt;/h2&gt;

&lt;p&gt;As if it wouldn’t be bad enough to pick some integer size and stick with it, it’s worse when it silently overflows. Ocaml, for example, with its emphasys of speed and type correctness allows you shoot in the foot:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;    % ocaml
    # 9876543210 * 9876543210;;
    - : int = -3910986626405429788
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;I would really have expected at least throwing an exception.&lt;/p&gt;

&lt;h2&gt;Bottom line&lt;/h2&gt;

&lt;p&gt;C, C++ and their ways of doing things won’t go anywhere. But for the new languages there’s a wondeful chance to question the stagnant traditions, not sacrificing the correctness of the results for some speed.&lt;/p&gt;</description><link>http://bugpipe.com/post/241419394</link><guid>http://bugpipe.com/post/241419394</guid><pubDate>Thu, 12 Nov 2009 14:20:26 +0200</pubDate></item><item><title>Okular, one of the best document viewers around</title><description>&lt;p&gt;If you’re somewhat like me and read alot of books or technical documentation in pdf or djvu format, then I’d like to suggest you checking out the Okular document viewer. It is a part of KDE project, and it has at least two excellent features which make it well worth setting it as the default document viewer.&lt;/p&gt;

&lt;h2&gt;Review mode&lt;/h2&gt;

&lt;p&gt;Review mode is a bunch of tools that allow you to make the notes and scribbles inside the document you’re reading. The following picture shows the document with a custom note and review toolbar visible:&lt;/p&gt;

&lt;p&gt;&lt;img src="http://spicausis.lv/tumblr-images/okular-review.png"/&gt;&lt;/p&gt;

&lt;p&gt;The notes themselves are saved transparently and independently from the document you’re viewing (under ~/.kde4/share/apps/okular) and they won’t mess with the originals — unlike e.g Foxit reader for windows, which insists on saving the file with the notes into a new pdf.&lt;/p&gt;

&lt;h2&gt;Trimmed margins&lt;/h2&gt;

&lt;p&gt;When reading documents from the monitor, the large margins that look nice when printed tend to get in the way and waste space. This feature removes them, making continuous reading easier, like this, original with margins visible:&lt;/p&gt;

&lt;p&gt;&lt;img src="http://spicausis.lv/tumblr-images/okular-normal.png"/&gt;&lt;/p&gt;

&lt;p&gt;And the trimmed margin view:&lt;/p&gt;

&lt;p&gt;&lt;img src="http://spicausis.lv/tumblr-images/okular-trim.png"/&gt;&lt;/p&gt;

&lt;p&gt;These little things make working with the pdfs and reading from the screen much more enjoyable. Try it out — it should be easily found in the software repositories of your OS.&lt;/p&gt;

&lt;p&gt;P.S The scary pictures come from the free book &lt;a href="http://www.math.umass.edu/~lavine/Book/book.html"&gt;Introduction to Statistical Thought&lt;/a&gt; by Michael Lavine.&lt;/p&gt;

&lt;p&gt;P.P.S I would really love to hear about how cool the pdf readers are under mac. While I’m an avid linux user, I’m very interested on how things are done in other systems.&lt;/p&gt;</description><link>http://bugpipe.com/post/231261575</link><guid>http://bugpipe.com/post/231261575</guid><pubDate>Tue, 03 Nov 2009 02:23:00 +0200</pubDate></item><item><title>Custom KDE–style window shortcuts in Gnome</title><description>&lt;p&gt;&lt;a href="http://github.com/einars/dotfiles/blob/master/bin/focus-or-run"&gt;http://github.com/einars/dotfiles/blob/master/bin/focus-or-run&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;KDE, both the good old 3.5 and new clunky 4, has vast options for customizing the window behaviour. For example, you can ask the chat windows to automatically open in one workspace, gimp — in other, and so on.&lt;/p&gt;

&lt;p&gt;When using Gnome, the feature I’m missing most is a possibility to assign window shortcuts: it is incredibly convenient to get rid of the alt-tab and use shortcuts like Alt-A to switch to firefox from anywhere.&lt;/p&gt;

&lt;p&gt;I’ll show how to emulate this using a custom script in Gnome, and even make it better, opening the application in question if it’s not running.&lt;/p&gt;

&lt;h2&gt;You’ll need:&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;a folder where you store all your own scripts.&lt;/strong&gt; If you’re using linux and working from console, you’ve probably already figured out that you need a place to drop all your scripts and helpers and whatnot. Usually ~/bin is used — just make a folder “bin” in your home folder, if you don’t have any.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="http://tripie.sweb.cz/utils/wmctrl/"&gt;&lt;strong&gt;wmctrl.&lt;/strong&gt;&lt;/a&gt; Wmctrl is a small script which allows other scripts to communicate with windows on screen and control them. It is available in stock ubuntu repository (universe) as “wmctrl”, the same in Arch Linux community repository, and generally you shouldn’t have problems finding and installing it.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;zsh.&lt;/strong&gt; Zsh is an interpreter which will run our script. The default shell interpreter in most of the linux distributions is called bash, yet zsh is easier to use and offers prettier scripting capabilities. There is no reason why the script couldn’t be written in bash or other interpreter of choice: I just use zsh for everything myself.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;h2&gt;The script&lt;/h2&gt;

&lt;p&gt;You can view and dowload the complete script here: &lt;a href="http://github.com/einars/dotfiles/blob/master/bin/focus-or-run"&gt;http://github.com/einars/dotfiles/blob/master/bin/focus-or-run&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;It is called “focus-or-run” and it takes two parameters: the first is window &lt;em&gt;class&lt;/em&gt; or a fragment of the title. Script will try to find the matching window and bring it to foreground.&lt;/p&gt;

&lt;p&gt;The second is an optional program name you wish to run in case the window was not found.&lt;/p&gt;

&lt;p&gt;So, this command:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;focus-or-run firefox /usr/bin/firefox
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;will attempt to find a window which belongs to “firefox” and, if found, focus that. If the window was not found, it will run /usr/bin/firefox and then focus the window again.&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;focus-or-run firefox
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Will actually work just fine, too.&lt;/p&gt;

&lt;h2&gt;Assigning the hotkeys&lt;/h2&gt;

&lt;p&gt;This is where the System-Preferences-Keyboard Shortcuts applet comes in handy. Some time ago it was reworked so that adding custom shortcuts now is a breeze.&lt;/p&gt;

&lt;p&gt;First, you have to create a new action by clicking Add, and filling in the information like this:&lt;/p&gt;

&lt;p&gt;&lt;img src="http://spicausis.lv/tumblr-images/gnome-shortcuts.png" alt="Adding a custom shortcut"/&gt;&lt;/p&gt;

&lt;p&gt;You’ll find the new command in the list below; you can now assign any keyboard shortcut to it:&lt;/p&gt;

&lt;p&gt;&lt;img src="http://spicausis.lv/tumblr-images/gnome-shortcuts-customize.png" alt="Created a new shortcut"/&gt;&lt;/p&gt;

&lt;p&gt;That’s all. Now you can press Alt-A anytime you want to get to that firefox window, and it’ll pop up.&lt;/p&gt;

&lt;p&gt;I’ll leave assigning other most frequently used software to shortcuts as a home exercise :)&lt;/p&gt;</description><link>http://bugpipe.com/post/228595413</link><guid>http://bugpipe.com/post/228595413</guid><pubDate>Sat, 31 Oct 2009 07:00:00 +0200</pubDate></item></channel></rss>
