Archive for January, 2007

h1

How to run your windows firefox on kubuntu with wine ?

January 28, 2007

I needed to run my windows firefox to retrieve some login (not password!) for things like my bank account…
Here comes an easy one, you’ll just need wine :
sudo apt-get install wine
Then you can launch your windows firefox (my partition is mounted on /media/sda1) :
wine /media/<YOUR_WINDOWS_PARTITION>/\
Program\ Files/Mozilla\ Firefox/firefox.exe

The problem is that your profile won’t be loaded. At first I wanted to link (ln) the profile from windows partition but that wouldn’t work as I have the basic ntfs driver that mount the partition as read only, and firefox would complain (and anyway I wouldn’t want wine to put a mess in my windows firefox profile…). So you’ll just need to copy it :
cp -R /media/<YOUR_WINDOWS_PARTITION>\
/Documents\ and\ Settings/<YOUR_WINDOWS_USERNAME>\
/Application\ Data/Mozilla/Firefox/ ~/.wine\
/drive_c/windows/profiles/<YOUR_KUBUNTU_LOGIN>\
/Application\ Data/Mozilla/

chmod -R 700 ~/.wine/drive_c/windows/profiles\
/<YOUR_KUBUNTU_LOGIN>/Application\ Data/Mozilla/Firefox

And you’re done, you can relaunch and your profile will be loaded.

Advertisements
h1

How to get symlinks to point tv and webcam in a non random manner ?

January 27, 2007

Starting with 2.5x kernels, all physical and virtual devices in a system are visible to userspace in a hierarchical fashion through sysfs. udev is replacing the functionality of devfs.

The order in which devices with the same function appear in /dev is essentially random. E.g., if you have a USB web camera and a TV tuner, sometimes /dev/video0 refers to the camera and /dev/video1 refers to the tuner, and sometimes after a reboot the order changes to the opposite one.

To get round this problem we will identify our hardware and create correct symlinks pointing to the right device.
For that :
udevinfo -a -p /sys/class/video4linux/video0
I got :
looking at device '/class/video4linux/video0':
KERNEL=="video0"
SUBSYSTEM=="video4linux"
SYSFS{name}=="Creative Labs Webcam 5"
SYSFS{dev}=="81:0"

This is my webcam, I don’t have that much device identification for it apart from the name and dev.
For my pctv card i get :
udevinfo -a -p /sys/class/video4linux/video1
looking at device '/class/video4linux/video1':
KERNEL=="video1"
SUBSYSTEM=="video4linux"
SYSFS{card}=="39"
SYSFS{name}=="BT878 video _Pinnacle PCTV Stud"
SYSFS{dev}=="81:1"
looking at device '/devices/pci0000:00/0000:00:09.0/0000:05:06.0':
ID=="0000:05:06.0"
BUS=="pci"
DRIVER=="bttv"
SYSFS{modalias}=="pci:v0000109Ed0000036Esv000011BDsd00000012bc04sc00i00"
SYSFS{local_cpus}=="01"
SYSFS{irq}=="66"
SYSFS{class}=="0x040000"
SYSFS{subsystem_device}=="0x0012"
SYSFS{subsystem_vendor}=="0x11bd"
SYSFS{device}=="0x036e"
SYSFS{vendor}=="0x109e"
looking at device '/devices/pci0000:00/0000:00:09.0':
ID=="0000:00:09.0"
BUS=="pci"
DRIVER==""
SYSFS{modalias}=="pci:v000010DEd0000005Csv00000000sd00000000bc06sc04i01"
SYSFS{local_cpus}=="01"
SYSFS{irq}=="0"
SYSFS{class}=="0x060401"
SYSFS{subsystem_device}=="0x0000"
SYSFS{subsystem_vendor}=="0x0000"
SYSFS{device}=="0x005c"
SYSFS{vendor}=="0x10de"
looking at device '/devices/pci0000:00':
ID=="pci0000:00"
BUS==""
DRIVER==""

Here we get more identification for the pctv device, we will ignore the ones with DRIVER==””, so we have the first 2 to keep.
Now we can create /etc/udev/rules.d/83-duplicate_devs.rules with identifications in :
# Persistent symlinks for webcam and tuner
KERNEL=="video*", BUS=="pci", \
SYSFS{device}=="0x036e", SYSFS{vendor}=="0x109e", \
SYMLINK+="tvtuner"
KERNEL=="video*", SYSFS{name}=="Creative Labs Webcam 5", \
SYMLINK+="webcam"

Now you can reboot and change the kde shortcut of your xdtv (or any tvsoft that doesn’t autodetect the device) with the new symlink here :
xdtv -c /dev/tvtuner

For more information on the subject : refer to this.

h1

How to make a simple image page counter / spyer in 20 minutes with Rails ?

January 27, 2007

At work I was a bit disappointed there is no counter on atlasian confluence wiki. I wanted to know whether my wiki page was being read by people and didn’t want to bug the admin to install the plugin for confluence. And this would be a good occasion to play with my beloved rails.

Prerequisites for your system (here kubuntu) :
I consider that you have rails installed (else sudo apt-get install rails), and mysql (else have a look here). You’ll also need to install mysql driver. First you need to install ruby packaging system : rubygems :
wget http://rubyforge.org/frs/download.php/16452/rubygems-0.9.1.tgz
tar xzvf rubygems-0.9.1.tgz
cd rubygems-0.9.1/
sudo ruby setup.rb

Gem needs dev package aswell else you’ll land with a
ruby extconf.rb install mysql
extconf.rb:1:in `require': no such file to load -- mkmf (LoadError)
from extconf.rb:1

To fix that :
sudo apt-get install ruby1.8-dev
You’ll also need libmysqlclient12 and libmysqlclient-dev :
sudo apt-get install libmysqlclient12
wget http://security.ubuntu.com/ubuntu/pool/main/m/mysql-dfsg/libmysqlclient-dev_4.0.20-2ubuntu1.7_amd64.deb
sudo dpkg -i libmysqlclient-dev_4.0.20-2ubuntu1.7_amd64.deb

Finally you can install the driver :
sudo gem install mysql

Create your application skeleton by :
rails counter
Edit counter/config/database.yml and fill your database settings.
Now we will think about the model, what we need to keep ? IP, Browser, when the page was visited and the image visited, can’t be simpler.
ruby counter/script/generate \
model visit

Now you can edit counter/db/migrate/001_create_visits.rb that will be responsible for the database creation and future upgrades.
We will add the column we need :
class CreateVisits < ActiveRecord::Migration
def self.up
create_table :visits do |t|
t.column "ip", :string, :limit => 50, :default => "", :null => false
t.column "created_on", :timestamp, :null => false
t.column "browser_agent", :string, :limit => 100, :default => "", :null => false
t.column "resource", :string, :limit => 30
end
end
def self.down
drop_table :visits
end
end

Create the schema in mysql (either by commandline or with MySQLQuery Browser for example). Now you can create database table and columns by just running the rake goal :
cd counter
rake db:migrate

If you land on getaddrinfo: Name or service not known it’s likely that you didn’t install the mysql driver (detailed in Prerequisites section).
Ok, we have our db ready, our model, and skeletons.
We will need an image library to create the counter image. I’ll use the popular and easy to use RMagick :
sudo apt-get install libmagick9-dev
sudo apt-get install imagemagick
sudo gem install rmagick

And after some minutes you’ll end with : Successfully installed rmagick-1.15.0 On windows you’ll just need to gem install rmagick-win32

What will be doing our CounterController ? We will render an image showing number of people that requested this image, and add a line to the visits in database. I created an image with framebox public/images/frame_small.jpg to make the counter look a little bit better than a simple number. (Yeah I know I could have created it with RMagick too).
Let’s create our controller CounterController :
script/generate controller Counter
We will add the method show in CounterController (app/controllers/counter_controller.rb) :
def show
@target = @params[:id]
counter_image = \
Magick::ImageList.new("public/images/frame_small.jpg")
text = Magick::Draw.new
# We count the visitor for the given target resource
counter = Visit.count(:conditions => \
[ "resource = ?", @target])
# puts "Counter for " + @target + " - " + counter.to_s
text.annotate(counter_image, 0, 0, 0, 0, counter.to_s) {
self.gravity = Magick::CenterGravity
self.pointsize = 16
self.font_family = "Verdana"
self.stroke = 'transparent'
self.fill = 'red'
self.font_weight = Magick::BoldWeight
}
counter_image.format = "GIF"
counter_image = counter_image.to_blob
# The image is created, we can render it as is.
render :text => counter_image, \
:status => 200, :content_type => 'image/gif'
end

Let’s add a filter to add a line to database, with IP… from the visitor (here we resolve the IP to get the dns which is more talkative in local network as here it contains the name of the user) :
before_filter :complete_stats, :only => :show
private
def complete_stats
@visit = Visit.new({:browser_agent => \
request.env['HTTP_USER_AGENT'], \
:ip => Resolv.getname(request.remote_ip.to_s).to_s, \
:resource => @params[:id]})
if @visit.save
#puts "Visit created"
else
#puts "Visit creation failed"
end
end

Finally you can test it (-p 80 will specify the port it turns on).
ruby script/server -p 80
You can now browse http://localhost/counter/show/imageA.gif, http://localhost/counter/show/imageB.gif, each time you visit one of them it gets incremented. Now you can insert in any confluence page a link to one of those virtual counter images and keep tracks of your visitors!

Of course this is a really simple version, but enough for my needs. You might check the referrers, count only one visit per ip per day…
You can get rails sources here (easier to read than from this wiki).

h1

How to get rid of the 10 minutes Blank Screen screensaver ?

January 27, 2007

You might not have noticed when you never happen to idle on your kubuntu more than 10 minutes, but a Blank Screen will be triggered. Not that embarassing you might think as there’s a big chance you’re away but well if there’s screensaver settings, it’s to configure that… And it becomes really irritating when you have a pctv card watching tv and that you have to move the mouse every 10 minutes.

So I couldn’t understand why this BlankScreen would appear although my settings in Desktop (right-click) / Configure Desktop / ScreenSaver was clearly using fireworks screensaver after 15minutes, and even after disabling it, I would still see this bloody BlanckScreen popping up. I thought it could be the Energy optimization from System Settings / Monitor & Display. But this one was set to 1 hour.

After some browsing on the net and some unsuccessful tries (with xset …) I thought I found it… in Desktop (right-click) / Configure Desktop / ScreenSaver / Blank Screen, unsetting the Start Automatically

Blank Screen Disabled

But that wouldn’t work either, finally I found a trick to disable this behavior thanks to ubuntu forum. In fact the problem appears when you run beryl with Xgl as a session on display :1. You’ll need to edit /etc/X11/xorg.conf and add at the end :
# To prevent Blank Screen from popping up every 10 minutes
# when xgl is run as a session on display :1,
# when all the power management settings
# you normally find only concerns display :0
Section "ServerFlags"
Option "blank time" "0"
Option "standby time" "0"
Option "suspend time" "0"
Option "off time" "0"
EndSection

h1

Playing with Beryl

January 21, 2007

My Beryl CubeToday I played a bit with Beryl. But firstly I needed to get the Super Key (Windows Key on Keyboard) working, this was accomplished by modifying Keyboard Section “InputDevice” in /etc/X11/xorg.conf with the following :
Option "XkbOptions" "altwin:super_win"
Now you can enjoy some more Beryl features, with the shortcuts (you can see snapshot of my desktop on the right) :

  • Pause Key or F8 : Scale Effect : Arrange and View All Windows
  • Ctrl + Alt + Left/Right Arrow : Switch desktops on cube
  • Ctrl + Shift + Alt + Left/Right Arrow : Switch desktops on cube – with active window following
  • Ctrl + Alt + left-click and grab desktop : Rotate cube manually
  • Alt + wheel mouse : Make window translucent/opaque
  • Super Key + wheel mouse up / down : Zoom-in/out manually
  • Ctrl + Super Key : Water
  • Shift + F9 : Rain

Also be sure to test the funky burn effect on windows minimizing through Beryl Settings Manager / Visual Effects / Animations / Minimize Animation => Burn

h1

About FLOSS phenomenon, and the rest…

January 21, 2007

After 15 years of existence of GNU/Linux, can we measure the impact of it and the FLOSS phenomena ?
That’s what EUROPA ENTR Study did in a quite complete Economic impact of open source software on innovation and the competitiveness of the formation and Communication Technologies.
You’ll see a lot of interesting figures and statistics there. You’ll also read Macro-analysis, ie that the most impacted, and active region by FLOSS is Europe, then America, but China and Latin countries will soon overtake Europe.
After leading the field of supercomputing (Top500 Operating system Family), with 75.20% being Linux (17.20% Unix), OSS is gaining popularity in Operating Serrver Systems in companies (15.7% OSS in UK, Sweden, Germany).
While the North/South fracture is disappearing for some country in some domain, the digital fracture is present :
World Map of Commiters by population
Some other interesting questions from the study are :

1. What were the actual costs of developing a given set of software, in terms of time and effort and the equivalent in monetary terms?
2. What is the substitution cost of the same software – i.e. how much would it have cost to build the same software entirely within a single firm in a proprietary software development model33.

Then are given figures about Debian 3.1 FLOSS distribution (2005) :

Source lines of code : 221,351,503
If Debian was written in a software company…
Estimated effort : 163 522 person years
Development cost estimate (till 2005) : Euro 11.9 billion
Development cost estimate (till 2010) : Euro 100 billion
Copyright © 2006 MERIT. Source: URJC estimates (cumulative effort estimation), payscale.com (salary data).

A note concerning this figure, it uses a COCOMO model adding complexity, without it it would be Person-Years = 2.4 * (KSLOC**1.05)) / 12 = 81915.
Firstly I didn’t know that latest Debian distros were that big, latest stats I read around about the Debian 2.2 potatoe were around 56 SLOC (56 Millions of Source Lines Of Code).
I guess that with those latest counts, X, Mozilla, Desktops are included.
Anyway what are 3 SLOC (for X), 6.2 SLOC (for KDE Snapshot / > 3.5.5), 1 SLOC (KOffice) next to the gigantic 221 SLOC.
You can do your own statistics using sloccount on your favorite projects (I did for X11R6.8.1, KDE Snapshot / > 3.5.5, I also did Beryl 0.1.4 : 0.2 SLOC).
So this has to be considered to the commercial equivalent Software :
Mac OS X 10.4 : 86 SLOC (Most of which must be from BSD…)
Vista : Said to be around 50 SLOC
So what to conclude the more SLOC, the better ? Not really, it’s hard to draw conclusion of the quality of a software only from the number of lines of code, but you can estimate the costs quite easily and you have an idea of how many license one needs to sale to make benefits.
Microsoft problem can be summed up easily :

Suddenly, the market changed and competitors started delivering technology at the speed of the Internet,” said James McQuivey, professor of market research at Boston University. “In some cases, they do it for free, and that’s painful for Microsoft.”

Vista is said to have cost 10 Billions Dollars, it is predicted to be installed on 76 Millions of computers, and should be responsible for $11.5 billion of profits by the end of June 2007.
That’s where we go and what European Study doesn’t emphasize, while there’s no doubt that the FLOSS is growing inside companies, the Personal Computer has a majority of Microsoft OS installed. So why Vista should be the last of it kind ?

h1

Kubuntu and the small security improvements features to copy

January 21, 2007

There are 2 features I would like to see integrated (without using thirdparties software) in any OS that brings little security easily to the user and the machine :

  • The kdewallet : KDE Wallet aims to provide secure storage for passwords and web form data. You can group different passwords in different wallets, and each one will only be opened with a master password (which you should never forget!). The default wallet is named “kdewallet”, and you can either create a new wallet for your local passwords or accept the default wallet for all data in the “Automatic Wallet Selection” section.
  • Finally with Kubuntu during install I was surprised there was no prompt for root password but just <youruser> password. I find this restrictive politic of sudoing each time you need it really efficient and secure and the lambda user shouldn’t even know of the existence of root.