Fork me on GitHub

Aug 30, 2007

MVideo Final Cut



Wow.....

Aug 25, 2007

Everybody Away?


Hey common people is saturday lets chat :), this is the first time that I saw this thing... weird.

Aug 22, 2007

Gnome 10 years of freedom


We are in a one month GNOME party , thanks to all that make GNOME possible, to provide us the best desktop environment ever. Thanks to everyone, I hope that someday I'll be one GNOME developer.

Results of 2007 Desktop Linux survey

http://www.desktoplinux.com/news/NS8454912761.html

It looks like I'm in the good(or at least popular) side of the forces :)

I use both VMware and Wine, because there's no way to run Visual Studio 2005 in Wine :(
This is like the difference between "MS Outlook" and "MS Outlook express", the 32% of Evolution(the one that I used... now only Gmail web client) is cool because Evolution is more enterprise than Thunderbird, which means that Linux is actually being used in the enterprise, thats good news.
Of course Firefox is the best browser ever, and the version 3.0 is going to be even better.
Long life to GNOME, simply the best Desktop environment.
Ubuntu is just the best overall :), but actually I also use SuSE sometimes... I'm surprised about the 9% of RedHat a big lost.

Aug 18, 2007

Recursion in C# vs Recursion in Python

I found recursion very useful but very dangerous, at least for Python is not to good use recursion, C# support a better recursion... at least it seams to have no limit.

A Pow function command in both languages, C# with mono 1.2 and Python with python2.5 all on a Ubuntu 7.10 Core 2 Duo 1.5Ghz and 2GB RAM:

Python code:


#!/usr/bin/env python

from sys import argv

def pow(num, n):
if n == 0:
return 1
else:
return num * pow(num, n - 1)

def test():
if len(argv) is not 3:
print "usage: rec.py num n"
else:
print pow(int(argv[1]), int(argv[2]))

if __name__ == "__main__":
test()

igor@igorlaptop:~/Desktop/testrecur$ time python rec.py 2 997
1339385758982834151185531311325002263201756014631917009304687985462938813906170153116497973519619822659493341146941433531483931607115392554498072196837321850491820971853028873177634325632796392734744272769130809372947742658424845944895692993259632864321399559710817770957553728956578048354650708508672

real 0m0.038s
user 0m0.012s
sys 0m0.008s

997 is the limit of this Python function and after that this happened:
igor@igorlaptop:~/Desktop/testrecur$ time python rec.py 2 998
File "rec.py", line 9, in pow
return num * pow(num, n - 1)
...
...
...
File "rec.py", line 9, in pow
return num * pow(num, n - 1)
RuntimeError: maximum recursion depth exceeded

real 0m0.181s
user 0m0.096s
sys 0m0.028s

Now lets see C#:

using System;

class Rec {
private static double pow(double num, double n) {
if(n == 0) {
return 1;
} else {
return num * pow(num, n - 1);
}
}

public static void Main(string[] args) {
if(args.Length != 2) {
Console.WriteLine("Usage: mono rec.exe num n");
} else {
Console.WriteLine(pow(double.Parse(args[0]), double.Parse(args[1])));
}
}
}

igor@igorlaptop:~/Desktop/testrecur$ time mono rec.exe 2 997
1.33938575898283E+300

real 0m0.087s
user 0m0.072s
sys 0m0.012s

Apparently recursion in C# is infinity this is the last numeric value that the function gives:
igor@igorlaptop:~/Desktop/testrecur$ time mono rec.exe 2 1023
8.98846567431158E+307

real 0m0.090s
user 0m0.068s
sys 0m0.016s

Recursion keeps working in C#

Last valid recursion:
igor@igorlaptop:~/Desktop/testrecur$ time mono rec.exe 2 174566
Infinity

real 0m0.096s
user 0m0.068s
sys 0m0.012s

But 174567 is the Magic number!!!... lets patch the program to get the exception:

--- rec.cs 2007-08-18 16:03:06.000000000 -0400
+++ recErrorHandling.cs 2007-08-18 16:02:33.000000000 -0400
@@ -2,10 +2,15 @@

class Rec {
private static double pow(double num, double n) {
- if(n == 0) {
- return 1;
- } else {
- return num * pow(num, n - 1);
+ try {
+ if(n == 0) {
+ return 1;
+ } else {
+ return num * pow(num, n - 1);
+ }
+ } catch (Exception e) {
+ Console.WriteLine(e);
+ return 0;
}
}

igor@igorlaptop:~/Desktop/testrecur$ time mono rec.exe 2 174567
System.StackOverflowException: The requested operation caused a stack overflow.
at Rec.pow (Double num, Double n) [0x00000]
at Rec.pow (Double num, Double n) [0x00000]
0

real 0m0.125s
user 0m0.104s
sys 0m0.020s

Lesson:

Python is faster in recursion that C# but C# have a much better range.

Codes:

Python Pow: http://monoport.com/4148
C# Pow: http://monoport.com/4147
C# Exception patch: http://monoport.com/4149

Aug 9, 2007

Me... in Banshee 0.13.0 release

Well, here I'm:

...

Contributors for this release
-----------------------------

Community makes Open Source work!

Aaron Bockover, Bill Dawson, Bojan Rajkovic, Brian Nickel, Dan Wilson,
Daniel Munckton, Eric Butler, Gabriel Burt, Igor Guerrero Fonseca,
Ilya Konstantinov, James Willcox, Jan Arne Petersen, Jason Conti,
Lauri Kotilainen, Michael Monreal, Pepijn van de Geer, Ruben Vermeersch, Scott Peterson, Sebastian Droge, Trey Ethridge

...

http://banshee-project.org/files/banshee/banshee-0.13.0.news

I'm very proud of myself... and thanks Banshee community ;)

disclaimer



Things written in this blog are my personal thoughts or points of view, and do not represent at all the position of my employer.

Code in the website is licensed under The MIT License

Content of this blog is:
Creative Commons License
Licensed under a Creative Commons Attribution-Share Alike 3.0 Unported License.