ScopePort is searching for Rails developers

ScopePort continues growing. We are going towards a first release to all those nice people who have announced their interest in ScopePort this year. A few weeks ago Ernesto Rocha joined the team. Welcome again! Ernesto is mostly developing the web interface: 100% Rails. I am still working on the server and the clients. (and also on the web interface)

We need all the help we can get now! If you just want to send some patches or join the team to be project member for a longer time: We need you!

All you need is experience with Rails and git. (Why git is better than X)

Please contact me if you are interested!

More information about ScopePort: http://www.scopeport.org/

Share and Enjoy:
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Mixx
  • Google
  • Furl
  • LinkedIn
  • Spurl
  • StumbleUpon
  • Technorati
  • Yigg

Gordon Freeman got his equipment: The CERN is safe now

Disturbing image material appeared when the Large Hadron Collider at the CERN was about to be fired up the first time. Reddit immediately pulled out all the stops and sent Gordon the equipment he needed to fight the head crabs that would appear after the LHC startup.

These days his equipment arrived at the CERN! Thank you reddit. (Oh. And also for all your referers!)

No, really. Every research organisation should be more like the CERN. You could make all of us nerds happy!

Share and Enjoy:
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Mixx
  • Google
  • Furl
  • LinkedIn
  • Spurl
  • StumbleUpon
  • Technorati
  • Yigg

Tags: , , , , ,

How to use the GitHub post-receive JSON API with Rails

GitHub offers you a lot of post-receive notifications. This means that some actions are made whenever you commit something. You can e.g. send notifications via Jabber or IRC - Another option is to call a URL with JSON data. This Rails snippet receives the JSON data and stores relevant information in your database:

class TunerController < ApplicationController

	# Basic HTTP authentication.
	USER, PASSWORD = "github", "secret"
	before_filter :authenticate

	# Disable need of authenticity token.
	skip_before_filter :verify_authenticity_token

	def index
		# Include JSON. (gem install json)
		require 'json'

		# Check if the JSON request is in correct format.
		if params[:payload].blank?
			# Wrong format. Exit.
			render :text => "no payload"
			return
		end

		# Parse the JSON request and store resulting hash.
		push = JSON.parse(params[:payload])

		# Get the "commits" part.
		commits = push["commits"]

		# Check if there were commits. Yes, there should be some...
		if commits.blank?
			# No commits found. Strange - Exit!
			render :text => "no commits found"
			return
		end

		# Store the interesting information of the last commit-
		last_commit_message = commits.last["message"]
		last_commit_timestamp = commits.last["timestamp"]
		last_commit_author = commits.last["author"]["name"]

		# Create a new object to save in databse.
		data = Git_Message.new do |d|
			d.last_commit_message = last_commit_message
			d.last_commit_timestamp = last_commit_timestamp
			d.last_commit_author = last_commit_author
		end

		# Save our commit data in the database!
		if !data.save
			# Could not save.
			render :text => "could not store in database"
			return
		end

		# Everything went well.
		render :text => "done"
	end

	private

	def authenticate
		authenticate_or_request_with_http_basic "nothing to see here"
                  do |id, password|
			id == USER && password == PASSWORD
		end
	end

end

Set the GitHub post-receive URL to something like http://github:secret@example.org/tuner - Where “github” is the user and “secret” the password. You can alternatively just enter the URL and remove the authentication methods from the Rails controller.

Share and Enjoy:
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Mixx
  • Google
  • Furl
  • LinkedIn
  • Spurl
  • StumbleUpon
  • Technorati
  • Yigg

Tags: , , , , , , , , , ,

How to add a value to a select field in Ruby On Rails

I’ll just leave this here: When you fill a select box directly from a array returned by .find(:all) you can add more values tothe select box this way:

Controller:

    @hosts = Host.find(:all).collect {|p| [p.name, p.id] }
    @hosts << ["None", nil]

View:

    <dd>
      <%= f.select :linkedhost, @hosts %>
      <%= error_message_on(:service, :linkedhost) %>
    </dd>
Share and Enjoy:
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Mixx
  • Google
  • Furl
  • LinkedIn
  • Spurl
  • StumbleUpon
  • Technorati
  • Yigg

Tags: , , , , ,

Things Microsoft Windows users just don’t have: Part I

If I was ever forced to use Microsoft Windows for professional work again there would be some things that I would really miss. Of course I could work with it and I would get my work done. I am not one of those Windows haters who say that they could never work with Windows, but I think I would tend to search for those little icons and menu points that make my work more comfortable every day. Today I want to show you two of those applications or more precisely GNOME applets.

Hamster
Hamster is a little time tracking application that runs in GNOME panels. You just click on Hamster and enter a short description of what you are doing. Hamster now tracks how long you are working on this task until you start another task or stop tracking of the current task. This is extremly useful if you have to maintain a log of your tasks at work. http://projecthamster.wordpress.com/

Things Microsoft Windows users just dont have: Part I

Avahi service discovery
Avahi is used for service discovery in a network. It is an implementation of Zerconf. Learn more about Zeroconf here. The Avahi service discovery applet can show you all Zeroconf services in your network. For this example I enabled the iTunes DAAP music sharing of Rhythmbox (a Zeroconf technique) on my workstation and clicked the discovery applet on my notebook. The Rhythmbox service on my Desktop was discovered immediately. You can find dozens of different services for music shares, file shares, printers, NTP or even version control. The applet is available in many distribution repositories. (Ubuntu: sudo aptitude service-discovery-applet)

Things Microsoft Windows users just dont have: Part I

Things Microsoft Windows users just dont have: Part I

Share and Enjoy:
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Mixx
  • Google
  • Furl
  • LinkedIn
  • Spurl
  • StumbleUpon
  • Technorati
  • Yigg

Tags: , , , , , , , , , ,

Rails Migrations: How to define an own column as primary key

Usually the Ruby On Rails convention to use ID as the primary key of tables is fine. But sometimes you want to use another column as primary key. In my case I wanted to use the column “pid” of the ScopePort table “health” as the primary key. This is the way to do it:

def self.up
  create_table :health, :primary_key => :pid do |t|
    t.integer :threads, :timestamp
    t.boolean :clienthandler
    t.string :vmem, :packetsOK, :packetsERR
  end
end

The first notable point is the create_table option “:primary_key => :pid”. It instructs rake not to create the ID column but to use the column “pid” as primary key. You don’t need to define :pid later - It will be created automatically as an integer.

Share and Enjoy:
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Mixx
  • Google
  • Furl
  • LinkedIn
  • Spurl
  • StumbleUpon
  • Technorati
  • Yigg

Tags: , , , ,

GNOME Twitter client: Gwibber

I have been looking for a really clean and easy to use Twitter client for a long time. I recently tried out Gwibber and it seems like I found what I wanted: Gwibber is easy to use, fast and focuses on the important things.

GNOME Twitter client: Gwibber

You can tweet by using the little input box at the bottom. You get a little bubble notification at the bottom left of your screen if somebody you follow tweets. (This can be disabled.) Gwibber stays in your tray if close it.

How to install Gwibber on Ubuntu 8.10 Intrepid

1. Create a file “/etc/apt/sources.list.d/gwibber.list” and add the Gwibber repository:

GNOME Twitter client: Gwibber

# File: /etc/apt/sources.list.d/gwibber.list
deb http://ppa.launchpad.net/gwibber-team/ubuntu intrepid main
deb-src http://ppa.launchpad.net/gwibber-team/ubuntu intrepid main

2. Update your local repository information cache and install Gwibber: (aptitude update, aptitude install gwibber)

3. Start Gwibber from your applications menu (Section “Internet”)

4. Add Gwibber to your GNOME autostart. This can be done in the GNOME session manager:

GNOME Twitter client: Gwibber

Gwibber also supports some other services that I did not try out:

  • Digg
  • Facebook
  • Jaiku
  • Pownce
  • Flickr
  • Identica

You can find out more on the Gwibber Launchpad site.

Share and Enjoy:
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Mixx
  • Google
  • Furl
  • LinkedIn
  • Spurl
  • StumbleUpon
  • Technorati
  • Yigg

Tags: , , , , , , ,

Nasty bugs: std::logic_error because of NULL string

I recently changed the Warning::getConditions() method of ScopePort. It now takes two parameters:

  • string hostid - The ID of the host on which the sensor to check is running
  • string st - The ID of the sensor to check.

I started up ScopePort and got the following error after about 2-3 minutes:

terminate called after throwing an instance of ’std::logic_error’
what():  basic_string::_S_construct NULL not valid

Because of the time delay I searched for the error in the recently changed Warning::getConditions() method. I expected that an usual alarm was causing something to fail. But as my investigations went on I noticed that the time delay was exactly 180 seconds. Each time. So I thought about it and remembered that the onlineStateChecks() thread was going into full operations after 180 seconds (That is to give the clients time to send data.). I quickly found out where the error was caused: Just at the time of the Warning::getConditions() method call. The debugger didn’t even let me step into the method. It failed right at the method call. As it was pretty late and I had to get up early the next day I went to sleep and planned to ask a friend the next day.

The next morning. At the time I was explaining my Problem to the friend I already found the error. (Sometimes it is really better to go to bed…): When I updated the onlineStateChecks and clientHandler() threads to use the new method I made a mistake: I used the wrong column of the database result. This ended in 0 as second parameter. Exactly. Not “0″ but 0.

My friend explained me that the compiler was not complaining because he just accepted the 0 as a NULL string. I didn’t even look for wrong parameter types because I thought the compiler wouldn’t even think about compiling 0 as string. Lesson learnt. Thank you.

Here is a little example program that reproduces the error:

#include "TestClass.h"
using namespace std;

int main(){
    TestClass test;
    test.testMe("foo", 0);
    return 0;
}

class TestClass {
     public:
         void testMe(string foo, string bar){
              return;
         }
};
Share and Enjoy:
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Mixx
  • Google
  • Furl
  • LinkedIn
  • Spurl
  • StumbleUpon
  • Technorati
  • Yigg

Tags: , , , , ,

New ScopePort feature: SMS Notifications

ScopPort SMS Notifications

ScopPort SMS Notifications

Share and Enjoy:
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Mixx
  • Google
  • Furl
  • LinkedIn
  • Spurl
  • StumbleUpon
  • Technorati
  • Yigg

Tags: , , , ,

lolwut: Flickr search link in Google results gives very unexpected result

Okay… Try this:

  1. Search for “flickr” in Google.
  2. Click on the “Search” link below the flickr.com result
  3. Think about the preselected search term.

lolwut: Flickr search link in Google results gives very unexpected result

Share and Enjoy:
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Mixx
  • Google
  • Furl
  • LinkedIn
  • Spurl
  • StumbleUpon
  • Technorati
  • Yigg

Tags: , , ,