Powered By Blogger

Freitag, 9. August 2013

Testing Windows 8.1 aka Windows Blue and Visual Studio 2013 Preview

Recently, I downloaded an evaluation build of Windows Blue and Visual Studio 2013 Preview in order to test both of them.

First, some words to Windows 8.1: All annoyances that affect me are still present, like what Microsoft calls "Modern UI" and switching around between that "Modern UI" and the desktop. I couldn't find a method to show the seconds in the clock (must be quite complicated to program *fg*), extra-complicated way just to view the current IP addess and many more. I am tired to count all of them - would Microsoft change anything? No, they wouldn't. At the beginning, I used Internet Explorer, but on blogger.com I got so many errors that I decided to install Firefox.

On the other side, Visual Studio 2013 Preview makes me delighted. Unfortunately, I never had the time to test VS 2012, so what I actually see are the differences between VS 2010 and VS 2013. The first thing that attracted my attention was C++/CX (component extensions) that enables you writing C++ programs targeting Windows Runtime. Unfortunately, in FILE | New | Project... there is no template for C++/CX console applications. I found a template for that, but it doesn't work in VS 2013 Preview:

Figure 1: Error message when trying to install CxxWinRTTemplate

However, it isn't that difficult to write C++/CX console applications. In the "New Project" dialog, select Visual C++ / Win32 / Win32 Console Application. Click "Next" various times, it's okay to leave the settings or change them as needed. Now we tell Visual Studio that we want to program against CX, so we open the project's properties page and navigate to "Configuration Properties", "C/C++", "General" and change "Consume Windows Runtime Extension" to "Yes". Next, we navigate to "All options" and set "Enable Minimal Rebuild" to "No". Last but not least we change "Additional using# Directories" to

C:\Program Files (x86)\Windows Kits\8.1\References\CommonConfiguration\Neutral;C:\Program Files (x86)\Microsoft SDKs\Windows\v8.1\ExtensionSDKs\Microsoft.VCLibs\12.0\References\CommonConfiguration\neutral;%(AdditionalUsingDirectories)

This website was helpful for that. You need the using# staff in order to include Windows.winmd and Platform.winmd.

Then you can start writing your first C++/CX console program. :-) Of course, mine was to the traditional "Hello World" program:

#include "stdafx.h"
//#using <Windows.winmd> // not required in this case
#using <Platform.winmd>
using namespace Platform;

[MTAThread]
int main(Platform::Array^ args)
{
    Platform::String^ message("Hello");
    message = Platform::String::Concat(message, " World!");
    Platform::Details::Console::WriteLine(message);
    return 0;
}


Of course, C++/CX offers many more possibilities and allows a modern programming style that let the borders between C# und C++ melt. If I find something that I like very much, I'll report it.

Mittwoch, 26. Juni 2013

Urlaub in Ca' Savio (VE, Italien) (4./5./6. Tag)

Am 4. Tag unseres Urlaubs waren wir in der Früh wieder beim Meer. Zu Mittag hat Astrid Nudeln mit Thunfischsauce gemacht.

Mmmmh, lecker!

Jana hat nach dem Mittagessen ein kleines Mittagsschläfchen gemacht, während Astrid mit Tobias eine tolle Fahrt auf einem Piratenschiff (inklusive Angriff auf ein anderes Piratenschiff) gemacht hat. Dort wurde viel getanzt und gesungen.

Piratenschiff "Jolly Roger"

Tobias auf der "Jolly Roger"

Am Abend fuhren wir alle gemeinsam wieder nach Jesolo, und dieses Mal suchten wir gleich ein Fahrrad. Wir strampelten 1 Stunde lang durch Jesolo und verdienten uns unser Abendessen redlich. Tobias meinte dann: "Ich habe schon einen Eistee- und Lasagnehunger!" Sein Wunschmenü bekam er natürlich, er war ja auch sehr aktiv an diesem Tag und hat alles aufgegessen. Trotzdem war bei Tobias, Jana, Nina und Lara noch Platz für eine Kugel Eis.

Am 5. Tag war es nicht so heiß wie an den anderen Tagen und auch die Luftfeuchtigkeit war spürbar geringer, sodass wir in der Früh nicht einmal die Klimaanlage brauchten. Trotzdem war das Wetter wunderschön, wenngleich es auch recht windig war. Am Meer waren die Wellen etwas höher als in den Tagen davor und das Meer war um einiges kälter (aber mit geschätzten 20 - 22 °C immer noch recht angenehm). Die etwas besser aushaltbaren Temperaturen haben wir dann genutzt, um mit dem Schiff nach Venedig zu fahren und uns dort ein bisschen was anzuschauen. Wir waren dann auch gleich in Venedig Abendessen und auch ein Eis durfte natürlich nicht fehlen.

Der 6. Tag unseres Urlaubs in Italien war dann leider auch schon der Letzte. In der Früh mussten wir schnell frühstücken und den Schlüssel abgeben. Um kurz vor 9 Uhr sind wir dann nach Jesolo gefahren, um dort das Aquarium und Terrarium anzusehen, wo wir Fische, Krokodile, Pinguine und Schlangen gesehen haben. Gekocht hat für uns McDonald's, dann sind wir noch einkaufen gegangen (haufenweise Nudeln, Tomaten, Getränke) und um 13 Uhr 45 Richtung Heimat aufgebrochen. Dabei haben wir scheinbar unendlich lange Autoschlangen gesehen, Zigtausende wollten an Meer (hauptsächlich Italiener). Um circa 15 Uhr 45 haben wir die Staatsgrenze überquert und im selben Moment hat es zum Regnen begonnen, sodass aus unseren Plänen, beim Wörthersee eine kurze Pause einzulegen, leider nichts wurde. Wir kamen dann auf der B 317 sogar in ein richtiges Unwetter, das Autofahren war alles andere als angenehm. Bei der Grenze zwischen Kärnten und der Steiermark wurde das Wetter aber wieder besser und nach einem kurzen Halt beim Hofer in Scheifling kamen wir dann um 18 Uhr 15 endlich zu Hause an.

Dienstag, 25. Juni 2013

Urlaub in Ca' Savio (VE, Italien) (2./3. Tag)

Am 2. Tag unseres Urlaubs war ich in der Früh beim Auto etwas holen und habe überrascht festgestellt, dass es im Auto - im Gegensatz zu unserem Caravan - sehr kühl war. Am Vormittag waren wir abermals im Meer, aber auch in einem Schwimmbad am Campingplatz. Dieses ist mit einem Piratenschiff im Bad selbst ausgestattet, wo es zwei kleine Rutschen ins Becken, Wasserpumpem zum Erzeugen von Fontänen sowie einen sich regelmäßig automatisch leerenden Wasserkübel gibt. Am Abend waren wir dann noch am Spielplatz.

Unser Caravan

Am 3. Tag ist Tobias in der Früh, so wie an jedem Tag, gleich mal zu Nina und Lara gelaufen, um "Guten Morgen" zu sagen. Dann sind wir gleich runter zum Meer gegangen, um viele schöne Muscheln zu sammeln.

Jana und ich beim Muschelnsammeln

Am Nachmittag sind wir dann ins Sea Life Centre nach Jesolo gefahren, was den Kindern natürlich sehr gut gefallen hat. Danach waren wir noch einkaufen und sind dann in Jesolo zum "Beach Grill" Abendessen gegangen. Dort hat's für die Kinder gratis einen kleinen Eistee gegeben. Tobias hat natürlich - wie immer - Lasagne bestellt. Dann wollten wir noch Rad fahren gehen, aber leider war es bereits so spät, sodass alle Räder verliehen waren. Dafür durften die Kinder noch mit kleinen Autos fahren, was ihnen nicht nur Riesenspaß machte, Tobias hat sich sogar ganz gut als Autofahrer gemacht. Natürlich haben wir dann noch alle ein gutes Eis gegessen.

Montag, 24. Juni 2013

Urlaub in Ca' Savio (VE, Italien) (1. Tag)

Am Sonntag, 16.06.2013 war es soweit: Um 21 Uhr habe ich das Leihauto, mit dem wir nach Italien gefahren sind, geholt. Leider mussten wir beim Einbau unseres DVD-Players feststellen, dass die Zigarettenanzünder keinen Strom liefern. So mussten wir die geplante Abfahrtszeit (4:15) verschieben, um in Villach das Problem lösen zu lassen. Wir fuhren am Montag um 5 Uhr 5 in Leoben weg, um 7 Uhr 5 waren wir beim McDonalds in der Maria-Gailer-Straße, wo wir mal alle aufs Klo gingen und uns eine Kleinigkeit fürs Frühstück holten. Dann fuhren wir zum ÖAMTC, der gleich um die Ecke war, der uns jedoch mit Hinweis auf die Garantie des Fahrzeugs zum Škoda-Händler schickte, der glücklicherweise auch nur wenige Minuten Fahrzeit entfernt war. Dort wurde dann die Sicherung ausgetauscht und Tobias und Jana konnten die Wickie-DVD ansehen und ich mein Handy aufladen. Um 8 Uhr 10 fuhren wir wieder auf die Autobahn auf. In Italien hatte es um 8 Uhr 45 schon 28 °C. Um kurz nach 10 Uhr sind wir dann in Cessalto von der Autobahn abgefahren und schließlich um 10 Uhr 55 am Campingplatz angekommen.

Der Schlüssel zum Maxi Caravan war leider noch nicht da, weswegen wir erst mal zum Meer gingen. Den Kindern hat das natürlich gefallen. Um 12 Uhr bekamen wir dann den Schlüssel und es ging ans Auspacken der Koffer. Dann hatten wir natürlich alle schon einen großen Hunger, den wir am Campingplatz im Restaurant stillten. Wir bestellten Lasagne und Pizza, womit wir unsere Bäuche füllten. Danach gingen wir ins Meer baden. Am Abend kamen dann auch unsere Freunde mit ihren Kindern und wir gingen gemeinsam zum Abendessen. Abermals bestellte Tobias Lasagne. Als ich ihn fragte, wie die Lasagne geschmeckt hat, antwortete er: "Sehr lecker! Ein bisschen leckerer als in Leoben." Scheinbar muss ich noch an meinem Lasagnerezept arbeiten. ;-)

Donnerstag, 16. Mai 2013

Switching keyboard layout in X11

There are three keyboard layouts that are in use on my computers:
1. Most time I need the German keyboard layout, because German is my native language.
2. Once in a while I like to use the English one because some characters like '[', '{' (which are used often in programming) and so on are easier to access.
3. Sometimes I need the Russian keyboard layout because I learn Russian and need to write texts in Russian.

In XFCE, it is possible to set up keyboard layouts and switch between them by clicking the corresponding entry in the settings dialog, but if you have to switch very frequently, that is quite annoying. In Windows, there is a keyboard shortcut for switching and also in Gnome it is possible to set that up. However, in XFCE there is only a setting for switching the input method, but none for switching the keyboard layout (at least in version 4.10 that I use in Xubuntu 12.10). But finally I found a solution, that is really simple:

As root, create a file named 65Xkbmap in /etc/X11/Xsession.d with the following contents:

setxkbmap -option grp:alt_shift_toggle,grp_led:scroll at,gb,ru

This would allow switching the keyboard layouts at (German), gb (English) and ru (Russian) by pressing "alt" and "shift" (left or right one - doesn't matter). To see which keyboard layout is currently active, a plug-in can be added to the XFCE panel.

Dienstag, 7. Mai 2013

Trying Debian kFreeBSD Squeeze

Recently I tried out Debian kFreeBSD Squeeze as a VirtualBox guest. It ships with FreeBSD 8.1, which is quite old (according to Distrowatch it has been released in July 2010) but not unusual for Debian, because its stable branch uses "well tested" software. I confess that I am good in Linux but just a beginner in FreeBSD. ;-)

The installation process went quite smooth as usual for Debian. I partitioned the virtual disk in a root and a /home partition. If I recall correctly, the installation took about an hour. I also installed the XFCE desktop. Unfortunately, the screen resolution could not be set higher than 800x600. There are VirtualBox guest additions for FreeBSD, but not on the built-in virtual CD, they must be installed via ports. I did not have an idea how to install ports on Debian kFreeBSD, googling did not yield helping results and I didn't want to invest too much time in that. There is a package "virtualbox-ose-guest-source", maybe that could be used somehow.

XFCE 4.6.2 in Debian kFreeBSD running FreeBSD 8.1


IPv6 works basically, but DHCPv6 doesn't. "dhclient -6" never returns. So the interface has only one IPv6 address assigned via router advertisements.

The system takes about half a minute until I can see the login screen. Now there are 3.1 GB used on the root partition.

Other problems that occured:
  • Trying to start Synaptic fails - it asks for the password (tried both the root password and that of my "normal" user), but Synaptic never appears. However, it is possible to do a "su" on the terminal and then type "synaptic" to start it.
  • Restarting the system from GDM doesn't work (just does nothing).
  • Logging in as root doesn't work in GDM (might be disabled for security reasons - I am certain that can be changed in some configuration file).
  • I browsed the web a little bit with Epiphany, but then it suddenly stopped working. Also Iceweasel doesn't work reliably. Restarting the system did not help. After trying around a bit, I found out that all IPv6-enabled sites don't work, but those only serving via IPv4 work perfectly.
  • ZFS is not installed by default, but there is a package "zfsutils"
Conclusion: Although there were some problems (some of them are my fault, maybe), Debian kFreeBSD looks promising to me. The possibility to use APT and its related tools like Synaptic is fascinating. The system runs fast and stable.


Epiphany and Iceweasel

Sonntag, 5. Mai 2013

Some years ago I noted a few lines in my wiki to "transfer" an installation of an operating system that uses APT from one system to another ("system" doesn't denote a "machine" but simply an installation of some operating system). Yesterday, I used this to transfer the installation from Xubuntu 12.04 x86 to Xubuntu 12.04 x64. Interestingly, it happend that there were a lot of "i386" packages installed. You can see this if you grep "386" from "dpkg --list". Results could be like this:

ii  6tunnel:i386                                                0.11rc2-5                                           TCP proxy for non-IPv6 applications

To replace these packages with their (in my case) amd64 counterparts, it is first necessary to remove those i386-packages:

apt-get remove `dpkg --list | grep "386" | cut -d' ' -f3 | tr '\n' ' '`

Explanation: List all packages that contain 386 in their name and take only that name, replace all line feeds with spaces and send the results to apt-get.

Next, let's write all packages that should be reinstalled to a file:

dpkg --list | grep "386" | cut -d' ' -f3 | sed 's/:i386/ /g' | grep -v ^lib | tr '\n' ' ' > new_packages

(possibly, that could be optimized to grep all lines not beginning with lib and containing 386 in one statement rather than two statements)

We can then review the file (maybe there are packages we don't need any more). After that, we issue

apt-get install `cat new_packages`

and apt-get installs the requested packages.

Freitag, 5. April 2013

Repairing dpkg after connection dropped and preventing that in the future

Recently I was logged in to my server via SSH, as suddenly the connection (UMTS network) dropped. The last command I ran was apt-get upgrade. Unfortunately, SSH does not resume a lost connection. When I issued apt-get upgrade again, I got an error that /var/cache/debconf/config.dat would be locked by another process. To solve that, it is possible to use the fsuer command:

fuser -v /var/cache/debconf/config.dat

The locking process can be killed with "kill -9 PID".

To prevent things like that happen in the future, I then installed "screen". When I log into my SSH server, I run screen and then work. If the connection drops again, I connect to my SSH server and say "screen -r" to get back to my previous session. Very useful. :-)

Montag, 4. März 2013

Read/Write data using Redis with Node JS

Today is Redis day. ;-) Now I wrote a small JavaScript app for Node JS that can query and change a key:

var http = require('http');
var redis = require('redis'),
        client = redis.createClient();
var url = require('url');

console.log('talktoredis started!');

http.createServer(function (req, res) {
  res.writeHead(200, {'Content-Type': 'text/html'});
  var testvalue = '';
  query = url.parse(req.url,true).query;
  client.get("testkey", function (err, reply) {
    testvalue = reply.toString();
    console.log('testvalue = ' + testvalue);
    res.write('Node.JS talks to Redis');
    res.write('Key "testkey" has value "' + testvalue + '".
');
    res.write('newvalue = "' + query.newvalue + '"
');
    res.write('Turn on ');
    res.write('Turn off');
    res.write('');
    res.end();
  });
  if (query.newvalue == 'on' || query.newvalue == 'off') {
    client.set("testkey", query.newvalue);
  }
}).listen(8000);


Together with my bash script written earlier this evening I can now use a web browser to change the behavior of a shell script.

A demonstration video was uploaded at YouTube.

EDIT: The source code isn't shown here correctly because it contains HTML tags. I uploaded the script here: https://www2.mkcs.at/temp/node_redis/talktoredis.js 

Get values from redis server from bash

Getting values from a redis server is also possible in (bash) shell scripts. On Github, I found a project providing two files (redis-bash-lib and redis-bash-cli) which enable such functionality. I wrote a small script that monitors a key for changes and writes a message to the screen, if the monitored key changes:

#!/bin/bash
SOMEVAR=''
OLDVAR=''
while /bin/true; do
    SOMEVAR=`redis-bash-cli -h localhost GET testkey`;
    if [ "$SOMEVAR" != "$OLDVAR" ]
    then
        echo "Value has changed from $OLDVAR to $SOMEVAR";
    fi
    OLDVAR=$SOMEVAR;
    sleep 1;
done;


Just open a terminal, start "redis-cli" und enter "set testkey perhaps", "set testkey again" or any other values and see how the script reacts to that change.

You could use redis server to exchange commands between some other software and your script. The script could evaluate the value and execute commands.