Recently in Programming Category

I've mentioned this book once before.

wizard.jpgStructure and Interpretation of Computer Programs has been MIT's introductory pre-professional computer science subject since 1981. It emphasizes the role of computer languages as vehicles for expressing knowledge and it presents basic principles of abstraction and modularity, together with essential techniques for designing and implementing computer languages. This course has had a worldwide impact on computer science curricula over the past two decades.

You can find the online videos and the free online book right here. For the case the ftp servers are busy you can download them from my own pub ftp instead (ftp.buetow.org/pub).

'Programming Haskell' online lectures

| 1 Comment | No TrackBacks

haskell.png I found a great series of free haskell lectures online at http://www.cs.nott.ac.uk/~gmh/book.html#videos. The referent is going through all the chapters of the book 'Programming Haskell'. The videos are pretty good and atm I am enjoying watching them. You should give them a try as well! I think you don't even need to buy the book in order to understand everything.

Update: I put those videos on my pub FTP server for download: ftp://ftp.buetow.org/pub/OnlineLectures/ProgrammingHaskell/

Redesign of the Fype Interpreter

| No Comments | No TrackBacks

fype_small.pngAfter reading Structure and Interpretation of Computer Programs I decided to rethink the interpreter of Fype. Fype is a small scripting language invented and implemented (in C) by me. I decided to take the code-base of Fype and to rewrite the core of its interpreter-part in order to use a Scheme/Lisp-like syntax. which is much easier to parse. The syntax is simpler and much more powerful now. So far it is now possible to define functions and sub-functions and to display all involving frames. Here is an example:

(def (test)
   (say "This is test")
   (def (test2) 
      (say "I am in test2" "And test3 will be defined next!")
      (def (test3)
         (say "Displaying all frames now:")
         (show-frames))
      (test3))
   (test2))
(test)

The invocation of the interpreter prints out the following result:

This is test
I am in test2
And test3 will be defined next!
Displaying all frames now:
FRAME(id=3) 0:
FRAME(id=2) 1:
+ST_LAMBDA(name=test3;args=)
( ( say Displaying all frames now: ) ( show-frames ) )
FRAME(id=1) 2:
+ST_LAMBDA(name=test2;args=)
( ( say I am in test2 And test3 will be defined next! ) ( def ( test3 ) ( say Displaying all frames now: ) ( show-frames ) ) ( test3 ) )
FRAME(id=0) 3:
+ST_LAMBDA(name=test;args=)
( ( say This is test ) ( def ( test2 ) ( say I am in test2 And test3 will be defined next! ) ( def ( test3 ) ( say Displaying all frames now: ) ( show-frames ) ) ( test3 ) ) ( test2 ) )

Now what's left to do: Implement a few more built in functions. And we have a new Scheme/Lisp-like language with a very very small footprint available :)

Btw.: This version of fype aims to be pure-functional and with lazy evaluation.

pwgrep v0.4 is out

| No Comments | No TrackBacks

I just released pwgrep v0.4. What's new? Besides of storing passwords into a single file, pwgrep can now also be used for storing a collection of files, which is very usefull for storing certificate files etc. Like passwords, all files stored within pwgrep are encrypted using GPG. The command pwfls will list all files currently stored in your database:

7.png

pwfadd adds a specific file to the database:

8.png
9.png

pwfls will show you that it has been added successfully:

10.png
11.png

File deletion can be accomplished using pwfdel:

12.png

In general you can decrypt/store/encrypt any specific file format (as well as binary files).

Introducing pwgrep.buetow.org

| No Comments | No TrackBacks

After introducing pwgrep itself I am now introducing the homepage of pwgrep. Its address is pwgrep.buetow.org.

It contains all informations about pwgrep :)

A few months ago I was looking for an easy tool for resolving host names and IP adresses. Well, I didn't have time to manage to write such a tool by myself. I was thinking: "Why making it so complicated?". So I came up with the following solution:

#!/bin/sh
exec xterm -geometry 60x10 -title 'resolving hosts or ips' \
     -e bash -c 'while read line; do [ ! -z $line ] \
     && host $line; done'

And I told my window manager (FVWM) all xterms with the title 'resolving hosts or ips' to always stay on top and to be sticky. I think this is an easy tool for resolving hosts and IPs. I just have to use Xorgs copy and paste mechanism (3rd mouse button) to copy those into the window in order to get resolved :)

resolver.png

The easiest solutions are the best solutions (at least in this case)!

Introducing pwgrep (Update)

| No Comments | No TrackBacks

Thumbnail image for seprian-logo-3.pngIn order to manage all my secret passwords I wrote myself a small bash/awk script which manages a database file using encryption of GnuPG. (Source of pwgrep v0.2)

The database file is divided in several records. Each record begins with its name followed by several lines holding all the secret informations. The (actually very simple) format of the database file is as follows:

some record name here
      after a tabulator some secret informations          
      more secret informations
another record name here ..... 
      secret username: foo
      secret password is bla
      you can write as many secret infos as you wish
.
.
secret stuff
      password: hello world
      username: mr. universe

The database is not stored in plain text. It is encrypted using GnuPG (database.gpg).

I can only search for the record names of a database file. For example if I want to see my secret username and password which is stored in the database.gpg file it will look like this:

1.png

After entering the password of my secret GnuPG key I will receive the informations requested:

2.png

pwgrep will print out automatically all records matching my search string. Not only the first one it finds.

I can use pwedit for the case I want to add something to the database or just to edit/delete something of the current database:

3.png

4.png

After editing, pwgrep will automatically wipe all temporally files securely and it will commit the new version into the versioning system (In this case subversion is being used. But others can be configured as well). pwgrep is using Vim (with swapping and backuping disabled) in order to edit the database file. If you want to use a different editor, you should make sure NOT to produce temporally files. If you produce temporally files, at least they should get wiped securely from the hard disk.

5.png

6b.png

If you want to look up your secret ebay stuff, just search for it with

pwgrep ebay

If found, pwgrep uses destroy or shred for wiping files. If none of those commands are found, pwgrep checks if the current operating system is FreeBSD. In this case, rm -P can be used as well. Otherwise an error will occur.

Update: Uploaded v0.2 of pwgrep. Before editing the newest version will be checked out before. This will avoid versioning conflicts. The tool also creates local snapshot files of the encypted database (for the case you lost internet connection and you want to roll back to the previous version) And a few other enhancements have been built in.

CXG Next Generation online

| No Comments | No TrackBacks

cxg.gifMy brother, Florian Bütow, has released the first version of OpenCXG which is a new pastebin script written from scratch in PHP. OpenCXG is the successor of the older CXG pastebin which was based on mod_python. The latter however was broken after a few major operating system and library upgrades.

OpenCXG still does not have all features which the older CXG used to have. However the plans for the future can be read on the OpenCXG homepage.

Xerl Revision 182

| No Comments | No TrackBacks

xerl.buetow.org.png Xerl is an open source website template engine (TE) with some features of a Content Management System (CMS) programmed in object oriented Perl and using XML.

It now supports the redirect:* directive. Which allows me to configure HTTP redirects from one host to another without using mod_rewrite or .htaccess. redirect:* is working like the alias:* directive of the previous feature upgrade.

One small step for Xerl - one giant step against duplicated content.

Xerl Revision 170

| No Comments | No TrackBacks

xerl.buetow.org.pngI've committed Xerl Revision number 170 to the subversion repository. Xerl is an open source website template engine (TE) with some features of a Content Management System (CMS) programmed in object oriented Perl and using XML.

Enhancements made:

  • Host aliases can now be configured using an alias:hostname file. E.g.:
    echo www.buetow.org > hosts/alias:buetow.org
    would create the host buetow.org as an alias to www.buetow.org. Means: buetow.org shows the same content as www.buetow.org. My hosts/ directory now looks like this (alias:* are host alias definitions and the rest are directories for the "real" virtual hosts):
    alias:buetow.org               fype.buetow.org
    alias:butow.org                irssi.buetow.org
    alias:dslvpnrouter.buetow.org  jsmstrade.buetow.org
    alias:pb-labs.com              lan.buetow.org
    alias:perl9.org                netcalendar.buetow.org
    alias:www.butow.org            niduterm.buetow.org
    alias:www.pb-labs.com          paul.buetow.org
    alias:www.xn--btow-0ra.com     perlchat.buetow.org
    alias:www.xn--btow-0ra.org     stud.buetow.org
    alias:xn--btow-0ra.com         use.perl9.org
    alias:xn--btow-0ra.org         vpndslrouter.buetow.org
    awksite.buetow.org             vs-sim.buetow.org
    bg.buetow.org                  www.buetow.org
    blogs.buetow.org               www.perl9.org
    calculator.buetow.org          xerl.buetow.org
    curses.buetow.org              ychat.buetow.org
    default                        yhttpd.buetow.org
    fuzzybot.buetow.org
    Because of duplicated content, the next version of Xerl may use a HTTP redirect instead (search engines). The old way of defining aliases still works as well:
    echo buetow.org=www.buetow.org >> conf.txt
    However this method is not the preferred anymore. conf.txt needs to get restructured anyway.
  • Initial support for plugins
  • Some code review including more documentations about the coding style to use.

Xerl is work in progress! It has no real documentation and no release available atm. This is mostly a hobby project fitting my own needs in having dynamic websites.

I am looking for a way of doing fuzzy string matching using the Haskell programming language. I want to parse the user's text input (which is a normal natural english sentence). The user may will have errors in his text, which should get recognized and replaced automatically by my program. I think the easiest way would be calculating the 'Levenshtein distance' to all known words and use the word with the smallest distance. Although, this is not really fuzzy logic (fuzzy logic depends, in my view, more on the context of the sentence which is written), I think it is a good starting point in order to get an initial version working. According to the Wikibook the Haskell implementation would be as easy as this:

levenshtein :: String- > String -> Int
levenshtein s t = 
    d!!(length s)!!(length t) 
    where d = [[distance m n|n<-[0..length t]]|m<-[0..length s]]
          distance i 0 = i
          distance 0 j = j
          distance i j = minimum [d!!(i-1)!!j+1, 
                                 d!!i!!(j-1)+1, d!!(i-1)!!(j-1) 
                                  + (if s!!(i-1)==t!!(j-1) 
                                     then 0 else 1)]

This method may be too slow if I've to compare each word with about serveral thousands words. Hrrm.

Or using another implementation, because:
The implementations of the Levenshtein algorithm on this page are illustrative only. Applications will, in most cases, use implementations which use heap allocations sparingly, in particular when large lists of words are compared to each other.

Yet another way would be implementing a Fuzzy Logic Library (as learned in the Neuronal Fuzzy Networks lecture @ Aachen University of Applied Sciences) from scratch.

Progress in Haskell

| 1 Comment | No TrackBacks

My first real program written in Haskell is growing. It is forming valid english sentences.

makeSentences = do
	let pronoun = SgI 
        in print $ (pronounForm pronoun) 
           +++ (futureForm pronoun $ IrregularVerb 
                         "go" "went" "gone") 
           +++ (superlative $ RegularAdjective "fast")
	let pronoun = SgHe 
        in print $ (pronounForm pronoun) 
           +++ (presentForm pronoun $ IrregularVerb 
                         "go" "went" "gone") 
           +++ (comparative $ RegularAdjective "fast")
	let pronoun = PlWe 
        in print $ (pronounForm pronoun) 
           +++ (pastForm pronoun $ RegularVerb "watch") 
           +++ (comparative $ IrregularAdjective 
                         "good" "better" "best")

The output of this small program is as follows:

*Main> makeSentences
"I will go the fastest"
"he goes faster"
"we watched better"

real-world-haskell.jpgSo far the program handles pronouns, regular verbs, irregular verbs, regular adjectives and irregular adjectives with all of their exceptions. The program is less then 200L. Since I am used to C/C++/Perl and Java, programming in Haskell forces me to rethink the way of programming. It's a great experience. I still 've much to learn. And my Real World Haskell book I've only finished half yet :)

Learning functional programming

| 4 Comments | 1 TrackBack

The last weeks I started (slowly but constantly) to learn functional programming using Haskell. First, I started with the functional programming practices (available as videos) of the RWTH Aachen (University). However those practices aren't so good if you don't have the lecture itself as well. Afterwards I was reading most of the Yet Another Haskell Tutorial and did most of the practices listed inside. I did this until I found out about the book Real World Haskell, which is also available for free as HTML pages. I decided a hard cover book is much nicer and it is supporting the authors, so I ordered myself a copy of this. While waiting for it, I found a 15 year old book about Informatics in my shelf.

vorlesung-informatik.jpg

The last ~150 pages teach how to functional program using the Gofer Programming Language. While waiting for Real World Haskell I am reading how to program in Gofer at the moment. Gofer can be seen as a very light version of Haskell. So if I learn Gofer, then I also learn Haskell. Today, Haskell is 100% compatible to Gofer plus more.

One of my long term goals may be reimplementing my AI IRC Bot in Haskell. At the moment, the bot is written in Perl.

JSMSTrade v0.2 released

| No Comments | 1 TrackBack

I just released the second (v0.2 to be more specific) version of JSMSTrade. JSMSTrade is a very small and handy client (programmed in Java) for SMSTRADE.de for sending SMS messages.

jsmstrade.buetow.org.png

The changes are as follows: The application is now using the english language and is not in german anymore. Also a small bugfix has been included: The input area will not freeze after typing more than 160 chars.

Enjoy ;)

Update: v0.3 has been released now too. This version only includes a major bugfix. Sadly, v0.2 was not able to deliver any SMS messages. This has been fixed by now :)

I've too many programming projects

| No Comments | No TrackBacks

I want to have several forks of myself. Because I want to release the following, but not enough time to do so right now:

  • C++: yChat 0.7.9.6-STABLE (atm. 0.7.9.5)
  • C++: yChat 0.9.0-CURRENT (atm 0.8.2)
  • Java: VS-Simulator 1.1 (atm 1.0)
  • Java: JSMSTrade 0.2 (atm 0.1) (Has been released by now)
  • Java: NetCalendar 1.0 (atm 1.0 RC5) (Has been released by now)
  • C99: Fype 0.1 (atm devel only)
  • Perl5: Xerl 0.1 (atm devel only)
  • Perl5: FuzzyBot 0.2 (atm proof of concept 0.1)

Probably I'll release VS-Simulator 1.1 the next days. Don't know yet which project I will push afterwards. ;)

The problem having so many projects at the same time: Most of them progress very slowly. The benefit: You have always at least one project which makes fun at the moment.

Dead projects of mine:

Guessing my Programming Environment

| 6 Comments | No TrackBacks

I just found the following picture:

programming.jpg

Do you recognize the Laptop (brand?) and the Editor and the Programming Language being used? Do you know what I am programming on this picture? Maybe you also know of the OS running on the Laptop. If you know me you will be able to answer most of those questions :)

However, I don't remember where I toke this picture. I think it was @ Airport Dortmund.

Cosmetic fixes for Xerl

| No Comments | No TrackBacks

Recently, I managed to program a few cosmetics fixes for the Xerl Template Engine. Xerl is a website template engine written in Perl and designed to use XML as its primary source for content and configurations.

  • Xerl is not logging any IP addreses anymore. Xerl is now logging hashsums of those instead.
  • Xerls logging internals have been improved.
  • Lots of other small but nice cosmetic fixes have been introduced.

As a user, nobody will recognize any of those changes. I wanted to mention recent work in order to show that Xerl is not dead. However, the progress of development is slow but constant.

Arrays Progress

| No Comments | No TrackBacks

Tonight I made the first real step in using Arrays in Fype. It is now possible to create arrays (even anonymous ones, which are used for multidimensional arrays). Here is an example:

# Create a function bar, it returns 0 by default
func bar { say "bar" }

# Create a multi dimensional array foo. Its first element is
# the return value of the func which is 0. The fourth value is a
# string "3" converted to a double number. The last element is
# an anonymous array which itself has another anonymous array
# as its last element.
my foo = [bar, 1, 4/2, double "3", ["A", ["BA", "BB"]]];

# Run on each element of foo recursively the function 'say'
say foo;

It produces the following output:
% ./fype test.fy
bar
0
1
2
3.000000
A
BA
BB

The next step will be array operations such as accessing single elements of an array or to add/remove or modify the elements.

Redesign of Fype's Garbage Collector

| No Comments | No TrackBacks

Fype needs a better garbage collector. I've implemented a garbage collector half a year ago for Fype, however many things have changed in the source and I lost the overview a little bit. The new garbage collector should be:

- Easy to use
- Easy to extend
- Easy to monitor

Formatting C Code

| 1 Comment | No TrackBacks
Use the following Code in your Makefile and use "make style" and get your C code formatted.  It will also prove that no  source line is longer than 80 chars. It will print a notice if more than 80 chars per line are reached and it will also print the affected filenames and line numbers. This script needs to have astyle installed and it has been tested on FreeBSD with pmake but not with GNU Make. You may need to modify the script if you are going to use Linux w/ GNU Make.

 style: astyle check
 astyle:
     find ./src -name '*.[ch]' -exec sh -c 'astyle -s3 {}; rm -f {}.orig' \;
 check:
     for f in `find ./src -name '*.[ch]'`; do awk -v f=$$f \
         '{ if (length($$0) > 80) { \
         printf "Max line length reached @ %s:%d => %d\n", \
         f, NR, length($$0) } }' $$f; done

About this Archive

This page is an archive of recent entries in the Programming category.

Podcasts is the previous category.

Python is the next category.

Find recent content on the main index or look in the archives to find all content.