Posts

Javascript object like a sir

In this post I will introduce Javascript objects, how to define them, how to add attributes and methods and how to access them. Maybe you have heard that Javascript is an object oriented language but that definition is not very precise, specially when comparing to other languages. There are no classes! (and it is considered a prototypal object oriented language). Anyway now we will dip our toes into the waters just a little to become familiar with the notation. Prototypes, inheritance and other advance stuff will come next.


Javascript like a sir

Javascript functions are apparently simple yet very flexible. Functions are data. Functions can be anonymous. Functions can even be shape shifters. And of course, closures deserve a look.


NaN wtf

This will be just another quick reveiw of the Javascript language basics. For any seasoned developer this may seem a pointless effort but perhaps you find something useful, at least to become a js nitpicker or a soon-to-be guru :D.


Javascript logo

When Node.JS server side engine came into play along with some other ideas like noSQL databases , javascript language definitely got my attention. These are technologies that turned inside out the way we can develop applications after years and years of php, jsp, aspx and the like querying data through SQL. Changes also came to the client side of the web since AJAX started playing a crucial role in massive apps such as gmail. After the browser wars, javascript seemed to be in an abandoned position in favor of other animated horrors made with flash. But fortunately, now there is a clear rebirth of this language with a plethora of frameworks to develop single page applications and an ever growing helper libraries covering all kind of tasks you can think of. If something exists for other languages you can certainly take for granted that some guy has a github hosted and forked project providing the same functionality. Ant/Maven and Grunt for example.

It is also remarkable that this is a community that does not need any well-known MegaCorportarion supporting them. Javascript has increasingly tiptoed to the exclusive group of the most required language on its own right. From support libraries like jquery to MVC frameworks such as Backbone o Angular, client side web has become so important that the classic web developer profile is now split between back-end and front-end developers; and mastering both sides of the web is becoming more and more difficult every day. Anybody who thinks that javascript was but a toy should be ready to rediscover this rich and active ecosystem. And let me whisper you a secret: forget Java or any other interpreted languages out there, relevant or not. Javascript is everywhere, because wherever a web browser is, a JS intepreter must be present no matter if it is an iPhone or your latest Ubuntu box. And anyway, if needed Node is available for many platforms.

But let's get down to business. I guess that you are reading this on a browser. Good! You are ready to start right away. Open the javascript console and you will be able to write and try code. Your best options are:

  • Firexox: the built-in web console or using the Firebug add-on, where you can write multiline code just pressing the up arrow on the right of the console. Remember the old days when you only have a console to see the errors? Now you can enter commands and even Tab to get code completion and proposals.
  • Chrome has also a built-in developer tool. Go to menu or press Ctrl-Shift-J. If you need to write multiple lines of code just press Shift-Enter. Then press just Enter to run.
  • JsFiddle or JsBin website. If you want yo use your browser screen directly this kind of website is the rightful choice. It allows you to include the most popular frameworks to code around.
  • Explorer, yes can you believe that? For those who lived through the nineties it is unbelievable this new attitude. Remember when you wanted to see the source code and notepad was opened? Now Explorer comes with some developer tools. It still sucks big time anyway.

There are other choices like Jetbrains Webstorm of course, but if you want to start quickly and just to learn or rediscover this language, stick to your favorite browser. Javascript seems simple, but when things get complex... hold tight because this could turn into a white-knuckle ride in the web roller coaster.


Migrate from google code to github or bitbucket

Google code disappears

Repent, the end is near. Google has just announced that they are shutting down google code project hosting. In the email of the announcement they make some suggestions to find a new house for your code such as bitbucket or github. I hope that they have been warned in order to be ready for a massive repository creation from the upcoming exodus of coder refugees.


En el acceso a discos parece ser que el Kernel usa una configuracion bastante floja y conservadora y se puede mejorar. Gracias al comando hdparm podemos mejorar el rendimiento de manera muy apreciable. Los discos IDE tienen capacidades que se pueden aprovechar como el DMA, las transferencias de 32bits y el acceso a multiples sectores a la vez.

Un ejemplo de uso de la libreria de regex de glibc, que trae herramientas basicas para las expresiones regulares.

Ejemplo de acceso a mysql desde c
Necesitaremos tener instalado el mysql-devel o libmysql para poder hacer que nuestro codigo C acceda a mysql. Ademas de eso debemos establecer con cuidado las opciones de compilacion:
Si tenemos alguna duda podemos ejecutar mysql_config y este nos dira los parametros que necesitamos.

Vagrant logo

Vagrant is a virtual machines management tool that allows us to easily create, run, configure and share customized virtual systems. The main goal of Vagrant is to provide a centralized way to share preconfigured virtual machines for software developers. In development teams, all members must share not only and up-to-date project source, but also the same system configuration: database management systems, web servers, application servers, IDEs, development kits,... It is almost impossible to keep them identical in each station, not to mention the same specific versions of each program needed. Another issue that comes to mind if you have ever suffered this is when your system crashed or you simply upgrade your hardware, or some IDE requires the latest operative system from Redmond: you will start again from scratch installing all the components you need to have your environment ready to work. This is a sort of myth of sisyphus adapted to coders.

Virtualization comes to the rescue! but this is not just about sharing a common virtual machine among developers. Vagrant wraps the virtualization system, and so we are not necessarily tied to any of them. Vagrant supports Virtual Box (easily available), VMWare and even Amazon EC2, is easy to get into it.


La herencia
Como bien se sabe la herencia no se reparte: se descuartiza. Bromas aparte, la herencia constituye una de las herramientas mas poderosas de culto OO. Si una clase hereda de la otra, lo que hereda son todos sus atributos y metodos.
Ademas de heredarlos puede sobreescribirlos, tanto los constructores-destructores como los metodos convencionales.
Veremos un ejemplo claro que resume lo que se puede hacer y los efectos de la herencia
Por un lado vemos la clase generica vehiculo y su descendiente: el coche.
La clase Vehiculo
/**
* Vehiculo.hpp
* Clase que define el objeto vehiculo
*
* Pello Xabier Altadill Izura
*
*/


    

subscribe via RSS