The World According to Marcus Furius

Saving Rome from the Barbarians

Furius ISO Mount Version 0.11.1.0 Released

This is a Python coded release and adds multiple image drag and drop auto-mounting functionality and nautilus file browsing support.

If you are using the deb installers and are upgrading from the Mono versions (0.9.2.0 and below) please remove any previous instances (sudo apt-get remove furiusisomount) prior to installing. If you do not wish to install Furius ISO Mount Version 0.11.1.0 then you can simply download the furiusisomount- 0.11.1.0.tar.gz, extract to a directory of your choice and run the furiusisomount shell script. This makes it an ideal tool for adding to your USB thumb drives!

Head on over to the Furius ISO Mount Projects page and grab yourself the latest version.

No comments

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)

  1. import time
  2.  
  3. def fibonacci(n):
  4.     if n < 2:
  5.         return n
  6.     else:
  7.         return fibonacci(n-1) + fibonacci(n-2)  
  8.  
  9. start = time.clock()
  10. for i in range(36):
  11.     print "n=%d => %d" % (i, fibonacci(i))
  12. end = time.clock()
  13. print "Time elapsed = ", end - start, "seconds"
Recursive (slow) Fibonacci Results

Recursive (slow) Fibonacci Results

Matrix (fast)

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

  1. import time
  2. import numpy
  3.  
  4. fibonacci_matrix = numpy.matrix([[1,1],[1,0]])
  5. def fibonacci(n):
  6.     return (fibonacci_matrix**(n-1)) [0,0]
  7.  
  8. start = time.clock()
  9. for i in range(36):
  10.     print "n=%d => %d" % (i, fibonacci(i))
  11. end = time.clock()
  12. print "Time elapsed = ", end - start, "seconds"
Matrix (fast) Fibonacci Results

Matrix (fast) Fibonacci Results

Pure Maths (super fast)

  1. import time
  2. from math import sqrt
  3.  
  4. def fibonacci(n):
  5.     root5 = sqrt(5)
  6.     phi = 0.5 + root5/2
  7.     return int(0.5 + phi**n/root5)
  8.  
  9. start = time.clock()
  10. for i in range(36):
  11.     print "n=%d => %d" % (i, fibonacci(i))
  12. end = time.clock()
  13. print "Time elapsed = ", end - start, "seconds"
Pure Maths (super fast) Fibonacci Results

Pure Maths (super fast) Fibonacci Results

RUBY

Recursive

  1. def fibonacci(n)
  2.     if n < 2
  3.         n
  4.     else
  5.         fibonacci(n-1) + fibonacci(n-2)
  6.     end
  7. end
  8.  
  9. start_time = Time.now
  10. 36.times do |i|
  11.     puts "n=#{i} => #{fibonacci(i)}"
  12. end
  13. end_time = Time.now
  14. puts "Time elapsed = #{end_time - start_time} seconds"

Matrix

  1. require ‘matrix’
  2.  
  3. FIBONACCI_MATRIX = Matrix[[1,1],[1,0]]
  4. def fibonacci(n)
  5.         (FIBONACCI_MATRIX**(n-1)) [0,0]
  6. end
  7.  
  8. start_time = Time.now
  9. 36.times do |j|
  10.         puts "n=#{j} => #{fibonacci(j)}"
  11. end
  12. end_time = Time.now
  13. puts "Time elapsed = #{end_time - start_time} seconds"

Pure Maths

  1. def fibonacci(n)
  2.         root5 = Math.sqrt(5)
  3.         phi = 0.5 + root5/2
  4.         Integer(0.5 + phi**n/root5)
  5. end
  6.  
  7. start_time = Time.now
  8. 36.times do |j|
  9.         puts "n=#{j} => #{fibonacci(j)}"
  10. end
  11. end_time = Time.now
  12. 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

  1. function fibonacci($n) {
  2.     if ($n < 2) {
  3.         return $n;
  4.     }
  5.     else {
  6.         return fibonacci($n - 1) + fibonacci($n - 2);
  7.     }
  8. }
  9.  
  10. $start_time = microtime(true);
  11. for ($i = 0; $i < 36; $i++) {
  12.     $fib = fibonacci($i);
  13.     print "n=$i => $fib\n";
  14. }
  15.  
  16. $end_time = microtime(true);
  17. $diff_seconds  = $end_time - $start_time;
  18. print "Time elapsed = $diff_seconds seconds";

VBA

  1. Private Function Fibonacci(ByVal n As Integer) As Long
  2.     If n < 2 Then
  3.         Fibonacci = n
  4.     Else
  5.         Fibonacci = Fibonacci(n - 1) + Fibonacci(n - 2)
  6.     End If
  7. End Function
  8.  
  9. Sub Main()
  10.     Dim StartTime As Date
  11.     Dim EndTime As Date
  12.  
  13.     StartTime = Time
  14.     For Index = 0 To 35
  15.         Debug.Print "n=" &amp; Index &amp; " => " &amp; Fibonacci(Index)
  16.     Next
  17.     EndTime = Time
  18.  
  19.     Debug.Print "Time elapsed = " &amp; (EndTime - StartTime) * 86400
  20. End Sub

C#

  1. static int Fibonacci(int n)
  2.     {
  3.         if (n < 2)
  4.         {
  5.             return n;
  6.         }
  7.         else
  8.         {
  9.             return Fibonacci(n - 1) + Fibonacci(n - 2);
  10.         }
  11.     }
  12.  
  13.     static void Main(string[] args)
  14.     {
  15.         Stopwatch stopwatch = new Stopwatch();
  16.         stopwatch.Start();
  17.         for (int i = 0; i < 36; i++)
  18.         {
  19.             Console.WriteLine("n={0} => {1}", i, Fibonacci(i));
  20.         }
  21.         stopwatch.Stop();
  22.         TimeSpan excecutionTime = stopwatch.Elapsed;
  23.         Console.WriteLine("Time elapsed = {0:00}.{1:00} Seconds",
  24.                 excecutionTime.Seconds, excecutionTime.Milliseconds / 10);
  25.         Console.ReadLine();
  26.     }

JAVA

  1. public static void main(String[] args) {
  2.         long start = System.currentTimeMillis( );
  3.         for (int i = 0; i < 36; i++)
  4.         {
  5.                 System.out.println("n=" + i + " => " + Fibonacci(i));
  6.         }
  7.         long end = System.currentTimeMillis( );
  8.         double deltaT = end-start;
  9.         System.out.println("Time elapsed = " + deltaT/1000 + " seconds.");
  10.         try {
  11.                 System.in.read( );
  12.         } catch (IOException e) {
  13.                 e.printStackTrace();
  14.         }
  15. }
  16.  
  17. public static int Fibonacci(int n) {
  18.         if (n < 2)
  19.         {
  20.             return n;
  21.         }
  22.         else
  23.         {
  24.             return Fibonacci(n - 1) + Fibonacci(n - 2);
  25.         }
  26. }

Enjoy!

No comments

Help Required Localizing Python Version of Furius ISO Mount

Due to my Microsoft Windows .Net programming background, I have had no experience localizing Python applications. As such, I am sending out of request for a Python coder to assist me in (i.e., do :p) the required setup and coding. If you are able to localize python applications (generate PO templates and files, create correct directory structure for the .mo files, add localization coding etc) and would like to help with Furius ISO Mount, please get in touch as your help will be greatly appreciated!

Many thanks.

No comments

Automaticaly Download and Process NZB’s in Mandriva 2009 using Hellanzb

From the Hellanzb website:

hellanzb is a Python application designed for *nix environments that retrieves nzb files and fully processes them. The goal being to make getting files from Usenet (e.g.: Giganews Newsgroups) as hands-free as possible. Once fully installed, all thats required is moving an nzb file to the queue directory. The rest; fetching, par-checking, un-raring, etc. is taken care of by hellanzb.

Installing Hellanzb

Open a terminal

Install the prerequisites (resolve dependencies as required)

su
urpmi libpython2.5-devel parchive2 unrar python-twisted

Get the latest version of hellanzb (version 0.13 latest at time of writting)

aria2c http://www.hellanzb.com/distfiles/hellanzb-0.13.tar.gz

Unpack archive

tar -xzvf hellanzb-0.13.tar.gz

Install hellanzb

cd hellanzb-0.13
python setup.py install

Configure Hellanzb

cp /usr/etc/hellanzb.conf.sample /usr/etc/hellanzb.conf
kwrite /usr/etc/hellanzb.conf

In the defineServer section changes the id, hosts, username and password values to those supplied by your usenet provider.

Under Important locations change Hellanzb.PREFIX_DIR = ‘/ext2/’ to Hellanzb.PREFIX_DIR = ‘/home/YOUR-USER-NAME/’

Other settings and locations can be changed if required but this is not necessary.

Running Hellanzb

Open a terminal

hellanzb.py

Download a NZB file and place it in

/home/YOUR-USER-NAME/nzb/daemon.queue/

Once files have been processed they will be placed in

/home/YOUR-USER-NAME/usenet/

No comments

Initial Python Implementation of Furius ISO Mount Released

A new version of Furius ISO Mount has been released (0.11.0.0) which is a complete rewrite in Python. This is the first beta release of the Python implementation of Furius ISO Mount. It currently contains all the functionality of the mono/C# version but does not include localization support.
Debian installers are available along with the source code. If you are using the deb installers please remove any previous instances (sudo apt-get remove furiusisomount) prior to installing. If you do not wish to install Furius ISO Mount Version 0.11 then you can simply download the furiusisomount-

0.11.0.0.tar.gz, extract to a directory of your choice and run the furiusisomount shell script.
This version is considered beta quality, but your help in testing would be much appreciated.

Please report any bugs here.

Python Implementation of Furius ISO Mount on Ubuntu 8.04

Python Implementation of Furius ISO Mount on Ubuntu 8.04

No comments

Furius ISO Mount Version 0.9.0.2 Released

A small point release to bring in more localization support; adding Danish, Hungarian and Slovenian to the growing list. Many thanks to Jens Sørensen, Dávid Völgyes and Robert Hrovat, respectively. A minor correction to the French translation was also made.

Head on over to the Furius ISO Mount Projects page and grab yourself the latest version.

Work has also been slowly going ahead on the Python version of Furius ISO Mount, so I thought I’d add a screenshot to show any interested parties how it’s progressing!

PyFuriusIsoMount Performing a Checksum

PyFuriusIsoMount Performing a Checksum

No comments

Furius ISO Mount Version 0.9.0.1 Released

A small point release to bring in more localization support; adding French and Italian to the growing list. Many thanks to Dubois Yaën Pujol and Riccardo Loti.

Head on over to the Furius ISO Mount Projects page and grab yourself the latest version.

No comments

Work has started on a Python version of Furius ISO Mount

Following various comments and, it would seem, a lot of people inherent mistrust of mono work has now started on a Python version  of Furius ISO Mount. The code should be uploaded soon.

1 comment

How to Install Furius ISO Mount on 64bit Ubuntu (x64)

EDIT: Not 10 minutes after writing this post, I decided to install a 64bit Ubuntu on one of my computers (don’t know why I didn’t do it sooner!). As a result, I have now built an amd64 deb file for Furius ISO Mount; get it from the Furius ISO Mount Projects page or just click here.

Unfortunately I don’t have a 64bit Ubuntu (x64) system installed so I am unable to provide a deb installer for 64bit systems. Thankfully, Furius ISO Mount is very easy to compile from source. Here, then, are the instructions on compiling Furius ISO Mount from source.

First, we must install the required dependencies and build tools.

sudo apt-get install build-essential mono-gmcs fuseiso libgtk2.0-cil libmono-system2.0-cil gksu

Next, we get the latest version (0.9.0.0 at time of post) and install.

wget http://www.marcus-furius.com/files/FuriusIsoMount/furiusisomount-0.9.0.0.tar.gz
tar xzvf furiusisomount-0.9.0.0.tar.gz
cd furiusisomount-0.9.0.0
./configure
make
sudo make install

Furius ISO Mount should now be installed and available under Sound & Vision.

If you wish, you can also create your own ‘personal’ deb installer using a tool called checkinstall.

Install checkinstall.

sudo apt-get install checkinstall

Then you can follow the instructions above; however, you should replace the last command (sudo make install) with…

sudo checkinstall

Just follow the onscreen instructions (choosing the default values will be fine).

Furius ISO Mount will now be installed and you will also have a deb file available if you ever need to install again… or send to your friends!

No comments

Furius ISO Mount Version 0.9.0.0 Released

This update brings in support for the ‘mount’ command. Some images mounted with fuse do not always work as expected, such as multisector images, therefore, the user can select to use ‘Loop’ to mount the image using the mount command. Since the mount command requires root privileges, gksu is used to gain root access. This release also brings in continued localization support with a Turkish translation; thanks to Irfan Emrah Kanat.

Head on over to the Furius ISO Mount Projects page and grab yourself the latest version.

No comments

Next Page »