Carlos Ble

Carlos Ble

I am a professional software developer, I solve problems.

I also teach and mentor developers to build better software.

Developing software since 2001.

Can I help you?

  • Do you need high quality tailor-made software?
  • Need training on TDD, clean code or refactoring?
  • Do you need a technical consultant?
  • May I pair with you to write better code?

Events

Upcoming training courses:

  1. TDD - [en Español] - 6 y 7 Octubre
    Gran Canaria
  2. TDD - [in English] - October 20, 21 & 22
    London, UK
  3. TDD - [en Español] - 29, 30 y 31 de Octubre.
    Madrid, Spain

Conferences:

  1. I'll be at the Agile Testing Days 2014
  2. I'll be at the London Test Gathering Workshops.

Archive for September, 2006



Here is a quick solution fot the "this.getDoc() error". The thing is that tinyMCE adds the control to the textarea successfully the first time but it can't add the control twice in the next load, so to remove the control when sending the form, could be a choice. Update the previous javascript functions to this ones:

function tinyRepaint() {
 var textarea_num = document.getElementsByTagName("textarea").length
 var textarea;
 for (var i = 0; i <= textarea_num; i++) {
  textarea = document.getElementsByTagName("textarea")[i];
  if (textarea != null) {
   inst = tinyMCE.getInstanceById(textarea.id);
   if (!inst) // just a test for debug
    tinyMCE.execCommand("mceAddControl", false , textarea.id);
  }
 }
}
function updateValues() {
  // manually save the tinyMCE content for each textarea
  var tas = document.getElementsByTagName('textarea');
  for(var i = 0; i < tas.length; i++) {
  // snag the textarea
   var ta = tas[i];
   // put focus in the editor
   tinyMCE.execInstanceCommand(ta.id, 'mceFocus');
   // manually save the content
   ta.value = tinyMCE.getContent();
   tinyMCE.execCommand("mceRemoveControl", false , ta.id);
  }
}

There are several javascripts that performs changes in document elements when the page loads. To use the scripts you call a init function in the html header and they works fine but they don't work when you request just a piece of html from the server using Ajax, because the header has already been loaded. You need to call the function once the Ajax has returned.

I'm using this function to show the tinyMCE editor on an ajax requested form:

function tinyRepaint() {
 var textarea_num = document.getElementsByTagName("textarea").length
 var textarea;
 for (var i = 0; i <= textarea_num; i++) {
  textarea = document.getElementsByTagName("textarea")[i];
  if (textarea != null) {
   tinyMCE.execCommand("mceAddControl", false, textarea.id);
  }
 }
}

So, you need to invoke the remote method using this syntax:

$AjaxHelper.LinkToRemote("link", "action.rails", $DictHelper.CreateDict("update=$placeholder", "with='parameter=value",
loading=javascript:waitPointer('content')", "complete=javascript:defaultPointer('content'); tinyRepaint();"))

I use waitPointer and defaultPointer to do the request more intuitive for the user that is wainting for the server. But you only need this:

$AjaxHelper.LinkToRemote("link", "action.rails", $DictHelper.CreateDict("update=$placeholder", "complete=javascript:tinyRepaint();"))

Another problem is to get the textarea value before you send the filled form. I use this function:

function updateValues() {
  // manually save the tinyMCE content for each textarea
  var tas = document.getElementsByTagName('textarea');
  for(var i = 0; i < tas.length; i++) {
  // snag the textarea
   var ta = tas[i];
   // put focus in the editor
   tinyMCE.execInstanceCommand(ta.id, 'mceFocus');
   // manually save the content
   ta.value = tinyMCE.getContent();
  }
}

And invoke it onclick:
input type="submit" onclick="javascript:updateValues(); onsubmit()" ...

I have copied the javascript functions from this site

The past few days has been very fun and exciting for me. I met great hackers (a couple of them were also friends) and all the presentations I attended have been really interesting. I am happy enough with my presentation and with the questions that people asked to me at the end. Thanks to Marc-André for sending me a video showing his Generator for my presentation, I thought that people enjoyed it. I hope that Mono, Castle, and MonoDevelop will gain more users here in Tenerife and the free/libre software production will increase in the Canary Islands.

You can read Alvaro's post about the conference, it is very nice; thank you very much for everything Alvaro. To talk with Rodrigo Moya, Antonio Larrosa, Steve McIntyre, Esteban Manchado and Agustin Benito was really nice. I also want to say thanks to Paco Almeida, René Martín, Adrián Santos & Javier Quijada for let me talk in the conference and for their effort in this big conference.

Yesterday when I took Steve to the airport in the south, the fly delayed 6 hours (initial estimated time 21, final real time 2.30). It was incredible but It was fun for me because we went to a beautiful beach to drink free beer and Steve told to me cool news about the future of Debian, some brilliant hacks and some other amazing things. I will post some photos when people send them to me.
See you soon my friends.
Update: Steve's photos. (Im the red t-shirt guy)

Me complace anunciar que la próxima semana se celebra el I Encuentro de Software Libre de la ULL. Mis felicitaciones a la organización porque realmente han conseguido un evento muy atractivo tanto por los contenidos como por los ponentes. También estoy muy contento de poder participar con una ponencia en las jornadas. Mas info sobre mi ponencia aqui. Espero que esta sea la primera de muchas otras jornadas. Enhorabuena

NPlot + Gtk#

Miguel wrote a fantastic Gtk# control for NPlot. The problem is that this tarball is using Gtk#1. To use Gtk# 2 you must to change lib/Makefile and replace gtk-sharp with gtk-sharp-2.0. You can download the fixed tarball here. This is another code example to draw a histogram:



#define GTK


#if GTK


using Gtk;

using NPlot.Gtk;

#endif


using NPlot;

using System.Drawing;

using System.IO;

using System.Drawing.Imaging;

class X {

  
static public void PlotBars (IPlotSurface2D plot){

    plot.Clear();

    HistogramPlot histogram=
new HistogramPlot();

    
float f=0.35f;

    System.Console.WriteLine(f);

    histogram.BaseWidth=f;

    histogram.Filled=
true;

    histogram.ShowInLegend=
true;

    histogram.Color=System.Drawing.Color.BlueViolet;

    histogram.Pen.Width=
2f;

    histogram.Pen.Alignment=System.Drawing.Drawing2D.PenAlignment.Inset;

    histogram.Pen.DashStyle=System.Drawing.Drawing2D.DashStyle.DashDot;

    
float[] a=new float[10];

    System.Random random=
new System.Random();

    
for (int i=0; i<a.Length; i++) {

      a[i]=random.Next();

    }

    histogram.DataSource=a;

    plot.Add(histogram);

  }
  
static void Main (){

    
#if GTK

    
Application.Init();

    Window w=
new Window("Test");

    w.DeleteEvent+=
delegate {

      Application.Quit();

    };

    NPlot.Gtk.PlotSurface2D plot=
new NPlot.Gtk.PlotSurface2D();

    PlotBars(plot);

    plot.Show();

    w.Add(plot);

    w.ShowAll();

    Application.Run();

    
#else

    
NPlot.PlotSurface2D s=new NPlot.PlotSurface2D();

    Bitmap b=
new Bitmap(10001000);

    Graphics g=Graphics.FromImage(b);

    g.FillRectangle(Brushes.White, 
0010001000);

    Rectangle bounds=
new Rectangle(0010001000);

    PlotTest(s);

    s.Draw(g, bounds);

    b.Save(
"file.png", ImageFormat.Png);

  
#endif

  
}
}