Joining the ‘Mono is a disease’ debate

I’ve recently read a couple of arguments regarding Mono and it’s effect on Linux. These are interesting debates and can be found here and here. I’ve decided to posy my 10 cents worth!

My most popular application is Furius ISO Mount which up until version 0.11.0.0  was written in C# using Mono. Prior to this application I had never done any development for Linux and all my previous programming work had been corporate driven Windows development. When I came to Linux, I thought it was great that my existing skill set was immediately transferable to Linux and I could start hacking some code together with limited Linux knowledge. I think this is an important point to take into consideration. I understand the political arguments, however, I feel that any technology that brings more developer to work with Linux is only a good thing.

There is often an argument that Cannabis is a gateway drug, while not as dangerous as other drugs, it can lead to exposure to the harder drugs; Mono was my gateway drug! Programming using Mono gave me exposure to Linux development and led me on to trying other languages, such as Python.

Furius ISO Mount was completely rewritten in Python for version 0.11.0.0 but if it wasn’t for Mono I would have never written the application and possibly never programmed for Linux. This reason. for one, is why I think the Mono project is a worthwhile endeavour and I hope it introduces more Windows programmers to developing for Linux.

Furius ISO Mount Version 0.11.2.1 Released

A new version of Furius ISO Mount has been released.

Added support for the ISO-13346 “UDF” file system specification when using the loop mount option. This should have been included in version 0.11.2.0 but was omitted in error.

Vala Programming Language Recursive Benchmark using Fibonacci

In a previous post I took a look at benchmarking the performance of various programming languages using recursive Fibonacci. Today I decided to take a look at Vala.

Vala is a new programming language that aims to bring modern programming language features to GNOME developers without imposing any additional runtime requirements and without using a different ABI compared to applications and libraries written in C.

First, of course, I had to install Vala and a suitable IDE. To do this on Ubuntu 10.04, I followed the instructions found here.

Here is the code and the benchmark result:

public class Main
{

  public static int Fibonacci(int n)
  {
    if (n < 2)
    {
      return n;
    }
    else
    {
      return Fibonacci(n - 1) + Fibonacci(n - 2);
    }
  }

  public static int main (string[] args)
  {
    var timer = new Timer();
    timer.start();
    for (int  i = 0; i < 36; i++)
    {
      stdout.printf("n=%d => %d\n", i, Fibonacci(i));
    }
    timer.stop();
    stdout.printf("Time elapsed = %f seconds\n", timer.elapsed());
    return 0;
  }
}

Results: Time elapsed = 0.640000 seconds

As you can see, compared to the recursive python benchmark (Time elapsed =  14.2846501707 seconds), this is very fast.

Vala looks like a very interesting language and is one I’ll be watching the progress of closely.

Please note: I’m not a C coder and have never programmed in either C or Vala before, as such, my timing routine is probably poorly implemented at best! If anyone knows how I should have done this, I’d love to hear from you.

Many thanks to frederik (see comments below) for showing me a better way of determining elapsed time!

Surf Anonymously with Ubuntu 10.04, Tor, Privoxy and Firefox

We all know that Big Brother is watching, but he doesn’t need to know what websites you’ve been visiting! Using Privoxy, a web proxy program, Tor, a software project that helps you defend against traffic analysis, and a firefox plugin called TorButton, you can browse the web in anonymous safety. Here is some an explanation of the technology from the Tor website:

Tor protects you by bouncing your communications around a distributed network of relays run by volunteers all around the world: it prevents somebody watching your Internet connection from learning what sites you visit, and it prevents the sites you visit from learning your physical location.

Please note: Because your communications are bounced around a global network, your surfing will take a slight performance hit. Because of this we are using TorButton to enable us to quickly turn this feature on and off.

Installation

First let’s install Tor and Privoxy (Ensure the restricted repositories are enabled)

sudo echo ‘deb http://deb.torproject.org/torproject.org lucid main’ | sudo tee -a /etc/apt/sources.list && gpg –keyserver keys.gnupg.net –recv 886DDD89 && gpg –export A3C4F0F979CAA22CDBA8F512EE8CBC9E886DDD89 | sudo apt-key add – && sudo aptitude update && sudo aptitude install tor tor-geoipdb polipo privoxy

Next, we need to configure Privoxy. Open /etc/privoxy/config in your favourite text editor.

sudo gedit /etc/privoxy/config

We need to find this line: listen-address localhost:8118
In my config file it was line number 741.

Beneath this we need to add the following text (including the period):

forward-socks4a / localhost:9050 .

Your config file should look like this…

/etc/privoxy/config

/etc/privoxy/config

Save and exit.

Now we need to restart Tor and Privoxy

sudo /etc/init.d/tor restart
sudo /etc/init.d/privoxy restart

Now we need to start firefox and install the TorButton plugin.

Navigate firefox to https://addons.mozilla.org/en-US/firefox/addon/2275 and click ‘Add to Firefox’

Restart firefox.

In the bottom right hand corner of firefox you will now have a button titles ‘Tor Disabled’, this can be clicked to enable and disable Tor. You can test your new found anonymity by visiting http://ip-address.domaintools.com/ (see screenshots below).

Tor Disabled

Tor Disabled

Tor Disabled

Tor Enabled

Tor Enabled

Tor Enabled

Happy anonymous surfing!

Super fast Fibonacci number generator for Python and Ruby

Some time ago at work my colleagues and I were discussing the performance of various programming languages (Python, C++, C#, VBA, JavaScript, Java, VB.Net, Ruby) and which one was the fastest. I therefore started writing recursive Fibonacci methods for each language and timing their execution (anything to get out of doing real work!). This then led to looking into faster methods of generating the Fibonacci sequence. Below are three different method for generating the sequence; recursive (slow), matrix (fast), and pure maths (super fast). Though I have yet to come across a need to generate a Fibonacci number in one of my applications, I thought I would share this as it may be of interest to some of you out there.

PYTHON Recursive (slow)

import time

def fibonacci(n):
    if n < 2:
     return n
    else:
     return fibonacci(n-1) + fibonacci(n-2)

start = time.clock()
for i in range(36):
    print "n=%d => %d" % (i, fibonacci(i))
end = time.clock()
print "Time elapsed = ", end - start, "seconds"

Results: Time elapsed =  14.2846501707 seconds

Matrix (fast) Note: This requires the python-numpy module (Ubuntu users can apt-get install python-numpy)

import time
import numpy

fibonacci_matrix = numpy.matrix([[1,1],[1,0]])
def fibonacci(n):
    return (fibonacci_matrix**(n-1)) [0,0]

start = time.clock()
for i in range(36):
    print "n=%d => %d" % (i, fibonacci(i))
end = time.clock()
print "Time elapsed = ", end - start, "seconds"

Results: Time elapsed =  0.0408389234748 seconds

Pure Maths (super fast)

import time
from math import sqrt

def fibonacci(n):
    root5 = sqrt(5)
    phi = 0.5 + root5/2
    return int(0.5 + phi**n/root5)

start = time.clock()
for i in range(36):
    print "n=%d => %d" % (i, fibonacci(i))
end = time.clock()
print "Time elapsed = ", end - start, "seconds"

Results: Time elapsed =  0.00034817521541 seconds

RUBY Recursive

def fibonacci(n)
    if n < 2
        n
    else
        fibonacci(n-1) + fibonacci(n-2)
    end
end

start_time = Time.now
36.times do |i|
    puts "n=#{i} => #{fibonacci(i)}"
end
end_time = Time.now
puts "Time elapsed = #{end_time - start_time} seconds"

Matrix

require 'matrix'

FIBONACCI_MATRIX = Matrix[[1,1],[1,0]]
def fibonacci(n)
 (FIBONACCI_MATRIX**(n-1)) [0,0]
end

start_time = Time.now
36.times do |j|
 puts "n=#{j} => #{fibonacci(j)}"
end
end_time = Time.now
puts "Time elapsed = #{end_time - start_time} seconds"

Pure Maths

def fibonacci(n)
 root5 = Math.sqrt(5)
 phi = 0.5 + root5/2
 Integer(0.5 + phi**n/root5)
end

start_time = Time.now
36.times do |j|
 puts "n=#{j} => #{fibonacci(j)}"
end
end_time = Time.now
puts "Time elapsed = #{end_time - start_time} seconds"

#########################################

For anyone who wishes to run some language benchmarks themselves (if you are really bored!!), here is the recursive sequence for other languages.

PHP

function fibonacci($n) {
    if ($n < 2) {
        return $n;
    }
    else {
        return fibonacci($n - 1) + fibonacci($n - 2);
    }
}

$start_time = microtime(true);
for ($i = 0; $i < 36; $i++) {
    $fib = fibonacci($i);
    print "n=$i =>; $fibn";
}

$end_time = microtime(true);
$diff_seconds  = $end_time - $start_time;
print "Time elapsed = $diff_seconds seconds";

VBA

Private Function Fibonacci(ByVal n As Integer) As Long
    If n < 2 Then
        Fibonacci = n
    Else
        Fibonacci = Fibonacci(n - 1) + Fibonacci(n - 2)
    End If
End Function

Sub Main()
    Dim StartTime As Date
    Dim EndTime As Date

    StartTime = Time
    For Index = 0 To 35
        Debug.Print "n=" & Index & " => " & Fibonacci(Index)
    Next
    EndTime = Time

    Debug.Print "Time elapsed = " & (EndTime - StartTime) * 86400
End Sub

C#

static int Fibonacci(int n)
    {
        if (n < 2)
        {
            return n;
        }
        else
        {
            return Fibonacci(n - 1) + Fibonacci(n - 2);
        }
    }

    static void Main(string[] args)
    {
        Stopwatch stopwatch = new Stopwatch();
        stopwatch.Start();
        for (int i = 0; i < 36; i++)
        {
            Console.WriteLine("n={0} => {1}", i, Fibonacci(i));
        }
        stopwatch.Stop();
        TimeSpan excecutionTime = stopwatch.Elapsed;
        Console.WriteLine("Time elapsed = {0:00}.{1:00} Seconds",
                excecutionTime.Seconds, excecutionTime.Milliseconds / 10);
        Console.ReadLine();
    }

JAVA

public static void main(String[] args) {
 long start = System.currentTimeMillis( );
 for (int i = 0; i < 36; i++)
        {
      System.out.println("n=" + i + " => " + Fibonacci(i));
        }
 long end = System.currentTimeMillis( );
 double deltaT = end-start;
 System.out.println("Time elapsed = " + deltaT/1000 + " seconds.");
 try {
  System.in.read( );
 } catch (IOException e) {
  e.printStackTrace();
 }
}

public static int Fibonacci(int n) {
        if (n < 2)
        {
            return n;
        }
        else
        {
            return Fibonacci(n - 1) + Fibonacci(n - 2);
        }
}

Enjoy!

Furius ISO Mount Version 0.11.2.0 Released

A new version of Furius ISO Mount has been released. This release has added some often asked for functionality:

Ability to change the base mount point of images (defaults to the user’s home directory)
Ability to mount an image from the command line (this allows people to use Furius ISO Mount in their own scripts, etc).

How to Change the Mount Point in Furius ISO Mount

Open a terminal window and type:
gedit .furiusisomount/settings.cfg

Change the following line as appropriate:
mount_point: /home/harris

For example, to mpount images in your Videos folder:
mount_point: /home/harris/Videos

How to Mount an Image with Furius ISO Mount from the Command Line

Open a terminal window and type:
furiusisomount /location/of/image/file

Enjoy the new release!

Hello world!

After a prolonged downtime, marcus-furius.com is finally back up and running. Please be patient while I try and rebuild the contents.
Many thanks,
Dean Harris
AKA
Marcus Furius

Return top

If you like Furius ISO mount, feel free to buy me a beer ;P

If you provide a link to your website or blog I'll post a link next to your name

Top Donations

£20.00 GBP from Edwin Peach

£2.00 GBP from Paul Field