Tuesday, August 31, 2010

More on Scala

Get Started on Debian/Ubuntu


Install scala, this would install version 2.7.7 though, 2.8.0 has just been out recently

apt-get install scala

Run the scala shell

scala

(optional) Quick upgrade to scala 2.8.0, install scala as per above and just copy the newer jars
Download scala from http://www.scala-lang.org/downloads and extract the tarball

tar xzf scala-2.8.0.final.tgz
cd scala-2.8.0.final/lib
cp scala-compiler.jar scala-library.jar scala-dbc.jar /usr/share/java


Get Started on Eclipse


Get the eclipse scala plugin http://www.scala-ide.org/ this would include the scala jar, compiler, console, etc.
When you have the plugin the following options are available

  • create a new scala project

  • right click on existing java project and add scala nature and you can now start coding both java and scala together

  • run the scala console inside eclipse



Reference and Links


Below are some useful reference

Scala Tutorial - useful w/ Java Background

Scala by Example - a little long, more like a scala cookbook

Programming Scala

First Steps to Scala - a bit old but still useful

Scala Idioms, Step 1, Lists and Maps - a bit old but quick way to learn about lists. Tuples are using old syntax of {x, y} which is now changed to (x, y)

Who is using Scala




Frameworks and OSS Projects


Wednesday, August 18, 2010

Looking at Scala again

I have been look at scala and lift (web framework built on scala), on and off about a year now. I have revisited it again for the past few weeks. Scala as a language seems to be promising. For me it adds something new to the main stream languages today, like pattern matching (not regexp), functional programming, actors library. There are some languages that have these properties but I think scala has got some transitional properties giving some balance. Using scala you get to access java libraries natively, despite its terse syntax it is still a static language, this would mean tool developers will have an easier.

Scala
Lift

I have also been re-using emacs again. Some interesting scala emacs some stuff.

Scala emacs tools

Friday, July 16, 2010

Low tech stuff

I have started on computers when its wasn't hip yet. When I was a kid, I toyed around a PC XT on green monochrome monitor. Then on to doing BASIC, then to over clocking on a Pentium when Asus brought out the first overclock board. Buying a linux book to get a slackware CD as downloading over a 2400bps modem is very slow. Time has passed so fast.

Lately the latest and greatest tech stuff hasn't been appealing for me. I do get touch the nice smart phones at work. Although new tech stuff isn't as appealing as before. Not sure why, maybe just too many tech stuff going around these days.

Back in the 80s there was something cool, which wasn't computers. I am talking about RC. Remote Control cars, me and my son have a few them.



These are low tech stuff, but very interesting for me. Its one of the interesting things to me as kid back then, aside from playing space wars on a PC XT. This appeals for me especially now as my son is able to build and play with me right now.

LXC on Ubuntu 10.04 Lucid Lynx

If you are like me who doesn't have a lot of time anymore, at times trying new stuff is a lot harder. About a year ago I used kvm, which is great and easy enough to get up and running. I have used it since then however Kvm is a bit too much for my needs as its a full paravirt. Container based virtualization like vserver and openvz seems to be more challenging to get running on a laptop.

Fast forward today, it seems LXC Linux Containers (http://lxc.sourceforge.net) has now made some strides. Its now part of the main kernel, most modern distro should have like. Here is a quick guide on how to get lxc up and running on Ubuntu Lucid.

Below is to setup a debian lenny guest, that uses virbr0 and has dhcp. Do the following as root:

- install libvirt as its easier to do networking on it. No need to setup your own bridge, ipchains and nat. libvirt default qemu network should create a virbr0 interface.


apt-get install libvirt-bin


I have installed this prior for kvm. What we want is virbr0 is up and running. You check this by ifconfig. Try to start it manually on /etc/init.d/libvirt-bin

- install lxc

apt-get install lxc debootstrap


- create the capabilities dir and mount it

mkdir /cgroup

add to /etc/fstab
none /cgroup cgroup defaults 0 0

mount /cgroup


- get and edit the lxc-debian script from /usr/share/doc/lxc/examples/lxc-debian.gz (gunzip it somewhere and apply correct permissions)

Edit and add the following lxc parameters on copy_configuration() function before EOF

# networking
lxc.network.type = veth
lxc.network.flags = up
lxc.network.link = virbr0
lxc.network.name = eth0
lxc.network.mtu = 1500
EOF

What this does is use the host virbr0 which is already NATed. This would appear as eth0 on the guest container.

You may need to edit increase the tty allowed, I was getting init warning on my syslog respawning. What I did was to edit my guest inittab to reduce the tty.

lxc.tty = 4 to lxc.tty = 6


- create your lxc dir. In my case the name of my container is "altair". Change it as you fit.

mkdir /home/lxc/altair
lxc-debian -p /home/lxc/altair create


This would start downloading debian lenny packages and create the root file system on /home/lxc/altair/rootfs.

- create the container

lxc-create -n altair -f /home/lxc/altair/config


- run the container

lxc-start -n altair

the above runs it on the foreground, once you have setup everything then you can run it as a deamon

lxc-start -n altair -d


Once you are inside the container, things that I did was
- set the hostname
- fix /etc/hosts
- add your favorite repo on /etc/apt/sources.list
- add X forwarding on ssh and install xauth package
- install rsyslog
- maybe edit your hosts /etc/hosts and add the IP address of the container.

Some useful links:

http://lxc.teegra.net/
http://blog.bodhizazen.net/linux/lxc-configure-ubuntu-lucid-containers/
http://nigel.mcnie.name/blog/a-five-minute-guide-to-linux-containers-for-debian
http://en.gentoo-wiki.com/wiki/LXC

HP 6910p, Acer 4315, HP dv6000 on Ubuntu 10.04 / Lucid Lynx

Its been a while since I posted on this blog. Been very busy and had a few months not really keen about computers, more on that later. Anyway for the past few weeks I have installed Lucid on my aging laptops. So far Lucid has been pretty good. Everything runs right out of the box, I needed to install restricted wireless drivers for the Acer 4315 and HP dv6000. Very easy now, as you can do this on GUI. Gone are the days of downloading tars balls, patching kernels, compile and create kernel images.

There has been some minor issues. The Acer 4315 after resume has the wireless disabled sometimes. The volume is now better for Acer 4315. At times after resume the screen brightness is set to lowest, doesn't seem to appear lately.

For the 6910p xrandr is now able to rotate the screen. So at work my 2nd dvi monitor is vertically oriented. Great when doing code. My xrandr script has something like this.


xrandr --output DVI-0 --auto --rotate left --right-of LVDS --crtc 1


What I really liked about upgrading to Lucid is it seems LXC (Linux Containers) seems to be good enough now. I have stayed away from vserver and openvz, as I didn't have much time patching the kernel, then patching again all hardware to work (e.g. wireless) and suspend to work. Will have another post on how to get LXC running on Lucid pretty fast and hassle free.