Thursday, May 21, 2009

» php-source-highlight

I spent an hour or two yesterday to write my first PHP extension in C++. It is a very simple wrapper around GNU source-highlight that also ships its functionality as a shared library and (C++) API since version 3.0. The whole point about that extension is that you can perform syntax highlighting using source-highlight's capabilities and broad support for many programming languages directly and naturally using a PHP function, instead of having to resort to executing a subprocess and fetching its output, or using the source-highlight CGI. Using the extension, source-highlight is preloaded as a shared library and hence, the performance is optimal. For example:
<?php
echo sourcehighlight("
public interface SomeInterface {
    void doSomething(String a, String b) throws IOException;
}
", "java");
?>
The above would result in this:
public interface SomeInterface {
    void doSomething(String a, String b) throws IOException;
}
It is currently a very first version, and I suppose that I will add more features in a near future (discussing a bit with Lorenzo Bettini, the author of GNU source-highlight), but the next step will be to implement a Mediawiki extension that uses php-source-highlight, which is pretty simple (I already wrote a few, once you know the API, it's trivial to do), in order to highlight Mediawiki markup, e.g.
<code lang="java">
public class Foo {
  public static final void main(String[] args) {
    System.out.println("Hello world");
  }
}
</code>
Resulting in this on rendered Mediawiki pages:
public class Foo {
  public static final void main(String[] args) {
    System.out.println("Hello world");
  }
}

Labels:

Monday, May 18, 2009

» openSUSE Conference 2009 Call for Papers Deadline

As you probably already heard, we'll have our first, very own, super-cool openSUSE Conference in September in N├╝rnberg. Obviously, the success of that event depends on your presence, active participation and as such, you might be interested in holding a talk. If so, make sure to register on the Call for Papers page, as the deadline is May 20th (in 2 days time) !

Labels:

Friday, May 15, 2009

» vnstat on openSUSE

vnstat is a network traffic monitor that collects the amount of data you transmit over network interfaces (typically, your Internet uplink), and can display them
  • on a terminal:
    screenshot

  • or, since version 1.7, also as graphs:
    vnstat graph
The latter can even be watched from a browser, using a CGI script. vnstat runs through a cron job at a regular interval (every 5 minutes by default) and collects network transfer statistics for selected network interfaces, to be able to give you information about daily, weekly, monthly traffic. To install and run vnstat on openSUSE, either use the 1-click install for openSUSE 11.1, openSUSE 11.0 or SLE 11, or proceed as follows:
# add the "server:monitoring" repository if needed:
zypper ar -r http://download.opensuse.org/repositories/\ server:/monitoring/openSUSE_11.1/server:monitoring.repo # (optionally adapt the URL above to match your distribution, # e.g. openSUSE_11.0 or SLE_11 instead of openSUSE_11.1) # download and refresh the repository metadata: zypper refresh # install the vnstat and vnstat-cgi packages: zypper install vnstat vnstat-cgi
That being done, simply run the following command as root to create a vnstat database for at least one of your network interfaces, obviously using whatever connection you want to collect statistics for instead of "eth0":
vnstat-create-db eth0
And we're already finished :) To see the results, give vnstat a few minutes to collect data (at least 5 minutes), and either see the results in a terminal:
vnstat
vnstat -h
Or point your favourite webbrowser at the following URL: http://localhost/vnstat Note: if the URL above doesn't work, make sure to start apache2 first, using the following command as root:
rcapache2 start

Labels: ,

» Import Packman package signing keys

Short version:

In order to import and trust the GPG key that signs Packman packages, do as follows (as root):
rpm --import ftp://packman.links2linux.de/pub/packman/public-keys.asc

Long version:

Here is why you might get warnings from RPM when installing packages from the Packman repository, telling you that the signing key is unknown: in our infrastructure, the packages are built on a different host than where they are served for public consumption, and while the RPM files are signed on our build host, the repository metadata is signed on the HTTP/FTP/rsync server. We currently use two different keys for doing that (one for the signing the packages, and another one for signing the repository metadata). But zypper and YaST2 (through their common package management stack in libzypp only support the automatic import of the key that is used for signing the repository metadata (well, after prompting you for doing so, obviously ;)). Hence you also need to import the public key that we are using to sign the RPM files. There are two options on how to do that:
1. use rpm --import:
Execute the following command in a terminal, as root:
rpm --import \
ftp://packman.links2linux.de/pub/packman/public-keys.asc

2. install the package rpmkey-packman:
That package is obviously available in the Packman repository, so if you already added the Packman repository to the package management stack, do this as root:
zypper install rpmkey-packman

And if you didn't, use 1-click-install to (optionally) add the repository and install the package, by clicking this link.

Labels: ,

Sunday, May 03, 2009

» tircd: Twitter from IRC

Twitter, yet another social network and instant messaging tool, yet another IM client with notifications. Annoying. Well there's an interesting alternative if you're already using an IRC client all the time, as I do. tircd is a Twitter to IRC gateway, implemented as an IRC server. It runs on your workstation (or a server in your network), you connect to it from your favourite IRC client (e.g. irssi, xchat, konversation, weechat, ...) and can post your tweets as well as receive tweets from the persons you subscribed to. Here is how to install it on openSUSE: 1. add the server:irc repository, e.g. like this for openSUSE 11.1:
zypper ar -r \ http://download.opensuse.org/repositories/\ server:/irc/openSUSE_11.1/server:irc.repo zypper ref
2. install the package tircd or, if you want tircd to start automatically at boot time, install the package tircd-daemon (which will also install the package tircd):
zypper in tircd-daemon
3. if you went with the latter option, start the daemon and activate the tircd init script to be run at boot:
rctircd start chkconfig --add tircd
If you prefer to run tircd manually, open a shell with your regular user (not root) and do this:
tircd
4. in your favourite IRC client, connect to the tircd server running on localhost:6667, using your Twitter username as the IRC nick name, as well as sending your Twitter password to the server (note that the port number can be changed in /etc/tircd.cfg for manual start/stop, and in /etc/tircd-init.cfg when running tircd as a daemon). With irssi:
/connect localhost 6667 password username
5. then join the IRC channel named "#twitter" on that server, still in your IRC client:
/join #twitter
For further information, such as adding/banning people, please refer to the tircd website.

Labels: , , ,