Skip to main content

Posts

UI-Design: View 2-D, Navigate 3-D?

Over-and-over again 3-D User Interface design was heralded "dead". The flat 2-D screen is a natural fit for orthographic projection of flat imagery like 2-D spread sheets, tables, lists and linear text. On the other hand, much of what is shown on a (2-D) screen is projected 3-D content, be it from computer games or from movies. Most human beings navigate and move in the physical world, and the brain makes sense of this world by encoding it as a 3-D space, the brain is hardwired to process, remember filter and associate information in context of a 3-D world. That's why I think that UX/UI design will benefit from using 2-D for data representation and form input, and closed-space 3-D for navigation through the application.

Keys, Values and Rules: Three Important Shake Concepts

The title was a click-bait! This article will actually try to explain five instead of three important notions in Shake. These are: Rules Keys Values The Build Database Actions This short blog post was inspired by the hurdles with my Shake based build, after the new Shake version was released, which had breaking API changes. Jump to the next section if you are not interested in the why and how of this blog post. Shake is rule based build system much like GNU make. Like make it is robust, unlike make, it is pretty fast and supports dynamic build dependencies. But you knew all that already, if you are the target audience of this post, since this post is about me explaining to myself by explaining to you, how that build tool, I used for years, actually works. Although I used it for years, I never read the paper or wrapped my head around it more than absolutely necessary to get the job done. When Shake was updated to version 0.16.x, the internal API for custom rules w...

erlangs gen_fsm with queueing

OK no time for a full blow, polished blog post; When using gen_fsm I realized that often I want some sort of queueing. Two reasons promote this: to reduce the complexity caused by {States} x {Events} to implement some kind of asynchronous command execution processing model I usualle encounter both reasons and I ended up with two useful function that I copy into every gen_fsm I build: deq(State = #state{evtq = []}) -> {next_state, ready, State}; deq(State = #state{evtq = [Msg | T]}) -> ?MODULE:ready(Msg, State#state{evtq = T}). This requires one adds evtq as a field to the #state{} record. The function deq/1 will be used to work of events(one could say commands) until the queue is empty and finally rests in the state ready . This function is called at the point where one would return {next_state, ready, State} So instead of transitioning directly to ready we call the deq function which will process all defered events. On the other hand there is a...

My minimalistic xinitrc, xmonad.hs and xmobarrc

put this in ~/.xinitrc ck-launch-session # start trayer to contain apps like nm-applet trayer --edge top --align right --SetDockType true --SetPartialStrut true --expand true --width 5 --transparent true --tint 0x191970 --height 12 & kmix & # some cool effects xcompmgr -c -f -F & # Set the background color hsetroot -tile /home/sven/Wallpapers/abstract-bluelights-1280x800-.jpg xset b 100 0 0 xset r rate 190 90 dbus-launch --exit-with-session xmonad put this in ~/.xmonad/xmonad.hs import XMonad import qualified XMonad . StackSet as W import XMonad . ManageHook import XMonad . Hooks . ManageHelpers import XMonad . Hooks . DynamicLog import XMonad . Hooks . ManageDocks import XMonad . Hooks . FadeInactive() import XMonad . Hooks . SetWMName ( setWMName ) import XMonad . Layout . NoBorders ( smartBorders ) import XMonad . Layout . Tabbed ( tabbed , shrinkText , defaultTheme ) import XMonad . Layout . LayoutHints ( layoutHints ) imp...

Installing GHC 6.12.2 on Red Hat Entrprise Linux 5.4 (i386)

Haskell, a general-purpose, purely functional programming language, has become more and more interesting for me, it allows me to write maintainable code, with acceptable performance even for tasks like analyzing large log files. I recently discovered how easy it is to write programs interacting with a unix like environment. It also very easy to write networking code. Haskell offers great opportunities for TDD and SDD through HUnit and QuickCheck, which - together with the pure and strong static type system of the language itself - enable trust in program correctness, which is vital for many commercial applications, or applications exposed to increased security requirements. In order to leverage the outstandingly great features of Haskell, one has to have that beast running on a stable, proven and hence archaic and outdated operating system. Even if one is not a firm believer in magical awesomeness of Enterprise labels on top of ridiculously obsolete tools(like gcc 4.1 and glibc 2.5), ...

haskell stuff in my .emacs

This does not include the ghc-mod configuration. ;; haskell section: (load "/usr/share/emacs/site-lisp/haskell-mode/haskell-site-file.el") (require 'inf-haskell) (autoload 'turn-on-haskell-doc-mode "haskell-doc" nil t) (add-hook 'haskell-mode-hook 'heyllStd) (add-hook 'haskell-mode-hook 'turn-on-haskell-font-lock) (add-hook 'haskell-mode-hook 'turn-on-haskell-decl-scan) (add-hook 'haskell-mode-hook 'turn-on-haskell-indent) (add-hook 'haskell-mode-hook 'turn-on-haskell-doc-mode) (add-hook 'haskell-mode-hook 'turn-on-haskell-ghci) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

Regular Expression Cheat Sheet YEAHH!!

...NOT! There seems to be no good regex escaping cheat-sheet, that is easy to find. I was so tired of remebering when to escape what in grep, awk, sed and emacs, that I asked google for help. The result of my search was not very satisfying :( So I started this blogpost as the location for gathering all diffrent escaping styles that I find during my daily work. sed \(\) \+ * . \/ (backslash must be escaped, even if not used as seperator cahracter) \| grep Like sed.

it

it syllables stroke hidden performances, relentlessly while she is singing with his song she - flowers and shines in a shower half through and yet stuck off by an occurence - hesitating wandering through grayness colorfull her tears hidden permitted to beast breaks old and new and she will see he is falling unforgottenly muted blended by invisable light not so pure not shining - hesitate! clicked links to the past before her metamorphoses cuting moments of pain and pity grayness wandering colorfull through his tears stainless trees fallen in the way running in a direction and the other where will we go from here?

Erlang mock - erlymock

NOTE THIS POST IS OUTDATED! The project has evolved and can be found here: ErlyMock Some features Easy to use Design based on easymock Works together with otp: can be used even if the clut is called from another process, by invoking mock:verify_after_last_call(Mock,optional: timeout) custom return functions predefined return functions for returning values, receiving message, throwing exceptions, etc.. erlymock automatically purges all modules that were mocked, after verify() Custom argument matchers: %% Orderchecking types: in_order, out_of_order, stub; %% Answering: {return, ...}|{error, ...}|{throw, ...}|{exit, ...}|{rec_msg, Pid}|{function, Fun(Args) -> RetVal} expect(Mock, Type, Module, Function, Arguments, Answer = {AT, _}) when AT==return;AT==error;AT==throw;AT==exit;AT==rec_msg;AT==function -> call(Mock, {expect, Type, Module, Function, length(Arguments), {Arguments, Answer}}). %% this version of expect is suited for useing custom argument matchers expect(Mock, Type, ...

my personal profiling guide

This is suited for functional programming. Blind optimizations: just say NO. 1. Write some unit tests that ensure your code stays correct. 2. DO NOT ASSUME ANY KNOWLEDGE ON WHAT SHOULD BE OPTIMIZED- but try to "see" possible bottlenecks. 3. Write a the smallest possible program that uses the code to optimize, such that the program exhibits the functionality that seems to be the bottleneck(s). Design this program to run for a few seconds without user interaction. 4. Use a decent profiler to profile a complete run of this program 5. Optimize the bad code in this order - estimate the complexity of the code around hotspots - try diffrent data structures and algorithms - try to involve background knowledge - try to combine several functions into one - records should fit into the cache of the target platform - add more strictness(dangerous) - move common subexpressions or constant subexpressions to a higher scope(generalisation of precalcu...

ArrowLoop - finally seeing the light at the end of a long tunnel

Today I achieved something I long lusted to acheive, I made the step from fix to loop. Basically by going from the applicative order Y combinator: (define (y f) ((lambda (ff) (lambda (xx) (f (ff ff) xx))) (lambda (ff) (lambda (xx) (f (ff ff) xx))))) (define (fak f n) (if (= 0 n) 1 (* (f (- n 1)) n))) ((y fak) 5) to writing the same in lazy haskell: y f = f $ y f fak r 0 = 1 fak r n = n * r (n - 1) -- ghci> y fak 5 ----> 120 someone told me that fix = y and that fix and loop are closely related. I found an aspiring blogpost and thought it would be fun to do the fibonacci recursion instead of the simple factorial. That resulted in: data SF a b = SF {runSF :: [a] -> [b]} instance Arrow SF where arr f = SF (map f) (SF f) >>> (SF g) = SF (f >>> g) first (SF f) = SF $ unzip >>> (first f) >>> zip' instance ArrowLoop SF where loop (SF f) = SF (\ins -> let (outs, r...

Got Religious

[this is the only religious post you will ever encounter on this blog] After an excessive amount of thinking, reading and weighting pros and cons I came to the final conclusion that actually and deep down in me, I beleive that 1. God exists 2. Christianity makes sense Many, many arguments exits against 1 and also 2. But as soon as you accept 1. arguing against 2 becomes really hard. All objections brought into field against 2. failed to convince me finally; ok some of them convinced me at first, and it took years to find out that they were errornous. Many objections seem clever at first, but really contain discrepancies or stem from pure ignorance. Most of those uttering them, do not really reflect these objections very well. A nice example is the following "objection" against 1. and partly 2.: "If god was almighty, could he create a stone so heavy, that he can't lift it?" It takes a bit of thinking, but is actually easy to debilitate. I will leave that as an ex...

Erlang code snippet....

Code like that: blah(X) -> X1 = f(X), X2 = g(X1), X3 = h(X2), i(X3). is very error prone, and worse very hard to extend. Just adding another function application between f(X) and g(X1) requires you to alter all lines upto the end of the function: blah(X) -> X1 = f(X), X2 = j(X1) X3 = g(X2), X4 = h(X3), i(X4). This causes 2*numberoflinestoendoffunction potential error sources; And this is also not at all a very functional style. Why not rewriting it like this: blah(X) -> (chain([ f, g, h, i ]))(X). where one chains together the functions. Adding a function invocation in between is as easy as pie. chain(FunList) -> lists:foldl( fun combine/2, fun id/1, FunList). id(X) -> X. combine(F,G) -> RF = to_local_function(F), RG = to_local_function(G), fun(X) -> RF(RG(X)) end. to_local_function(F) -> case F of {FM, FF} -> F; _ when is_atom(F) -> {?MODULE, F} end. Anot...

Lazy Evaluation(there be dragons and basement cats)

Lazy Evaluation and "undefined" I am on the road to being a haskell programmer, and it still is a long way to go. Yesterday I had some nice guys from #haskell explain to me lazy evaluation. Take a look at this code: Prelude> let x = undefined in "hello world" "hello world" Prelude> Because of Haskells lazyness, x will not be evaluated because it is not used, hence undefined will not be evaluated and no exception will occur. The evaluation of "undefined" will result in a runtime exception: Prelude> undefined *** Exception: Prelude.undefined Prelude> Strictness Strictness means that the result of a function is undefined, if one of the arguments, the function is applied to, is undefined. Classical programming languages are strict. The following example in Java will demonstrate this. When the programm is run, it will throw a RuntimeException, although the variable "evilX" is never actually used, strictness requires that all argu...