To do SEO: what it really means

Sorry, this entry is only available in Español.

Posted in General | Leave a comment

Searching the method for seeing what we miss

Sorry, this entry is only available in Español.

Posted in General | Leave a comment

Landing Ideas

Sorry, this entry is only available in Español.

Posted in General | Leave a comment

Methodology for Reverse Engineering.

Sorry, this entry is only available in Español.

Posted in Ingeniería en Reversa - Reverse Engineering | Leave a comment

Programming habits

Let’s contribute to some programming habits that might help every member of the community:

1. When you detect a mistake of something nonsense, that used to work BEFORE, THEN DON’T START OVER. Some people prefer to repeat the process from the beginning, wanting that the second time everything will go better. Don’t do that. Seek for the mistake, and LEARN from it. In that way, the next time it occurs, you will find it quicker, and you will trust both in the technology and, more important, in your own developments.

Posted in General | Leave a comment

javascript: document.documentElement.scrollHeight can return 0 (Zero). Problem solved.

Remember there are several ways to obtain the height of a body object, and one of those ways is using the instruction

<blockquote>alert(document.documentElement.scrollHeight);</blockquote>

However, I began to obtain “0″ for this instruction, in spite I was sure it was working in my server, in an application I was building. I felt very curious about this, so the solution was to re-load an old version from my server, download it using the Mozilla-Firefox browser, and compare it with the new one that was failing <a href=”http://investigacionyprogramacion.com/wordpress/?p=61&lang=en”>See: habits for good programming</a>.

But when I tested the new downloaded file, it worked!!! So its code was alright. However, the new version was still failing. So I came to the new version, and studied the code directly from Firefox’s source code viewer. I noted this:

<blockquote>
<script language=”javascript”>
alert(document.documentElement.scrollHeight);
</script>
<!DOCTYPE HTML PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN” “http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd”>
<html xmlns=”http://www.w3.org/1999/xhtml”><head><meta http-equiv=”Content-Type” content=”text/html; charset=ISO-8859-1″><title>POBOXTORE</title></head><body id=”_”>

….[[and other stuff]]

</blockquote>

As you can see, there is a <script></script> block BEFORE the <html> tag. If you do this, you are going to retrieve “0″ as the result of

<blockquote>alert(document.documentElement.scrollHeight);</blockquote>

If you use “javascript:alert(document.documentElement.scrollHeight);” in your address bar, it will fail also. So the explanation was very simple, but a little tricky to trace, because when you use mozilla-firefox to save a page whose structure is

<script></script><html><head> ….

then Mozilla-Firefox changes to this one when saving it:

<html><head> <script></script> ….

So your saved file WILL work although the exact same file when seen directly in the server doesn’t work.

Last, but not least: it doesn’t matter WHAT BLOCK you have before <html><head>. If you put <invented block>anything</invented block>, it will fail also.

<strong><span style=”font-size: 3Em”>Problem solved.</span></strong>

By the way, one last comment about this instruction, of retrieving body’s height. I’ve been using successfully these lines, for browser compatibility:

<blockquote>
<SCRIPT type=”text/javascript” language=”javascript”>
if (navigator.userAgent.toString().indexOf(“Chrome”)==-1) {
height = document.documentElement.scrollHeight;
} else { //If it’s google Chrome:
height = document.body.scrollHeight;
}
</blockquote>

I hope this will be useful for a few people.

Best Regards,

Investigación y Programación Ltda.

Posted in javascript | 2 Comments

Excel macro to export table to MySQL in SQL format, better than the CSV option

This post exists only in Spanish. Please read it here: http://investigacionyprogramacion.com/wordpress/?p=39&lang=es

Posted in Excel Macros | Leave a comment

Yii: Default selected value in a dropdownlist

Let’s say we want to write a Dropdownlist using Yii, for example:

echo $form->dropDownList($model,’tipo_de_cliente’, array(’1′ => ‘Persona Jurídica’, ’2′ => ‘Persona Natural’), array(‘prompt’=>’Seleccione…’, ‘onchange’=>”javascript:cambio_en_TIPO_de_cliente();”, ‘id’=>’tipodecliente_lst’));

How can we set a default selected value? There are several methods. I’m gonna begin with the two methods that I like the least (I don’t like them, but nonetheless they are illustrative), and the 3rd one is the method I recommend.

1. Changing the model’s attribute, but it has the problem of not being the best solution if the dropdownlist is multiselect. Besides, it is a model level solution for an interface issue: unless we are talking about a very sensitive decision, sometimes the default-selection is a matter of visualization only, sometimes it is a programmer’s whim to leave a default selection, but it doesn’t deeply affect the database, nor the model itself, nor the application gravely, so I think that the solution should be in the views layer.

2. Creating a default value in the table, is another solution that is being proposed in other threads.
This is worse, I think: it uses a database-level solution for something that is a matter of visualization (read the argument of point 1).

3. A views’ level solution, is using the “options” entry in the array of htmloptions, I read it in the CHtml Dropdownlist (http://www.yiiframew…DownList-detail) documentation, but I applied it for an ActiveForm Dropdownlist. So in this example, if the reader wants the item with key value “2″ to be selected by default, she/he should use:

<?php
echo $form->dropDownList($model,’tipo_de_cliente’, array(’1′ => ‘Persona Jurídica’, ’2′ => ‘Persona Natural’), array(‘prompt’=>’Seleccione…’, ‘onchange’=>”javascript:cambio_en_TIPO_de_cliente();”, ‘id’=>’tipodecliente_lst’,
‘options’=>array(2=>array(‘selected’=>’selected’))
));
?>
Posted in Yii | 6 Comments

Why WordPress?

Well, we got lost in all the alternatives. After a year of thinking about the project, we made it clear: we only need a multilingual website, and we need it to be capable of drawing LaTeX equations. WordPress had widgets that made all this possible in an amazingly easy-to-install way. Look, for example, Schrödinger’s equation, as an example of Latex usage here:

-\frac{\hbar^2 \nabla^2 \Psi}{2m} + V \Psi = i \hbar \frac{\partial \Psi}{\partial t}

Posted in General | 6 Comments

Things are rather different now

Ten years ago, every web application had to be built from scratch by the programming team: the client javascripts (or java applets back in those times), every html table for the layout (css was not yet a true possibility), every suffering with the database engines. Nowadays things are quite different: the revolution of Internet in the last days is not only about videos or social networks: it is also about possiblities and speed in programming.

Zehn Jahre vor,  jede web Anwendung musste ganz gemacht von der Programmierer werden.  Jedes Projekt hatte eine gute Dosis von Phantasie. Heute wir wirken unterschiedlich… Wie kann es sein? Die Revolution von Internet ist nicht nur über Videos und SozialeNetzwerke: es ist auch über Geschwindigkeit in die Programmierung der Projekte.

Posted in General | Leave a comment