Stoppt die Vorratsdatenspeicherung! Jetzt klicken & handeln!Willst du auch bei der Aktion teilnehmen? Hier findest du alle relevanten Infos und Materialien:

Ubuntu 9.10 and the Google Go Emacs Mode

November 24, 2009 on 1:00 pm | In english, hacking, linux, open source, technic | No Comments

After some hours with google go I recognize the emacs mode in the source directory of the current distribution.

It is easy to install the mode for ubuntu 9.10 (karmic). First install the emacs with

sudo apt-get install emacs23

After that copy the the two .el files from you google ~/go/misc/emacs directory to

/usr/share/emacs/23.1/lisp

Now create a .emacs file in you home directory and add the following to lines.

(add-to-list ‘load-path “/usr/share/emacs/23.1/lisp” t)
(require ‘go-mode-load)

Now the google mode is activated after loading a .go file.


Emacs with go mode





Google Go and the Mandelbrot Set Part II

November 17, 2009 on 12:22 pm | In english, hacking, linux | No Comments

The following code is my solution for parallel calculation of a mandelbrot set with google go.

package main

import ( "image";
        "image/png";
	"bufio";
	"fmt";
	"os";
	"math";
	"time"; )

type PixelCalc struct {  x int;
     	                 y int;
                         cx float64;
	                 cy float64; }

func PointIteration(in chan *PixelCalc,ready chan int,img *image.RGBA){

	for {
		pixelCalc :=  <- in; 

		xt := float64(0);
		yt := float64(0);
		x := float64(0);
		y := float64(0);
		quadValue := float64(0);
		iter := 0;

		for quadValue <= 255.0 && iter < 255 {
			xt= ( x * x ) - ( y * y) + pixelCalc.cx;
			yt= ( float64(2.0) * x * y ) + pixelCalc.cy;
			x = xt;
			y = yt;
			iter++;

			quadValue = ( x * x ) + ( y * y );
		}

		color := new(image.NRGBAColor);
		color.A = 255;
		iter8 := uint8(iter);
		color.R = iter8;
		color.G = iter8;
		color.B = iter8;
		img.Set(pixelCalc.x,pixelCalc.y,color);

		ready <- 1;
	}
}

func main(){
	start := time.Seconds();

	const pictureSize = 1000;

	img := image.NewRGBA(pictureSize,pictureSize);

	f, err := os.Open("mandel.png", os.O_WRONLY|os.O_CREAT, 0666);
	if err != nil {
		fmt.Printf("Can't create picture file\n");
	}

	calc := make(chan *PixelCalc,pictureSize*pictureSize);
	out := make(chan int,pictureSize*pictureSize);

	for i:=0;i<4;i++{
		go PointIteration(calc,out,img);
	}

	deltaX := math.Fabs(float64(-2.0 - 1.0)) / float64(pictureSize);
        deltaY := math.Fabs(float64(-1.0 - 1.0)) / float64(pictureSize);

	cx := float64(-2.0);

	for x:=0;x<pictureSize;x++{
		cx+=deltaX;
		cy := float64(-1.0);

		for y:=0;y<pictureSize;y++{
	    		cy+=deltaY;
			pixelCalc := new(PixelCalc);
			pixelCalc.cx = cx;
			pixelCalc.cy = cy;
			pixelCalc.x  = x;
			pixelCalc.y  = y;

			calc <- pixelCalc;
		}
	}	

	for i:=0;i<pictureSize*pictureSize;i++{
		<- out;
	}

  	w := bufio.NewWriter(f);
	png.Encode(w,img);
	w.Flush();

	fmt.Printf("Seconds needed %d\n",time.Seconds() - start);
}

At this time the go compiler has some bugs regarding the multiprocessor support. But sometimes I can see the use of my two processors.

processor load

I hope there will fix that bug fast. The first workaround for that bug is the GOMAXPROCS environment variable. I set this to 2. But this did’nt help everytime.

Link to part 1





Google Go and the Mandelbrot Set

November 13, 2009 on 12:30 pm | In english, hacking, linux | 1 Comment

Learning a new programming language is fun. Here is my version of calculating the mandelbrot set and save the result as a PNG picture with Google Go.

package main

import (   "image";
           "image/png";
           "bufio";
	   "fmt";
	   "os";
           "math";
           "time"; )

func PointIteration( cx, cy, maxValue float64, maxIter uint8) uint8{
     quadValue := float64(0.0);
     iter := uint8(0);
     x := float64(0.0);
     y := float64(0.0);

    for quadValue <= maxValue && iter < maxIter {
        xt:= ( x * x ) - ( y * y) + cx;
        yt:= ( float64(2.0) * x * y ) + cy;
        x = xt;
        y = yt;
        iter++;
        quadValue = ( x * x ) + ( y * y );
    }
    return iter;
}

func main(){
    start := time.Seconds();     

    const pictureSize = 500;
    img := image.NewRGBA(pictureSize,pictureSize);

    f, err := os.Open("mandel.png", os.O_WRONLY|os.O_CREAT, 0666);
    if err != nil {
       fmt.Printf("Can't create picture file\n");
    }

    deltaX := math.Fabs(float64(-2.0 - 1.0)) / float64(pictureSize);
    deltaY := math.Fabs(float64(-1.0 - 1.0)) / float64(pictureSize);

    cx := float64(-2.0);
    for x:=0;x<pictureSize;x++{
        cx+=deltaX;
        cy := float64(-1.0);
        for y:=0;y<pictureSize;y++{
           cy+=deltaY;
           iter := PointIteration(cx,cy,255.0,255);

           color := new(image.NRGBAColor);
           color.A = 255;
           color.R = iter;
           color.G = iter;
           color.B = iter;
           img.Set(x,y,color);
	}
     }

     w := bufio.NewWriter(f);
     png.Encode(w,img);
     w.Flush();

     fmt.Printf("Seconds needed %d\n",time.Seconds() - start);
}

And here the result. :-)

Mandelbrot Set - calculated with google go

Next step is trying to improve the speed by using goroutines and channels.





We’re Linux - Video Contest Winners

April 15, 2009 on 9:41 am | In linux, open source | No Comments

Obwohl die Linux Foundation diesen Film als Gewinner des Linux Video Contest ausgeschrieben hat, muss ich mich dieser Entscheidung ja nicht anschließen und zeige hier einfach den zweiten Platz. Der gefällt mir persönlich sehr viel besser.



GNOME 3.0 kommt

March 22, 2009 on 4:12 pm | In linux, open source, technic | No Comments

Nach dem großen Aufsehen um die neue KDE Version (4.2) ist GNOME in den letzten Monaten etwas in Rückstand geraten. Obwohl es schon seit einigen Jahren Diskussionen rund um GNOME 3.0 gibt. In den letzten Monaten haben sind nun schon so einige neue Konzepte von GNOME 3.0 herauskristallisiert.

Als Erstes wird die untere Leiste, in der normalerweise der Bildschirmwechsler, der Mülleimer und die Windowsleiste sind, verschwinden. GNOME 3.0 wird ähnlich wie OS X nur noch eine Menüleiste am oberen Bildschirmrand besitzen. Die Programmmenüs bleiben aber wie bisher in den Programmfenstern selbst. Das macht die Menüzugriffe bei größeren Monitoren leichter.

Auf dem unteren Bild sieht man rechts unter den Usernamen das neue Action Menü. Dieses Menü kann zusätzliche Plug-Ins aufnehmen. Angedacht werden Plug-Ins, die sich vor allem um den Social Bereich kümmern. Also Plug-Ins für Instant Messenger, Twitter oder Facebook. Zusätzlich bietet das Action Menü wie in der aktuellen Version die Standardoptionen wie Computer neu starten, ausschalten oder abmelden.


Gnome 3.0

Für GNOME 3.0 soll ein Notification Center kommen. Ansätze gibt es schon mit D-Bus in der aktuellen Version. Verschiedene Programme (EMail, Batteriestatus usw.) senden Notifications über den D-Bus. Dieser zeigt dann in einem kleinen Fenster rechts oben den Inhalt der Notification an. In GNOME 3.0 soll dieses Konzept noch ausgebaut werden. Anwender können Notifications filtern und es wird ein Plug-In System eingebaut. Dann werden sicherlich Notification Plug-Ins für RSS Feeds, W-LAN Status, Facebook, Twitter, Spiegel Online Artikel und ähnliches in den Desktop kommen. Die Notifications soll es Benutzern leichter machen auf den Laufenden zu bleiben, anstatt immer wieder über verschiedene Software Pakete oder Websites ihre Daten zu kontrollieren. Die Darstellung wird sich dann vielleicht an dem Facebook Notification Widget orientieren.

Zusätzlich soll es eine neue Sidebar Komponente geben. Diese wird mit reichlich Plug-Ins ausgestattet sein (Suche, Programme starten oder Desktop Übersicht). Folgende Bilder zeigen 2 mögliche Mockup Screens:



GNOME 3.0



Gnome 3.0

Frühestens Anfang 2010 kann man mit der Veröffentlichung von GNOME 3.0 rechnen. Ob das dann alles so aussieht wie in den oberen Bildern, bleibt abzuwarten. Vielleicht kommen auch noch ganz andere Lösung zur Diskussion Die nächsten Monate werden für GNOME spannend werden.

Weiter Infos Link

Next Page »

Powered by WordPress with Pool theme design by Borja Fernandez.
Entries and comments feeds. Valid XHTML and CSS. ^Top^