Sunday, June 20, 2004

* ** ***

Whenever I tex my math or tech homework I'm using lisp as a calculator as it knows how to handle fractions and as I'm using Emacs it's just a buffer away. So yesterday, while checking my calculations I discovered this imho funny piece of lisp code: (* ** *). Which multiply the second-last with the last return value, nothing you would use in a program, but quite usefull in the REPL.

Monday, June 14, 2004

the end is near

The semester ends soon (July 14th), which means I'm learning for exams. Vocabulary and grammar for finnish, vocabulary and grammar for formal CS, ideas & whatsoever for technical CS and IMG (IT, Man & Society). At the moment I'm reading “F2 - Automaten und formale Sprachen”, which will be followed by a short repitition of “F1 - Formale Gundlagen der Informatik”.

Thursday, June 03, 2004

php-complete-function ready for testing

I think I have completed it and would love to have some feedback, especially if it works with XEmacs. You can download it here, before you use it however you should M-x customize-group RET php RET it and set php-manual-path to directory which contains the php manual in many html files or generate a file with one function name per line and set php-completion-file to it. If you want to include completions from your tag file you must visit-tags-file. The key combination for completion is M-TAB, if that doesn't suit you rebind it.

php-completion-table

I did solve the problem of getting the right table and solved a another problem. The right completion table is now computed by etags-tags-completion-buffer and the other problem was that I didn't join the right tables, not having thought about how it was done, the incorret code would do nothing because (mapatoms (lambda ...) nil) should do nothing.

(defun php-completion-table ()
  (or php-completion-table
      (let ((table (make-vector 1022 0))
            (php-completion-buffer (find-file-noselect php-completion-buffer-file))
            (my-tags-table (if (functionp 'etags-tags-completion-table)
                               (with-current-buffer (get-file-buffer tags-file-name)
                                 (etags-tags-completion-table))
                               nil)))
        (save-excursion
          (set-buffer php-completion-buffer)
          (goto-char (point-min))
          (while (re-search-forward
                  "^\\([-a-zA-Z0-9_.]+\\)\n"
                  nil t)
            (intern (buffer-substring (match-beginning 1) (match-end 1))
                    table)))
        (when my-tags-table
          ;; Combine the tables.
          (mapatoms (lambda (sym) (intern (symbol-name sym) table))
                    my-tags-table))
        (setq php-completion-table table))))

Fanta the german drink

I just heard it on the radio and could not believe it so I checked the Wikipedia entry for Fanta. Basically there was shortage of ingredients to produce coca-cola in Third Reich and thus a new drink Fanta (from fantastisch - fantastic) was invented.

php-complete-function

Dissapppointed by the poor php-mode for emacs, I am trying to improve it by adding php-complete-function. I can now complete most of the php functions (methods of objects are missing), but I'm struggling on how to mix the php functions with user defined functions from TAGS. I somehow can't get the right tags-completion-table and merge it with my php-completion-table.

(defcustom php-completion-buffer-file "/home/tekai/emacs/php_functions"
  "*Path to the file which contains the function names"
  :type 'string
  :group 'php)

(defvar php-completion-table nil
  "Obarray of tag names defined in current tags table.")
;; Define function name completion function

(defun php-complete-function ()
  "Complete the function name at the point from known PHP functions."
  (interactive)
  (let ((pattern (funcall (or find-tag-default-function
                              (get major-mode 'find-tag-default-function)
                              'find-tag-default)))
        beg
        completion
        (php-functions (php-completion-table)))
    (search-backward pattern)
    (setq beg (point))
    (forward-char (length pattern))
    (setq completion (try-completion pattern php-functions nil))
    (cond ((eq completion t))
          ((null completion)
           (message "Can't find completion for this \"%s\"" pattern)
           (ding))
          ((not (string= pattern completion))
           (delete-region beg (point))
           (insert completion))
          (t
           (message "Making completion list...")
           (with-output-to-temp-buffer "*Completions*"
             (display-completion-list
              (all-completions pattern php-functions)))
           (message "Making completion list...%s" "done"))))
  ;;(complete-tag)
  ;;(message "php-complete-function not implemented yet")
  ;; how to read the list of functions from a separate file?
  )

(defun php-completion-table ()
  (or php-completion-table
      (let ((table (make-vector 1022 0))
            (php-completion-buffer (find-file-noselect php-completion-buffer-file))
            (tags-table (if (functionp 'tags-completion-table)
                            (progn (visit-tags-table-buffer)
                                   (tags-completion-table))
                            nil)))
        (save-excursion
          (set-buffer php-completion-buffer)
          (goto-char (point-min))
          (while (re-search-forward
                  "^\\([-a-zA-Z0-9_.]+\\)\n"
                  nil t)
            (intern (buffer-substring (match-beginning 1) (match-end 1))
                    table)))
         (if tags-table
             ;; Combine the tables.
             (mapatoms (lambda (sym) (intern (symbol-name sym) tags-table))
                   php-completion-table))
        (setq php-completion-table table))))

The php_functions file has one function name per line.

Aside: I find the poor quality of php-mode somewhat strange, maybe I shouldn't compare it with slime, but I expected it to do better, PHP is not that new. But maybe most PHP coders don't grasp (e)lisp, use IDEs and are just codemonkeys who doing are doing most of their work copy&paste. But really why is the php-mode that bad?

Monday, May 31, 2004

FarCry

It is a bit surreal when you walk into a room where, just a few seconds ago, trigents and mercenaries were fighting each other and now everything is silent but instead of dead bodies lying around, they are walking, not moving. It is like as time has been frozen, and everybody has to do the same move over and over again but you can walk around freely. It feels like they could come back to life every instant and attack you. Surreal.

Turmbunker

If you take the S-Bahn in Hamburg from Holstenstraße to Hasselbrook you can see three of those bunkers which have sparked my interest.

Lostplaces: Luftschutztürme - Bauarten und -typen:

In Hamburg beispielsweise hält wahrscheinlich ein Großteil der jüngeren Bevölkerung die Zombeck-Türme für historische Wasserspeicher, in anderen Städten dürfte dies wahrscheinlich kaum anders sein.

If you know what they are you can spot them easily because round towers are an unusual sight and they all look the same. The bunkers are “verklinkert” and thus do not look as dull & scary as the “normal” grey bunker does.

Turmbunker am S-Bahnhof Hasselbrook

Dogville

Nicole Kidman

I saw Dogville on friday and must say it is a horrible movie, not horribly bad but what happens in he movie is cruel.

Lars von Trier managed to shoot an very intense movie, starring the ever so beautiful Nicole Kidman, using very few stage props and just one location. It is not a movie to be enjoyed but thought provoking, showing the dark side of man. Not easy to digest but I definitely recommend it.

Thursday, May 20, 2004

Finding a good digital camera

For ~300€ incl. 128MB was not easy for me. I have now ordered two cameras from amazon, a Fuji Finepix S5000 and a Canon PowerShot A70. I do not need two cameras and the Fuji has a serious flaw so I'm going to return it.

Looking at the specs it seems nice, especially the 10x optical zoom, however once I found out that you can not change the image compression which results in (imho) low grade images.

After the disaster with the low image quality of the Fuji I searched specifically for a camera with good image quality. The Canon PowerShot A70 already has two successors, the A75 and the A80, which could have been my choice, if it had not been for the price difference of 40/110 €. It is a 3.2 megapixel camera with a 3x optical zoom and uses CF cards, so it fullfills three criteria of at least 3 megapixels, optical zoom and cheap storage. Other than that there is not much to say as I am not able to use it yet.

Saturday, May 15, 2004

GNU TAGS

I somwhat find the xemacs code for etags better, amongs other things you can specify a list where to search for TAGS files. While this macro isn't that sophisticated it covers my needs 99% of the time.

(defadvice find-tag (before c-tag-file activate)
 "Automatically search for tags in higher directories."
 (let ((file1  (concat default-directory "TAGS"))
       (file2  (concat default-directory "../TAGS"))
       (file3  (concat default-directory "../../TAGS")))
   (let ((tag-file
          (cond ((file-exists-p file1) file1)
                ((file-exists-p file2) file2)
                ((file-exists-p file3) file3)
                (t nil))))
     (when tag-file
       (visit-tags-table tag-file)))))

Tuesday, April 06, 2004

Maths & Theory

Maths & Theory, those are the courses for which I did the least, and yet I regard Theory as the most interesting course, it's just that I am very lazy and you aren't required to do any work for the F2 & F3 courses, you have a written exam about F1 & F2, which I didn't take yet, and a oral exam about F3 & F4. But I do know theses courses are interesting, context free grammar, turing machines, complexity, automatons. It's theory but it's theory upon which languages, compilers, algorith and computers a based on.
With Math it's a different, it was fine back in school, because it was easy, dead easy. But university math not school math, it's a lot more and it's complex. And worst for me, but I didn't see any use for most the the things I learned, they did say that some off it is needed for encryption of compression, but we never did any compression or encryption, just abstract theory.

Last thursday we had a Cognitive Science course, and in the course, which btw. is very entertaining, it made click. The lecturer used a picture, taken by a b/w camera, to show when and where you need a formal/mathematical theory. Maths is not just all maths for maths, there is a hidden link between practice and theory.

Sunday, April 04, 2004

bad style

I was going to critize two articles, who imho are mostly bashing others. The GNOME article is esp. shallow GNOME is simple while the competition has a bad UI. He rarely explains why. It reads like propagande and imho really is.

I consider them to be badly written, they could and should have written their critcism in a more objective, less derogatrive and more constructive way.

The worst for me is that they anger me, for their imho obvious stupidity.

Wednesday, March 31, 2004

Lisp Books

So I aquired the CLOS book and CLtL2 and read a bit in these two and the UCI Lisp manual. Apparently in old Lisps there were functions which were used purely for their sideeffects, such as MAP which always returns nil regardless of it's parameters. When I saw PROG2 for the first time, I thought it was a optimized PROGN for only two forms, little did I know that the 2 means the value of the 2nd form will be returned instead of the last form. in LOOP AS and FOR are interchangeable, though I prefer the latter one.

Time to blog

I didn't have it in the last few weeks, however quite a few things happened.

First of all o got a new PC, which is one of the reasons I didn't have time, and it is causing trouble. It's a new AMD 64 3000+ (really 2GHz), with 1GB of RAM, a shuttle AN50R mainboard and a HIS ATI Radeon 9600 XT (no VIVO). It's a bitch, it looks fine Warcraft 3 is running smoothly at 1280x1024, Divx movies aren't a problem anymore and with the new gfx card it's really quiet. But, and thats a big but, there are some issues like freezing, random segment violations, dirty IRQs, lost DMAs and 2.4 kernels not getting into the net. While the last problems have been resolved by kernel upgrades and fault-save BIOS settings, the others are still causing reboots, and I don't know what to do.

Wednesday, March 17, 2004

lisp books

Yesterday I browsed Amazon for lisp books and decided to buy Keenes CLOS book. Browsing a bit more I came along a unusual suspect, someone was trying to sell CLtL2 on Amazon marketplace, well he succeded and I'm now a proud owner of CLtL2, I can't wait till I hold it in my hands.

I have advanced to chapter 5 in PAIP, but it took me almost halve a day to solve exercise 4.2: Write a functions that generates a list of all permutations of a givn list. There were two problems for me: Bridging the gap between algorithm and code and figuring out that I didn't cover the simplest case: (PERMUTE '()) -> (()) while I thought (PERMUTE '(A)) -> ((A)) was the simplest case.

Sunday, March 14, 2004

keyboards, keybindings, keywords ...

I ordered a keyboard with a US layout to see if programming with is easier/faster because often used keys like ([{/ are easier to reach and some emacs keybindings should seem less painfull, because you don't have to stretch your hand over the whole keyboard. Depending on if I want to keep the windows key as meta/super or I like the old IBM keyboard click better I'll try to get a IBM keyboard with US layout.

While I'm at it, i learned some new and very useful keybindings if you are editing lisp or any other code with lots of parenthesis. In addition to those a also added the following code, which is not as good as insert-parethesis, but does well enough for me.

(defun insert-doublequotes ()
  "Like insert-parenthesis, but inserts doublequotes (\")
   instead of parenthesis "
  (interactive)
  (insert "\"\"")
  (backward-char))
(global-set-key "\M-\"" 'insert-doublequotes)

I always wondered why you need C-f, C-b etc. when you have arrow key which are there for just that specific purpose, but when you use parenthesis movement it's very nice to have them, because your hands can stay where they are and don't have to move to the arrow keys.

Saturday, March 13, 2004

books

So much for writing daily, maybe it will work later.

At the moment I'm reading “Paradigms of Artificial Intelligence Programming” by Peter Norvig. So far it's easy and thus fun, and this time I'm actually typing most of the code in the book & try to do most exercises. Before that I read “ANSI Common Lisp” by Paul Graham, having tried to read “On Lisp” first I must say OnLisp is not for the novice, despite the almost identical introductions saying otherwise.

Wednesday, March 03, 2004

xmms-remote 0.21

I have updated xmms-remote again and added /xmms-volume to get & set the main volume, added /xmms pp to toggle between play & pause and replaced COYPING with a file that actually contains a license, somehow it had become a gzipped tar.

Saturday, February 28, 2004

xmms-remote

I have updated xmms-remote to work with X-Chat 2.

xmms-remote was my first C program, I wanted a program to show the mp3 I'm currently playing, simply because it was “hip” at that time. The program itsself was easy to write, yet finding out how to make it a X-Chat plugin wasn't. There was hardly any documentation, a sample plugin was provided with the source, but it did not use the functions I needed, so I had search for them myself in the sourcecode. Luckily that changed, as the X-Chat 2.0 C API is properly documented.