Repositorio de ideas
Lenguajes
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:
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
Mostrando el branch de git en el prompt de la consola
May 20th
Mostrando el branch de git en el prompt de la consola (In english below)
Tiene aproximadamente dos meses que empecé a trabajar con git, y la experiencia ha sido muy buena, bastante interesante, pero con los primeros tutoriales que empecé a ver noté que los aliases ayudan a hacer más ágil el trabajo con git, curiosamente hasta este momento no los he usado, creo que ha llegado la hora de agregarlos en mi configuración. Así que al final de mi archivo $HOME/.gitconfig agrego:
[color] ui = auto [alias] ci = commit co = checkout st = status
Por cierto, que la parte de [color] es para mostrar con colores mis cambios cuando le doy git status, aunque ahora con estos cambios ya le podría dar git st.</p> <p>Otra cosa que noté en mis inicios con git fue que en un screencast de peepcode, en el prompt de la consola aparecía el branch en el que se encontraba trabajando, en ese entonces busqué como hacerlo pero no tuve éxito hasta ahora, entonces para lograr esto hay que agregar un archivo con funciones .bash_functions
# git-related functions in here git_branch () { GIT_BRANCH="$(git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/\1/')" if [[ -n "$GIT_BRANCH" ]] ; then echo ":($GIT_BRANCH) " fi } empty_branch () { name="$1" if [[ -n "$name" ]] ; then echo "This will create a new empty branch in the current" echo -n "git repository called '${name}' ... Continue? [y/N] " read VERIFY if [[ "$VERIFY" = "Y" || "$VERIFY" = "y" ]]; then echo "creating branch '$name'" git symbolic-ref HEAD refs/heads/$name rm .git/index git clean -fdx echo "you should be on your new empty branch! " echo "add/commit files as usual! " echo "( your new branch will show up after you commit something to it )" else echo -n "" fi else echo "Creates a new empty branch in your git repository." echo "" echo "Usage: empty_branch [name_of_new_branch]" fi } # vim:set ft=sh:
Y dependiendo del archivo de configuración del shell que estén usando agregar en él esto:
# if .bash_functions if a file then source it # if .bash_functions is a directory, then sourec all its files if [ -f ~/.bash_functions ]; then . ~/.bash_functions fi if [ -d ~/.bash_functions ]; then for function in ~/.bash_functions/*; do . $function; done fi # bash prompt prompt () { PS1="\[\e[34m\]\u\[\e[37m\]@\[\e[36m\]\h\[\e[37m\]:\[\e[31m\]\w\[\e[37m\]$(git_branch)$ " } PROMPT_COMMAND=prompt export PROMPT_COMMAND
En mi caso, en leopard yo estoy usando .profile, pero podría ser .bash_rc o algún otro profile de shell. Ya para cargar la info del profile habría que ejecutar source .profile ó bien salirse de la consola y volverla a abrir para que cargue la nueva configuración.
Todavía falta mucho por aprender de git, pero creo que voy por buen camino, también he aprendido bastante de los flujos que siguen algunos equipos de trabajo ágiles, son muy interesantes.
Recursos:
Aliases
.bash_functions file from Remi
.bash_rc file from Remi
Git workflow for agile teams
Showing the git branch in the console prompt
I have working with git since started two months ago, the experience have been too good, I must say awesome, when I started to work I saw that you could use aliases with git, it is funny but since then I’ve never used aliases, so now it’s time to add them to my configuration file $HOME/.gitconfig
[color] ui = auto [alias] ci = commit co = checkout st = status
This [color] section enable colors when I execute git status and see my changes, but now with my aliases I could write git st.</p> <p>Another nice stuff that I noticed when started to work with git and I was watching a Peepcode screencast was that in the console prompt appeared the git branch, in that moment I googled it but no results got, until now that I found how to do this; one file with the git functions is created .bash_functions
# git-related functions in here git_branch () { GIT_BRANCH="$(git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/\1/')" if [[ -n "$GIT_BRANCH" ]] ; then echo ":($GIT_BRANCH) " fi } empty_branch () { name="$1" if [[ -n "$name" ]] ; then echo "This will create a new empty branch in the current" echo -n "git repository called '${name}' ... Continue? [y/N] " read VERIFY if [[ "$VERIFY" = "Y" || "$VERIFY" = "y" ]]; then echo "creating branch '$name'" git symbolic-ref HEAD refs/heads/$name rm .git/index git clean -fdx echo "you should be on your new empty branch! " echo "add/commit files as usual! " echo "( your new branch will show up after you commit something to it )" else echo -n "" fi else echo "Creates a new empty branch in your git repository." echo "" echo "Usage: empty_branch [name_of_new_branch]" fi } # vim:set ft=sh:
And depending which shell are you using you add this into it
# if .bash_functions if a file then source it # if .bash_functions is a directory, then sourec all its files if [ -f ~/.bash_functions ]; then . ~/.bash_functions fi if [ -d ~/.bash_functions ]; then for function in ~/.bash_functions/*; do . $function; done fi # bash prompt prompt () { PS1="\[\e[34m\]\u\[\e[37m\]@\[\e[36m\]\h\[\e[37m\]:\[\e[31m\]\w\[\e[37m\]$(git_branch)$ " } PROMPT_COMMAND=prompt export PROMPT_COMMAND
I’m using .profile in leopard, but could be .bash_rc. Now to load this new changes from your profile it’s need to execute source .profile or you also could close your console window and open a new one.
I’ve learned a lot until now but I still need to learn more (even english
), I’ve learned also from agile workflows that helps with your work.
Notes:
Aliases
.bash_functions file from Remi
.bash_rc file from Remi
Git workflow for agile teams
Another note:
This is my first try to write in english, I definitely need to learn to be more fluid in my english writing also speaking, but it’s needed to start in some place. So if this is not understandable you can give some feedback, thanks.
Scaling Rails
Feb 27th
Hace un par de semanas aproximadamente buscando información de como hacer escalar aplicaciones Rails me encontré con un material bastante interesante y con información muy valiosa, y lo mejor de todo es que en screencasts, los cuales han sido publicados por Gregg Pollack de RailsEnvy con el soporte de NewRelic, sería muy bueno que les den una revisada. Los screencasts publicados hasta el momento son:
Rails y Merb se fusionan para Rails 3
Dec 23rd
Así es, esto es una muy buena noticia para los que seguimos estos dos fabulosos frameworks, hoy 23 dieron esta noticia de que se unirán para Rails 3, aquí está el enlace de la noticia en el weblog de rubyonrails.org.

