| cabal-install haddock documentation - another round of workarounds |
[Nov. 8th, 2009|10:35 pm] |
Today I've found a way to
cabal-install
offline documentation – with source hyperlinks! – for a
Haskell package.
(The reddit
link was quite helpful by pushing me in right direction.)
To obtain documentation without source hyperlinks you just
- run `cabal install' with `--enable-documentation' option ...or
- enable `documentation' parameter
in ~/.cabal/config
Then reinstall the package with `cabal install --reinstall'
command. Documentation will appear in
~/.cabal/share/doc/PACKAGE-VERSION/html/ directory.
But if you want proper documentation – with `Source'
links to the right of declarations – try these commands
(replacing `iteratee' with your favourite package):
$ cd /tmp
$ tar -xzf ~/.cabal/packages/hackage.haskell.org/iteratee/0.2.4/iteratee-0.2.4.tar.gz
$ cd iteratee-0.2.4
$ cabal configure
$ cabal haddock --hyperlink-source
## NOTE:
## * Make sure `documentation' is *disabled* in ~/.cabal/config.
## * Don't use `--enable-documentation' in `cabal install' command.
## Otherwise links to source code will be omitted from documentation.
$ cabal install --reinstall
That's almost it. But source code pages will not be
syntax-highlighted, because hscolour.css is missing. I've
used a workaround:
$ cd ~/.cabal/share/doc/iteratee-0.2.4/html/src
$ ln -s /usr/share/doc/ghc6-doc/libraries/Cabal/src/hscolour.css
Now everything is sweet (i.e., documented and hyperlinked to
sources).
This post is a reminder to myself, which may possibly help some
other haskeller.
SEE ALSO
- Cabal
ticket #534:
cabal haddock should --hyperlink-source by default
- Cabal
ticket #517:
make cabal install command support haddock options
(Opened 8 months ago. Patch available.)
- Debian
bug #500924:
Should have a system-wide hscolour.css
|
|
|
| Making Motorola playlists (.pla files), part 3 |
[Nov. 1st, 2009|07:24 pm] |
(See part 1 and part 2.)
Motorola SLVR7e L7e phone has FAT16 filesystem on its memory
card. Using wikipedia article on
FAT16 design we will
locate .mp3 entries in the filesystem and try to
correlate them with .pla file (the playlist).
FAT16 consists of boot sector (1 sector is 512 bytes), two File
Allocation Tables (FATs), root directory, and data region. Boot
sector specifies various parameters of the filesystem. The ones
of our interest are:
- [number of] sectors per cluster,
- sectors per FAT,
- maximum number of root directory entries.
Note that FAT16 entries – including boot sector parameters
– are little endian.
We will use this helper function to read values from the
filesystem:
read_at() {
case "$2" in
1) t='C';;
2) t='v';;
*) echo 'Usage: read_at OFFSET SIZE' >&2; return 1;;
esac
dd if=/dev/sdb1 bs=1 skip=$1 count=$2 2>/dev/null | \
perl -wspe '$_ = unpack("'$t'") . "\n"'
}
And these are the boot sector values we need:
$ read_at $((0xd)) 1 # sectors_per_cluster
32
$ read_at $((0x16)) 2 # sectors_per_FAT
239
$ read_at $((0x11)) 2 # max_root_entry
512
( Read more... )
To be finished... |
|
|
| Быстрый нудный пост (про проблемы с Иксами) |
[Oct. 25th, 2009|01:20 am] |
Итак, проблема
Тормозит отрисовка окон: scroll и при перетягивании мышью.
(Изначально "проблем с Иксами" было больше, но я вам про них не
расскажу, чтоб не сбить нарратив.)
Решение
Поставить драйвер NVIDIA.
Реализация
...Затрудняется тем, что драйвер из пакета `nvidia-kernel-source'
не
собирается для ядер старше 2.6.26. Я его пропатчил, как мог (чтобы
собрался с двумя директориями linux-headers-*-686 и
linux-headers-*-common, и свежим API), но
Xserver отказался с запускаться с тем, что получилось.
Решение
На работе времени мало. Значит, надо принести туда исправный
ноутбук из дому, а глючную Тошибу взять на выходные на "debug с
пристрастием".
...Пятничным утром, благородно дав мне возможность ввести в строй
замену (перебросить почту, всё такое), ноутбук-с-тормозящими-исками
перестал реагировать на клавиатуру. За что был выключен кнопкой (в
последствии — неоднократно).
Новые симптомы
Xserver перестаёт реагировать на клавиатуру. Мышка лазит, но толку
с неё. "Подвисаем" по-разному: один раз не смог даже username вбить
при входе в сессию, другой раз только успело xterm нарисовать; обычно
— вскоре после начала работы.
Отладка
Есть два полезных документа: ServerDebugging
на Xorg Wiki и Xserver Debugging
Hints. Они убедили меня поставить пакет с отладочной информацией,
`xserver-xorg-core-dbg'.
После этого оставалось:
- дождаться зависания иксов,
- зайти с другого компьютера по ssh,
- gdb /usr/lib/debug/usr/bin/Xorg `pgrep X`,
- увидеть бесконечный цикл внутри модуля `nv' (пакет `xserver-xorg-video-nv').
Победа
Исправляем в /etc/X11/xorg.conf драйвер с "nv" на
"vesa". Рестартуем xdm (всё в том же ssh). И прекрасно работаем
– стабильно и достаточно быстро – с vesa драйвером.
Резюме
Посылаю драйвера nv и nvidia в виртуальную задницу. (Сидеть им там
не пересидеть, в 3D игры я не играю.)
Из полезного: настроил русский язык в текстовой консоли. (Всего-то и
надо `console-cyrillic' поставить.)
Пост получился ослепительно нудным, но я предупреждал. Удачи! |
|
|
| Болею |
[Oct. 18th, 2009|01:12 pm] |
С лицом, измученным и серым,
На белой смятой простыне,
Как жертва бешеной холеры,
Лежит коленками к стене.
Протяжно стонет, как при родах.
Трясется градусник в руках.
Вся вековая боль народов
Застыла в суженных зрачках.
По волевому подбородку
Струится за слезой слеза.
Он шепчет, жалобно и робко:
"Как ты с детьми теперь – одна?.."
В квартире стихли разговоры
Ночник горит едва-едва.
Темно. Опущены все шторы.
У мужа – тридцать семь и два...
Это про меня.
(Списал отсюда. Автор
неизвестен.) |
|
|
| Fixing dosbox arrow keys |
[Oct. 14th, 2009|01:31 am] |
Problem
Arrow keys don't work in dosbox-0.72 .
Details
`dosbox -startmapper' shows that `left' key has become
`right alt', `up' — `print screen'; `down' and `right' keys are
not recognized.
Solution
Unset `usescancodes' in your ~/.dosboxrc.
$ cat ~/.dosboxrc
[sdl]
usescancodes=false
NOTE: This bug may be fixed in 0.73 (there is evdev mentioned in
the changelog).
See also
Debian bug
#549611 |
|
|
| Very Public или Всесмывающий поток семантики |
[Oct. 12th, 2009|04:40 pm] |
В C++ не хватает степеней "публичности" для элементов классов. В [больном на голову] коде часто встречается такое:
class Foo : public Bar {
public:
enum One { one = 1 };
enum Two { two = 2 };
public:
Foo(int n);
virtual ~Foo(); // the empty body is defined elsewere
public:
int val;
protected:
enum Three { three = /* a lot */ one + two };
};
C+++ должен понимать, что перечисления One и Two — публичные, конструктор и деструктор — очень публичные, а переменная(-член) — совсем публичная(-чный). |
|
|
| () |
[Oct. 10th, 2009|11:45 pm] |
Надо же! Оказывается, доклады на тему ``Business-Critical System
vs. Your Favourite Functional
Language'' популярны. |
|
|
| Making Motorola playlists (.pla files), part 2 |
[Oct. 6th, 2009|04:32 pm] |
(See part
1.)
As long as .pla file is binary, we will view it in hex. Here's a
hex dump of a playlist containing first three tracks
of Led Zeppelin
IV:
$ hd lz4.pla
00000000 00 03 00 01 00 00 00 00 01 40 00 04 00 00 3d 60 |.........@....=`|
00000010 01 40 00 0e 00 00 3d 60 01 40 00 02 00 00 3d 5f |.@....=`.@....=_|
00000020
This playlist is named `lz4.pla'. We will refer to it below.
Header
I've created several playlists "manually" and noticed that the
second byte is always equal to the number of tracks in playlist (`03'
in lz4.pla). Bytes with offsets 0 and 2–7 are the same for all
playlists I've seen. Thus we can guess the format of .pla
file header:
00 <nn> 00 01 00 00 00 00,
where <nn> is number of tracks in playlist.
Entry
Playlist header is followed by entries — 8-byte-long
track specifications. There are as many entries as there are tracks
in a playlist (lz4.pla file has three: address ranges 0x8–0xf,
0x10–0x17, and 0x18–0x1f).
When we open playlist in Motorola, we see the names of tracks
included. But there is no chance for 8 bytes of .pla entry to contain
the name of track: the third track is displayed as `03 - The Battle of
Evermore' making a string of 27 characters.
Thus, we can assume that .pla entry encodes position of
.mp3 file within the underlying filesystem.
Continued... |
|
|
| Making Motorola playlists (.pla files), part 1 |
[Oct. 1st, 2009|11:58 pm] |
I've got Motorola SLVR L7e mobile phone. The device is capable of
playing MP3 audio files, and I use this feature occasionally.
Once a musical album is uploaded to phone's microSD, it is better to
create playlist, otherwise playback will stop as soon as the
first track finishes.
And while uploading albums is very simple (you just copy
directories like you do with ordinary USB memory stick), creating playlists
on L7e is pain.
( What's the problem with playlists? )
Continued... |
|
|
| %-/ |
[Sep. 7th, 2009|05:04 pm] |
(Re: Daily WTF to Ultimate Refactoring?)
Чувствую себя лейтенантом Рипли, которая забежала с зажжённым
огнемётом в склизкую колонию "чужих" с благородной целью (сделать на
этом месте солнечную лужайку с бабочками), но постепенно начала
осознавать масштабы. Подлая "матка" загадила яйцами невообразимые площадя... |
|
|
| Daily WTF to Ultimate Refactoring? |
[Sep. 4th, 2009|11:44 am] |
It ain't easy to profile 2.6K SLOC program made of 3 functions.
PS: I've narrowed the problem: 99.1% time is spent in one of these functions; just 1000 lines of code. |
|
|
| ``Gromit, that's it! Cheese!'' |
[Aug. 6th, 2009|10:51 am] |
Using Debian's required package, you can learn a lot about French cheeses:
$ aptitude changelog login | awk -F\" '/The ".+" release/ {print $2}'
Tome des Bauges
Chevrotin
Banonet
Banon
Chambérat
Le Puant Macéré
Rocamadour
Morbier
Bleu des Causses
Bleu d'Auvergne
...
( Without Debian... ) |
|
|
| "d-a-i" sequences explained |
[Jul. 5th, 2009|12:54 pm] |
Well,
the promised
explanations.
The screenshot
shows work-log.el
debugging session. The "a-a-i-i-d" patchwork you see there is a work
log model (more on this below). A work log is a sequence of dates,
active entries, and inactive entries (the latter include comments);
see example
here.
In short: resolved tasks == inactive, pending ones == active, that's it.
Now. `work-log-hide-inactive' function (`C-c C-h') lets user
concentrate on open tasks, making inactive "noise" invisible.
The first implementation of the hiding function did hide resolved
tasks but also left some dates with no entries at all hanging
void. Like this:
2009-07-03
http://lib/it/processMMS: update scenarios' table
2009-07-02
2009-07-01
import `recsep' to CVS
Note the "hanging" 2009-07-02.
Okay. Let's omit the boring details (head scratching, pencil
sketching, and a couple of "aha!" moments) and goto right to
the way I debugged the damn function...
Here the simplified model of a work log suffice: a "d-a-i"
sequence -- sequence of ['d', 'a', 'i', '-'] characters, where
'd' represents date, 'a' -- active entry, and 'i' --
inactive. Hyphen ('-') is either empty line or the continuation of
previous entry (a task entry in real log can consist of several
lines).
All we need to do is change a bit the hiding function (substitute
regexps, replace `forward-line' with `forward-char', and show the
"hidden" regions in inverted color instead of actually hiding them)
and run it on a bunch of dai-sequences.
Testing input is easy to generate:
import Data.List (permutations)
main = putStrLn $ concatMap (\(x,y) -> x++y) (xs `zip` repeat "-")
where xs = concat $ permutations ["a", "a", "i", "i", "d"]
Given "i-d-a-d-i-d-a-i-" we get:
i-d-a-d-i-d-a-i-
Do you see a hanging date? The hidden (black) region in the middle
should cover preceding date ('d-') but it does not.
Well, you got the idea. Once the testing routine was established, it was easy
to fix the bug.
i-d-a-d-i-d-a-i-
Q.E.D.
* * *
Yes, and while you're here, I'd like to recommend this post:
Benefits
of automated functional testing (was: Why unit testing is a waste of
time)
Have fun! |
|
|
| navigation |
| [ |
viewing |
| |
most recent entries |
] |
| [ |
go |
| |
earlier |
] |
| |
|
|