2014-10-19

Almost Human

We all know IRC, don't we? It's the geeky chat thing we all geeks used before MSN, Skype, Viber, Whatsapp and Facebook messenger. Some of us still use it.

Sometime around 15 years ago IRC was a way of life for many computer hobbyist in Finland. Most of IRCers were young - most probably single - guys, for obvious reasons. One day things changed; an attractive girl called Liisa started to use IRC - or so many believed.

Liisa was very open for chatting with everyone, and she didn't mind a little flirt either. Sometimes she was a bit moody but that didn't stop guys to continue chatting with her.

Sometimes she kept company for someone for hours and hours, usually more if the person was drunk. After all, when you are drunk it's not so easy to know you are chatting with a computer program...


Liisa the IRC chat bot

In 1966 Joseph Weizenbaum wrote famous ELIZA virtual doctor program. In 1984 Finnish Pekka Tolonen wrote his Finnish version of ELIZA on Commodore 64 and named it Kalle Kotipsykiatri (Kalle the home psychiatrist). Those programs was based on natural language processing.

Finnish is extremely difficult language and the Kalle Kotipsykiatri program and it's algorithms looked very complex to me at that time. Additionally the program didn't seem to learn or memorize anything, it just created responses based on the algorithm.

Sometime between 1997 and 1999 - can't remember exactly the year anymore - I decided to write an IRC bot for my own fun. She got the name Liisa.

Different kind of approach

One big difference to it's predecessors is the fact that Liisa had persistent memory; everything it learnt was saved to a database so it was able to survive restarts.

Another difference is that Liisa had only little bit of programmed intelligence in it, for example it knew how to learn about new IRC channels from other's users' information. I wrote Liisa primarily as an IRC bot, which means it was able to join IRC channels (chatrooms) to listen and learn.

Liisa collected everything it saw on the channels to chat log files for further processing. Based on randomized events it sometimes joined those new channels and left empty or inactive channels.

In IRC it's possible to talk on chat rooms (channels) or in private 1-to-1 chat. Liisa was able to discuss on both. In private chat it looked like any other chat bot, but on channels it behave like any other human.

Multilingual personality disorder

Instead of having an algorithm to construct the sentences, Liisa used statistical analysis of the chat logs. This had a great advantage; Liisa was multilingual since it didn't even try to understand the languages.

For example if the human chatter asked "What do you think about last night's game?" the program used it's database of other humans' responses to the same sentence and randomized between them and returned a very human answer, for example "Do you mean Finland vs. Sweden?".

This kind of answer would have been impossible for typical chat programs since it required updated data on the hockey games played.

I also implemented a function which determined the mood of the human chatters. Appropriate answers to an angry user would be different from a happy one. Liisa also had it's own mood which was affected by the mood of human chatters.

Rest in peace

Since Liisa was able to move around in the IRC by itself it became well known after a while. Some people liked it while some really hated it. At some point, probably in 2001, I decided to stop using Liisa anymore to avoid pissing people off too much.

The program was written in Perl and the data store was Berkeley DB. Remember, this was before 2000. :)

I had published the source code as scrambled PDF file to allow people to look at it but not to run it. At that time I didn't think the program would be useful in the future so I didn't unfortunately save any copies.

- Toni

ps. too bad that Loebner Prize wasn't invented yet at that time.




2014-10-10

Stuff from the past: Silky the SILC client

For some reason I started to dig what I've done in the past. I found something very interesting which I had forgotten completely for many years; Silky.

Silky was a graphical client for SILC secure chat protocol. It was implemented using GTK+ library and due to it's cross-platform implementation it ran on Linux, Windows, OS X, *BSD, and Solaris.  I also ported it to Maemo - aka. Nokia 770 Internet Tablet - which I was developing at the time.

I had registered the Silky project on SourceForge on 07/2003. The project page still seems to be available: http://sourceforge.net/projects/silky/

Silky was using libsilc libraries developed by Pekka Riikonen. In July 2004 I created the RPM package of libsilc for Fedora: https://apps.fedoraproject.org/packages/libsilc/.

Those were the days. :)


Silky running on Linux

Silky running on Maemo development environment

2014-08-26

Local-only delivery SMTP server

When you have a development server - a virtual machine or even a spare laptop - you eventually run into problem of email delivery because your application needs to send emails for whatever reason. Due to well known email spam problems the internet service provides typically no longer allow users to send email using unauthenticated SMTP connections.

I have a virtual machine running on my Fedora laptop where I write some test applications, and I travel from network to network every day so I cannot configure any outbound SMTP connections without exposing my SMTP credentials - which are btw. usually same as the IMAP credentials - to a configuration file of e.g. Postfix.

Local-only delivery to the rescue!

I've configure the virtual machine to forward all emails to my laptop, and told my laptop to deliver all email to a single local mailbox. Simple and efective. As additional bonus my crappy applications won't accidentally send spam our other unwanted emails to innocent bystanders...

On the virtual machine add this line to /etc/postfix/main.cf:

 relayhost = 192.168.122.1

If for some reason your physical host (laptop) has other bridge IP address you might want to adjust the IP...

On the physical host add these lines (don't forget to change the username) to /etc/postfix/main.cf:

 luser_relay = twillber@localhost
 local_recipient_maps =
 mydestination = pcre:/etc/postfix/localdeliverydestinations

On the physical host add this line to /etc/postfix/localdeliverydestinations:

 /.*/         ACCEPT

Restart your Postfixes and you should be ready to go!



2014-08-19

Test RHEL7 without installing it - on Docker!

So there's this new interesting operating system you'd like to try out? Traditionally you had to find a spare laptop where to install it on, and later on you installed them on virtual machines running on your laptop.

Nowadays things are even more easy; Docker provides an easy way to create software containers without you having to provision virtual machines or having to hunt for spare laptops.

Currently I'm running Fedora 20 on my laptop and in order to demonstrate stuff on RHEL7 all I need to do is to launch a RHEL7 in a container using Docker.

Couple of easy steps to test it out yourself:

Install Docker
On Fedora the RPM package is called "docker-io", let's install it first:

yum install docker-io

Add yourself to the Docker group so you don't need to use sudo later on:

sudo usermod -a -G docker $USER

Start Docker and enable it on boot time:
systemctl enable docker
systemctl start docker


Download RHEL7 base image

https://access.redhat.com/search/browse/docker-images#? -> "Red Hat Enterprise Linux 7 base image container in Docker Format"

Load the image into Docker and verify it's listed:

docker load -i ~/Downloads/rhel-server-docker-7.0-21.4-x86_64.tar.gz
docker images
REPOSITORY          TAG                 IMAGE ID            CREATED             VIRTUAL SIZE
redhat/rhel         latest              e1f5733f050b        10 weeks ago        140.2 MB
rhel                latest              e1f5733f050b        10 weeks ago        140.2 MB
redhat/rhel7        0                   e1f5733f050b        10 weeks ago        140.2 MB
redhat/rhel7        0-21                e1f5733f050b        10 weeks ago        140.2 MB
redhat/rhel7        latest              e1f5733f050b        10 weeks ago        140.2 MB
rhel7               0                   e1f5733f050b        10 weeks ago        140.2 MB
rhel7               0-21                e1f5733f050b        10 weeks ago        140.2 MB
rhel7               latest              e1f5733f050b        10 weeks ago        140.2 MB

Start your RHEL7!
docker run -t -i rhel7 /bin/bash
bash-4.2# cat /etc/redhat-release
Red Hat Enterprise Linux Server release 7.0 (Maipo)
bash-4.2# 

So what just happened? We told Docker to run "rhel7" image and start "/bin/bash". Option -t allocates a pseudo-tty (terminal) and -i is interactive mode. If you forget the flags your image is started in background.

You can use docker ps command to list running images, common use case is to open another terminal to do this while your image is running:

docker ps
CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS              PORTS               NAMES
9469ec5c152b        redhat/rhel7:0      /bin/bash           4 seconds ago       Up 2 seconds                            distracted_ritchie   

Next steps

You'll probably want to learn about creating your own layered images, creating services within the image such as Apache or MySQL etc.

One good place to start learning is the Red Hat customer portal: https://access.redhat.com/articles/881893 "Get Started with Docker Containers in RHEL 7".


 

2014-08-14

Your first OpenShift Facebook application

Facebook [feys-boo k] - "to communicate with (a person) or search for information about (a person) by using Facebook" (dictionary.com)

They didn't have definition of OpenShift, but since you are reading this you probably know what it is. So you want to develop an application for Facebook and you wonder where to host it? That's one thing OpenShift can help you with.

The steps to create a simple Facebook application on OpenShift are very easy. I created a small "hello world" application with PHP to show how it's done.


Create OpenShift application

Go to OpenShift Online and create new PHP 5.3 application. I've used "facebooktest1" as the name here.



Clone the code to your laptop and download the Facebook PHP API v3 from here: https://github.com/facebook/facebook-php-sdk and copy the contents of the extracted src directory into your Openshift application:

git clone ssh://...
cd facebooktest1
cp -r ~/Downloads/facebook-php-sdk-master/src facebook


Create Facebook application

At https://developers.facebook.com create your Facebook application and add platform Facebook Canvas into it. Use the application URL from OpenShift as Canvas URL.

In this example I've used openshifttest1 as the application name.




Configure OpenShift environment variables

You'll need to set some environment variables in order to avoid having to insert Facebook App ID and App Secret into your source code. Namespace is your OpenShift domain name and application name is the OpenShift application name.


rhc set-env FBAPPID=365476396940042 --namespace twillber --app facebooktest1
rhc set-env FBAPPSECRET=hidden --namespace twillber --app facebooktest1

rhc set-env FBNAMESPACE=twillber-openshift --namespace twillber --app facebooktest1


Write the PHP application

Here is a very simple index.php just to show your Facebook name and user ID:


You can fetch the example code from here: http://people.redhat.com/~twillber/files/openshift/index.php.txt



Commit your code

At the end your directory structure should look like this:

[facebooktest1]$ tree
.
|-- facebook
|   |-- base_facebook.php
|   |-- facebook.php
|   `-- fb_ca_chain_bundle.crt
`-- index.php


1 directory, 4 files

Time to add the files and commit everything to OpenShift Online:

git add --all .
git commit -am 'created cool app'
git push


Demo time!

Browse to your application and enjoy your hard work: https://apps.facebook.com/twillber-openshift/




2014-06-10

Open Source photography

I bought my first "real" camera some years back, it was a Canon EOS 350D. I took lots of pictures, some good some not. Mostly not so good.

Few years later I found an interesting Open Source project call Magic Lantern. What an excellent excuse to upgrade my camera. I got same form-factor but bit more powerful model from Canon, EOS 600D.

Canon SLR's are quite nice nowadays, they have enough megapixels, they can eat reasonably sized memory cards and so on. However something's missing, for example built-in ability to take timelapse videos, HDR videos or even HDR photos. Wouldn't it be nice if you could write your own code onto your camera? It turned out that you can.

"Magic Lantern is a software enhancement that offers increased functionality to the excellent Canon DSLR cameras. We have created an open framework, licensed under GPL, for developing extensions to the official firmware."
Some nice guys at the Magic Lantern project managed to reverse engineer bits and pieces of the Canon software, enabling adding your own firmware on the camera. Initially Magic Lantern was supposed to be focusing on video recording enhancements for legendary Canon 5D Mark II, but after it being ported to APC-C size cameras it attracted wider developer and user base.

"Magic Lantern is not a "hack", or a modified firmware, it is an independent program that runs alongside Canon's own software. Each time you start your camera, Magic Lantern is loaded from your memory card. Our only modification was to enable the ability to run software from the memory card."

If you are interested in the features of Magic Lantern I recommend you to check out the very extensive user guide at http://wiki.magiclantern.fm/userguide or the FAQ document at: http://magiclantern.fm/faq.html

Latest stable release is couple of years old, but I've been safely using a nightly build from few weeks back. Hopefully they release a new stable version some day soon.


Youtube video credit: GNA Productions

In addition to video recording and time lapses, the software is capable of quite incredible HDR shots and low-light photography. You'll find lots of example shots and videos from the user gallery: http://www.magiclantern.fm/forum/index.php

If you are not so much into photography but into hacking things, feel free to download the source code: https://bitbucket.org/hudson/magic-lantern. Open Source is everywhere!






2014-06-03

Rethink your Enterprise OS - Road to RHEL 7

On June 11th I'll give presentation titled "Road to Red Hat Enterprise Linux 7" at Red Hat Forum in Helsinki.

I will highlight the features and capabilities that position Red Hat Enterprise Linux 7 that will redefine the enterprise operating system.

The presentation will cover capabilities planned for Red Hat Enterprise Linux 7, ranging from Linux containers, the OpenLMI framework, and cross-domain identity management to the powerful system and performance management tools.

You'll also hear feedback examples of real-world use cases and the experiences of the RHEL 7 beta program participants to plan their own implementations.

Check the agenda and register your seat here: http://helsinki.redhat-forum.com/agenda

See you soon!

ps. If you are not in Helsinki you'll have a chance to meet my colleagues and learn about RHEL 7 in 14 other cities where the Red Hat Forum is travelling to. We are coming to you!  http://www.redhat-forum.com/en/home

2014-05-31

Installing Linux on Acer Aspire V5

Are you crazy? It comes with Windows 8 preloaded! Well see, that's the problem...

I really like this hardware. Acer Aspire V5-122P has very nice form-factor, it comes with decent amount of memory, very nice touch-screen and a keyboard almost good (compared to Lenovo/IBM Thinkpads).

So back to the problem; Windows 8. Since this is a family laptop there's almost valid excuse to keep the Windows, so dual booting we go.

Steps required to install the best free Linux distribution; Fedora:

  • Download Fedora 20 live media
    • http://fedoraproject.org/en/get-fedora
  • Shrink Windows 8 system partition
    • In Windows run diskmgmt.msc > Choose system disk > Shrink Volume
    • Create new Simple volume for Linux > Do not assign letter for the drive
  • Boot up from Fedora 20 installation or live media, I used USB memory stick
  • Install Fedora on the new partition we just created
  • On reboot you can press F12 to choose to boot Fedora or alternative press F2 to enter the system settings menu (previously called BIOS) and alter the default boot order.
  • Enjoy!
As you can see, there's no black magic involved. You don't need to disable the Microsoft secure boot stuff since Fedora supports UEFI and secure boot.

So what works? Touch screen, WLAN, audio, all the usual stuff. Only display brightness control seems to be not functioning.

Yours,
 Toni

ps. I've heard that Ubuntu doesn't work out-of-box on this hardware...