Could my beloved America really go from Bush to a duo that's worse than Bush?

http://www.nytimes.com/2008/09/14/us/politics/14palin.html?hp

rafael | Politics | 14 September, 12:52am | 4 comments

Always ingenious, John Stewart delivers one of the best reviews of what went on this week with McCain's campaign reaching for new lows with their attack adds aimed at painting a picture of an "elitist Obama"

Update: Priceless comment from reddit:

http://www.reddit.com/comments/6uis9/jon_stewart_mccains_celebrity_attack_add_is_the/c04wkkx

rafael | Politics | 2 August, 2:21am | Comment on this

Does anyone know of such strange, yet delightful, gathering? I would like to see how things are going in mono land...

rafael | Mono | 23 July, 4:12pm | 2 comments

"Flip-flops are only worn by girls and gay guys. On John McCain it's just beach wear."

Original here: http://reddit.com/info/6kas2/comments/

rafael | Politics | 22 May, 2:23am | Comment on this

I'm typing this as I wait for my dad's brand new Sony VAIO to run Vista's "checking your hardware" utility; it has been doing this for about 8 minutes now. Before this lovely state, I had to wait while it ran "windows gets ready to run for the first time" for about 20 minutes.

wait.. it just rebooted, looks like it is done.

So in total, it took me 5 minutes to unpackage the VAIO plug it in and turn it on, and about 28 minutes to run Vista for the first time.

Two things I don't understand:

1) This is a brand new US$2,000 laptop with a fancy hybrid hard drive, why does it need to "check my hardware"?
2) Why OEM's put up with this? I mean Sony should have enough leverage to force Microsoft to provide them with a "quick firstboot" version of Vista.

Don't get me wrong, I'm not a Windows hater, I'm fine with it for the most part, but this just pushes my patience to a whole new level... has no one at Microsoft used a Mac and seen their elegant "firstboot" system? Or used pretty much any recent Linux distro for that matter?

btw.. windows is still booting...

rafael | General | 2 May, 11:20pm | 6 comments

For some odd reason I came across this video today, it brings together Mr. Dawkins and Pastor Ted. I'm not quite sure why professor Dawkins would even consider something like this but it is hella funny.

Even if you are a big Pastor Ted fan, this video should still serve to show you the crumbling grounds that one must take to argue about logic and reason against an evolutionary biologist.

rafael | General | 10 March, 2:55am | 2 comments

This may not surprise some of you but, believe it or not, you can write very simple asynchronous delegates in plain old bash. Yeah that's right, BASH.

Here's the scenario, let's say you have to perform a task that might take a long time (let's pretend you need to check the health of an nfs server prior to attempting to mount exports from it) but you do not want to block the main "process" waiting for it, here's how something like that can be implemented:

###################################################
# ASYNC NFS CHECK
# Rafael Ferreira <raf@ophion.org>
###################################################

# CONFIG FLAG - whether NFS has been checked or not
NFS_OK=1

# Runs a command asynchronously
# $1 is the command to run
# $2 is the callback function
async_run() {
        {
                $1 &>/dev/null

                # calling the callback passing the result
                $2 $?
        }&
}

nfs_callback() {
        if [ $1 == "0" ]
        then
                touch /tmp/$$
        fi
}

for i in $(mount -l  -t nfs | grep nfs2 | awk -F ":" '{print $1}')
do
        if [ $NFS_OK == "1" ]
        then
             async_run "/usr/sbin/rpcinfo -p $i" nfs_callback
             disown

        fi
done

sleep 1s

if [ -f /tmp/$$ ]
then
        echo "NFS OK"

else
        echo "NFS NOT OK"
fi
 

In a nutshell, async_run() is where all the action happens. It takes a string parameter of a command to be run and a callback function to be dispatched once the command is done. On the example above, I decided to block the main process and wait for the async call to return for at most 1 sec, this allows me to have constant execution O(1), no matter how long the async task takes.

Yeah, I know this is pretty silly, but hey, I like it.

rafael | General | 6 March, 11:00am | 3 comments

This guy Mark Fink should get the Arse of the Year Award for the most obtuse gnome mailing list post:

http://mail.gnome.org/archives/desktop-devel-list/2008-February/msg00131.html

My fav quote from that whole thread:

"I've never written a program before so I also need some help. Also I need a place to put it on the web"

We are indeed doomed....

rafael | General | 23 February, 1:03am | 5 comments

This might turn out to have the same effect to Mike Huckabee's bid for the White House as Howard Dean's now infamous "rahhh!".

http://firstread.msnbc.msn.com/archive/2008/01/15/579265.aspx

Now, to be clear, I'm not putting Howard Dean's deranged scream in equal footing with Mr. Huckabee's comments but I do see a parallel that could lead to the same kind of political turmoil.

Fundamentally, I see two things wrong with Huckabee's stance:

a) He manages to display complete lack of respect towards the US Constitution and the principles in which it was based b) He shows a lack of insight into the complexity of Christianity and how one must quantify what "God's standards" mean in light of the different interpretations of the Bible (I must say this one is extra troublesome coming from a "minister")

Well, enough said. Let's all seat back and watch.

rafael | | 16 January, 3:01am | 1 comments

"Given enough eyeballs, all bugs are shallow." - Eric S. Raymond

rafael | | 5 January, 1:39pm

For the last year or so, along with my dual Master's degree, I've been working with a partner on what I think is a long overdue addition to the educational marketplace in the US, an open source educational software company providing software that aims at shaking up things and really increase the value of what you get today when you think educational software.

http://www.uvasoftware.com Open Educational Middleware

We have just released version 0.1 of our flagship product: Uva Core an open source SIF agent library.

That's it... now it's official.... carry on...

rafael | | 1 October, 10:58pm

I'm at OSCON in Portland for the week.. and I'm glad that I got to see the presentation on Mono and say hello to the Novell guys here :)

Thus far, the most interesting presentation I've seen was the one from Microsoft Research on "Transaction Memory for Parallelism" by Simon Peyton-Jones and his follow up session "Nested Data Parallelism in Haskell".

rafael | | 25 July, 7:18pm

I'm convinced that Mike Gravel is by far the most interesting candidate in the presidential race.

rafael | | 11 July, 11:38pm

I got my Wii yesterday... a truly amazing piece of technological innovation.

rafael | | 19 May, 10:40am

For instance in the code below:

using System.Threading;
public class foo {
        public static void Main() {
                new Timer(new TimerCallback(cb),null,200,5000);
                Thread.Sleep(Timeout.Infinite);
        }
        public static void cb(object state) {}
}

 

the current implementation of Threading.Timer will create a new thread for every new Timer object created. Why is this bad you might ask... well, primarily this is bad because we end up with a bunch of idle threads that do nothing but consume memory just to trigger the TimerCallback delegate at the end of its trigger period. Since each thread requires a chunk of stack space to exist, operating systems can only create a finite amount of threads before running out of memory... this makes threads somewhat of an expensive commodity to be just sitting idle for most of the time.

The patch that I have submitted changes this logic to utilize a single scheduler thread that is in charge of trigger all the timer events registered with its scheduler. The practical implications of this is that n timers can be created at the expense of a single thread.

Enough mambo-jambo, here's an example of what I described above...

using System.Threading;
using System;

public class foo {
        public static void Main(string[] args) {
       
                int count = 1000;
               
                if (args.Length > 0) {
                        count = Convert.ToInt32(args[0]);
                }
               
                Random rad = new Random();
                Console.WriteLine("Starting tests");
                Console.WriteLine("running test for {0} timers", count);
               
                DateTime start = DateTime.Now;
                for (int i=0;i < count;  i++) {
                        new Timer(new TimerCallback(callback),null,rad.Next(5000),rad.Next(5000));
                }
                Console.WriteLine("{0} timers created in {1} msec",count,DateTime.Now.Millisecond - start.Millisecond);
                Thread.Sleep(Timeout.Infinite);
               
               
        }

        public static void callback(object state) {
        }
}

 

The code above just creates n timers (n being args[0]) as quickly as possible and under mono 1.1.13.4 the result is:

[rafael@stan tmp]$ mono timer2.exe 100
Starting tests
running test for 100 timers
100 timers created in 84 msec

Now, under the single-thread scheduler Timer implementation the result is:

[rafael@stan tmp]$ /devel/bin/mono timer2.exe 100
Starting tests
running test for 100 timers
100 timers created in 66 msec

So, slightly faster you might think right? Well, being faster is not the main goal of the Timer scheduler, it's more like a side-effect under these conditions,, so let's try a better test that really shows its capacity. For instance, changing our test to create a slightly grater number of timers, let's say 10000 on mono 1.1.13.4:

[rafael@stan tmp]$ mono timer2.exe 10000
Starting tests
running test for 10000 timers

causes the timer creation loop to never end because my x86 desktop (and pretty much all other systems out there) cannot really create 10k threads. Now, standing on the other side of the ring is our new Timer implementation which...

[rafael@stan tmp]$ /devel/bin/mono timer2.exe 10000
Starting tests
running test for 10000 timers
10000 timers created in 276 msec

Can handle 10k timers without any issues. However, be warn! CPU consumption does become significant under 10k timers taking anywhere from 8 - 50% on my 1.8Ghz AMD cpu.

Well, I hope this helped you understand how mono's Threading.Timer class works and how our single thread scheduler hopes to make it even better.

rafael | | 13 June, 11:02pm | 7602 comments

If you haven't seem these videos yet you should!

rafael | | 1 February, 6:54am | 917 comments

I just submitted a patch to upgrade monodoc to gtk-sharp-2.0 and thus finally put an end to all of the Pango related crashes in our beloved documentation browser... hopefully that will mean no more angry emails complaining that monodoc crashes too much. We will see.

Update.. here's the proof: monodoc

rafael | | 17 January, 12:25am | 1590 comments

So, I'm writing a little toy app (a single thread web server in c#) and I'm using the awesome "heap-buddy" tool to track heap usage... and this is what I see:

[rafael@salamandra Ophion.ZServer]$ heap-buddy /tmp/zserver.pf types fullname

Type # Total AvSz AvAge BT#
string 6462 563k 89.2 0.7 663
int 14731 172k 12.0 0.0 235
object[] 1043 68k 66.8 0.4 114
byte[] 1204 62k 53.5 0.1 98
char[] 107 51k 490.9 1.7 89
System.Text.StringBuilder 1294 30k 24.0 0.1 160

about 90% of the 563k of string allocation came from log4net.... that is just plain awefull for a webserver in which every ms of waisted servicing time counts. I'm going to pursue this further an post a better analysis of the problem later, but for right now, all I can say is LAME!.

rafael | | 27 November, 10:45pm | 2769 comments

So, it looks like the democrats took both Jersey and Virginia today... it will be interesting to see if this is the start of a downfall for the Republican party....

rafael | | 9 November, 9:14am | 1392 comments

I commited the new bookmark code to monodoc yesterday. Even tho things are still pretty unpolished, I'm pretty happy with the outcome (give it a try and let me know!). Now I'm going to focus on tracking down some bugs that are making the browser crash while loading some "anchored" HTML. In the meantime, any feedback is much appreciated.

rafael | | 6 November, 1:39pm | 3858 comments