Repositorio de ideas
Bundler gem and Daemons error (The default Gemfile was not found)
Feb 12th
Some days ago we deployed an application with rails, in this application we are using some daemons (with daemons gem) to take care about some business processes, and recently to have more control with all gems used by our application we started to use bundler.
Almost all was done, so, at the moment to start the daemons, we get the following error:
/usr/lib/ruby/gems/1.8/gems/bundler-0.9.3/lib/bundler.rb:122:in `default_gemfile': The default Gemfile was not found (Bundler::GemfileNotFound) from /usr/lib/ruby/gems/1.8/gems/bundler-0.9.3/lib/bundler.rb:64:in `setup'
So, looking for this error in google we didn’t get anything, and looking into the bundler gem code the solution to this problems was:
ENV['BUNDLE_GEMFILE'] ||= File.join(Dir.pwd, 'Gemfile')
The complete daemon code here:
Hace algunos días hicimos el deployment de una aplicación con rails, con esta aplicación corremos algunos demonios (con la gema daemons) que se hacen cargo de algunas operaciones de negocio, y recientemente para tener más control de las gemas que utilizamos empezamos a usar bundler.
Ya se tenía todo listo, al momento de correr los demonios nos encontramos con el siguiente error:
/usr/lib/ruby/gems/1.8/gems/bundler-0.9.3/lib/bundler.rb:122:in `default_gemfile': The default Gemfile was not found (Bundler::GemfileNotFound) from /usr/lib/ruby/gems/1.8/gems/bundler-0.9.3/lib/bundler.rb:64:in `setup'
Cabe mencionar que buscando en google no se encontró nada de como resolver el problema, así que indagando un poco en el código de bundler, llegamos a la siguiente solución, que fue agregar la siguiente línea al código que levanta nuestro demonio.
ENV['BUNDLE_GEMFILE'] ||= File.join(Dir.pwd, 'Gemfile')
El código completo del demonio es el siguiente:
Se busca desarrollador rails
Jan 21st
Nota: Deja un comentario aquí si estás interesado o bien manda un correo con tu CV a jcastaneyra@gmail.com.
Table names case insensitive for MySQL Linux
Jan 7th
Hola a todos, feliz año 2010, que tal se pasaron estas fechas? descansaron bastante? Pues yo más o menos, unos ratos descansaba y otros trabajaba, y para variar me encontré con esto en el trabajo.
Resulta que estaba montando un servidor de Weblogic y MySQL en Linux, para instalar una aplicación que originalmente estaba con Weblogic y Oracle, y resulta que al cargar las tablas de esta aplicación en MySQL empecé a encontrarme problemas con los nombres de las tablas (entre otras cosas, como los tipos de datos entre Oracle y MySQL), yo no sabía que MySQL por default en Linux es case sensitive, por lo que me di a la tarea de investigar y buscar como deshabilitar esta función.
Es necesario editar el archivo my.cnf que se puede encontrar en /etc o bien en /etc/mysql, e inmediatamente después de la sección [mysqld], agregar lo siguiente:
lower_case_table_names=1
Guardamos el archivo y reiniciamos MySQL, con esto al momento de crear nuevas tablas estas se harán en minúsculas, y ya no tendremos problemas de si son mayúsculas o minúsculas.
Como crear un archivo zip con ruby
Nov 16th
Hace unos días me encontré con el problema de generar archivos Zip que contuvieran archivos de un curso de SCORM, ¿Cómo hacerlo?, lo primero que me vino a la mente fue Ruby!!!
La gema que me sirvió para esto fue rubyzip, y con el siguiente fragmento de código se realizaron los archivos zip:
Espero que les sirva como a mi.
Links:
http://ruby-doc.org/core/classes/Dir.html
http://ruby-doc.org/core/classes/FileUtils.html
http://rubyzip.sourceforge.net/
Etiquetando código en git/Tagging code in git
Nov 5th
Etiquetando código en git (English)
Resulta que al estar trabajando con nuestro código queremos marcar o etiquetar nuestro código en cierto momento de tiempo, algo así como versionar nuestro código.
A decir verdad no soy un experto en git, pero esto es lo que me ha funcionado. Primero que nada tendríamos que etiquetar nuestro código (ponerle una marca), para esto usamos el comando git tag:
git tag -a -m "My old and ugly style" old_style
Para ver nuestros tags locales tenemos que ejecutar
git tag -l
Pero como le agregué una descripción a mi tag ejecuto lo siguiente para poder ver el tag junto con su descripción
git tag -l -n1
Con esto tenemos agregado el tag localmente, pero como yo trabajo con un repositorio remoto, para subir mi tag tengo que hacer
git push origin --tags
Ya tengo una etiqueta en mi código, ahora supongamos que pasan dos semanas y que quiero ver algo en mi viejo y feo estilo, sólo tendría que hacer lo siguiente:
git checkout -f -b mybranch old_style
Así tendría un nuevo branch con mi código que tiene la etiqueta de old_style.
Links:
http://ariejan.net/2009/09/05/git-tag-mini-cheat-sheet-revisited/?doing_wp_cron
http://polywww.in2p3.fr/~gaycken/Calice/Software/my_git_workflow.html
When we are working with our code in some time of the project we want to mark or tag the code in order to have control until that time of the project and code, something like versioning.
I’m not a git expert, but this worked for me. First of all, we need to tag our code, use this command:
git tag -a -m "My old and ugly style" old_style
In order to see all local tags
git tag -l
Since I added a description to my tag it’s needed to execute the following to see the description
git tag -l -n1
Until now we have this tag added locally, but if we work with a remote repository we are going to push the tag
git push origin --tags
I already have this tag in my code, now suppose that some weeks have been passed and you want to see something in your old and ugly style, you would need to do:
git checkout -f -b mybranch old_style
With this command you would have a new branch with the code tagged with old_style.
Links:
http://ariejan.net/2009/09/05/git-tag-mini-cheat-sheet-revisited/?doing_wp_cron
http://polywww.in2p3.fr/~gaycken/Calice/Software/my_git_workflow.html
Instalando RabbitMQ
Jun 7th
Instalando RabbitMQ (English)
RabbitMQ es un sistema de message queue (MQ), el cual provee comunicaciones asíncronas, es decir que el productor y consumidor no tienen la necesidad de interactuar con los mensajes al mismo tiempo, además de que es una implementación del protocolo AMQP (Advanced Message Queuing Protocol), un protocolo para mensajeo de alto rendimiento, y por último decir que RabbitMQ está desarrollado con Erlang, Erlang es un lenguaje de programación funcional.
En Ubuntu 9.04
La instalación de RabbitMQ en Ubuntu 9.04 es tan simple como correr el comando
sudo aptitude install rabbitmq-server
Y con el cual si no has instalado Erlang te mostrará que paquetes tendrá que instalar para que lo tengas también.
jcastaneyra@ubuntu:~/sources$ sudo aptitude install rabbitmq-server [sudo] password for jcastaneyra: Reading package lists... Done Building dependency tree Reading state information... Done Reading extended state information Initializing package states... Done Writing extended state information... Done The following NEW packages will be installed: erlang-base{a} erlang-nox{a} libltdl7{a} odbcinst1debian1{a} unixodbc{a} The following partially installed packages will be configured: rabbitmq-server 0 packages upgraded, 5 newly installed, 0 to remove and 8 not upgraded. Need to get 28.6MB of archives. After unpacking 46.9MB will be used. Do you want to continue? [Y/n/?]
Una vez instalado ya está corriendo.
En Mac leopard
La instalación es a través de los MacPorts, hay que bajar el instalador de la página www.macports.org/install.php, pero para poder compilar es necesario tener XCode instalado. Los MacPorts son instalados en /opt, por lo que hay que asegurarnos que se tengamos agregados los paths necesarios en el profile para ejecutar los comandos de MacPorts.
En mi caso en .profile (pero también puede ser el .bash_login) debe estar algo así (si no está lo agrego):
# MacPorts Installer addition on 2009-02-25_at_15:37:48: adding an appropriate PATH variable for use with MacPorts. export PATH=/opt/local/bin:/opt/local/sbin:$PATH # Finished adapting your PATH environment variable for use with MacPorts. # MacPorts Installer addition on 2009-02-25_at_15:37:48: adding an appropriate MANPATH variable for use with MacPorts. export MANPATH=/opt/local/share/man:$MANPATH # Finished adapting your MANPATH environment variable for use with MacPorts.
Una vez que están los MacPorts hay que instalar primero erlang, así que ejecutamos
sudo port install erlang
Y esperamos un buen rato a que se instale.
Una vez instalado erlang, bajamos la última versión de RabbitMQ
mkdir /tmp/rabbitmq && cd /tmp/rabbitmq curl -O http://www.rabbitmq.com/releases/rabbitmq-server/v1.5.5/rabbitmq-server-generic-unix-1.5.5.tar.gz tar xvzf rabbitmq-server-generic-unix-1.5.5.tar.gz sudo mv rabbitmq_server-1.5.5/ /opt/local/lib/erlang/lib
Ahora ya lo podemos ejecutar.
sudo /opt/local/lib/erlang/lib/rabbitmq_server-1.5.5/sbin/rabbitmq-server
Recursos
http://www.rabbitmq.com
http://playtype.net/past/2008/10/9/installing_rabbitmq_on_osx/
Installing RabbitMQ (Español)
RabbitMQ is a complete and highly reliable Enterprise Messaging system, it provides asynchronous communications, meaning that the sender and receiver of the message do not need to interact with the message queue at the same time, also it is a AMQP implementation (Advanced Message Queuing Protocol) a protocol for high performance messaging, and last RabbitMQ is developed with Erlang, a functional programming language.
In Ubuntu 9.04
RabbitMQ instalation in Ubuntu 9.04 is so simple, it is just needed to run a command
sudo aptitude install rabbitmq-server
With this also install all packages needed by rabbitmq, Erlang is installed also.
jcastaneyra@ubuntu:~/sources$ sudo aptitude install rabbitmq-server [sudo] password for jcastaneyra: Reading package lists... Done Building dependency tree Reading state information... Done Reading extended state information Initializing package states... Done Writing extended state information... Done The following NEW packages will be installed: erlang-base{a} erlang-nox{a} libltdl7{a} odbcinst1debian1{a} unixodbc{a} The following partially installed packages will be configured: rabbitmq-server 0 packages upgraded, 5 newly installed, 0 to remove and 8 not upgraded. Need to get 28.6MB of archives. After unpacking 46.9MB will be used. Do you want to continue? [Y/n/?]
Once the installation is finished RabbitMQ will be running.
In Mac leopard
RabbitMQ installation is done through MacPorts, you need to download the MacPorts installer from www.macports.org/install.php, also XCode is needed. MacPorts are installed in /opt, for that reason we put these paths in the .profile file (could be .bash_login), if you don’t have these paths add them to your profile file:
# MacPorts Installer addition on 2009-02-25_at_15:37:48: adding an appropriate PATH variable for use with MacPorts. export PATH=/opt/local/bin:/opt/local/sbin:$PATH # Finished adapting your PATH environment variable for use with MacPorts. # MacPorts Installer addition on 2009-02-25_at_15:37:48: adding an appropriate MANPATH variable for use with MacPorts. export MANPATH=/opt/local/share/man:$MANPATH # Finished adapting your MANPATH environment variable for use with MacPorts.
In order to install erlang execute the following command:
sudo port install erlang
You need to wait some time, maybe several minutes
Once you have erlang installed, we download the last RabbitMQ version
mkdir /tmp/rabbitmq && cd /tmp/rabbitmq curl -O http://www.rabbitmq.com/releases/rabbitmq-server/v1.5.5/rabbitmq-server-generic-unix-1.5.5.tar.gz tar xvzf rabbitmq-server-generic-unix-1.5.5.tar.gz sudo mv rabbitmq_server-1.5.5/ /opt/local/lib/erlang/lib
Now we execute rabbitmq-server with this
sudo /opt/local/lib/erlang/lib/rabbitmq_server-1.5.5/sbin/rabbitmq-server
Links
http://www.rabbitmq.com
http://playtype.net/past/2008/10/9/installing_rabbitmq_on_osx/

