Search

KLone: C web programming framework

June 3rd, 2007 edited by Tincho

Article submitted by Kari Pahula. We are running out of articles ! Please help DPOTD and submit good articles about software you like NOW !

PHP is well known for its coding style, mixing HTML with source code inside special <?php code > tags. There are tools and frameworks for that kind of web development using other programming languages like Perl and Python, but there is one fairly surprising choice of programming language that you could use instead, namely C.

KLone is a web application development framework that takes HTML with C embedded in as its input and turns it all into a single binary that is the server and the web app in one package.

Let’s step through an example of how to make a simple Hello World type of web app. First off, apt-get install klone-package. That’ll install KLone and a few tools you can use in a Debian environment. Change to a directory where you have a write permission.

$ make-klone-project create -p myhello
$ cd myhello-0.1

There will be a number of files and directories in the project directory. The important ones are debian/, where you have the files necessary for generating Debian packages containing your web app. We’ll return to that part later on. For now, let’s concentrate on the other directory of interest, userdata/.

$ cd userdata
$ mkdir etc
$ cd etc

Create and edit a file called kloned.conf.

server_list my_http
allow_root yes

my_http
{
    type      http
    addr.type IPv4
    addr.port 8880
    dir_root  /www
}

Now we’re ready for action!

$ cd ..
$ mkdir www
$ cd www

Create and edit a file called index.kl1. Any files that end with the .kl1 suffix will be treated as HTML/C files.

<%!
#include <time.h>
time_t now;
%>
<html>
<head><title>A hello world app for debaday</title></head>>
<body>
<h1>Hello World</h1>
<p><%
now = time(0);
io_printf(out, "Time is now %s\n", ctime(&now));
%>
</body>
</html>

That’s really all there is to it. Now, return to the project root directory and to build a kloned server, just run:

$ kloned-build -o myapp userdata
$ ./myapp -F

That -F switch is there so that the server won’t start as a daemon. Now you can access http://localhost:8880/ with the web browser of your choice to see a friendly greeting and to know the current time. But this isn’t the whole story, yet. Stop the web app you just created, run apt-get install dpkg-dev and then do the following:

$ dpkg-buildpackage -rfakeroot
$ sudo dpkg -i ../myhello_0.1*deb

You have just installed a Debian package containing your web app. As long as the package is installed, you can rely on having your app start at boot time.

If you want to see more examples of how to use KLone, feel free to visit KoanLogic’s web pages.

KLone is available in Debian in Etch and later, and in Ubuntu since Edgy.

Posted in Debian, Ubuntu | 9 Comments »

Trickle: A lightweight userspace bandwidth shaper

May 30th, 2007 edited by ana

Article submitted by Ferry Boender. We are running out of articles ! Please help DPOTD and submit good articles about software you like NOW !

Sometimes, you’ll want to download something but you don’t want it to completely saturate your Internet connection. Perhaps you’re already downloading something more important, or you simply don’t want to get in the way of other people that are sharing the same Internet connection. Some programs, such as gFTP, wget and bittorrent, offer built-in up/download rate limiting. Other programs, such as apt-get and associates, don’t. Enter Trickle.

Trickle is a user space bandwidth shaper. It allows you to limit the bandwidth consumption of a program without requiring all kinds of kernel patches, firewall configurations or root access to the machine on which you wish to use it. Trickle can run in collaborative and stand alone mode. In collaborative mode, trickle can limit the bandwidth used by a bunch of programs at the same time. In stand alone mode, trickle simply limits the program you specify.

Stand alone mode

Trickle is easiest to use in stand-alone mode. Simply run trickle with a download and/or upload limit and a program you want to limit. For example:

[todsah@jib]~$ trickle -d 20 -u 20 wget http://www.electricmonk.nl/bigfile
trickle: Could not reach trickled, working independently: No such file or directory
–12:19:18–  http://www.electricmonk.nl/bigfile
           => `bigfile’
Resolving www.electricmonk.nl… 194.187.77.6
Connecting to www.electricmonk.nl|194.187.77.6|:80… connected.
HTTP request sent, awaiting response… 200 OK
Length: 51,200,000 (49M) [text/plain]

 0% [                                     ] 180,224       21.83K/s    ETA 38:03

In the example above we use wget for demonstrative purposes, even though it has built-in bandwidth shaping. As you can see, the download rate is 21.83K/s. Of course, this is not exactly 20 K/s, but the download rate will vary between 19 and 21 K/s giving an average of 20 K/s. You can use the -w and -t command-line options to fine-tune this behaviour. The longer trickle runs, the closer it will get to 20 K/s. For more information, check out the manual page.

Daemon mode

In daemon mode, trickle can limit a group of programs to a fixed limit of bandwidth. To start the daemon, run the trickled command:

[todsah@jib]~$ trickled -d 20 -u 20

This will start the trickle daemon that will limit the total bandwidth available to all programs run via trickle to 20 K/s both up and down. So if you run a single program via trickle, it can consume 20 K/s. Two programs can each consume 10 K/s, etc. As an example, we start three wget sessions:

[todsah@jib]~/temp$ trickle wget http://www.electricmonk.nl/bigfile
 1% [                                     ] 933,888        6.66K/s  ETA 1:47:17
[todsah@jib]~/download$ trickle wget http://www.electricmonk.nl/bigfile
 1% [                                     ] 720,896        6.65K/s  ETA 1:56:59
[todsah@jib]~$ trickle wget http://www.electricmonk.nl/bigfile
 2% [                                     ] 1,228,800      6.64K/s  ETA 1:45:00

The download rate is limited to about 6.6 K/s per session, making a total of 19.8 K/s. As is usually the case with bandwidth shapers, it may take a couple of seconds before all sessions are correctly limited. This is because of the algorithm used by shapers to determine how much they should delay the sending and receiving of traffic.

Availability

Trickle has been available in Debian at least since v3.1 (’Sarge’) and in Ubuntu since Warty. apt-get install trickle should do the trick.

Notes

  • Trickle doesn’t work with setuid programs. The reason for this is that setuid programs ignore the LD_PRELOAD functionality for security reasons. Trickle requires this functionality to do its shaping. (It also doesn’t work with statically linked programs for the same reason.)
  • Trickle only works with programs that use the socket(2) interface for transmitting and receiving data. Also, it only works with TCP connections, not with UDP connections.

Posted in Debian, Ubuntu | 17 Comments »

Konversation, A simple irc client with a few surprising features.

May 27th, 2007 edited by ana

Article submitted by Kyle Hamar. We are running out of articles ! Please help DPOTD and submit good articles about software you like NOW !

A sense of community remains a powerful feature of Linux. Few tools reveal the power of open source, and none more clearly link this community better than IRC clients. Dozens of clients exist, from the small and powerful (irssi) to the complex (centericq). I prefer a lightweight gui: Konversation.

Think of IRC as an open window to hundreds of open source projects, where developers often respond to questions from users on every imaginable subject. Freenode, a service of the Peer-Directed Projects Center supports many popular interest areas.

Konversation

Usage

I recommend the use of freenode, a service of Peer-Directed Projects Center. Freenode host a very comprehensive list of groups related to most major peer directed and open source projects, like Apache or KDE. If you are new to IRC it would be wise to review the general questions and user registration requirements in the faq. Other projects, for example Debian, uses the OFTC network.

Konversation Screenshot

This screenshot of the #debian channel includes someone searching for help with a Perl module, others are asking about Apache. These community supported areas are only a few keystrokes away using Konversation.

Konversation boasts a simple tab-based interface, interrupted only by a few programmable buttons on-screen. These buttons may be modified to provide one-click application of numerous commands. The usual IRC display options are available; including font selection, colors, and various display options. The themed nicklist offers several different options for display of nick information.

configure

Minimize Konversation and it will pop up a small on-screen display activated by a keyword or your nick after you enable the option. The feature works very well, and you can add sounds to notifications also.

on-screen display

One nice feature is the ability to execute commands from within the chat window and return the output for everyone to see:

command execution

Konversation also integrates with Kaddressbook. This allows for whois information to display the users real name.
The point of Konversation seems to be a simple interface with a few nice features. It does not offer the extensive internal scripting support of other clients. In fact, I would say the lack of kitchen-sink bells and whistles is a feature and not a detraction. Konversation can /exec any script you wish (Bash, Perl, or etc.) and provides a DCOP port to return information to the channel. The ability to post the outcome of arbitrary commands to a chat window (how else should you say look at this error!) and the on-screen display while minimized are important features.

Most users probably do not need the bot-like features of this simple client but they are easy to use if you need them. I first tried Konversation on the recommendation of a friend while struggling with a small bug with another client. I’ve not gone back since!

Links

Posted in Debian, Ubuntu | 6 Comments »

UltraStar NG: karaoke game that allows user supplied songs

May 23rd, 2007 edited by ana

Article submitted by Miriam Ruiz. We are running out of articles ! Please help DPOTD and submit good articles about software you like !

Karaoke (カラオケ, 空 kara, “empty” or “void”, and オーケストラ ōkesutora, “orchestra”) is, according to the Wikipedia, a form of entertainment in which an amateur singer or singers sing along with recorded music on microphone. In a typical karaoke game, the system plays the music and displays the corresponding lyrics on the screen, sometimes also showing a video as well, while the singer or singers sing along. Sony went one step further with their game SingStar, for PS2: you not only had to sing the song, but you also had to sing it properly. The game came along with a couple of USB microphones, and the game decided how well you were singing the song.

Then came UltraStar, a Free Software (GPL’ed) SingStar clone in which you could add your own songs in the forms of mp3s along with a text file, as well as pictures and videos. In UltraStar, the original song is being played, and the lyrics shown, while the wannabe singer tries to do their best with the microphone. A gray bar shows the length and pitch of the original song, and the player’s own voice is displayed with a blue bar, which shows whether the song has been sung correctly or not. The better the performance, the more points you get. In the end, you might turn to be an amateur, or a lead singer. Unfortunately, UltraStar was programmed in Kylix/Delphi, and only available for the popular proprietary operating system you’re thinking about. The good thing about UltraStar is that there are lots of people making songs for it, so you might be able to find your favourite ones all along the Internet, in some web pages devoted to the program, in peer to peer network systems, etc. It’s quite easy to make your own songs for UltraStar, or converting them from SingStar format.

UltraStar-NG is the remake of UltraStar that works under GNU/Linux. It is coded in C++, and, for the technical part, it uses alsa for audio acquisition, fftw3 for getting the notes sung by the player, SDL for the visualisation and keyboard input, xine or gstreamer to play the music and librsvg or cairo to display the themes (which are vectorial images). The goal of the game, as you might have guessed, is to get the maximum of points while singing the songs of your choice.

UltraStar intro screen

UltraStar intro screen, you have more screenshots here.

It’s been a long way, but finally we’re able to play UltraStar-NG in our Debian machines. Have fun, and don’t forget that, if the game says you’re singing out of tune, that might not be a bug in the program but in the singer ;)

Posted in Debian, Ubuntu | 17 Comments »

Problems with DPotD

May 21st, 2007 edited by Tincho

This post is to inform our readers that we had a problem with an upgrade that we are working to solve. Something went wrong when updating wordpress and the pictures and our theme are gone. Also, permalinks aren’t working.

Thanks for your patience. The DPotD team.

Posted in Debian, Ubuntu | 2 Comments »

« Previous Entries Next Entries »