<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Bicosyes - since evermore...</title>
	<atom:link href="http://bicosyes.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://bicosyes.com</link>
	<description></description>
	<lastBuildDate>Sat, 06 Mar 2010 20:03:06 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Code Monkey like Fritos</title>
		<link>http://bicosyes.com/code-monkey-like-fritos/</link>
		<comments>http://bicosyes.com/code-monkey-like-fritos/#comments</comments>
		<pubDate>Sat, 06 Mar 2010 20:01:55 +0000</pubDate>
		<dc:creator>blaxter</dc:creator>
				<category><![CDATA[LOL]]></category>
		<category><![CDATA[Programación]]></category>
		<category><![CDATA[acustic]]></category>
		<category><![CDATA[code monkey]]></category>
		<category><![CDATA[english]]></category>
		<category><![CDATA[song]]></category>
		<category><![CDATA[video]]></category>

		<guid isPermaLink="false">http://bicosyes.com/?p=922</guid>
		<description><![CDATA[Until now I've never heard about this song, about a code monkey, funny and nice at the same time. The same songwriter, Jonathan Coulton, has a lot more of similar (geek) songs. Awesome. Code Monkey get up get coffee Code &#8230; <a href="http://bicosyes.com/code-monkey-like-fritos/">Sigue leyendo <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Until now I've never heard about this song, about a code monkey, funny and nice at the same time. The same songwriter, <a href="http://en.wikipedia.org/wiki/Jonathan_Coulton">Jonathan Coulton</a>, has a lot more of similar (geek) songs. Awesome.</p>
<div class="center"><object width="480" height="385"><param name="movie" value="http://www.youtube.com/v/7s8S7QxpjeY&hl=es_ES&fs=1&rel=0"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/7s8S7QxpjeY&hl=es_ES&fs=1&rel=0" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="480" height="385"></embed></object></div>
<blockquote><p>
Code Monkey get up get coffee<br />
Code Monkey go to job<br />
Code Monkey have boring meeting with boring manager Rob<br />
Rob say Code Monkey very diligent<br />
but his output stink<br />
his code not functional or elegant<br />
what do Code Monkey think<br />
Code Monkey think maybe manager want to write goddamn login page himself<br />
Code Monkey not say it out loud<br />
Code Monkey not crazy just proud</p>
<p>Code Monkey like Fritos<br />
Code Monkey like Tab and Mountain Dew<br />
Code Monkey very simple man<br />
with big warm fuzzy secret heart<br />
Code Monkey like you<br />
Code Monkey like you</p>
<p>Code Monkey hang around at front desk<br />
tell you sweater look nice<br />
Code Monkey offer buy you soda<br />
bring you cup bring you ice<br />
you say no thank you for the soda cause<br />
soda make you fat<br />
anyway you busy with the telephone<br />
no time for chat</p>
<p>Code Monkey have long walk back to cubicle<br />
he sit down pretend to work<br />
Code Monkey not thinking so straight<br />
Code Monkey not feeling so great</p>
<p>Code Monkey like Fritos<br />
Code Monkey like Tab and Mountain Dew<br />
Code Monkey very simple man<br />
with big warm fuzzy secret heart<br />
Code Monkey like you<br />
Code Monkey like you a lot</p>
<p>Code Monkey have every reason<br />
to get out this place<br />
Code Monkey just keep on working<br />
to see your soft pretty face<br />
Much rather wake up eat a coffee cake<br />
Take bath, take nap<br />
This job fulfilling in creative way<br />
such a load of crap<br />
Code Monkey think someday he have everything even pretty girl like you<br />
Code Monkey just waiting for now<br />
Code Monkey say someday, somehow</p>
<p>Code Monkey like Fritos<br />
Code Monkey like Tab and Mountain Dew<br />
Code Monkey very simple man<br />
with big warm fuzzy secret heart<br />
Code Monkey like you<br />
Code Monkey like you</p></blockquote>
<img src="http://bicosyes.com/?ak_action=api_record_view&id=922&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://bicosyes.com/code-monkey-like-fritos/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Practical Reporting with Ruby and Rails</title>
		<link>http://bicosyes.com/practical-reporting-with-ruby-and-rails/</link>
		<comments>http://bicosyes.com/practical-reporting-with-ruby-and-rails/#comments</comments>
		<pubDate>Mon, 11 Jan 2010 11:58:40 +0000</pubDate>
		<dc:creator>blaxter</dc:creator>
				<category><![CDATA[Libros técnicos]]></category>

		<guid isPermaLink="false">http://bicosyes.com/?p=911</guid>
		<description><![CDATA[Practical Reporting with Ruby and Rails es un libro escrito por David Berube sobre reporting con la ayuda de ruby. Se compone de varios capítulos que van desde generar un gráfico con gruff, generar xml/csv/pdf, importaciones desde feeds, hojas de &#8230; <a href="http://bicosyes.com/practical-reporting-with-ruby-and-rails/">Sigue leyendo <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p><a href="http://bicosyes.com/wp-content/uploads/2010/01/practicalreporting.jpg"><img src="http://bicosyes.com/wp-content/uploads/2010/01/practicalreporting-227x300.jpg" alt="practical reporting with ruby and rails" title="practical reporting with ruby and rails" width="127" class="noframe alignleft size-medium wp-image-913" /></a><a href="Practical Reporting with Ruby and Rails">Practical Reporting with Ruby and Rails</a> es un libro escrito por <a href="http://dtb.me/">David Berube</a> sobre reporting con la ayuda de ruby. Se compone de varios capítulos que van desde generar un gráfico con <a href="http://nubyonrails.com/pages/gruff">gruff</a>, generar <a href="http://github.com/clivecrous/remarkably">xml</a>/<a href="http://fastercsv.rubyforge.org/">csv</a>/<a href="http://ruby-pdf.rubyforge.org/pdf-writer/">pdf</a>, importaciones desde <a href="http://sporkmonger.com/projects/feedtools">feeds</a>, hojas de cálculo o <a href="http://ruby-doc.org/stdlib/libdoc/win32ole/rdoc/index.html">Microsoft Office</a>. Todo esto suena bastante bien, pero es el propio carácter del libro, <em>practical</em>, que hace que pierda bastante puntos por su simpleza y falta de profundidad a la hora de tocar los distintos temas.</p>
<p>Es un libro realmente bueno si lo lees con las expectativas apropiadas, y puede llegar a ser un auténtico fiasco en otros casos. En mi particular caso fue el último escenario.</p>
<p>Ya es la segunda vez que me pasa con libros de esta editorial, <a href="http://www.apress.com/">Apress</a>. Son libros bien escritos, tratando muchos temas, pero con un nivel bastante bajo en cuanto a profundidad de conceptos y nivel requerido. Esto no es malo, por supuesto, simplemente es algo a tener en cuenta para saber si es un libro que te reportará algún beneficio y satisfacción.</p>
<p>Cada capítulo suele seguir la siguiente estructura: (1) Puesta en contexto del problema a resolver, (2) introducción de herramientas a usar, (3) trozo de código, (4) explicación del código. Donde las dos últimas partes suelen ser prácticamente la totalidad del capítulo. El código suele ser bastante simple y sencillo de entender, pero a pesar de ello tendremos luego un considerable número de páginas para explicar obviedades para cualquiera que haya programado mínimamente en ruby o en reporting en general. Si a esto añadimos que el libro no es muy extenso en páginas (280 aprox.) tenemos que se podría resumir el libro en un listado de referencias a herramientas usadas y 5 o 6 <em>snippets</em> de código interesantes de no más de 200 líneas.</p>
<p>De todas formas, para alguien que esté interesado en estos temas (reporting) y que no tenga mucha experiencia (en reporting, en ruby o en ambos), es un libro bastante bueno, bien redactado, bien explicado (demasiado) y de rápida lectura. En otros casos no lo recomendaría, y personalmente no me ha gustado mucho que digamos.</p>
<img src="http://bicosyes.com/?ak_action=api_record_view&id=911&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://bicosyes.com/practical-reporting-with-ruby-and-rails/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>boost::asio, synchronous read with timeout</title>
		<link>http://bicosyes.com/boostasio-synchronous-read-with-timeout/</link>
		<comments>http://bicosyes.com/boostasio-synchronous-read-with-timeout/#comments</comments>
		<pubDate>Sun, 20 Dec 2009 20:48:25 +0000</pubDate>
		<dc:creator>blaxter</dc:creator>
				<category><![CDATA[C++]]></category>
		<category><![CDATA[boost]]></category>
		<category><![CDATA[boost::asio]]></category>
		<category><![CDATA[C]]></category>
		<category><![CDATA[english]]></category>
		<category><![CDATA[snippet]]></category>

		<guid isPermaLink="false">http://bicosyes.com/?p=833</guid>
		<description><![CDATA[The boost::asio (which means asynchronous input/output) library, is quite powerful library for asynchronous i/o, but it could be a bit difficult at first to figure out how to do a normal synchronous read. So, as a reminder for my future-me, &#8230; <a href="http://bicosyes.com/boostasio-synchronous-read-with-timeout/">Sigue leyendo <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>The <strong><a href="http://www.boost.org/doc/libs/1_40_0/doc/html/boost_asio.html">boost::asio</a></strong> (which means asynchronous input/output) library, is quite powerful library for asynchronous i/o, but it could be a bit difficult at first to figure out how to do a normal <strong>synchronous</strong> read. So, as a reminder for my future-me, and for you, this snippet it'll be very useful to accomplish that. Probably there will be another ways for doing that, but this is how I managed to do it:</p>
<pre class="cpp"><span style="color: #0000ff;">using</span> <span style="color: #0000ff;">namespace</span> boost::<span style="color: #00eeff;">asio</span>;
<span style="color: #0000ff;">using</span> <span style="color: #0000ff;">namespace</span> boost::<span style="color: #0000dd;">system</span>;
<span style="color: #0000ff;">using</span> boost::<span style="color: #00eeff;">optional</span>;
&nbsp;
ip::<span style="color: #00eeff;">tcp</span>::<span style="color: #00eeff;">socket</span> _socket; <span style="color: #ff0000;">// it could be another kind of socket, not only ip::tcp</span>
&nbsp;
<span style="color: #ff0000; font-style: italic;">/**
 * Dumb function to be used as handler argument and save the error_code
 * into a pointer
 *
 * e.g.: boost::bind( &amp;set_result, some_pointer, _1 )
 */</span>
<span style="color: #0000ff;">void</span> set_result<span style="color: #000000;">&#40;</span> optional&lt;error_code&gt;* a, error_code b <span style="color: #000000;">&#41;</span>
<span style="color: #000000;">&#123;</span>
  a-&gt;reset<span style="color: #000000;">&#40;</span> b <span style="color: #000000;">&#41;</span>;
<span style="color: #000000;">&#125;</span>
&nbsp;
<span style="color: #339900;">#define TIMEOUT 60</span>
<span style="color: #ff0000; font-style: italic;">/**
 * it uses _socket
 * if timeout happends throw a system_error exception
 */</span>
template&lt;typename MutableBufferSequence&gt;
optional&lt;error_code&gt; read_with_timeout<span style="color: #000000;">&#40;</span>
    <span style="color: #0000ff;">const</span> MutableBufferSequence&amp; buffer
  <span style="color: #000000;">&#41;</span> throw<span style="color: #000000;">&#40;</span> system_error <span style="color: #000000;">&#41;</span>
<span style="color: #000000;">&#123;</span>
  optional&lt;error_code&gt; timer_result;
  optional&lt;error_code&gt; read_result;
&nbsp;
  deadline_timer timer<span style="color: #000000;">&#40;</span> _socket.<span style="color: #00eeff;">io_service</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#41;</span>;
&nbsp;
  timer.<span style="color: #00eeff;">expires_from_now</span><span style="color: #000000;">&#40;</span> seconds<span style="color: #000000;">&#40;</span>TIMEOUT<span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#41;</span>;
  timer.<span style="color: #00eeff;">async_wait</span><span style="color: #000000;">&#40;</span> boost::<span style="color: #00eeff;">bind</span><span style="color: #000000;">&#40;</span>&amp;set_result, &amp;timer_result, _1<span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#41;</span>;
&nbsp;
  boost::<span style="color: #00eeff;">asio</span>::<span style="color: #00eeff;">async_read</span><span style="color: #000000;">&#40;</span>
      _socket,
      buffer,
      boost::<span style="color: #00eeff;">asio</span>::<span style="color: #00eeff;">transfer_at_least</span><span style="color: #000000;">&#40;</span> buffer_size_helper<span style="color: #000000;">&#40;</span>buffer<span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#41;</span>,
      boost::<span style="color: #00eeff;">bind</span><span style="color: #000000;">&#40;</span> &amp;set_result, &amp;read_result, _1 <span style="color: #000000;">&#41;</span>
    <span style="color: #000000;">&#41;</span>;
&nbsp;
  _socket.<span style="color: #00eeff;">io_service</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>.<span style="color: #00eeff;">reset</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
&nbsp;
  <span style="color: #0000ff;">while</span> <span style="color: #000000;">&#40;</span> _socket.<span style="color: #00eeff;">io_service</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>.<span style="color: #00eeff;">run_one</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#41;</span>
  <span style="color: #000000;">&#123;</span>
    <span style="color: #0000ff;">if</span> <span style="color: #000000;">&#40;</span> read_result <span style="color: #000000;">&#41;</span>
    <span style="color: #000000;">&#123;</span>
      timer.<span style="color: #00eeff;">cancel</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
    <span style="color: #000000;">&#125;</span>
    <span style="color: #0000ff;">else</span> <span style="color: #0000ff;">if</span> <span style="color: #000000;">&#40;</span> timer_result <span style="color: #000000;">&#41;</span>
    <span style="color: #000000;">&#123;</span>
      _socket.<span style="color: #00eeff;">cancel</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
      throw system_error<span style="color: #000000;">&#40;</span>
          error_code<span style="color: #000000;">&#40;</span> errc::<span style="color: #00eeff;">timed_out</span>, get_generic_category<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#41;</span>
        <span style="color: #000000;">&#41;</span>;
    <span style="color: #000000;">&#125;</span>
  <span style="color: #000000;">&#125;</span>
  <span style="color: #0000ff;">return</span> read_result;
<span style="color: #000000;">&#125;</span>
&nbsp;</pre>
<p>I hope it will be useful, have fun.</p>
<img src="http://bicosyes.com/?ak_action=api_record_view&id=833&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://bicosyes.com/boostasio-synchronous-read-with-timeout/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Mostrar iconos en los botones y menús de gnome</title>
		<link>http://bicosyes.com/mostrar-iconos-en-los-botones-y-menus-de-gnome/</link>
		<comments>http://bicosyes.com/mostrar-iconos-en-los-botones-y-menus-de-gnome/#comments</comments>
		<pubDate>Wed, 02 Dec 2009 20:14:24 +0000</pubDate>
		<dc:creator>blaxter</dc:creator>
				<category><![CDATA[Ubuntu]]></category>
		<category><![CDATA[gconf]]></category>
		<category><![CDATA[gnome]]></category>
		<category><![CDATA[icons]]></category>
		<category><![CDATA[ui]]></category>

		<guid isPermaLink="false">http://bicosyes.com/?p=904</guid>
		<description><![CDATA[En la última versión de gnome, han decidido poner por defecto que no salgan iconos ni en los botones, ni en los menús. Hasta ahora, tenías iconos en todos lados, esto implicaba que los botones eran siempre más grandes de &#8230; <a href="http://bicosyes.com/mostrar-iconos-en-los-botones-y-menus-de-gnome/">Sigue leyendo <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>En la última versión de <a href="http://www.gnome.org/">gnome</a>, han decidido poner por defecto <a href="http://www.osnews.com/story/21935/GNOME_To_Drop_Icons_in_Buttons_Menus">que <strong>no</strong> salgan iconos ni en los botones, ni en los menús</a>. Hasta ahora, tenías iconos en todos lados, esto implicaba que los botones eran siempre más grandes de los normal (por incluir dentro de ellos el icono pertinente) lo que hacia que en general, en gnome, las cosas fuesen como <em>más grandes</em>. Con este cambio los layouts van a ser más compactos, aunque también más rancios y menos usuables, <acronym title="en mi opinión">IMHO</acronym>.</p>
<p>No me gusta nada este cambio, más vale una imagen que mil palabras, teniendo iconos vas más rápido porque los reconoces y no necesitas leer cosas, aparte que uno de los aspectos que más me gusta de gnome es esa sensación de que todo es grandote <img src='http://bicosyes.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> . Al menos volver a tenerlos es tarea simple, activa <em>/desktop/gnome/interface/buttons_have_icons</em> y <em>/desktop/gnome/interface/menus_have_icons</em> en el editor de configuración de gnome y ya los tendrás.</p>
<pre>$ gconftool-2 --type bool --set /desktop/gnome/interface/buttons_have_icons true
$ gconftool-2 --type bool --set /desktop/gnome/interface/menus_have_icons true</pre>
<img src="http://bicosyes.com/?ak_action=api_record_view&id=904&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://bicosyes.com/mostrar-iconos-en-los-botones-y-menus-de-gnome/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Mostrar notificaciones emergentes desde la consola</title>
		<link>http://bicosyes.com/mostrar-notificaciones-emergentes-desde-la-consola/</link>
		<comments>http://bicosyes.com/mostrar-notificaciones-emergentes-desde-la-consola/#comments</comments>
		<pubDate>Sun, 29 Nov 2009 14:20:21 +0000</pubDate>
		<dc:creator>blaxter</dc:creator>
				<category><![CDATA[Ubuntu]]></category>
		<category><![CDATA[bashrc]]></category>
		<category><![CDATA[d-bus]]></category>
		<category><![CDATA[notificaciones]]></category>
		<category><![CDATA[notify]]></category>
		<category><![CDATA[tips]]></category>
		<category><![CDATA[ubutu]]></category>

		<guid isPermaLink="false">http://bicosyes.com/?p=894</guid>
		<description><![CDATA[A veces es útil mostrar algún tipo de notificación gráfica para informarte, por ejemplo, de cuándo se ha terminado una tarea. Las notificaciones emergentes de Ubuntu, añadidas hace un par de versiones, son una muy buena opción. Dos opciones, (1) &#8230; <a href="http://bicosyes.com/mostrar-notificaciones-emergentes-desde-la-consola/">Sigue leyendo <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>A veces es útil mostrar algún tipo de notificación gráfica para informarte, por ejemplo, de cuándo se ha terminado una tarea. <a href="https://wiki.ubuntu.com/NotifyOSD">Las notificaciones emergentes de Ubuntu</a>, añadidas hace un par de versiones, son una muy buena opción.</p>
<p>Dos opciones, (1) instalarnos esta librería de perl <em>libnet-dbus-perl</em>, y nos ponemos esta función en nuestro <em>~/.bashrc</em></p>
<pre class="bash"><span style="color: #000000; font-weight: bold;">function</span> notify<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>
<span style="color: #7a0874; font-weight: bold;">&#123;</span>
    <span style="color: #c20cb9; font-weight: bold;">perl</span> -e <span style="color: #ff0000;">&quot;use Net::DBus; my <span style="color: #000099; font-weight: bold;">\$</span>sessionBus = Net::DBus-&gt;session; my <span style="color: #000099; font-weight: bold;">\$</span>notificat
ionsService = <span style="color: #000099; font-weight: bold;">\$</span>sessionBus-&gt;get_service('org.freedesktop.Notifications'); my <span style="color: #000099; font-weight: bold;">\$</span>n
otificationsObject = <span style="color: #000099; font-weight: bold;">\$</span>notificationsService-&gt;get_object('/org/freedesktop/Notifi
cations', 'org.freedesktop.Notifications'); my <span style="color: #000099; font-weight: bold;">\$</span>notificationId; <span style="color: #000099; font-weight: bold;">\$</span>notificationI
d = <span style="color: #000099; font-weight: bold;">\$</span>notificationsObject-&gt;Notify(shift, 0, '', '$1', '$2', [], {}, -1);&quot;</span>
<span style="color: #7a0874; font-weight: bold;">&#125;</span></pre>
<pre>$ notify foooooooo baaarrr</pre>
<p><a href="http://bicosyes.com/wp-content/uploads/2009/11/notify.png"><img src="http://bicosyes.com/wp-content/uploads/2009/11/notify.png" alt="notify" title="notify" width="357" height="204" class="aligncenter size-full wp-image-895" /></a></p>
<p>El primer parámetro es el título y el segundo el contenido. </p>
<p>Otra forma (2) todavía más fácil es instalarnos el paquete <em>libnotify-bin</em>, el cual contiene el binario <em>notify-send</em> que hace justamente esto. Probablemente la primera solución nos servirá para cualquier distro, mientras que la segunda solo en debian, ubuntu y derivados. Ambas funcionan exactamente igual y sin problemas.</p>
<img src="http://bicosyes.com/?ak_action=api_record_view&id=894&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://bicosyes.com/mostrar-notificaciones-emergentes-desde-la-consola/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>How to know, in ruby, which methods have been added and by whom?</title>
		<link>http://bicosyes.com/how-to-know-in-ruby-which-methods-have-been-added-and-by-whom/</link>
		<comments>http://bicosyes.com/how-to-know-in-ruby-which-methods-have-been-added-and-by-whom/#comments</comments>
		<pubDate>Mon, 23 Nov 2009 19:50:37 +0000</pubDate>
		<dc:creator>blaxter</dc:creator>
				<category><![CDATA[Ruby]]></category>
		<category><![CDATA[debug]]></category>
		<category><![CDATA[english]]></category>
		<category><![CDATA[method_added]]></category>
		<category><![CDATA[monkeypatching]]></category>

		<guid isPermaLink="false">http://bicosyes.com/?p=885</guid>
		<description><![CDATA[If you are not very careful, monkeypatching could be very harmful. One thing to remember is that you should never override a method to add funcionality, for those kind of thinks you must use alias chain method pattern, a safer &#8230; <a href="http://bicosyes.com/how-to-know-in-ruby-which-methods-have-been-added-and-by-whom/">Sigue leyendo <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>If you are not very careful, monkeypatching could be very harmful. One thing to remember is that you should <strong>never</strong> override a method to <strong>add</strong> funcionality, for those kind of thinks you must use <em>alias chain method pattern</em>, a safer way of doing that. </p>
<p>For the rest of the <em>monkeypatching</em>, i.e. add new methods, you could debug them really easy with something like this:</p>
<pre class="ruby"><span style="color:#9966CC; font-weight:bold;">class</span> <span style="color:#9966CC; font-weight:bold;">Class</span>
   <span style="color:#9966CC; font-weight:bold;">def</span> method_added<span style="color:#006600; font-weight:bold;">&#40;</span>method_name<span style="color:#006600; font-weight:bold;">&#41;</span>
      <span style="color:#CC0066; font-weight:bold;">puts</span> <span style="color:#996600;">&quot;#{method_name} added to #{self}, callstack:&quot;</span>
      <span style="color:#CC0066; font-weight:bold;">puts</span> <span style="color:#CC0066; font-weight:bold;">caller</span>.<span style="color:#9900CC;">map</span><span style="color:#006600; font-weight:bold;">&#123;</span>|line| <span style="color:#996600;">&quot;<span style="color:#000099;">\t</span>#{line}&quot;</span> <span style="color:#006600; font-weight:bold;">&#125;</span>.<span style="color:#9900CC;">join</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">&quot;<span style="color:#000099;">\n</span>&quot;</span><span style="color:#006600; font-weight:bold;">&#41;</span>
   <span style="color:#9966CC; font-weight:bold;">end</span>
<span style="color:#9966CC; font-weight:bold;">end</span></pre>
<p>You can always add more code to filter by class or by method's name. Let's see an example:</p>
<pre class="ruby">$ more example.<span style="color:#9900CC;">rb</span>
<span style="color:#CC0066; font-weight:bold;">require</span> <span style="color:#996600;">'date'</span>
<span style="color:#CC0066; font-weight:bold;">require</span> <span style="color:#996600;">'time'</span>
&nbsp;
<span style="color:#9966CC; font-weight:bold;">class</span> <span style="color:#9966CC; font-weight:bold;">Class</span>
   <span style="color:#9966CC; font-weight:bold;">def</span> method_added<span style="color:#006600; font-weight:bold;">&#40;</span>method_name<span style="color:#006600; font-weight:bold;">&#41;</span>
      <span style="color:#0000FF; font-weight:bold;">return</span> <span style="color:#9966CC; font-weight:bold;">if</span> %w<span style="color:#006600; font-weight:bold;">&#40;</span>method_added<span style="color:#006600; font-weight:bold;">&#41;</span>.<span style="color:#9966CC; font-weight:bold;">include</span>? method_name.<span style="color:#9900CC;">to_s</span>
      <span style="color:#CC0066; font-weight:bold;">puts</span> <span style="color:#996600;">&quot;#{method_name} added to #{self}, callstack:&quot;</span>
      <span style="color:#CC0066; font-weight:bold;">puts</span> <span style="color:#CC0066; font-weight:bold;">caller</span>.<span style="color:#9900CC;">map</span><span style="color:#006600; font-weight:bold;">&#123;</span>|line| <span style="color:#996600;">&quot;<span style="color:#000099;">\t</span>#{line}&quot;</span> <span style="color:#006600; font-weight:bold;">&#125;</span>.<span style="color:#9900CC;">join</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">&quot;<span style="color:#000099;">\n</span>&quot;</span><span style="color:#006600; font-weight:bold;">&#41;</span>
   <span style="color:#9966CC; font-weight:bold;">end</span>
<span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
<span style="color:#9966CC; font-weight:bold;">class</span> <span style="color:#CC00FF; font-weight:bold;">Time</span>
   <span style="color:#9966CC; font-weight:bold;">def</span> to_date
      <span style="color:#CC00FF; font-weight:bold;">Date</span>.<span style="color:#9900CC;">ordinal</span> <span style="color:#0000FF; font-weight:bold;">self</span>.<span style="color:#9900CC;">year</span>, <span style="color:#0000FF; font-weight:bold;">self</span>.<span style="color:#9900CC;">yday</span>
   <span style="color:#9966CC; font-weight:bold;">end</span>
<span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
<span style="color:#9966CC; font-weight:bold;">class</span> <span style="color:#CC00FF; font-weight:bold;">Date</span>
   <span style="color:#9966CC; font-weight:bold;">def</span> to_time
      <span style="color:#CC00FF; font-weight:bold;">Time</span>.<span style="color:#9900CC;">parse</span> <span style="color:#0000FF; font-weight:bold;">self</span>.<span style="color:#9900CC;">to_s</span>
   <span style="color:#9966CC; font-weight:bold;">end</span>
<span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
<span style="color:#CC0066; font-weight:bold;">raise</span> <span style="color:#996600;">&quot;to_date not working&quot;</span> <span style="color:#9966CC; font-weight:bold;">unless</span>
   <span style="color:#CC00FF; font-weight:bold;">Time</span>.<span style="color:#9900CC;">now</span>.<span style="color:#9900CC;">to_date</span> == <span style="color:#CC00FF; font-weight:bold;">Date</span>.<span style="color:#9900CC;">today</span>
<span style="color:#CC0066; font-weight:bold;">raise</span> <span style="color:#996600;">&quot;to time not working&quot;</span> <span style="color:#9966CC; font-weight:bold;">unless</span>
   <span style="color:#CC00FF; font-weight:bold;">Time</span>.<span style="color:#9900CC;">now</span>.<span style="color:#9900CC;">to_date</span>.<span style="color:#9900CC;">to_time</span> == <span style="color:#CC00FF; font-weight:bold;">Date</span>.<span style="color:#9900CC;">today</span>.<span style="color:#9900CC;">to_time</span></pre>
<p>The output will be:</p>
<pre>$ ruby example.rb
to_date added to Time, callstack:
	example.rb:13
to_time added to Date, callstack:
	example.rb:19</pre>
<p>Nice, isn't it?. Remember to be carefull with your monkeypatching, with great power comes great responsibility, it's just a tool, neither magic nor the panacea.</p>
<img src="http://bicosyes.com/?ak_action=api_record_view&id=885&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://bicosyes.com/how-to-know-in-ruby-which-methods-have-been-added-and-by-whom/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

