• 03lug

    Yep, it is, MindGapper has been renamed into MooGraph.

    Why? Well, it’s pretty simple, MindGapper was a funny name based on GapMinder, but now MindGapper – MooGraph is a complete software for statistical data, so we decided to change it’s name.

    Sooner or later also the project on SourceForce will be renamed (we hope!), so keep on following us on our trac! And if you have questions, don’t heistate writing them down as comments!

    Tags: ,

  • 04giu

    Your remote_function or remote_form_tag could stop working if you use jQuery into your Ruby on Rails project. This is because the jQuery $ function is different from the prototype one, and RoR uses some particular function that is not available with jQuery.

    For example, you can get an error like this submitting your remote_form_tag:

    $(form).getElementsByTagName is not a function
    http://localhost:3000/javascripts/prototype.js?1239274532
    Line 3483

    To solve this kind of problem, you have to use the jQuery no-conflict method, like explaned on the jQuery site. Simply add theese lines of code in your default layout between into a <script> tag:

    jQuery.noConflict();
    jQuery(document).ready(function($) {
    })

    Now, RoR can use prototype calling the default function $ and you can use jQuery using the jQuery function:

    jQuery("#myId").hide("def");

    Tags: , , , ,

  • 30apr

    If you create a scaffold for your rails project, it will create for you a lot of things; for example, a way to show your object in xml format. But what about adding custom elements to that xml?

    I solved in this way:

    class MyObject < ActiveRecord::Base
      #[...]
      def to_xml(options={})
        cp = attributes.clone
        cp["something"] = "some value"
        cp["another thing"] = self.some_relation.length
        cp.to_xml(options)
      end
    end

    Tags: ,

  • 24apr

    When using wx:TileList with your own ItemRenderer, you have to remember two important things to avoid scrolling problems:

    1. If you override the set data method, remember to call super.data = value.
    2. Remember that the TileList reuses the ItemRenderer instances when scrolling the component! So, if you have a TileList with 5 rows and 5 cols, and an array with 500 elements as DataProvider, it will create about 25 instances of your ItemRenderer, calling the set data method on them when scrolling. So, if you add some child to your ItemRenderer under some data condition (like I did), remember to remove them if the data condition is not valid.

    Tags: ,

  • 05mar

    I love to write my own visual classes in actionscript3. Some days ago I was searching for an undefined loader, like a rotating animated gif. But I thought that it would be great to have something wrote in as3 to do that, so I code it.

    I wrote a simple as3 class that shows some circles that moves from a point to the external of the loader, creating a simple bubble effect.

    Here you can see it in action: UndefinedLoader.swf

    What do we need? Well, I usually use Caurina.Tweener for the animations, you can download it on google code. Download the as3 version and copy it in your source directory.

    After that create a new class extending Sprite and create a simple costructor like this:

    package myControls
    {
        import caurina.transitions.Tweener;
        import flash.display.*;
     
        public class UndefinedLoader extends Sprite
        {
            private var w:Number;
            private var h:Number;
            private var colors:Array = [0xFFFFFF];
     
            public function UndefinedLoader(w:Number, h:Number, colors:Array = null)
            {
                this.w = w;
                this.h = h;
                this.visible = false;
                if (colors != null)
                    this.colors = colors;
            }
    }

    We set the width and height attributes, and if the user want to change the color of the loader we set it.
    We will use the ‘visible’ attribute to indicate if the loader is running or not. So we have to write a get function for that:

            public function get loading(): Boolean {
               return this.visible;
            }

    After that, we need some constants in the class, indicating the minimum and the maximum radius of the circles, the time for the animation, how many circles we want and the type of transition (see the Tweener documentation for the possible values)

            private const NCIRCLES: int = 25;
            private const MIN_DURATION: Number = 1;
            private const MAX_DURATION: Number = 2.5;
            private const MIN_RADIUS:int = 2;
            private const MAX_RADIUS:int = 5;
            private const TRANSITION: String = "linear";

    Ok, now we need the start and the stop functions. When we start the loader, we want to create the circles, storing them into a private array. After that we will call the animation function on each of them. Stopping the loader will only hide it. The animation will automatically stop by itself (see later).

            public function start(): void
            {
                if (this.visible)
                    return; // animazione gia` partita!
     
                this.visible = true;
     
                if (circles.length == 0)
                    for (var i:int = 0; i &lt; NCIRCLES; i++) {
                        circles[i] = new Sprite();
                        addChild(circles[i]);
                    }
     
                for (i = 0; i &lt; circles.length; i++)
                    tween(circles[i]);
     
            }
            public function stop(): void
            {
                this.visible = false;
            }

    Now let we write the tween function: first of all we need to check if the loader is still shown. If it’s not, we will return, doing nothing. Otherwise, we generate randomly the color of the circle, the duration of the animation, the radius and the angle to move on. After that, reset the circles attribute, redraw it, and start the animation. When it will be completed, it will be recalled the tween function, checking if the loader is still working or not.

            private function tween(c:Sprite): void
            {
                if (!this.visible) {
                    return; // fermiamo l'animazione.
                }
     
                var color:int = (colors.length == 1) ? colors[0] : Math.random()*(Math.abs(colors[1]-colors[0]));
                var time:Number = Math.random()*(MAX_DURATION - MIN_DURATION);
                var radius:Number = Math.random()*(MAX_RADIUS - MIN_RADIUS);
                var beta:Number = Math.random()*(2*Math.PI);
     
                c.alpha = 1;
                c.x = 0;
                c.y = 0;
                c.graphics.clear();
                c.graphics.lineStyle(1, color, 1);
                c.graphics.drawCircle(w/2, h/2, radius);
     
                Tweener.addTween(c, {x:w/2*Math.cos(beta), y:h/2*Math.sin(beta),
                                     alpha:0, time:time, transition:TRANSITION,
                                     onComplete: tween, onCompleteParams:[c]} );
            }

    You can download the source code here: undefinedloader.as

    Tags: , , ,

  • 03nov

    I have a MacBook Pro 4th generation (Penryn) and using Ubuntu 8.04 all was  perfect!

    Two days ago I upgraded the operating system to Intrepid Ibex (8.10), and after some hour downloading the packages and installing them, the new Ubuntu was running on my MacBook… But also some problems war running as well! Ubuntu has some audio problem (no sound at all!!) on MacBook Pro…

    The sound card is the Hda-Intel and the kernel module is the snd-hda-intel. The solution? After some search on the net, I found that: help.ubuntu.com

    Here the solution (very easy, really):

    1. Open the file /etc/modprobe.d/options (you need to be root)

    sudo gedit /etc/modprobe.d/options

    2. Add the following line at the end of the file

    options snd_hda_intel model=mbp3

    3. If you have changed /etc/modprobe.d/alsa-base previously, adding something similar to the previous line, comment it.

    4. Reboot (mute your microphone before doing that, or your ears will implore pity!)

    Tags: , , , ,

  • 26set

    In my informatic life I’ve wrote a lot of code lines, and sometimes I’ve spent hours and hours searching on the web the solution to problems, finding them on forums and blogs. But sometimes people that solve their problems don’t write it down their solutions, or sometimes the discussion about how to solve something is very very chaotic.

    I’ve decided to write down the solution to my informatic problem here, hoping that this will help someone to solve their ones.

    Another reason of this blog is that I’ve to improve my english, and the only way to do it is to use it! So first of all, I’m sorry for all the mistakes you will find on this blog, but I’m italian and is known that Italy people like only their own language…

    Tags: ,

   

Recent Comments

  • It's very strange, you're right... The code seems to be ok....
  • it is using its default renderer.. ...
  • I'm sorry but I cannot understand. If you have commented out...
  • hi, am also having this ghost image problem.. problem is tha...
  • Ok, I think I could elaborate on that =) Take this method: ...