2009-09-20

Scala and idioms

From the article : Is Scala really more complicated than Java? The same program can be written in Scala with different idioms:

Easy way:

val name = "Dick Wall"
println("""
Happy Birthday to you
Happy Birthday to you
Happy Birthday dear """ + name + """
Happy Birthday do you
""")


Procedural:
for (n <- 1 to 4) {   
print("Happy Birthday")
if (n == 3)
print(" dear XXX")
else
print(" to you")
println
}


Mixed:

(1 to 4).map {
i => "Happy Birthday %s".format(if (i == 3) "Dear XXX" else "To You")
}.foreach println


Functional:

(List.make(4, "Happy birthday ")
zip (List.tabulate(4, {
case 2 => "dear friend"
case _ => "to you"}))
) map (Function.tupled(_+_)) mkString ("\n")


More freedom ? hope Scala will avoid to be like Perl ! Not everybody will be able to maintain a Scala program. But that is also true with Java or anything. The complexity can be everywhere anyway, it is just more or less visible.

Read also: It's not the languages, but their idioms that matter.

2009-09-11

Nice way to describe Kerberos: a Dialogue in Four Scenes

As I needed to refresh my knowledge about Kerberos, I found a nice theater-like Dialogue in Four Scenes. Kerberos is really complex and hard to follow. It is revealing that its authors found theater more efficient than traditional technical docs and schema to explain their ideas.
It remember me of the comics used by Google to describe Chrome. Only it was done in 1988 !!
Also the best theater reference for me is always Ralph König's Lysistrata, his prologue really strikes me.

2009-09-07

MDSD: UML or DSL ?

This blog is a lot about Linux, because I use it as a reminder. I want to remember how I solved some problems or some great applications or short cut.
But it doesn't reflect my main interest that is development, design and creation. My Google Reader Shared post gives a better view of this part.
Also how I shifted my interest from Semantic web to Model Driven Development and DSL.
So I will just notice that I didn't realize how UML and DSL can be antagonist.

Sound and iPod with Awesome Windows Manager

Just a short note about the great Awesome window manager.
There was no sound with some applications. There are 2 programs to know about sound control : alsamixer (command line) and pavucontrol (manage PulseAudio with a simple GTK interface).

For the iPod, I am using RockBox, gtkPod and gpodder. Nothing fancy, but it does the job quickly.

Just have to remember to manually mount the iPod, by adding this in /etc/fstab:
/dev/disk/by-label/IPOD /media/IPOD vfat defaults,umask=000,auto,rw,user 0 0

Also a simple trick to eject the iPod : eject /media/IPOD

2009-08-17

LUA, commun point for VLC, Awesome, SciTE ...

It is amazing to see that most of the software I like and use embed LUA, the "powerful, fast, lightweight, embeddable scripting language" :
It is good to know that you can invest into it.

2009-08-09

Getting rid of the DisplayManager, Choose your run level

The Display Manager (generally: GDM, KDM, or XDM, Slim ...) is there for historical reason, but it isn't useful unless you need special features.
Now the problem is that Ubuntu restricted the uses of Run Levels ! So you have to tweak the system a little bit if you want to start in text mode.
So lets read:
Add a text-only runlevel to Ubuntu Gutsy and
Boot time RunLevel
Then modify your /etc/event.d/rc-default:
#
# This task guesses what the "default runlevel" should be and starts the
# appropriate script.

start on stopped rcS

script
runlevel --reboot || true

if grep -q -w -- "-s\|single\|S" /proc/cmdline; then
telinit S
elif RL="$(grep -o "[[:blank:]][2345]$" /proc/cmdline || true)"; then
if [ -n "$RL" ]; then
telinit $RL
else
telinit 2
fi
elif [ -r /etc/inittab ]; then
RL="$(sed -n -e "/^id:[0-9]*:initdefault:/{s/^id://;s/:.*//;p}" /etc/inittab || true)"
if [ -n "$RL" ]; then
telinit $RL
else
telinit 2
fi
else
telinit 2
fi
end script


Then knowing that I use Grub 2, the following file has to be modified /etc/grub.d/10_linux (no more menu.lst). Just add the bold part:
...
cat << EOF
menuentry "${OS}, linux ${version}" {
linux ${rel_dirname}/${basename} root=${linux_root_device_thisversion} ro ${GRUB_CMDLINE_LINUX} ${GRUB_CMDLINE_LINUX_DEFAULT}
EOF
if test -n "${initrd}" ; then
cat << EOF
initrd ${rel_dirname}/${initrd}
EOF
fi
cat << EOF
}
EOF

cat << EOF
menuentry "${OS}, linux ${version} (text mode)" {
linux ${rel_dirname}/${basename} root=${linux_root_device_thisversion} ro 3 ${GRUB_CMDLINE_LINUX}
EOF
if test -n "${initrd}" ; then
cat << EOF
initrd ${rel_dirname}/${initrd}
EOF
fi
cat << EOF
}
EOF

cat << EOF
menuentry "${OS}, linux ${version} (single-user mode)" {
linux ${rel_dirname}/${basename} root=${linux_root_device_thisversion} ro single ${GRUB_CMDLINE_LINUX}
EOF
if test -n "${initrd}" ; then
cat << EOF
initrd ${rel_dirname}/${initrd}
EOF
fi
cat << EOF
}
EOF

...

That worked for me, but be careful as it can screw your system !
Now just log in and type: $ startx awesome

2009-07-30

Set up wireless without KDE nor Gnome

One of the first problem faced when going away from KDE, Gnome or XFCE is that you have to set up your wireless connection manually.
If you have 10 minutes, it can be done once and for all: just follow this how to HOWTO: Wireless Security - WPA1, WPA2, LEAP, etc..
Then you can remove the NetworkManager startup script : "sudo update-rc.d -f NetworkManager remove".
Keep in mind to launch a "sudo /etc/init.d/networking restart" in case of problem.

Update: I just found a solution to automatically start Network Monitor Applet (nm-applet) with Awesome Window Manager. But I am quite happy with my current setting, it just connect when it starts.

Festival de la Cooperative OASIS - 2026

 https://Cooperative-OASIS.org/ Abonnement la revue Passerelle Eco    Papier . Mais les annonces sont dispo:  Revue trimestrielle de l’ Ecov...