Showing posts from 2009

Tech support cheat sheet

I wish most people grew intuition. Are you one who regularly gets bothered by friends, relatives or random people with every snippety problem they encounter? Are they also spreading your recommendation for such problems to more random people? Then you need to start distributing the following on your calling card: Tech support cheat sheet (xkcd)

Sorted and aggregated disk usage script

I've been asked for this script many times lately, so I'll publish it. It lists the disk usage of subdirectories in a given directory in descending order, right justified and suffixed with kilobytes or megabytes appropriately. #!/bin/sh display() {  local DIR=$1  du -sk $DIR/..?* $DIR/.[!.]* $DIR/* 2>/dev/null |   sort -n |   awk '    {     size = $1;     sum += size;     name = $2;     if ($1 < 1024){      printf("%9ik %s\n",size,name);     } else {      printf("%9.3fM %s\n",size/1024,name);     }    }    END{     print sum " kiB"    }   ' } main() {  local DIR=$1  if [ "$DIR" = "" ]  then   display $HOME   quota  else   display $DIR  fi } main "$@"

Rapid serial visualisation for portable book reading

I've received the following link recently that I believe I have already stumbled upon earlier. Rapid Serial Visual Presentation (Wikipedia) I didn't see much perspective for it before, but I've given second thought now. Just imagine a tiny note taking device which combines the above speed reading technique with a chorded keyboard (like the DataEgg )!

Haskell IDE

Gtk+: Leksah - Haskell IDE in Haskell built on Gtk+ and gtk2hs ( HaskellWiki: Leksah ) Eclipse : EclipseFP - functional programming support for Eclipse (Installation experience and comments: 1 , 2 ) Emacs : Haskell Mode for Emacs from Svein Ove Aas (previous maintainer was Stefan Monnier: 1 , 2 ) (TODO: is (setq haskell-font-lock-symbols 'unicode) the default?) , MMM (Multiple Major Modes) Mode for Emacs , scion-lib Haskell IDE library , HaRe -- The Haskell Refactorer Vim : Haskell mode for Vim , Superior Haskell Interaction Mode (SHIM): GHCi integration for VIM , Vim as a Haskell IDE, first steps illustrated tutorial, scion-lib Haskell IDE library , HaRe -- The Haskell Refactorer And of course we all know what xkcd: Real Programmers use. I'm eagerly awaiting your feedback!

Converting between Bird-literate and plain Haskell

Literate programming is a good idea, and there exist many creative ways in which you could take advantage of it, like one described in Literate Haskell with Markdown and Syntax Highlighting . However, if you're using the text editor Geany version 0.18, you will be faced with a bug that makes it unable to interpret Bird-style literate source. As a simple fix, I provide two programs to convert between simple Bird-literate and non-literate source code. You could also convert your Bird-literate to TeX-style . # bird_lhs2hs sed '   s/^>//   t   s/^ *$//   t   s/^/-- /  ' in.lhs > out.hs # hs2bird_lhs sed '   s/^-- //   t   s/^ *$//   t   s/^/> /  ' in.hs > out.lhs

DataRow.Delete with SqlDataAdapter

A note to myself. I've figured this out few years ago, but it looks like I forgot it... :-D Always use the Delete() method on the DataRow object instead of Remove(DataRow) on the DataRowCollection, or else the corresponding SqlDataAdapter.DeleteCommand won't trigger for an Update. So deleting from the table won't work, no execution will be done.

LALR-1 parseable C++

In The Design and Evolution of C++, Stroustrup observes that "within C++ there is a much smaller and cleaner language struggling to get out" [Stroustrup, B., The Design and Evolution of C++, Section 9.4.4., Addison-Wesley, 1994.] and foresees the development of "other interfaces" to C++. A Modest Proposal: C++ Resyntaxed by Ben Werther & Damian Conway (Department of Computer Science, Monash University) Significantly Prettier and Easier C++ Syntax (Wikipedia)

Eee Keyboard PC - C=64 rebirth?

Well, what do you know, it looks like history does repeat itself: Eee Keyboard splayed, detailed by FCC (Engadget) Trends Are Cyclical: the Asus Eee Keyboard (OSNews) ASUS Eee Keyboard (Wikipedia)

Erlang vs. Scala

From Yariv’s Blog: Erlang vs. Scala - aspects discussed: concurrent programming, hot code swapping, garbage collection, scheduling, distributed programming, mnesia, tail recursion, network IO, remote shell, simplicity, libraries, reliability and scalability See also: bkil: Haskell vs. Erlang vs. Scala

C/C++ refactoring support

EDIT: updated on 2016-02-06 (fixed links, added QtCreator) The people I've discussed refactoring with usually got pretty enthusiastic about it when showing them what can be done in properly designed languages like Java, Erlang or Haskell. They asked whether these kind of things were doable for weaker programming languages like C and C++ by free open source tools. I don't have much experience in this topic, as I haven't done bigger projects in this language yet, and the small ones I did were usually properly designed for the purpose from the start. So I looked around for possible solutions , and doing a few web searches yielded the following links. I may try some of these in the future just for curiosity. Be warned that not all listed features are available or complete. If you have experience with any of these, or with any refactoring tool for that matter, please let us hear your voice in the comments. (Maybe it would be worthwhile to open a wiki about available ref

Food Waste: Canada $3-5+ billion, UK $10+ billion per year?

Elimination of food waste could lift 1bn out of hunger, say campaigners (The Guardian) Food Waste: Canada $3-5+ billion, UK $10+ billion per year? Supermarkets throw away two million tons of food a year (UK) An Apple a Day Gets Thrown Away (UK) Hunger and food waste (in Sweden, Switzerland and elsewhere)

Scala in practice

Here are some nice pointers related to the promising multi-paradigm (OOP, FP, COM), multi-platform ( .NET +JVM) language we all adore. Some introductory guides: The Scala Programming Language - a quick and conscious overview [2009] Catching Up with Scala - another conscious overview [2007] Some background: The Scala Experiment – Can We Provide Better Language Support for Component Systems? - explains the intentions behind designing the language [2004] Java yields to other languages on the Java Virtual Machine an overview of some alternatives by Paul Krill from InfoWorld [2009] Some applications: Twitter on Scala - A Conversation with Steve Jenson, Alex Payne, and Robey Pointer by Bill Venners [April 3, 2009] Scala at Stanford Pervasive Parallelism Laboratory [2009] Ray tracer language comparison ported to Scala (and Groovy) - performance is on par [2007]

FreeArc - advantage of developing in Haskell

FreeArc, a great performing free software archiver written in combined Haskell/C

Typing speed tests

Yesterday's "party" prompted me to do some drills of typing in order to improve my accuracy. :-) Results are the following on a random acceptable, but not new keyboard in our lab: A simple single sentence test without much caps: 70 A large paragraph (about one minute) of well-balanced text: 62(2), 66(1), 70(0), 66(1) Crazy phrases (two sentences each): 61(0), 67(0), 66(0), 69(0), 74(0), 70(0), 62(0), 63(0), 77(0), 65(1), 63(0), 79(0), 114(0), 56(0), 76(0), 61(0), 61(0), 70(0), 65(0), 57(0), 73(0), 87(0), 79(0), 77(0), 62(0), , 72(0), 72(0) Random letters (59 characters): 38(0), 39(0), 49(0), 45(0), 40(0), 39(0), 39(0), 36(0) Random letters, numbers and punctuation (59 characters): 35(0), 37(1), 36(0), 35(0) One minute of well-balanced text: 72(0), 69(0), 72(0), 74(0), 72(0), 71(0), 75(0), 80(0), 76(0), 72(0)

The balance between meat and plant consumption

The following article explains that if most of us would follow a healthy, but rational diet, then not only would obesity problems be a nightmare of the past, but it would also greatly reduce our ecologic footprint . U.S. could feed 800 million people with grain that livestock eat, Cornell ecologist advises animal scientists (with David Pimentel, professor of ecology in Cornell University's College of Agriculture and Life Sciences)

Why do telephone keypads count from the top down, while calculators count from the bottom up?

I've been thinking about the very same thing not too long ago: A Staff Report from the Straight Dope Science Advisory Board: Why do telephone keypads count from the top down, while calculators count from the bottom up?

Haskell for embedded: C output, compilers, monads, Timber

Tricks to use Haskell for developing embedded systems: Re: [Haskell-cafe] compilation to C, not via-C - question involving if you could output prettier C (answer: YHC/LHC or monadic generators) CUFP 2008 Program - see Controlling Hybrid Vehicles with Haskell by Tom Hawkins, Eaton Corporation TIMe - eMBEdded - Reactive - a promising O'Haskell inspired strict embedded research language

Unary math Towers of Hanoi in naked (D)ASH and BASH

The following solution assumes neither BASH extensions, nor any external executables. Hence it could be ran from a preboot environment like a frugal initrd. A slight compromise was to use unary math. Did you know, that you can access an animated version from Emacs by typing M-x hanoi ? pop(){  shift  echo $* } top(){  echo $1 } print_towers(){  echo "a=[" $a "], b=[" $b "], c=[" $c "]" } hanoi(){  [ "$n" ] || return  local ln  ln=$(pop $n)  n=$ln  hanoi $1 $3 $2  print_towers  echo "$1 -> $2"  eval $2=\"$(eval top \$$1) $(echo \$$2)\"  eval $1=\"$(eval pop \$$1)\"  n=$ln  hanoi $3 $2 $1 } main(){  a="1 2 3 4 5"  b=  c=  n=$a  hanoi a b c  print_towers } main "$@"

Simple Pascal-triangle implementations

-- The first version can output a row of Pascal's triangle : import System.Environment(getArgs) pas 0       = [1] pas n | n>0 = let l = pas (n-1) in zipWith (+) (0:l) (l++[0]) main = do     [s] <- getArgs     print . pas $ read s -- The second revision can output a certain number of rows of the triangle: import System.Environment(getArgs) pas = iterate nextline [1] where     nextline l = zipWith (+) (0:l) (l++[0]) main = do     [s] <- getArgs     putStr . unlines . map show $ take (read s+1) pas -- And the last monolith solves a very simple homework assignment: import Data.List(intersperse) import System.Environment(getArgs) pas 0 = [1] pas n = let l = pas (n-1) in zipWith (+) (0:l) (l++[0]) strPas s = do     let n = read s     if n<0 || n>30 then         fail "Pascal out of range"     else do         let list = concat . intersperse " " . map show         return (n, list $ pas n) main = do     l <- getArgs     case l of         [s] -> do (_,

Discussion on Ada, Java and Clean

We had a discussion on programming language preferences last week with a friendly undergraduate guy. He strongly prefers C++ and Qt, also showing enthusiastic interest in studying Concurrent Clean, while showing great dislike of Java, C# and Ada. I won't go through the whole argument here, but the most interesting aspect of his mentality is disliking the last one. He went on to demonstrate the inferiority of Ada with examples that prove true even in the case of Clean or Haskell! In favor of C++, he mentioned the forgiving nature of the type system. As an issue against Java, he named garbage collection, and against Ada, he listed many issues like instance derivation of type classes and the obscure syntax (I think he used a word like incongruent). He was desperate even after I told him that he will face with very similar issues under Clean. Well, in my opinion, he will have a great time after getting hang of all that! ;-)

Haskell optimization

edit2: added Real World Haskell link via Mr. baja :-) (edit1: tiny formatting correction) Chapter 25. Profiling and optimization from Real World Haskell by Bryan O'Sullivan, Don Stewart, and John Goerzen Acovea (Analysis of Compiler Options via Evolutionary Algorithm) - this is compatible with virtually all compilers Evolving faster Haskell programs via Acovea - 18% runtime reduction in one case, even for hand-tuned code! Haskell as fast as C: working at a high altitude for low level performance - this shows that introducing higher abstractions shouldn't automatically cause a slowdown Map fusion: Making Haskell 225% faster a similar article HaskellWiki: Performance/GHC optimization tricks and tips to apply by hand And a little reminder about the secret option used during our discussion on performance analysis: ghc -ddump-simpl $FILE > core.txt

Which one is better, functional or logic programming?

The following paper illustrates that you don't always need to decide: Expressivity of Functional-logic Languages and their Implementation by Juan José Moreno Navarro, LSIIS - Facultad de Informática, Universsidad Politécnica de Madrid It first shows simple problems in which one or the other is superior. Then it goes on to plot a possible implementation of a hybrid language in detail.

Lightweight web browsing as I do

edit: tiny formatting correction I usually browse the web with many instances of the graphic links2 (my own patched version) and Epiphany concurrently, depending on the complexity of the site in question. When I was on Firefox, I used flashblock to lighten the load on my rusty old processor. I did hack it up for Epiphany around the time I made the switch, but gave up on it sometime later, as the exact blocking scheme looked pretty inefficient. I.e., I could sometimes observe an embedded object loading and taking up a lot of CPU time until the blocker has hidden it from sight. I never cared to come up with Java blocking similar to NoScript on this browser. As I rarely used it anyway, I simply removed the Java plugin package from my system, and extracted the Flash plugin to a subfolder of my profile directory. A hackish script of mine deleted or recreated a symbolic link to the plugins on demand, which was basically the only course-grained way I have been controlling this up until today.

Refactoring driven development instead of complete rewrites

I happen to share Joel Spolsky's view on the question of whether it's worth it to rewrite from scratch . He goes into great detail to show that you'd be almost always better off to reuse and refactor as much as you can from an evolutionarily tried and mostly working solution. He puts it as follows: The idea that new code is better than old is patently absurd. Old code has been used. It has been tested. Lots of bugs have been found, and they've been fixed. There's nothing wrong with it. It doesn't acquire bugs just by sitting around on your hard drive. He then goes on to analyze some of the most prominent issues that could lead the development team to consider a rewrite, and how to solve them without throwing away code. Nevertheless, would you be surprised if I shared that, according to my limited information, some modules of a certain programming language refactoring tool go through regular rewriting from scratch? It seems that not all eat their own dog food.

Code sample formatting I use here

You may have noticed that I mostly use <code> tags instead of the more conventional <pre> to signal source code. Although the <code> tag was invented to show HTML markup, and mostly one-liners of those too, I find them more convenient for two good reasons. One is that I usually publish source code instead of prose, so using <code> is the semantically more appropriate one of the two. The second is a practical one: by definition, preformatted text does not support reflowing by the end user. Although that does make sense in most cases, especially for layout-based languages like Haskell, however, introducing scroll-bars in small windows or on embedded devices is a major nuisance. Your layout is toast even if you only have one or two lines that are too wide in the source. Though, I do try to prevent the former case as much as possible. This question is a usability issue, as in my opinion, it's much better to fiddle a bit with deciphering the one or two lines

The code escaper I use for this blog

Edit: numeric HTML escaping added (not Unicode compliant); minor refactoring (readFile and writeFile improvement, some renames) Previously, I had two bash scripts for this task, but ironically, I had escaping problems within them, so I've decided to go for the clean, well-written solution below. I usually patch issues like this in my scripts, but sometimes it just isn't worth it. Fixing these is more akin to juggling, than to real bug fixing. So this is what I use from now on: import Prelude hiding(readFile,writeFile) import qualified Prelude(readFile,writeFile) import System.Environment(getArgs) import Data.List(group) import Data.Char(ord) data FileName = FileName String readFile (FileName s) = Prelude.readFile s writeFile (FileName s) d  = Prelude.writeFile s d toHtml = concatMap code where     code '&' = "&amp;"     code '<' = "&lt;"     code '>' = "&gt;"     code c | ord(c)<32 || ord(c)>126 =

Three-phase AC voltage generation with triple software PWM

This is one of the assembly programs I could be kind of proud of. It's composed of a heap load of macros and is built up in an almost completely neat, high-level hierarchical structure. I could post some snippets if anyone is interested. After making it build, it needed very few compile and test cycles despite the fact that I haven't programmed such a platform in years. I can recall one real, non-trivial defect that needed a second thought. It took some time of analyzing the (soundcard-based!) scope data to arrive at the conclusion that the embedded table contained inverted data (or something similar). Thus, actually the shell script was in (logical) error that generated the data table. After this correction, all three outputs of the device were verified to generate perfectly shaped (unfiltered) sine waves. This was a nice feat, as the generation of the three outputs were implemented in an unintuitively tangled way in order to maximize output resolution.

Nice cross-platform puzzle framework and collection

You can find some very nice and small, MIT-licensed open source puzzles at Simon Tatham's Portable Puzzle Collection , they are all both downloadable and playable online. They're also available from the official Debian/Ubuntu repositories as a package named " sgt-puzzles ". An interesting feat of these, is that they are being developed under a cross-platform abstract board-game framework for C. The mid-end provides some common higher level game-oriented routines. The back-end supports executable generation in the following formats: native Win32, native Mac OS X, Unix/GTK and Java applets - all from the same C source! Note that I planned to design something similar in the future, but using much higher level domain-specific languages. You will find out more about my plans in a future post.

Nice and clean bash scripting for dialyzer dependencies

edit2: New escaper run. edit: Backslash is fixed now. I made a nice script that checks an Erlang source tree for base library dependencies. I needed this in order to speed up the system library PLT building analysis phase of the Dialyzer on my old computer. The trivially implemented algorithm is only an approximation based on sed-processed program text, but according to my review it's should almost never generate a smaller set of packages than a proper parser. Note that even a proper parser would have problems with the pathological cases which this simple one would fail on. The style is, however, much more interesting if you take a look at the attached code. What do you think about it? #!/bin/dash ##### library code ### # unpure! debug(){  [ -n "$NDEBUG" ] &&   echo "DEBUG:" "$@" >> $LOG } # unpure! warning(){  echo "warning:" "$@" >> $LOG } # unpure! error(){  echo "error: ${1}!" >&2  sleep 1  

My Psion is sick - I'm doomed!

The backlight is out, what am I going to do now?! Nah, actually I would only be in trouble if it wasn't a sunlight readable, electroluminescent transflective FSTN LCD! :-) You see, my current usage pattern involved less than 1% of backlight use, and in almost all cases it was more of a convenience than a necessity. It is, however, a sign of deterioration of the flexible cable, so I am getting a bit worried. I am prepared for all possibilities.

Optimized Java bytecode scheme for embedded devices

There exist interesting research related to reducing the resource demands of Java runtimes. Squawk takes this to the extreme by providing an almost completely standards-compliant implementation of the CLDC , the smallest configuration of J2ME , on which MIDP is layered. It's also of importance to note, that the source is almost entirely written in Java itself! They have worked around the issue of implementing lower level routines by falling back to a common subset of Java and C for those parts. That's a nifty trick, and I wanted to blog about something similar long time ago. It's a good thing that I'm not dreaming all the time and many of my ideas can be realized in practice. A complete runtime including the interpreter and the garbage collectors of the said takes up 25KiB of ROM. The standard CLDC library takes up a further 146KiB of ROM when uncompressed, or 64KiB if compressed. To execute the null program, it needs about half a kilobyte of RAM for the Java heap and

Is Java a slow language?

You can have a look for yourself at the Computer Language Benchmarks Game: Java vs. Erlang ( Erlang in the industry ) Java vs. Scala Java vs. C# Mono (note that I'm told that Mono's runtime may be inferior in some aspects to the official .NET CLR) Various approaches to detailed analysis: Java performance (Wikipedia) Java is Slow Revisited (2007) Performance of Java versus C++ by J.P.Lewis and Ulrich Neumann, Computer Graphics and Immersive Technology Lab, University of Southern California (2003) Java theory and practice: Urban performance legends, revisited (IBM, 2005) Java Performance (Code Instructions) All in all, we can conclude that neither Java, nor it's much higher level sibling, Scala deserves a reputation for being slow, though memory usage does show room for improvement. However, I would look forward to seeing results of the game tests ran under different virtual machines. I am working on a post about efficient high level embedded programming (including Java),

Progress report for this blog

Let's get back to work. Before you lose all hope, I'll cheer you up with the fact that I'm not at all out of ideas. There are dozens of articles of mine in the works, actually in excess of fifty, which you could enjoy soon! Most stand pretty good, many of which are almost complete. Others need to get decomposed, refactored, supplemented with additional references, illustration or corrections. I've taken your expressed wishes into consideration, so there are many hardware related among them now.

Leading edge language type system research: Cayenne and Epigram (links)

Cayenne (programming language) is implemented in Haskell and provides a very rich research alternative with dependent types Epigram (programming language) is based on ALF , and for which the compiler can certify a proof of correctness thanks to the strong type system also based on dependent types At first, those listed weren't of an interest to me, but the more I browse through their materials, the more I'm reminded about my goals laid out about an ideal programming environment many years ago. If only these things provided a less ugly syntax... :-)

Program Erlang/OTP without the syntax quirks

I think I can say that you can be pretty comfortable with Erlang after a while, but you never forget how clear and conscious Haskell (or Scala, etc.) code is compared to that. If only you needed to type less punctuation and if it had static types... Anyway you can both have your pie and eat it according to some projects: Targeting a Haskell compiler for the Erlang BEAM The following were newbie hacking attempts at transforming Haskell syntax to Erlang syntax at the source level: The Haskerl index of some related mails [erlang-questions] Any recent progress on Haskerl? (the project page seems to be unavailable at the moment)

Haskell vs. Erlang vs. Scala

Comparing Haskell , Erlang and Scala by way of examples and intelligent analysis: An Example Syntax in Haskell, Erlang and Scala (blogtrader) The multicore crises: Scala vs. Erlang (a detailed and informed analysis by Niclas Nilsson and nice follow-up discussion) Programming language shootout game on x86-64: Haskell Programming language shootout game on x86-64: Erlang Programming language shootout game on x86-64: Scala Of course, all three are great languages, with Haskell having an edge over the competition in pureness and syntax neatness, Scala in technology, experience transfer and sometimes syntax, while Erlang has the edge over provenly great concurrency, scalability and a beginner-friendly straight-forward syntax - in exchange for being a dynamic language. Expect to read more introductory articles on Scala in the future.

My interests at Wikipedia

I've uploaded a preliminary version of my interests to the Wikipedia user page of bkil . I'll keep you posted if I find something else interesting, but you could also follow the logs. Your suggestions are welcome!

Oh no, I've been infected by a virus again!!

Edit: typo fixes Yesterday, I needed to get a monochromatic ID picture printed to photographic paper and while at it, I also needed to print a page of text. I've visited a nearby mall in the morning for this reason. To my surprise, they had decent automated kiosks just for this purpose at the photo specialty store. Naturally, none of them could read my flash key drive, even after asking for assistance from the pretty lady at the counter. She said this does happen sometimes. Thankfully everything went fine after manually selecting the image at her computer, as the drive was read in a second there. Probably too many files on the drive for the bogous software to cope with. Anyway, the whole process about five to ten minutes. After that, I went to the normal printing booth for my other task. The guy was busy on the phone for about five minutes while he was acting as if he was refilling paper. After hanging up, he asked for the place where he could find the items to print. I quickly pro

Playing with lambda elimination and point-free style

It was a long time since I've last played with Haskell, so I decided to do a bit of lambda elimination as an exercise. let f=(\x y->x++y);g=(\x y z->x++y++z)in f(g "1""2""3")"4" let f=(++);g=(f.).f in f(g "1""2""3")"4" let f=(++);g=(f.).f in (f(g "1""2""3"))"4" let f=(++);g=(f.).f in (f.(g "1""2"))"3""4" let f=(++);g=(f.).f in (f.((g "1")"2"))"3""4" let f=(++);g=(f.).f in ((f.).(g "1"))"2""3""4" let f=(++);g=(f.).f in ((f.).g "1")"2""3""4" let f=(++);g=(f.).f in (((f.).).g)"1""2""3""4" let f=(++);g=(f.).f;h=((f.).).g in h"1""2""3""4" let f=(++);h=((f.).).(f.).f in h"1""2""3""4" let

Splitting this blog by categories?

I am considering a split in the long term if that would improve user experience. What I still need to figure out is what to do with multidisciplinary articles.

I plan to use summaries and shorter posts

I have been thinking about the previous recommendation of a friend of mine, and it does sound reasonable to expect to read about as narrow subject as possible in a single post. The problem is that it happens to me often that I mix in articles of mine between average blog posts. I think it would be a much better choice to build professional articles for my website in the said topics that could contain figures, statistics, research, references, reviews and comparisons, while I would only post short summaries of the said articles here.

My new POLL about topics of interest

You can take part in my newest poll at the top or post comments about it here. I'd be honored to hear from the few loyal readers of mine again this year, but naturally all participants are welcome! Stay tuned, as I will be back to we blogging soon after finishing my Erlang duties.

The superiority of open source by Frank Lloyd Wright

This is one of the best quotes I could find about the superiority of open source software: "The physician can bury his mistakes, but the architect can only advise his clients to plant vines." — Frank Lloyd Wright, New York Times Magazine (4 October 1953)

Unintentionally formatting your system drive is a bad idea

One day, I was playing with a chroot jail. This whole incident has taken place some months ago. I wanted to test if I could install software from user mode because my apt-get was doing a system update. Well, building from source via "apt-get -b source" would have also solved the issue, though dependency handling in this case is not automatic if I understand correctly. In order for this process to take as little overhead as possible, I wanted to simulate a manual copy-on-write filesystem by creating links to the parts that are common with my root system, and recreating directories which are partially different. I first tried to use symbolic links, but I had to realize that relative links that point outside the sandbox were dysfunctional. Hence I made a hardlink for my root in the chroot. Well, it was a read-only bind-mount to be more exact. Note that I did succeed previously with a different system and kernel (Gentoo 2005.x) by using symbolic links, that's why I gave it a

Wooden house good idea after all

I had a conversation with a friend of mine some years ago about buildings made out of renewable material. Well, it wasn't actually a healthy argument, as I scared the guy off with a few tongue-in-cheek expressions, like the example of Tom and Jerry. :) I wanted to continue, but sadly, he said he was convinced and changed his mind. Nowadays, I myself consider this an ever more viable alternative, given the low ecological footprint and the numerous successful projects in this area. Note that while I have not analyzed the per-year cost of these less durable materials yet, renewable by definition is almost always better than non-renewable. The following links (and many others) seem to imply the same: Build Your Own Affordable, Eco-Friendly House by Dr. Owen Geiger Natural Resources & Sustainability Environmentally Friendly Homes by Adam Downing Wooden Eco-buildings - energy efficiency in LCA perspective

Social interaction is prime

Who would have guessed that even mathematical logic is not a pure expression of general intelligence, but rather a device evolved directly out of simple reward-punishment and social exchange? wiki: Wason selection task Okay, perhaps the amount of practice done in this area by most humans could also provide part of the explanation.

Chopping a long string into smaller ones toy

I made a great tool I can't do without from now on! ;-D Update#1: added null string checking, renamed "i" to "s". Update#2: upgraded output format, added BASH version! Here's the Haskell source code: import System.Environment(getArgs) import Data.List(unfoldr,intersperse) chop k | k>0 = unfoldr f where  f [] = Nothing  f s  = Just $ splitAt k s main = do  [k,s@(_:_)] <- getArgs  let out = show . concat . intersperse " "      res = chop (read k) s  putStrLn $ "filter(/=' ')" ++ out res Typing: ./chop.hs 27 Gives: filter(/=' ')" 09/05/chopping-long-string- into-smaller-ones.html" Or if you prefer, you could alternatively opt for the following BASH routine: main(){  printf 'echo "'  printf "$2"|sed -r "s~.{$1}~& ~g"  echo '"|sed "s~ ~~g"' } This one

Substituting power plant fired switchgrass for ethanol

Edit: fixed dead link Just as I've been telling everybody for many years now: the internal combustion engine is unsustainable. Note that a possibly even better alternative would be some strain of algae. Also note that I am nevertheless still advocating commuting to work by electric motorcycle or bicycle for most people! UK (REUTERS): Researchers eye better use for biomass than ethanol

Quine in Erlang

How could I have forgotten about the friend of mine who's fond of Erlang? :-D -module(q). -export([s/0]). s()->io:format("~s~p.\n",[p(),p()]). p()->"-module(q).\n-export([s/0]).\n\ns()->io:format(\"~s~p.\\n\",[p(),p()]).\n\np()->". Here's another one for the Eshell REPL: fun(P)->io:format("~s\n~p).\n",[P,P])end( "fun(P)->io:format(\"~s\\n~p).\\n\",[P,P])end("). And as I know he's also in love with LISP, here's a Haskell variant rewritten in that spirit: (\ (x)-> ((++) x (show x)))"(\\ (x)-> ((++) x (show x)))"

Fixing grey background (default bgcolor) in graphic links2

#Installing dependencies if you can become root is easy (Debian names shown): apt-get install pkg-config libpng12-dev libjpeg62-dev xorg-dev # libssl-dev libgpm-dev libbz2-dev #Fetch the web browser source: mkdir mylinks && cd mylinks && apt-get source links2 #Here's the magic, changing the default graphics mode background color from grey to white: patch -p 0 <<END diff -u links2-2.1pre37.old/default.c links2-2.1pre37/default.c --- links2-2.1pre37.old/default.c 2008-06-21 18:05:53.000000000 +0200 +++ links2-2.1pre37/default.c 2009-05-09 22:10:48.000000000 +0200 @@ -1453,7 +1453,7 @@ struct rgb default_vlink = { 255, 255, 0, 0 }; struct rgb default_fg_g = { 0, 0, 0, 0 }; -struct rgb default_bg_g = { 192, 192, 192, 0 }; +struct rgb default_bg_g = { 255, 255, 255, 0 }; struct rgb default_link_g = { 0, 0, 255, 0 }; struct rgb default_vlink_g = { 0, 0, 128, 0 }; END #Now we can compile the software: cd links2-* && ./configure --with-x --enable-

Quine in Haskell

I've constructed a neat little quine in Haskell, the popular research language we all adore. ;-) It's so short, I could have pasted it right into the title! :-D putStr(p++show p)where p="putStr(p++show p)where p=" That's what I like about Haskell: the solutions you write in it are usually elegant, conscious and close to the problem space in representation. You read the above source as follows: print out the program accompanied by a quoted (shown) version of the same, where the program is just what I said. Can you put it any simpler than that?! I've first started on a traditional route by introducing constants for backslash, quotation mark and all that, until I've realized how foolish I was. As you may have already known, Haskell has a handy function called 'show' that does all quoting for you. I've been using that all over the place if you have read any of my sources, so I'm not sure why it slipped my mind. Sometimes we overlook the most o

A little background information about this blog

I write almost all articles and text on my Ericsson MC218 when I'm traveling and have nothing better to do. Note that I can touch type almost as fast on my mini-Dvorak as on my full-sized one, so this is by no means a limitation (>55WPM)! :-) When I get home, I upload them to my PC, covert them with a simple script of mine, proof-read them and run a second pass of spell checking. I then put them in a waiting queue based on completion ratio and importance, sometimes doing a bit splitting at the same time. Once in a while, I take one from the top of the stack and publish it. Hence for me, there's no such thing as lack of time or inspiration! :-D

POLL: How do you use this site; posts you check

Note that checking multiple options is allowed in both polls. I forgot to post an entry about it, but one of my most die-hard readers has already noticed! Actually, I think the majority of my readers have already voted... XD The low readership is expected because of many issues with the articles, like the abstract, specialized, mostly time-invariant knowledge and language. I believe that to reach as far as possible, especially of such narrow-scope material, you need to write in a suitable language. Toki Pona and Lojban would have been my second choice... ;-D

Ergonomics of the computer mouse and keyboard from a hardware perspective

It's a pretty interesting fact that we still use the not so ergonomic kludges of many decades ago for our daily work. Let's just skip keyboard layouts altogether, as we all know the truth about them! ;-) You see, for technical reasons, ergonomics wasn't considered for these input devices by the original designers. They simply tried to solve the engineering problems of the day - and they have succeeded! They always have two driving forces: one, how similar problems have been solved in the past and two, how to construct a device as simple as possible (i.e., to invent as few things as possible at once). They are initially dominated by the limitations of technology of the day, while later on, they must keep in mind to provide an easy migration path for earlier users of the same or a similar invention ( Wikipedia: Path dependence ). For example, the typewriter has influenced the computer keyboard in all practically possible ways - i.e., they tried to mimic as closely as possibl

Embedded water content of goods

Have you been living a water-conserving life up until now? Think twice before you answer: BBC News: World's major rivers 'drying up' BBC News: The ripple effect of cutting water

Double clicking is evil

To both a novice and an advanced user, there is no conceptual difference between pressing another button on the mouse and double clicking. Well, actually there is one: you can proceed with superior comfort and greater speed after a bit practicing of the former, while the latter will remain awkward forever. Therefore, it could greatly improve usability if the pointing device had additional buttons to replace this vulgar action. Chording (simultaneously pressing multiple buttons) is also an option. See Wikipedia: Chorded keyboard for more information. As you probably already know, I'm all against any form of double, triple or even quadruple pushing the same button on either the keyboard or the mouse. As a historical note, I'm positive that no human with expert knowledge in the field - or even having any trace of commonsense - would recommend such crippling of ergonomics and usability as banging the same button in succession. I think they have implemented this because the interfa

A few things solved from the list about Lenny

These things have been working for weeks now, it's just that I've been too lazy up till now to write it all down! :-D I have found a new workaround for the notorious Xv flickering bug in my mature S3 Trio3D video card. I have tested it in fullscreen before but it invariably makes it worse: it only displays (the upper) half of the canvas (while the other half is blue). However, I seem to have forgotten to experiment more on this issue, as resizing the window seems to alter the bug. It's plainly correlated to the window size: shrinking it makes it worse, while enlarging it makes it somewhat better. This is so pronounced, that enlarging it to full-window (not fullscreen) fixes it entirely! :-D In the same session a few hours back in time, the weird focus loss bug has happened to me yet again! I have been running Epiphany with the proprietary flash plugin, a flash video has just loaded in the very instant that the (unstable) MPlayer from debian-multimedia has brought up a windo

Partition to enhance the performance of your hard drive

Most users up until now had only a single partition on their single rotating media disk in their personal computers. Common operating systems did not (and some still not) encourage their end users to organize their data into partitions in a different way. Naturally, this would be both an overkill and a mental overload for most users. However, an advanced user should not turn away from the possible benefits of restricted fragmentation and lowered seek times. Also consider the ease of backing up only the partitions that contain truly precious data. A few words about fragmentation. Most random access file systems today use block-sizes of discreet steps (sometimes only a single block size). External fragmentation is the physical discontinuity of logically continuous stored entities (files). Internal fragmentation is the overhead of this block scheme. Naturally if a file is composed of many identically sized, relatively large buckets, then most files will have some buckets that are not com

Improving the CPU usage of MPD (Music Player Daemon)

I have added format "48000:16:2" to the audio_output section and samplerate_converter 4 to the main body of ~/.mpdconf . This has reduced mpd's CPU usage from 30-40% to less than 5%! I should have done this before. I found out about this issue by doing web searches, but I have later encountered the neatly written summary linked below. In short: good quality (double?) software scaling is not very economical.

Miscanthus grass - an energy crop much more efficient than canola

The following article is from 2005, but I think it's still relevant. Please correct me if I'm in error. What's Next In Science & Technology: Hybrid grass may prove to be valuable fuel source

When will people learn to properly escape preformatted blocks?

I've noticed this when I first posted source code in Haskell to this blog few months ago. I think I have encountered this problem before (maybe even multiple times!), but it was so long ago that it slipped my mind. So it happened that I have posted unescaped code between <pre> and </pre> tags . This is trivially a silly act (imagine if your source code had </pre>...) and the standards are also clear on this issue: HTML 4.01 Specification: Character entity references [], Using character entities and NCRs: When to use escapes []. Always remember to escape at least &lt;, &gt; and &amp; ! You may be wondering how I noticed that in the first place while most web browsers today are so forgiving. Some years ago when I first committed this error (perhaps with comparison operators), I have fixed it myself because on second thought it was trivially ill formed (and I have also looked it up in the standard later). But this time, it was by accident! :

Equality is only a dream

Such a touching story: IQ Will Put You In Your Place - By Charles Murray (From the Sunday Times) Breaking the Last Taboo [related]

Shredded tires to cover landfills (link)

I like simple, cheap (=energy efficient), realistically implementable (feasible) and proven eco-friendly methods such as the following: edit of 2014: sorry for the broken link, here are some fresh ones: SHREDDED TIRES A CHEAP, ENVIRONMENTALLY FRIENDLY WAY TO COVER LANDFILLS (James E. Kloeppel, Physical Sciences Editor) Shredded tires a cheap, environmentally friendly way to cover landfills (

Binary numbers toy in Erlang GS graphics

Because of popular demand, I have ported the previous example to Erlang using it's built-in GS package. Enjoy! :-D All code and text in this post is Copyright (c) [also known as bkil], 2009; and is licensed under the GNU GPL v2. Refer to the standard license texts from June 1991 for exact conditions. Here is an example link: Here's the core (simbins.erl): -module(simbins). -export([radix/3, binaries/2, simbins/1]). %% Radix conversion with LSB output. radix(_,0,_) -> []; radix(R,W,N) -> [N rem R | radix(R, (W-1), (N div R))]. %% A full-matrix transpose stub. transpose([H|T]) when is_list(H) -> Append = fun(V, M) -> lists:zipwith(fun(E,L) -> [E|L] end, V, M) end, Vector = fun(L) -> lists:map(fun(E) -> [E] end, L) end, [RH|RT] = lists:reverse([H|T]), lists:foldl(Append, Vector(RH), RT). %% 'binaries' is a solution to Paul R. Potts's idea. %% Prepend `lists:reverse( ` to get MSB. bi

Binary numbers toy in Haskell SOE graphics

I've been browsing Mr. Paul R. Potts's blog when I stumbled across a simple, yet neat idea. I was not quite satisfied with the lengthy solution given, so I decided to construct something similar looking from scratch. I'm using the Hugs and GHC built-in HGL/Graphics.SOE package. See the result below. Expect to see more later. All code, text and the 5 images in this post are Copyright (c) [also known as bkil], 2009. I place the images in the public domain. The code and text are licensed under the GNU GPL v2. Refer to the standard license texts from June 1991 for exact conditions. Here is an example link: Here's the core (Simbins.hs): module Simbins where import Data.List(transpose) -- Radix conversion with LSB output. radix _ 0 _ = [] radix r w n = (n `mod` r : radix r (w-1) (n `div` r)) -- 'binaries' is a solution to Paul R. Potts's idea. -- Prepend `reverse . ` to get MSB. binaries w = transpose . map (radix

Problems with Debian Lenny

If you followed this blog, you would know that I have been testing this distribution for some time now. It's still yet to be released, but I am generally satisfied with it's quality. Etch was also nice and I still have it installed and updated. However, I needed newer versions of a few applications badly (Erlang, Emacs, Epiphany) and libraries (glib 2.10). It also has some annoying bugs lurking around (like sometimes Xorg fails to resume after waking from hibernate-disk). Most issues I list below about Lenny are either notorious upstream bugs, or are related to my aging hardware, so they shouldn't be taken too seriously. hibernate-disk (1.99-1)+MPD [0.13.2]+via686a [Linux-image-686/2.6.26+17]: sound output doesn't resume after hibernation, and MPD seems to hang with 100% CPU usage until either it is killed or some other application does proper sound output. Fix: either killall mpd&&{sleep 5;mpd;} or aplay/dd something (perhaps even patch mpd). Workaround: put th

My luck with google on Valentine's day (UNIX Epoch 1234567890)

The day before yesterday, something remarkable happened. I was preparing to go to sleep and turn my computer off. I have closed all applications and almost hit the power button when something flashed into my mind. I forgot to check something important: I wanted to do a web search, so I fired up Google. And to my great surprise the standard Google logo was replaced with a very interesting one. It said the following: Google $ date +%s 1234567890 I have understood that immediately, but I hesitated for a few seconds because of the surprise. When I typed it in a terminal, the output was as expected: 1234567897 (because of the overall reaction time). I clicked on the logo to see the background story. I wonder for how long that logo was enabled. Was it there for only a second? Am I really so lucky to have snitched the exact second of that happening?! Add to the fact that it was Friday the 13th in UTC (but already Valentine's day in CET). It's a pretty odd event anyway if you

Enumerating all subsequences for password recovery v0.1

I needed to write this trivial Haskell sample for a script of mine to crack one of my passwords! :) You see, I do keep some of my passwords written down on paper. But it's not any ordinary piece of paper: it's a paper full of random characters! :-D It does help a lot against nosy audience. I also keep it with me next to high value banknotes, so I would say it's well protected. I eventually memorize most passwords this way, but until then, I only keep the position of it in mind. It's a bad habit of mine, and I haven't been doing this before. I have only recently found myself in a need for replacing a lot of my old passwords. If I could be sure in that every workstation I sit at will have md5sum installed at the very least then a single master password would suit my needs. Come to think of it, I could put my little Psion computers in order just for this very purpose! :) You have probably heard of (cryptographically secure-) hashed password generation before. So let