<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>Arturo Herrero</title>
    <description>The personal website of Arturo Herrero.</description>
    <link>https://arturoherrero.com/</link>
    <atom:link href="https://arturoherrero.com/index.xml" rel="self" type="application/rss+xml" />
    <pubDate>Mon, 18 May 2026 15:13:11 +0000</pubDate>
    <lastBuildDate>Mon, 18 May 2026 15:13:11 +0000</lastBuildDate>
    <generator>Jekyll v3.10.0</generator>
    
      <item>
        <title>H. Solano</title>
        <description>&lt;p&gt;Hoy estamos aquí para honrar la memoria de mi padre, pero me gustaría en primer
lugar dar las gracias a mi madre por la maravillosa persona que es, su trabajo y
dedicación. Gracias, mamá.&lt;/p&gt;

&lt;p&gt;Mi madre me pidió que dedicara unas palabras durante el funeral de mi padre pero
es imposible expresarlo mejor que Jorge Manrique cuando escribió en el siglo XV
las coplas a la muerte de su padre:&lt;/p&gt;

&lt;blockquote&gt;
  &lt;p&gt;&lt;em&gt;Recuerde el alma dormida,&lt;/em&gt;&lt;br /&gt;
&lt;em&gt;avive el seso y despierte&lt;/em&gt;&lt;br /&gt;
&lt;em&gt;contemplando&lt;/em&gt;&lt;br /&gt;
&lt;em&gt;cómo se pasa la vida,&lt;/em&gt;&lt;br /&gt;
&lt;em&gt;cómo se viene la muerte&lt;/em&gt;&lt;br /&gt;
&lt;em&gt;tan callando,&lt;/em&gt;&lt;br /&gt;
&lt;em&gt;cuán presto se va el placer,&lt;/em&gt;&lt;br /&gt;
&lt;em&gt;cómo, después de acordado,&lt;/em&gt;&lt;br /&gt;
&lt;em&gt;da dolor;&lt;/em&gt;&lt;br /&gt;
&lt;em&gt;cómo, a nuestro parecer,&lt;/em&gt;&lt;br /&gt;
&lt;em&gt;cualquiera tiempo pasado&lt;/em&gt;&lt;br /&gt;
&lt;em&gt;fue mejor&lt;/em&gt;.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Yo soy incapaz de escribir un poema de lamentación, pero voy a intentar escribir
un elogio a la muerte de mi padre.&lt;/p&gt;

&lt;p&gt;Comenzaré, ante todo, explicando que mi padre fue dos personas distintas a lo
largo de su vida: una antes de la enfermedad y otra después. La enfermedad
desdibuja a una persona hasta convertirla en un desconocido. Tanto es así que mi
mujer no ha llegado a conocer realmente a mi padre, ya que apenas compartieron
un par de ocasiones en 2015 cuando él todavía estaba bien. La ciencia y la
medicina le permitieron vivir 7 años más y pudo conocer a su nieta, aunque no
disfrutarla. Asusta darse cuenta de la fragilidad de todo lo que nos rodea.
Polvo eres y en polvo te convertirás o, como él solía decir, vanidad de
vanidades todo es vanidad.&lt;/p&gt;

&lt;p&gt;Ahora, es mi responsabilidad contarles quién fue mi padre, quién fue su abuelo.&lt;/p&gt;

&lt;p&gt;El problema es que «cuando un anciano muere, una biblioteca arde». No sólo
perdemos a una persona sino todo el conocimiento y sabiduría acumulados a lo
largo de la vida. Desaparece parte de nuestro mundo, de nosotros mismos y
nuestros recuerdos, aspectos únicos de nuestra vida que tal vez nunca nos
contaron. Desaparece “el mundo de ayer”, el mundo que conoció y del que fue
testigo. Es como si se quemara una biblioteca llena de libros valiosos y únicos
que no pueden ser reemplazados, o en su caso de cuadros y obras de arte.&lt;/p&gt;

&lt;p&gt;Tratar de explicar la vida de una persona es una tarea imposible. Podría
contar algunas anécdotas de su vida: su época en el internado cuando era niño,
la magia que suponía para un chaval una Gran Vía llena de cines con carteles
pintados a mano en los años 60, sus primeros trabajos, empezar a pintar, conocer
a mamá, juegos con nosotros de pequeños…&lt;/p&gt;

&lt;p&gt;Repasando la vida de mi padre, me he dado cuenta de que lo importante no son los
grandes logros y proezas que uno logra en la vida sino las escenas cotidianas e
íntimas del día a día.&lt;/p&gt;

&lt;p&gt;La palabra “recordar” proviene del latín “recordari”, que se forma a partir de
las palabras “re” (de nuevo) y “cordis” (corazón). Antiguamente se pensaba que
la sede de la memoria se ubicaba en el corazón. Recordar quiere decir mucho más
que tener a alguien presente en la memoria. Su significado original era “volver
a pasar por el corazón” o “volver a traer a la mente algo que se tenía en el
corazón”. Así que si decimos que estamos recordando a alguien, lo que en
realidad estamos diciendo es que le estamos volviendo a pasar por el corazón.&lt;/p&gt;

&lt;p&gt;¿Quién era mi padre? Mi padre son los siguientes recuerdos:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Madrugar para veranear en Santa Pola escuchando Los Sabandeños en el coche&lt;/li&gt;
  &lt;li&gt;Jugar a la petanca, las carreras de chapas y el frontón&lt;/li&gt;
  &lt;li&gt;Las espalderas&lt;/li&gt;
  &lt;li&gt;Los partidos de tenis durante los fines de semana&lt;/li&gt;
  &lt;li&gt;Lavarse con agua fría de la nevera por las mañanas&lt;/li&gt;
  &lt;li&gt;La estufa que ponía aquellas mañanas de invierno antes de llevarme al colegio&lt;/li&gt;
  &lt;li&gt;El zumo de naranja recién exprimido&lt;/li&gt;
  &lt;li&gt;Las discusiones durante las comidas en los fines de semana&lt;/li&gt;
  &lt;li&gt;Salir al coche las tardes soleadas de invierno para leer el periódico y echar una cabezadita&lt;/li&gt;
  &lt;li&gt;Las noches en los que cenábamos juntos en la cocina&lt;/li&gt;
  &lt;li&gt;El kéfir que tomaba todas las noches&lt;/li&gt;
  &lt;li&gt;El aloe vera&lt;/li&gt;
  &lt;li&gt;Los cuentos infantiles y el Sartenero&lt;/li&gt;
  &lt;li&gt;Quedarse dormido en el sofá por las noches mientras veía la tele&lt;/li&gt;
  &lt;li&gt;Nueva York y Frank Sinatra&lt;/li&gt;
  &lt;li&gt;El cine y las películas clásicas que tanto le gustaban&lt;/li&gt;
  &lt;li&gt;Ciudadano Kane&lt;/li&gt;
  &lt;li&gt;Su estudio de Don Felipe y la cola de conejo&lt;/li&gt;
  &lt;li&gt;915227291&lt;/li&gt;
  &lt;li&gt;Dos de las palabras más bellas del diccionario: cornucopia y paspartú&lt;/li&gt;
  &lt;li&gt;Un bote de cristal lleno de pinceles&lt;/li&gt;
  &lt;li&gt;Las acuarelas y las obras de arte&lt;/li&gt;
  &lt;li&gt;H. Solano&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Estos y muchos más son los recuerdos de mi padre. Cada uno tendréis los vuestros
y seguramente compartamos muchos de ellos. Espero que la vida me brinde—nos
brinde—muchos momentos para poder recordar a mi padre, es decir, para volverle a
pasar por el corazón. Muchas gracias.&lt;/p&gt;
</description>
        <pubDate>Tue, 20 Jun 2023 00:00:00 +0000</pubDate>
        <link>https://arturoherrero.com/h-solano/</link>
        <guid isPermaLink="true">https://arturoherrero.com/h-solano/</guid>
        
        <category>personal</category>
        
        
      </item>
    
      <item>
        <title>Ciudades</title>
        <description>&lt;p&gt;Londres es una de las ciudades más multiculturales y cosmopolitas del mundo.
Parece que todo lo que ocurre en el mundo está ocurriendo aquí, y eso se nota en
el ambiente y en la gente. Las ciudades mandan mensajes de maneras sutiles.&lt;/p&gt;

&lt;blockquote&gt;
  &lt;p&gt;Great cities attract ambitious people. You can sense it when you walk around
one. In a hundred subtle ways, the city sends you a message: you could do more;
you should try harder.&lt;/p&gt;

  &lt;p&gt;The surprising thing is how different these messages can be. New York tells
you, above all: you should make more money. There are other messages too, of
course. You should be hipper. You should be better looking. But the clearest
message is that you should be richer.&lt;/p&gt;

  &lt;p&gt;What I like about Boston (or rather Cambridge) is that the message there is:
you should be smarter. You really should get around to reading all those books
you’ve been meaning to.&lt;/p&gt;

  &lt;p&gt;When you ask what message a city sends, you sometimes get surprising answers.
As much as they respect brains in Silicon Valley, the message the Valley sends
is: you should be more powerful.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;a href=&quot;http://www.paulgraham.com/cities.html&quot; target=&quot;_blank&quot; rel=&quot;noreferrer&quot;&gt;Cities and Ambition&lt;/a&gt;, Paul Graham.&lt;/p&gt;

&lt;blockquote&gt;
  &lt;p&gt;Hay ciudades que sosiegan y otras que estimulan. El efecto, supongo, varía
según cada cual. En lo que a mí se refiere, Sevilla, Lisboa o Tánger, por
ejemplo, son de las primeras. De las que inspiran paz y ganas de pasear
tranquilo, sin complicarte la vida: comer, leer, tomar una copa, mirar los
lugares hermosos y ver pasar a la gente. Aquéllas donde no sientes la necesidad
de hacer nada diferente a lo que haces. Otras ciudades, sin embargo, me causan
un efecto distinto. En ellas es como si te tomaras una taza de café solo, bien
cargado, o te fumaras un cigarrillo de los tiempos en que fumabas. O tuvieras
quince años y te enamorases de alguien. Ciudades que abren puertas, que sugieren
cosas quizá interesantes que todavía no has hecho. Puestos a seguir con los
ejemplos, eso me ocurre en Londres, o en Nueva York, o en la ciudad de México.
Son ciudades que incitan a hacer, a vivir, a imaginar. Que, como digo,
estimulan. Que te vuelven lúcido y creativo.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;a href=&quot;https://www.zendalibros.com/perez-reverte-mi-paris-y-otros-amores/&quot; target=&quot;_blank&quot; rel=&quot;noreferrer&quot;&gt;Mi París y otros amores&lt;/a&gt;, Arturo Pérez-Reverte.&lt;/p&gt;

</description>
        <pubDate>Thu, 05 Jan 2023 00:00:00 +0000</pubDate>
        <link>https://arturoherrero.com/ciudades/</link>
        <guid isPermaLink="true">https://arturoherrero.com/ciudades/</guid>
        
        <category>ideas</category>
        
        
      </item>
    
      <item>
        <title>iShows Server</title>
        <description>&lt;p&gt;About 10 years ago, I got involved in a very interesting project: &lt;a href=&quot;/ishows/&quot;&gt;iShows&lt;/a&gt;.
Now that the project is over, I would like to pay a small tribute to it.&lt;/p&gt;

&lt;p&gt;At that time, a server was needed to provide images with specific sizes to
an iOS mobile application. This started as a side project, but ended up serving
over a billion images. Billion! One thousand million. 1,000,000,000.&lt;/p&gt;

&lt;p&gt;Basically, the server was a man-in-the-middle. The mobile application requested
an image to the server, the server forwarded the request to TheTVDB, got the
image, resized or cropped it, cached the final image, and served it to the mobile device.&lt;/p&gt;

&lt;p&gt;Along the way, I solved many problems, and I always tried to stick to the Minimal
Viable Change (MVC)—the smallest possible solution that offers value to the
users. Examples:&lt;/p&gt;
&lt;ul&gt;
  &lt;li&gt;I switched the server to DigitalOcean to save money.&lt;/li&gt;
  &lt;li&gt;Caching images requires a lot of disk space, so a cron job deleted images
that had not been accessed for 30 days.&lt;/li&gt;
  &lt;li&gt;Working in a directory with 362,444 files was hard. You get errors for normal
operations: &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;/bin/rm: cannot execute [Argument list too long]&lt;/code&gt;.&lt;/li&gt;
  &lt;li&gt;A Docker image was the way to go, but taking snapshots of the server was enough.&lt;/li&gt;
  &lt;li&gt;Sometimes images that gave errors were requested, but a simple text file was
enough to filter out the bad URLs.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;We were lucky with the server and, despite receiving constant authentication
attempts, there were no major problems. Our uptime was practically the same as
the DigitalOcean’s or TheTVDB’s uptime. I suspect that a simple command-line
one-liner Denial-of-Service attack from any laptop would have given us a
lot of headaches, but that was an MVC that I did not have to solve.&lt;/p&gt;

&lt;p&gt;The project is open source &lt;a href=&quot;https://github.com/arturoherrero/ishows&quot; target=&quot;_blank&quot; rel=&quot;noreferrer&quot;&gt;arturoherrero/ishows&lt;/a&gt;.
Here are the glorious ~50 Ruby lines of code that have served a thousand million images.&lt;/p&gt;

&lt;div class=&quot;language-ruby highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nb&quot;&gt;require&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;logger&quot;&lt;/span&gt;
&lt;span class=&quot;nb&quot;&gt;require&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;mini_magick&quot;&lt;/span&gt;
&lt;span class=&quot;nb&quot;&gt;require&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;sinatra/base&quot;&lt;/span&gt;

&lt;span class=&quot;no&quot;&gt;IMAGES_PATH&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;images/&quot;&lt;/span&gt;
&lt;span class=&quot;no&quot;&gt;BAD_URLS_FILE&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;tmp/bad-urls.txt&quot;&lt;/span&gt;

&lt;span class=&quot;k&quot;&gt;class&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;Server&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt; &lt;span class=&quot;no&quot;&gt;Sinatra&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;no&quot;&gt;Base&lt;/span&gt;
  &lt;span class=&quot;c1&quot;&gt;# Resize an image for a given URL&lt;/span&gt;
  &lt;span class=&quot;c1&quot;&gt;# http://localhost:3000/width/X/url&lt;/span&gt;
  &lt;span class=&quot;n&quot;&gt;get&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;/width/:value/*/?&quot;&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;do&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;|&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;value&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;url&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;|&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;process_image&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;value&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;url&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;do&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;|&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;image&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;|&lt;/span&gt;
      &lt;span class=&quot;n&quot;&gt;resize&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;image&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;value&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;end&lt;/span&gt;
  &lt;span class=&quot;k&quot;&gt;end&lt;/span&gt;

  &lt;span class=&quot;c1&quot;&gt;# Resize and crop an image for a given URL&lt;/span&gt;
  &lt;span class=&quot;c1&quot;&gt;# http://localhost:3000/crop/XxY/url&lt;/span&gt;
  &lt;span class=&quot;n&quot;&gt;get&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;/crop/:dimensions/*/?&quot;&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;do&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;|&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;dimensions&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;url&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;|&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;process_image&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;dimensions&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;url&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;do&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;|&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;image&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;|&lt;/span&gt;
      &lt;span class=&quot;n&quot;&gt;resize&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;image&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;#{&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;dimensions&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;^&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
      &lt;span class=&quot;n&quot;&gt;crop&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;image&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;dimensions&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;end&lt;/span&gt;
  &lt;span class=&quot;k&quot;&gt;end&lt;/span&gt;

  &lt;span class=&quot;kp&quot;&gt;private&lt;/span&gt;

  &lt;span class=&quot;k&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;process_image&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;dimensions&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;url&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
    &lt;span class=&quot;c1&quot;&gt;# WORKAROUND: Sinatra match the route parameter&lt;/span&gt;
    &lt;span class=&quot;c1&quot;&gt;# with only one slash http:/&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;url&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;:/&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;://&quot;&lt;/span&gt;

    &lt;span class=&quot;k&quot;&gt;unless&lt;/span&gt; &lt;span class=&quot;no&quot;&gt;File&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;foreach&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;no&quot;&gt;BAD_URLS_FILE&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;).&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;any?&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;|&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;line&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;|&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;line&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;include?&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;url&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
      &lt;span class=&quot;k&quot;&gt;unless&lt;/span&gt; &lt;span class=&quot;no&quot;&gt;File&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;exist?&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;filename&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
        &lt;span class=&quot;n&quot;&gt;image&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;no&quot;&gt;MiniMagick&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;no&quot;&gt;Image&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;open&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;url&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
        &lt;span class=&quot;k&quot;&gt;yield&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;image&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
        &lt;span class=&quot;n&quot;&gt;image&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;write&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;filename&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
      &lt;span class=&quot;k&quot;&gt;end&lt;/span&gt;

      &lt;span class=&quot;n&quot;&gt;send_file&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;filename&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;ss&quot;&gt;type: &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;image/jpeg&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;ss&quot;&gt;disposition: &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;inline&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;end&lt;/span&gt;
  &lt;span class=&quot;k&quot;&gt;rescue&lt;/span&gt; &lt;span class=&quot;no&quot;&gt;StandardError&lt;/span&gt;
    &lt;span class=&quot;no&quot;&gt;Logger&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;new&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;no&quot;&gt;BAD_URLS_FILE&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;).&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;error&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;url&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
  &lt;span class=&quot;k&quot;&gt;end&lt;/span&gt;

  &lt;span class=&quot;k&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;filename&lt;/span&gt;
    &lt;span class=&quot;vi&quot;&gt;@filename&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;||=&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;#{&lt;/span&gt;&lt;span class=&quot;no&quot;&gt;IMAGES_PATH&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;}#{&lt;/span&gt;&lt;span class=&quot;no&quot;&gt;Digest&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;no&quot;&gt;SHA1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;hexdigest&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;request&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;path&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;
  &lt;span class=&quot;k&quot;&gt;end&lt;/span&gt;

  &lt;span class=&quot;k&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;resize&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;image&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;dimensions&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;image&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;resize&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;dimensions&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
  &lt;span class=&quot;k&quot;&gt;end&lt;/span&gt;

  &lt;span class=&quot;c1&quot;&gt;# WORKAROUND: http://stackoverflow.com/q/8418973/462015&lt;/span&gt;
  &lt;span class=&quot;k&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;crop&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;image&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;dimensions&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;image&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;crop&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;#{&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;dimensions&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;+0+0&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
  &lt;span class=&quot;k&quot;&gt;end&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;end&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

</description>
        <pubDate>Sun, 02 Oct 2022 00:00:00 +0000</pubDate>
        <link>https://arturoherrero.com/ishows-server/</link>
        <guid isPermaLink="true">https://arturoherrero.com/ishows-server/</guid>
        
        <category>programming</category>
        
        
      </item>
    
      <item>
        <title>París: la capital del flâneur</title>
        <description>&lt;p&gt;&lt;strong&gt;&lt;em&gt;Flâneur&lt;/em&gt;&lt;/strong&gt; significa ‘paseante’ o ‘callejero’. Aquel que vaga por las
calles, sin rumbo ni objetivo, abierto a todas las vicisitudes y las
impresiones que le salen al paso. El término tuvo interés académico en el siglo
XIX como símbolo de la experiencia urbana y la modernidad.&lt;/p&gt;

&lt;p&gt;Yo llegué a este concepto leyendo &lt;em&gt;Antifrágil: Las cosas que se benefician del
desorden&lt;/em&gt;, donde Nassim Taleb extiende la definición a una manera filosófica de
pensar y de vivir:&lt;/p&gt;

&lt;blockquote&gt;
  &lt;p&gt;&lt;em&gt;Flâneur&lt;/em&gt; racional (o simplemente &lt;em&gt;flâneur&lt;/em&gt;): Alguien que, a diferencia de un
turista, toma a cada paso la decisión oportunista de revisar su plan (o su
destino) para impregnarse de nuevos elementos basados en la nueva información
que va obteniendo. En los ámbitos de la investigación y la empresa, ser un
&lt;em&gt;flâneur&lt;/em&gt; equivale a «buscar la opcionalidad». Es una manera no narrativa de
enfocar la vida.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Sin embargo, un detalle al que no había prestado suficiente atención es que la
palabra procede del francés, y no es casualidad que así sea. La idea del
&lt;em&gt;flâneur&lt;/em&gt; surgió en París después de que el barón Haussmann rediseñara la
ciudad. Los sombríos callejones se transformaron en anchos bulevares y plazas
despejadas, se crearon parques y jardines, terminales ferroviarias, sistema de
alcantarillado y alumbrado público, etc.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/assets/images/posts/boulevard-haussmann-antoine-blanchard.png&quot; alt=&quot;Boulevard Haussmann. Antoine Blanchard&quot; /&gt;&lt;/p&gt;

&lt;p&gt;&lt;sup&gt;Le Boulevard, Paris (Boulevard Haussmann). Antoine Blanchard.&lt;/sup&gt;&lt;/p&gt;

&lt;p&gt;El impacto de la transformación de la ciudad fue extraordinario. Leyendo a
algunos autores uno puede empezar a imaginar lo maravilloso que fue aquel
París.&lt;/p&gt;

&lt;blockquote&gt;
  &lt;p&gt;[…] Ah, ¡qué fácil y qué bien se vivía en París, sobre todo si uno era joven! El
solo vagar por las calles ya era un placer y, a la vez, una lección permanente,
porque todo estaba abierto a todos: por ejemplo, se podía entrar en una
librería de viejo y hojear libros durante un cuarto de hora sin que el dueño
refunfuñara y gruñera; se podía entrar en las pequeñas galerías, ver y tocar en
las tiendas de &lt;em&gt;bric-à-brac&lt;/em&gt;, gorrear en las subastas del hotel Drouot y charlar
con las institutrices en los jardines; no era fácil detenerse cuando uno había
empezado a callejear, la calle le atraía a uno como un imán y le mostraba cosas
nuevas sin cesar, como un calidoscopio. Cuando uno se cansaba, se podía sentar
en la terraza de uno de los diez mil cafés y escribir cartas en el papel que le
daban gratis y dejar que los vendedores ambulantes le exhibieran un montón de
objetos absurdos e inútiles. Una sola cosa era difícil: quedarse en casa o
volver a casa, sobre todo cuando estallaba la primavera, la luz resplandecía
plateada y blanda sobre el Sena, los árboles de los bulevares empezaban a
espesarse de verde y las muchachas llevaban, prendidos con agujas, ramilletes
de violetas a un &lt;em&gt;sou&lt;/em&gt; cada uno; pero la verdad es que no hacía falta la
primavera para estar de buen humor en París.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;em&gt;El mundo de ayer: Memorias de un europeo&lt;/em&gt;, Stefan Zweig.&lt;/p&gt;

&lt;hr /&gt;

&lt;blockquote&gt;
  &lt;p&gt;Las nubes, de color de rosa, formaban una franja por encima de los tejados;
empezaban ya a levantar los toldos de algunas tiendas; los carros de riego
derramaban su lluvia sobre el polvo, y una inesperada frescura se mezclaba
con las emanaciones de los cafés, que dejaban ver por sus puertas abiertas,
entre plateados y dorados, flores en canastillos que se dibujaban en los
altos espejos. La gente andaba despacio; había grupos de hombres hablando en
medio de la acera, y pasaban las mujeres con cierta blancura en los ojos y
ese tinte de camelia que da a las carnes femeninas la lasitud de los grandes
calores. Algo enorme se extendía envolviendo las casas. Jamás París le
pareció tan hermoso. En el porvenir únicamente percibía una interminable
serie de años enteramente llenos de amor.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;em&gt;La educación sentimental&lt;/em&gt;, Gustave Flaubert.&lt;/p&gt;

</description>
        <pubDate>Mon, 02 May 2022 00:00:00 +0000</pubDate>
        <link>https://arturoherrero.com/paris-la-capital-del-flaneur/</link>
        <guid isPermaLink="true">https://arturoherrero.com/paris-la-capital-del-flaneur/</guid>
        
        <category>ideas</category>
        
        
      </item>
    
      <item>
        <title>Don Quijote de la Mancha</title>
        <description>&lt;p&gt;«Desocupado lector», al igual que a muchos otros estudiantes, me obligaron a
leer en el colegio &lt;em&gt;Don Quijote de la Mancha&lt;/em&gt; de Miguel de Cervantes. Lectura
que ni comprendí, ni disfruté. Por suerte, muchos años más tarde decidí leerlo
de nuevo. En esta segunda ocasión, escogí la edición puesta al castellano actual
por Andrés Trapiello.  Una auténtica maravilla.&lt;/p&gt;

&lt;p&gt;Pocas cosas fomentan menos la lectura que la obligación de leer. En mi caso,
además, se cumple aquella frase que Nassim Taleb escribía en &lt;em&gt;Antifrágil&lt;/em&gt;:
«lo que me hicieron estudiar ya lo he olvidado, pero aún recuerdo lo que decidí
leer».&lt;/p&gt;

&lt;p&gt;No deja de ser curioso que uno de los personajes más famosos de la historia de
la literatura sea un hombre al que «del poco dormir y del mucho leer, se le secó
el cerebro de tal manera, que acabó perdiendo el juicio».&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/assets/images/posts/don-quixote.jpg&quot; alt=&quot;Don Quijote&quot; /&gt;&lt;/p&gt;

&lt;p&gt;&lt;sup&gt;Don Quijote ilustrado por Gustave Doré.&lt;/sup&gt;&lt;/p&gt;

&lt;p&gt;De entre todos los aspectos que se pueden destacar de esta novela hay dos que
me fascinan: la metaficción y los refranes.&lt;/p&gt;

&lt;h3 id=&quot;1-la-metaficción&quot;&gt;1. La metaficción&lt;/h3&gt;

&lt;p&gt;La metaficción es una forma narrativa donde nosotros como lectores somos
conscientes de estar ante una obra de ficción, y el autor comienza a jugar con
la relación entre la ficción y la realidad.&lt;/p&gt;

&lt;p&gt;Cervantes confronta la realidad y la ficción involucrándonos a nosotros como
lectores: un personaje que enloquece y se cree un héroe y un cuerdo que
sigue al loco; lo que creemos que somos y lo que somos, lo que somos y lo que
los demás admiten que somos.&lt;/p&gt;

&lt;p&gt;Al final, la realidad y la ficción quedan difuminadas en un juego
caleidoscópico: referencias a la novela dentro de la novela, personajes que han
conocido a Cervantes, el Quijote “real” y el Quijote de Avellaneda. ¿Qué es
real y qué soñado?&lt;/p&gt;

&lt;h3 id=&quot;2-los-refranes&quot;&gt;2. Los refranes&lt;/h3&gt;

&lt;p&gt;Cervantes tuvo una vida agitada: soldado, prisionero, escritor, recaudador de
impuestos, etc. La calle como escuela de vida. Un maestro en artimañas, trucos
y engaños.&lt;/p&gt;

&lt;p&gt;Aún conociendo su biografía y vivencias, resulta increíble la cantidad de rimas,
dichos, chascarrillos y refranes que fue capaz de recoger en el Quijote. Algunos
pasajes son sencillamente excepcionales:&lt;/p&gt;

&lt;blockquote&gt;
  &lt;p&gt;[…] Pero ¡quita!, que es ella muy buena moza y hay pastores más maliciosos
que simples, y no querría que fuese por lana y volviese trasquilada; y los
amores y los no buenos deseos suelen andar lo mismo por los campos que por las
ciudades, por las chozas pastoriles y por los palacios reales, y quitada la
causa, se quita el pecado, y ojos que no ven, corazón que no siente, y más vale
quitarse de en medio que andar razonando.&lt;/p&gt;

  &lt;p&gt;—No más refranes, Sancho, pues cualquiera de los que has dicho basta para dar a
entender tu pensamiento; y muchas veces te he aconsejado que no seas tan
pródigo en refranes, y que te sujetes, pero me parece que es predicar en el
desierto, y ríñeme mi madre, por un oído me entra y por otro me sale.&lt;/p&gt;

  &lt;p&gt;—Me parece que vuesa merced es como aquello de: Dijo la sartén a la caldera:
quítate allá, ojinegra. Me está reprendiendo que no diga yo refranes, y los
ensarta vuesa merced de dos en dos.&lt;/p&gt;

  &lt;p&gt;—Mira, Sancho: yo traigo los refranes a propósito, y cuando los digo vienen
como anillo al dedo, pero tú los traes tan por los cabellos, que los arrastras,
y no los guías; y si no me acuerdo mal, te dije ya otra vez que los refranes
son sentencias breves, sacadas de la experiencia y especulación de nuestros
antiguos sabios, y el refrán que no viene a propósito es antes disparate que
sentencia.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;hr /&gt;

&lt;p&gt;Por último, me despido de ti, lector, igual que lo hacía Cervantes en el prólogo
de la novela: «Y con esto Dios te dé salud y a mí no me olvide. Vale».&lt;/p&gt;

</description>
        <pubDate>Sun, 13 Mar 2022 00:00:00 +0000</pubDate>
        <link>https://arturoherrero.com/don-quijote-de-la-mancha/</link>
        <guid isPermaLink="true">https://arturoherrero.com/don-quijote-de-la-mancha/</guid>
        
        <category>reading</category>
        
        
      </item>
    
      <item>
        <title>Viajar o «ser viajado»</title>
        <description>&lt;p&gt;He viajado de muchas formas, desde mochilero con un pase de Interrail
hasta siendo arrastrado a autocares con paradas programadas. Viajes de un día
o de varias semanas. Con planificación o sin ninguna en absoluto.&lt;/p&gt;

&lt;p&gt;Siempre asumí que viajar era ver cosas—cuantas más mejor—, quizás
aprender algo nuevo y regresar a casa con las fotografías pertinentes. Fotos a
las que rara vez he regresado. Odias a los turistas, pero te comportas como tal.&lt;/p&gt;

&lt;p&gt;Sin embargo, poco a poco me he ido alejando de esa necesidad de ver y
fotografiarlo todo. Antes podía fácilmente peinar una galería de arte de punta
a punta, pero ahora sólo me interesa detenerme en unas pocas obras. Viajar para
descubrir poco, pero que ese poco se quede conmigo para siempre.&lt;/p&gt;

&lt;p&gt;Una de las mejores definiciones entre un turista y un viajero la encontré
leyendo &lt;em&gt;Orient-Express: El tren de Europa&lt;/em&gt; de Mauricio Wiesenthal, quien
recorrió París con una guía de viajes &lt;em&gt;Baedeker&lt;/em&gt; de 1902, buscando «los
rincones dorados de la Belle Époque».&lt;/p&gt;

&lt;blockquote&gt;
  &lt;p&gt;El &lt;em&gt;Baedeker&lt;/em&gt; estaba escrito para gente mucho más delicada que los turistas de
ahora. No sé por qué hoy se editan tantas guías que presuponen que la gente
se mueve sólo entre cemento, haciendo colas en los museos y puntuando los
restaurantes como si fuesen a ser subastados. No creo que pueda considerarse
sabroso ni saludable nada que sea puntuable. Tampoco comprendo por qué, si
hay tanto aficionado al arte, no se visitan las bibliotecas para conocer a
los clásicos de la cultura o se compran más libros en las librerías para
regresar con un buen botín a casa, dándonos la oportunidad y el placer de
practicar los idiomas de los países que visitamos.&lt;/p&gt;

  &lt;p&gt;Se viajaba entonces mejor, prestando atención a las sagradas escrituras de la
historia, a las reliquias de la cultura, a los encantamientos del buen gusto,
a las fuentes y a las aguas termales, a los senderos de montaña y a la
vegetación. Y se daba importancia a los nombres de las maderas, a las flores,
y a las hierbas que crecen en las ruinas y perfuman los jardines abandonados,
donde hay niños que juegan a ínsulas extrañas.&lt;/p&gt;

  &lt;p&gt;[…]&lt;/p&gt;

  &lt;p&gt;No sé cuántas horas he dejado persiguiendo direcciones en las páginas sedosas
de mis &lt;em&gt;Baedeker&lt;/em&gt;, editadas con diminuta letra. A menudo la búsqueda de un
viejo café me llevaba a un billar sórdido, que era lo único que quedaba de su
leyenda. Los espejos y veladores se habían convertido en enormes mesas de
paños verdes donde entrechocaban las bolas con un chasquido de marfil. Pero
en la penumbra de humo se distinguía un perchero apolillado en el que Balzac
había dejado olvidado un abrigo. Mis &lt;em&gt;Baedeker&lt;/em&gt; me llevaban siempre al tiempo
de los pianos negros y de los terciopelos violetas. A veces había sombreros
viejos que nadie había reclamado desde que un escritor sin suerte se marchara
de una novela que nadie quiso editarle. Y, siguiendo la dirección de una
confitería famosa, donde me prometía degustar la mejor &lt;em&gt;Sachertorte&lt;/em&gt; de Viena,
me encontraba con una tienda de &lt;em&gt;turkish delight&lt;/em&gt;. Pero nunca me importaron
esos extravíos y rodeos, porque disfruto sentándome en un café de
Montparnasse y leyendo, en una guía de París de 1902, que «los carruajes con
cocheros de sombrero blanco son generalmente mejores. Tienen las ruedas
cubiertas de caucho, y se les reconoce por las campanillas que llevan los
caballos en el cuello».&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Otra joya literaria que aborda el creciente turismo de masas es un artículo de
Stefan Zweig escrito en 1926 bajo el título &lt;em&gt;Viajar o «ser viajado»&lt;/em&gt;, que viene
incluido en &lt;em&gt;La eternidad de un día: Clásicos del periodismo alemán (1823-1934)&lt;/em&gt;
de Francisco Uzcanga Meinecke.&lt;/p&gt;

&lt;blockquote&gt;
  &lt;p&gt;Me apasionan los puertos y las estaciones. Me puedo quedar horas y horas parado
delante de ellos, contemplando cómo una nueva e impetuosa ola de personas y
mercancías se abalanza sobre la que acaba de romper; disfruto con los
enigmáticos signos que marcan la hora y el destino, con los gritos y ruidos,
confusos y broncos, que se entremezclan en sonidos reveladores. Cada estación
es única, cada una de ellas arrastra una lejanía diferente, cada puerto y cada
barco trae un flete distinto. Representan el mundo en nuestras ciudades, la
diversidad en nuestro día a día.&lt;/p&gt;

  &lt;p&gt;Pero he descubierto un nuevo tipo de estaciones, en París por primera vez:
están en medio de la calle, sin cochera ni cubierta, carecen de distintivos y
sufren sin embargo el mismo flujo incesante. Son las sedes de las grandes
compañías de autocares, que tal vez suplanten algún día al vagón de tren; con
ellas se instaura una nueva forma de viajar, el viaje en masa, el viaje por
contrato, lo que yo llamo el «ser viajado». Las nueve: el primer tropel baja
del bulevar, cuarenta, cincuenta pasajeros, la mayoría norteamericanos e
ingleses, un guía con gorra de colores los carga en el vehículo, los van a
llevar a Versalles, a los castillos del Loira, al Mont Saint-Michel, a la
Provenza incluso. Una organización matemática les ha planificado y preparado
todo el viaje: ellos no necesitan buscar nada ni hacer números. El motor
arranca, pone rumbo a una ciudad desconocida, allí les espera el almuerzo
(incluido en el precio) y, por la noche, la cama; las atracciones turísticas y
los museos están abiertos de par en par a su llegada, no hace falta llamar al
portero ni dar propina alguna. La duración de las visitas está programada con
antelación, la calle escogida según experiencias anteriores. ¡Qué cómodo es
todo esto! No hay que ocuparse del dinero, ni prepararse, ni leer libros, ni
informarse sobre alojamientos—detrás de los viajados (no digo viajeros) espera
el guarda con la gorra de colores (y es que sin duda es una especie de guarda o
vigilante) y les aclara de forma mecánica cualquier contingencia—. No hay que
hacer nada, basta con ir a una agencia de viajes, seleccionar un destino, pagar
el importe—es como suscribir por quince días un título de viaje de renta fija,
y ya rueda el equipaje por delante, laboriosos duendecillos preparan mesa y
cama en un entorno nunca visto—, y así, sin mover un dedo, viajan hoy en día
cientos de miles de turistas desde Inglaterra, desde Norteamérica, hasta aquí.
O, más bien, los llevan de viaje.&lt;/p&gt;

  &lt;p&gt;He intentado ponerme por una vez en la situación de esta riada humana; es
innegable que ofrece muchas comodidades. Todos los sentidos quedan libres para
observar y disfrutar: se evita el estorbo de tener que ocuparse de cuestiones
liliputienses, pero a la vez imprescindibles, como buscar alojamiento y
reservar en un restaurante; tampoco hace falta consultar el horario de los
trenes, no acaba uno vagando por callejuelas equivocadas, no se es víctima de
engaños y estafas, no hay que chapurrear una lengua extranjera; todos los
sentidos se concentran exclusivamente en absorber la novedad. Y esta novedad ha
sido además tamizada a lo largo de muchas décadas de experiencia; en estos
viajes organizados tan sólo se visita lo realmente importante; no les falta
compañía a quienes necesitan compartir el placer para disfrutarlo de verdad.
Además, es algo barato, práctico y, sobre todo, cómodo, de ahí que
probablemente sea la fórmula del futuro. No se viajará más, lo viajarán a uno.&lt;/p&gt;

  &lt;p&gt;Ahora bien: ¿no se pierde con este agrupamiento arbitrario precisamente lo más
fascinante del viaje? La misma palabra &lt;em&gt;viaje&lt;/em&gt; viene envuelta, ya desde tiempos
remotos, por un aroma de aventura y peligro, por un hálito de azar veleidoso y
de seductora incertidumbre. Cuando viajamos, no lo hacemos sólo para buscar la
lejanía sino también para abandonar lo propio, el mundo doméstico cotidiano y
metódico, para disfrutar del no estar en casa y, por ello también, del no ser
uno mismo. Deseamos interrumpir el simple ir viviendo  por medio de vivencias.
Pero aquellos que prefieren que los lleven de viaje sólo llegan a conocer lo
novedoso de forma superficial, sin penetrar en su interior; se pierden
irremediablemente todo lo peculiar y propio de un país al dejar que sus pasos
sean conducidos por un guía y no por el verdadero dios del viajero: el azar.
Estos ingleses y norteamericanos que se desplazan en autocares no salen en
realidad de Inglaterra ni de Norteamérica, no oyen la lengua extranjera, no
perciben (por falta de contacto) la singularidad, las costumbres del lugar. Ven
lo que merece ser visto, cierto, pero en veinte descargas diarias; todos juntos
presencia idénticas atracciones turísticas, todos tienen exactamente las mismas
vivencias y en mayor medida, si cabe, al venir las explicaciones de la misma
persona. Y nadie las vive a fondo, porque se acercan a los valores y a los
mundos seleccionados en compañía, conversando y charlando, sin contemplar nunca
a solas lo novedoso, sin absorber con devoción y en solitario las maravillas
que se les ofrecen; lo que se lleva cada uno de vuelta no es sino el simple
orgullo de haber tenido ante sus ojos esta iglesia o aquel cuadro (más una
gesta deportiva que el sentimiento propio de un aprendizaje interior y de un
enriquecimiento cultural).&lt;/p&gt;

  &lt;p&gt;De ahí que sea mejor lo incómodo, lo molesto, lo desagradable incluso: forma
parte de todo verdadero viaje, porque siempre hay un contrasentido entre lo
confortable, lo que se ha conseguido sin esfuerzo, y lo que se ha
experimentado de verdad. Todo lo esencial en la vida, todo lo que
consideramos provechoso, nace del esfuerzo y de la superación, todo lo que
aumenta de verdad nuestra capacidad de entender el mundo tiene que partir de
alguna forma de lo más íntimo de uno mismo. La mecánica cada vez más refinada
del viaje se me antoja por ello más un peligro que una ventaja para quien no
se conforma con acercarse a lo extraño de modo tangencial, sino que prefiere
alimentar su espíritu con imágenes vivas e intensas de los nuevos paisajes.
Allí donde no descubrimos algo o, por lo menos, suponemos descubrirlo, allí
donde no sentimos una energía o una atracción oculta que nos conduce a nuevos
hallazgos, el disfrute adolece de esa misteriosa tensión, de ese extraño
vínculo entre lo nunca visto y nuestra mirada pasmada, y cuanto más reacios
seamos a experimentar cómodamente las vivencias y, en vez de ello, optemos por
aventurarnos en su busca, con tanta mayor intensidad se acabarán grabando en
nuestro interior. Los funiculares son maravillosos: en una hora nos suben a
las más grandiosas cumbres, descansados y con toda comodidad podemos
disfrutar de la panorámica que se extiende a nuestros pies. Pero en este
traslado pasivo y mecánico se echa de menos un estímulo anímico, un orgullo
singular y turbador: el sentimiento de conquista. Y de este sentimiento,
ciertamente peculiar y privativo de las auténticas vivencias, adolecen todos
aquellos que «son viajados» en vez de viajar ellos mismos, aquellos que en
algún mostrador pagan con la cartera el precio de un trayecto, pero no abonan
el otro precio, el más caro, el más valioso, y que se paga con la voluntad
interior, con el ánimo inquieto. Curiosamente es esta última inversión la que
se recupera a posteriori con mayor margen de ganancia. Porque sólo las
impresiones que se adquieren tras sufrir molestias, incomodidades y
equivocaciones, permanecen luego en la memoria de forma duradera e intensa,
nada se recuerda con más agrado que los pequeños contratiempos, las
penalidades, los descuidos y los extravíos de un viaje, de igual modo que, ya
en la edad madura, uno se regocija sobre todo con las boberías más pueriles
de su juventud. Que nuestra vida diaria sea cada vez más mecánica, que
circule por los pulidos raíles de un siglo tecnificado, es algo que no
podemos evitar, y tampoco queremos hacerlo, ya que así nos ahorramos muchos
esfuerzos. Pero el viaje debe seguir siendo derroche, sumisión del orden al
azar y de lo cotidiano a lo excepcional, debe seguir siendo la expresión más
personal y auténtica de nuestras inclinaciones; de ahí que tengamos que
protegerlo frente a la nueva, burocrática y mecánica forma de turismo masivo
e industrializado.&lt;/p&gt;

  &lt;p&gt;Salvemos este pequeño reducto aventurero de nuestra vida en exceso ordenada, no
nos dejemos transportar como si fuéramos fletes de agencias utilitarias,
sigamos viajando al modo de nuestros antepasados, según nuestra voluntad y
eligiendo los destinos: sólo así se convertirá cada uno de nuestros viajes en
un descubrimiento no sólo del mundo exterior sino de nuestro propio mundo
interior.&lt;/p&gt;
&lt;/blockquote&gt;
</description>
        <pubDate>Wed, 23 Feb 2022 00:00:00 +0000</pubDate>
        <link>https://arturoherrero.com/viajar-o-ser-viajado/</link>
        <guid isPermaLink="true">https://arturoherrero.com/viajar-o-ser-viajado/</guid>
        
        <category>ideas</category>
        
        
      </item>
    
      <item>
        <title>Success</title>
        <description>&lt;p&gt;Success:&lt;/p&gt;
&lt;ol&gt;
  &lt;li&gt;the achieving of the results wanted or hoped for.&lt;/li&gt;
  &lt;li&gt;something that achieves positive results.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;“Success” is a word that should always be in quotation marks as its definition
varies from person to person. Let everyone define what it means to them in life.
I personally like the following definitions.&lt;/p&gt;

&lt;blockquote&gt;
  &lt;p&gt;When I was 17, I read a quote that went something like: “If you live each day
as if it was your last, someday you’ll most certainly be right.” It made an
impression on me, and since then, for the past 33 years, I have looked in the
mirror every morning and asked myself: “If today were the last day of my life,
would I want to do what I am about to do today?” And whenever the answer has
been “No” for too many days in a row, I know I need to change something.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;—&lt;a href=&quot;https://youtu.be/UF8uR6Z6KLc&quot; target=&quot;_blank&quot; rel=&quot;noreferrer&quot;&gt;Commencement Address 2005 Stanford University&lt;/a&gt;, Steve Jobs.&lt;/p&gt;

&lt;hr /&gt;

&lt;blockquote&gt;
  &lt;p&gt;For I have a single definition of success: you look in the mirror every
evening, and wonder if you disappoint the person you were at 18, right before
the age when people start getting corrupted by life. Let him or her be the only
judge; not your reputation, not your wealth, not your standing in the
community, not the decorations on your lapel. If you do not feel ashamed, you
are successful. All other definitions of success are modern constructions;
fragile modern constructions.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;—&lt;a href=&quot;https://youtu.be/Fzmr3urk28I&quot; target=&quot;_blank&quot; rel=&quot;noreferrer&quot;&gt;Commencement Address 2016 American University of Beirut&lt;/a&gt;, Nassim Taleb.&lt;/p&gt;

&lt;hr /&gt;

&lt;blockquote&gt;
  &lt;p&gt;To laugh often and much;&lt;br /&gt;
To win the respect of intelligent people and the affection of children;&lt;br /&gt;
To earn the appreciation of honest critics and endure the betrayal of false friends;&lt;br /&gt;
To appreciate beauty;&lt;br /&gt;
To find the best in others;&lt;br /&gt;
To leave the world a bit better, whether by a healthy child,&lt;br /&gt;
a garden patch, or a redeemed social condition;&lt;br /&gt;
To know even one life has breathed easier because you have lived.&lt;br /&gt;
This is to have succeeded.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;—Attributed to Ralph Waldo Emerson, actually by Bessie A. Stanley.&lt;/p&gt;

&lt;hr /&gt;

&lt;blockquote&gt;
  &lt;p&gt;There are no secrets to success: don’t waste time looking for them. Success is
the result of perfection, hard work, learning from failure, loyalty to those for
whom you work, and persistence.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;—Colin Powell.&lt;/p&gt;

&lt;hr /&gt;

&lt;blockquote&gt;
  &lt;p&gt;Success is neither magical nor mysterious. Success is the natural consequence
of consistently applying the basic fundamentals.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;—Jim Rohn.&lt;/p&gt;

</description>
        <pubDate>Sun, 30 Jan 2022 00:00:00 +0000</pubDate>
        <link>https://arturoherrero.com/success/</link>
        <guid isPermaLink="true">https://arturoherrero.com/success/</guid>
        
        <category>quotes</category>
        
        
      </item>
    
      <item>
        <title>Decisive moments in history of computing</title>
        <description>&lt;p&gt;I’ve read &lt;em&gt;The story of computing: From the Abacus to Artificial Intelligence&lt;/em&gt;
by—Alan Turing’s nephew—Dermot Turing. Exploring the history of computing was
very stimulating, but how wonderful it would be if a great writer could capture
these stories. Something similar to &lt;a href=&quot;https://en.wikipedia.org/wiki/Decisive_Moments_in_History&quot; target=&quot;_blank&quot; rel=&quot;noreferrer&quot;&gt;&lt;em&gt;Decisive Moments in History&lt;/em&gt;&lt;/a&gt;
by Stefan Zweig.&lt;/p&gt;

&lt;p&gt;The following are the possible chapter titles—cryptically evocative—of &lt;em&gt;Decisive
Moments in Computer History: Twenty-three historical miniatures&lt;/em&gt;:&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;The use of the abacus at the Hanging Gardens of Babylon.&lt;/li&gt;
  &lt;li&gt;Charles Babbage’s difference engine and Analytical Engine.&lt;/li&gt;
  &lt;li&gt;1890 U.S. census: punched cards &amp;amp; tabulating machine.&lt;/li&gt;
  &lt;li&gt;On computable numbers, Enigma codes, and Turing tests.&lt;/li&gt;
  &lt;li&gt;Truth is binary. Shannon’s information theory.&lt;/li&gt;
  &lt;li&gt;ENIAC, EDVAC, and the von Neumann architecture.&lt;/li&gt;
  &lt;li&gt;Grace Hopper, from bugs to compilers.&lt;/li&gt;
  &lt;li&gt;Silicon Valley and the Intel Trinity.&lt;/li&gt;
  &lt;li&gt;IBM: Thinking inside the box.&lt;/li&gt;
  &lt;li&gt;NASA’s Apollo program.&lt;/li&gt;
  &lt;li&gt;The Mother of All Demos and the magic from Xerox PARC.&lt;/li&gt;
  &lt;li&gt;UNIX: Ken typed | Dennis defined.&lt;/li&gt;
  &lt;li&gt;ARPANET and the first-ever email.&lt;/li&gt;
  &lt;li&gt;Atari, Sinclair, and Commodore.&lt;/li&gt;
  &lt;li&gt;Windows, apples, and spreadsheets.&lt;/li&gt;
  &lt;li&gt;Just a hobby, won’t be big and professional…&lt;/li&gt;
  &lt;li&gt;The World Wide Web and the WorldWideWeb.&lt;/li&gt;
  &lt;li&gt;Googol.&lt;/li&gt;
  &lt;li&gt;An iPod, a phone, and an Internet communicator.&lt;/li&gt;
  &lt;li&gt;DeepBlue, AlphaGo, and AI.&lt;/li&gt;
  &lt;li&gt;Bitcoin: A Peer-to-Peer Electronic Cash System.&lt;/li&gt;
  &lt;li&gt;Chat Generative Pre-trained Transformer.&lt;/li&gt;
  &lt;li&gt;Autonomous pilots and machines.&lt;/li&gt;
&lt;/ol&gt;

</description>
        <pubDate>Wed, 08 Dec 2021 00:00:00 +0000</pubDate>
        <link>https://arturoherrero.com/decisive-moments-in-history-of-computing/</link>
        <guid isPermaLink="true">https://arturoherrero.com/decisive-moments-in-history-of-computing/</guid>
        
        <category>programming</category>
        
        
      </item>
    
      <item>
        <title>Cómo hacer filosofía en casa</title>
        <description>&lt;p class=&quot;side-image-border&quot;&gt;&lt;img src=&quot;/assets/images/notes/como-viajar-con-un-salmon.jpg&quot; alt=&quot;Cómo viajar con un salmón&quot; /&gt;&lt;/p&gt;

&lt;blockquote&gt;
  &lt;p&gt;Será que la gente ya no soporta la televisión basura, será que en el mundo
suceden tantas cosas malas que se siente la necesidad de algunos momentos de
reflexión sosegada, pero el caso es que se están multiplicando los lugares y
las ocasiones en que la filosofía se ofrece como propuesta al gran público. La
del bachillerato, concretamente. Puede llevarse a cabo en un café donde
reunirse los domingos, como en París; o mediante vulgarizaciones de fácil
lectura; otras veces, convocando a un público enormemente vasto en salas donde
los filósofos profesionales discuten. En todo ello está presente la moda y la
simplificación mediática, desde luego, pero no hay que pasar por alto este
síntoma. Así pues, se me ocurre proponer algunas sugerencias para los no
especialistas, incluso para aquellos que no estudiaron filosofía en el
bachillerato, o para aquellos que fueron a algún sitio a oír hablar a los
presuntos filósofos y no entendieron nada. A todos ellos les aconsejo el camino
más sencillo: leer lo que han escrito los verdaderos filósofos.&lt;/p&gt;

  &lt;p&gt;La filosofía no siempre debe presentarse como algo fácil, a veces tiene que
ser difícil, pero no está dicho en ningún lado que para filosofar haya que
hablar difícil. En filosofía, la dificultad del lenguaje no es señal ni de
calidad ni de perversidad, a menudo depende del problema que se encara. Hay
obras maestras de la filosofía que han cambiado nuestra forma de ser y de
pensar, y que son inevitablemente difíciles, así que no invitaré a nadie que
no sea un especialista a leerse la &lt;em&gt;Metafísica&lt;/em&gt; o el &lt;em&gt;Órganon&lt;/em&gt; de
Aristóteles, la &lt;em&gt;Crítica de la razón pura&lt;/em&gt; o ese libro sublime pero abstruso
que es la &lt;em&gt;Ética&lt;/em&gt; de Spinoza.  Claro que también hay filósofos que han sabido
hablar de manera accesible; y a menudo son los mismos que en otras obras han
hablado de forma inaccesible. Así pues, me limitaré a aconsejar unos cuantos
libritos (cada uno tendrá, de promedio, un centenar de páginas) en los que se
aprecia que es posible filosofar sin usar demasiados términos técnicos.&lt;/p&gt;

  &lt;p&gt;Empecemos por Platón. Yo propondría el &lt;em&gt;Critón&lt;/em&gt;, donde se aprende cómo y por
qué un ciudadano no debe escapar de la observancia de las leyes (llámese
Sócrates o Silvio) y, pasando a Aristóteles, la &lt;em&gt;Poética&lt;/em&gt;. Olvidad que habla
de la tragedia clásica. Leedlo como si nos describiera cómo se hace una
novela negra o una película del Oeste. Nuestro hombre ya entendió todo eso
que más de dos mil años después entenderían Hitchcock o John Ford. A
continuación, leed el &lt;em&gt;De magistro&lt;/em&gt; de san Agustín: habla de cómo se le habla
a un hijo de temas de todos los días. Un librito genial por su sencillez y
agudeza.&lt;/p&gt;

  &lt;p&gt;Aun siendo como soy un amante de la Edad Media, me resulta difícil aconsejar
un texto de la gran época escolástica, porque unas pocas páginas, leídas
fuera de su contexto sistemático, pueden confundirnos. Saltemos el foso, el
estrictamente filosófico, y orientemos a nuestro lector hacia el epistolario
(amoroso, en efecto) de Abelardo y Eloísa. No esperéis demasiado sexo, pero
vale la pena.&lt;/p&gt;

  &lt;p&gt;Para el Renacimiento, podemos probar con la &lt;em&gt;Oración acerca de la dignidad
del hombre&lt;/em&gt; de Pico della Mirandola. Y luego (pero solo en forma de
antología, que las hay) algún pasaje de los &lt;em&gt;Ensayos&lt;/em&gt; de Montaigne. Sienta
bien en dosis homeopáticas. Inmediatamente después, el &lt;em&gt;Discurso del método&lt;/em&gt;
de Descartes, ejemplar por su claridad, y a continuación una antología de los
pensamientos de Pascal. Y, por último, un filósofo que escribía como si
estuviera hablando después de cenar con sus amigos, culto y sensato, el John
Locke del &lt;em&gt;Ensayo sobre el entendimiento humano&lt;/em&gt;. La obra entera se hace
larga, pero yo diría que podemos limitarnos al tercer libro, el que está
dedicado al uso que hacemos de las palabras. Igual que en el caso de
Aristóteles, leedlo como si Locke nos hablara de los discursos de hoy,
comparad sus observaciones con las primeras planas de los periódicos y con
los debates televisivos de nuestros días.&lt;/p&gt;

  &lt;p&gt;Para la Ilustración, me limitaría por ahora al &lt;em&gt;Cándido&lt;/em&gt; de Voltaire; al fin
y al cabo, se trata de una novelita, y muy agradable. El siglo XIX es un mal
bicho, se trata de libracos difíciles, aunque solo nosotros, los italianos,
no consideramos el &lt;em&gt;Zibaldone&lt;/em&gt; de Leopardi una obra de alta filosofía.
Recientemente, en Francia, lo han recuperado con inmenso respeto. Aquí
también avanzaremos mediante antológicos, una paginita o dos por la noche
antes de dormirnos. O bien puedo haceros una propuesta provocadora.  Visto
que Kant es por definición demasiado exigente, salgámosle al encuentro allá
donde, para redondear su sueldo, daba clases a los estudiantes sobre temas en
los que no estaba especializado, y se mostraba gracioso, extravagante, capaz
de contar anécdotas y de expresar opiniones incluso paradójicas: es decir,
leamos sus &lt;em&gt;Lecciones de antropología&lt;/em&gt;. Puede que el título infunda respeto,
pero el texto es digno de aparecer en un semanario de gran prestigio.&lt;/p&gt;

  &lt;p&gt;¿Y luego? Pues luego, como el espacio de esta columna se ha acabado, tendré
que dejar de lado a los contemporáneos. A no ser que queráis saborear,
saltando de aquí para allá, algunas de las observaciones de Wittgenstein en
sus (no dejéis que el título os asuste) &lt;em&gt;Investigaciones filosóficas&lt;/em&gt;. De vez
en cuando diréis que estaba loco. Sí, estaba loco. Pero menudo loco.&lt;/p&gt;

  &lt;p&gt;(2004)&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;em&gt;Cómo viajar con un salmón&lt;/em&gt;, Umberto Eco.&lt;/p&gt;

</description>
        <pubDate>Sun, 10 Oct 2021 00:00:00 +0000</pubDate>
        <link>https://arturoherrero.com/como-hacer-filosofia-en-casa/</link>
        <guid isPermaLink="true">https://arturoherrero.com/como-hacer-filosofia-en-casa/</guid>
        
        <category>reading</category>
        
        
      </item>
    
      <item>
        <title>Las virtudes burguesas</title>
        <description>&lt;p class=&quot;side-image&quot;&gt;&lt;img src=&quot;/assets/images/notes/las-virtudes-burguesas.jpg&quot; alt=&quot;Las virtudes burguesas&quot; /&gt;&lt;/p&gt;

&lt;blockquote&gt;
  &lt;p&gt;[…] El sistema combina de manera un tanto improvisada las virtudes «paganas»
apropiadas para un ciudadano libre de Atenas (Valentía, Templanza, Justicia y
Prudencia) y las virtudes «cristianas» apropiadas para un creyente de Nuestro
Señor y Salvador (Fe, Esperanza y Amor).&lt;/p&gt;

  &lt;p&gt;Improvisadas o no, defenderé que las siete cubren lo que necesitamos para
prosperar como seres humanos. Lo mismo valdría en el caso de otros sistemas
éticos —por ejemplo, el confucianismo, el judaísmo talmúdico o el chamanismo
de los indios de América del Norte—, los que ocupan un sitio, por analogía,
al lado de las siete virtudes. Existen muchas maneras de ser humano. Sin
embargo, resulta natural comenzar, y para nuestros fines aquí sobre todo
terminar, con estas siete virtudes, pues son ellas las que dan forma a la
tradición ética de Occidente, ahí donde la vida burguesa adquirió
preponderancia por primera vez.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;table&gt;
  &lt;thead&gt;
    &lt;tr&gt;
      &lt;th style=&quot;text-align: left&quot;&gt;Aristócrata&lt;br /&gt;Patricio&lt;/th&gt;
      &lt;th style=&quot;text-align: left&quot;&gt;Labriego&lt;br /&gt;Plebeyo&lt;/th&gt;
      &lt;th style=&quot;text-align: left&quot;&gt;Burgués&lt;br /&gt;Mercantil&lt;/th&gt;
      &lt;th style=&quot;text-align: left&quot;&gt;Sacerdote&lt;br /&gt;Artístico/Intelectual&lt;/th&gt;
    &lt;/tr&gt;
  &lt;/thead&gt;
  &lt;tbody&gt;
    &lt;tr&gt;
      &lt;td style=&quot;text-align: left&quot;&gt;heróe&lt;/td&gt;
      &lt;td style=&quot;text-align: left&quot;&gt;labriego/santo&lt;/td&gt;
      &lt;td style=&quot;text-align: left&quot;&gt;comerciante&lt;/td&gt;
      &lt;td style=&quot;text-align: left&quot;&gt;sacerdote&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td style=&quot;text-align: left&quot;&gt;pagano&lt;/td&gt;
      &lt;td style=&quot;text-align: left&quot;&gt;creyente&lt;/td&gt;
      &lt;td style=&quot;text-align: left&quot;&gt;secular/mundano&lt;/td&gt;
      &lt;td style=&quot;text-align: left&quot;&gt;monástico&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td style=&quot;text-align: left&quot;&gt;Odiseo&lt;/td&gt;
      &lt;td style=&quot;text-align: left&quot;&gt;Jesús&lt;/td&gt;
      &lt;td style=&quot;text-align: left&quot;&gt;Benjamin Franklin&lt;/td&gt;
      &lt;td style=&quot;text-align: left&quot;&gt;Picasso/Bertrand Rusell&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td style=&quot;text-align: left&quot;&gt;orgullo de ser&lt;/td&gt;
      &lt;td style=&quot;text-align: left&quot;&gt;orgullo de senvir&lt;/td&gt;
      &lt;td style=&quot;text-align: left&quot;&gt;orgullo de lograr&lt;/td&gt;
      &lt;td style=&quot;text-align: left&quot;&gt;orgullo de crear&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td style=&quot;text-align: left&quot;&gt;gesto&lt;/td&gt;
      &lt;td style=&quot;text-align: left&quot;&gt;acción&lt;/td&gt;
      &lt;td style=&quot;text-align: left&quot;&gt;acuerdo&lt;/td&gt;
      &lt;td style=&quot;text-align: left&quot;&gt;ritual&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td style=&quot;text-align: left&quot;&gt;honor&lt;/td&gt;
      &lt;td style=&quot;text-align: left&quot;&gt;deber&lt;/td&gt;
      &lt;td style=&quot;text-align: left&quot;&gt;confiabilidad&lt;/td&gt;
      &lt;td style=&quot;text-align: left&quot;&gt;integridad&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td style=&quot;text-align: left&quot;&gt;franqueza&lt;/td&gt;
      &lt;td style=&quot;text-align: left&quot;&gt;candor&lt;/td&gt;
      &lt;td style=&quot;text-align: left&quot;&gt;honestidad&lt;/td&gt;
      &lt;td style=&quot;text-align: left&quot;&gt;precisión&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td style=&quot;text-align: left&quot;&gt;lealtad&lt;/td&gt;
      &lt;td style=&quot;text-align: left&quot;&gt;fe&lt;/td&gt;
      &lt;td style=&quot;text-align: left&quot;&gt;sociabilidad&lt;/td&gt;
      &lt;td style=&quot;text-align: left&quot;&gt;profesionalismo&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td style=&quot;text-align: left&quot;&gt;valentía&lt;/td&gt;
      &lt;td style=&quot;text-align: left&quot;&gt;fortitud&lt;/td&gt;
      &lt;td style=&quot;text-align: left&quot;&gt;iniciativa&lt;/td&gt;
      &lt;td style=&quot;text-align: left&quot;&gt;imaginación&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td style=&quot;text-align: left&quot;&gt;resignación&lt;/td&gt;
      &lt;td style=&quot;text-align: left&quot;&gt;esperanza&lt;/td&gt;
      &lt;td style=&quot;text-align: left&quot;&gt;previsión&lt;/td&gt;
      &lt;td style=&quot;text-align: left&quot;&gt;ambición&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td style=&quot;text-align: left&quot;&gt;elocuencia&lt;/td&gt;
      &lt;td style=&quot;text-align: left&quot;&gt;jocosidad&lt;/td&gt;
      &lt;td style=&quot;text-align: left&quot;&gt;humor&lt;/td&gt;
      &lt;td style=&quot;text-align: left&quot;&gt;ironía&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td style=&quot;text-align: left&quot;&gt;cortesía&lt;/td&gt;
      &lt;td style=&quot;text-align: left&quot;&gt;reverencia&lt;/td&gt;
      &lt;td style=&quot;text-align: left&quot;&gt;respeto&lt;/td&gt;
      &lt;td style=&quot;text-align: left&quot;&gt;aprecio&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td style=&quot;text-align: left&quot;&gt;decoro&lt;/td&gt;
      &lt;td style=&quot;text-align: left&quot;&gt;humildad&lt;/td&gt;
      &lt;td style=&quot;text-align: left&quot;&gt;modestia&lt;/td&gt;
      &lt;td style=&quot;text-align: left&quot;&gt;autocrítica&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td style=&quot;text-align: left&quot;&gt;magnanimidad&lt;/td&gt;
      &lt;td style=&quot;text-align: left&quot;&gt;benevolencia&lt;/td&gt;
      &lt;td style=&quot;text-align: left&quot;&gt;consideración&lt;/td&gt;
      &lt;td style=&quot;text-align: left&quot;&gt;simpatía&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td style=&quot;text-align: left&quot;&gt;justicia&lt;/td&gt;
      &lt;td style=&quot;text-align: left&quot;&gt;imparcialidad&lt;/td&gt;
      &lt;td style=&quot;text-align: left&quot;&gt;responsabilidad&lt;/td&gt;
      &lt;td style=&quot;text-align: left&quot;&gt;precisión&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td style=&quot;text-align: left&quot;&gt;previsión&lt;/td&gt;
      &lt;td style=&quot;text-align: left&quot;&gt;sabiduría tradicional&lt;/td&gt;
      &lt;td style=&quot;text-align: left&quot;&gt;prudencia&lt;/td&gt;
      &lt;td style=&quot;text-align: left&quot;&gt;visión&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td style=&quot;text-align: left&quot;&gt;templanza&lt;/td&gt;
      &lt;td style=&quot;text-align: left&quot;&gt;frugalidad&lt;/td&gt;
      &lt;td style=&quot;text-align: left&quot;&gt;ahorro&lt;/td&gt;
      &lt;td style=&quot;text-align: left&quot;&gt;disciplina&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td style=&quot;text-align: left&quot;&gt;amor&lt;/td&gt;
      &lt;td style=&quot;text-align: left&quot;&gt;caridad&lt;/td&gt;
      &lt;td style=&quot;text-align: left&quot;&gt;afecto&lt;/td&gt;
      &lt;td style=&quot;text-align: left&quot;&gt;ágape&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td style=&quot;text-align: left&quot;&gt;gracia social&lt;/td&gt;
      &lt;td style=&quot;text-align: left&quot;&gt;dignidad&lt;/td&gt;
      &lt;td style=&quot;text-align: left&quot;&gt;autodominio&lt;/td&gt;
      &lt;td style=&quot;text-align: left&quot;&gt;conciencia de sí&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td style=&quot;text-align: left&quot;&gt;subjetividad&lt;/td&gt;
      &lt;td style=&quot;text-align: left&quot;&gt;objetividad&lt;/td&gt;
      &lt;td style=&quot;text-align: left&quot;&gt;conjetividad&lt;/td&gt;
      &lt;td style=&quot;text-align: left&quot;&gt;metateoría&lt;/td&gt;
    &lt;/tr&gt;
  &lt;/tbody&gt;
&lt;/table&gt;

&lt;p&gt;&lt;em&gt;Las virtudes burguesas&lt;/em&gt;, Deirdre N. McCloskey.&lt;/p&gt;

</description>
        <pubDate>Sun, 13 Jun 2021 00:00:00 +0000</pubDate>
        <link>https://arturoherrero.com/las-virtudes-burguesas/</link>
        <guid isPermaLink="true">https://arturoherrero.com/las-virtudes-burguesas/</guid>
        
        <category>economy</category>
        
        
      </item>
    
      <item>
        <title>Memoria selectiva</title>
        <description>&lt;blockquote&gt;
  &lt;p&gt;[…] De modo que no guardo de mí pasado más que lo que llevo detrás de la frente. En
estos momentos, todo lo demás me resulta inaccesible o, incluso, perdido. Pero
nuestra generación ha aprendido a conciencia a no llorar las cosas perdidas y,
además, quién sabe si la falta de documentación y de detalles no acabará
redundando en beneficio de este libro. Porque yo no considero a nuestra memoria
como algo que retiene &lt;em&gt;una&lt;/em&gt; cosa por
mero azar y pierde &lt;em&gt;otra&lt;/em&gt; por casualidad, sino como una fuerza que ordena a
sabiendas y excluye con juicio. Todo lo que olvida el hombre de su propia vida,
en realidad ya mucho antes había estado condenado al olvido por un instinto
interior. Sólo aquello que yo quiero conservar tiene derecho a ser conservado
para los demás. Así que ¡hablad, recuerdos, elegid vosotros en lugar de mí y
dad al menos un reflejo de mi vida antes de que se sumerja en la oscuridad!&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;em&gt;El mundo de ayer: Memorias de un europeo&lt;/em&gt;, Stefan Zweig.&lt;/p&gt;

&lt;hr /&gt;

&lt;blockquote&gt;
  &lt;p&gt;Montaigne no se cansa de lamentarse de su mala memoria. Junto a una cierta
pereza, ve en ella el verdadero defecto de su ser. Su entendimiento y su
capacidad de percepción son extraordinarios. Lo que ve, lo que comprende, lo
que observa y reconoce, lo capta con el ojo rápido del halcón. Pero luego es
demasiado holgazán, como se reprocha constantemente, para ordenar
sistemáticamente estos conocimientos, desarrollarlos con lógica, y, apenas ha
concebido un pensamiento, lo pierde y lo olvida. Olvida los libros que ha
leído, no tiene memoria para las fechas, no recuerda los acontecimientos
esenciales de su vida. Todo pasa por delante de él como un río y nada se le
queda, ni una convicción profunda, ni una opinión sólida, nada fijo, nada
estable.&lt;/p&gt;

  &lt;p&gt;Esta debilidad de la que Montaigne tanto se lamenta es en realidad su
fortaleza. Esta actitud de no quedarse con nada lo impulsa siempre a ir más
lejos. Para él nada está acabado. No se instala en sus experiencias, no reúne
un capital del que vivir, sino que su espíritu debe ganárselo continuamente. De
modo que su vida es un constante proceso de renovación: «Estamos siempre
recomenzando a vivir». Las verdades que descubre ya no lo son al año siguiente
ni, a menudo, al instante siguiente. Tiene que buscar de nuevo. Y así surgen
muchas contradicciones. Tan pronto parece un epicúreo como un estoico o un
escéptico. Él lo es todo y no es nada. Siempre es otro y siempre el mismo.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;em&gt;Montaigne&lt;/em&gt;, Stefan Zweig.&lt;/p&gt;

&lt;hr /&gt;

&lt;blockquote&gt;
  &lt;p&gt;En general, me esfuerzo por memorizar un detalle curioso sobre un hecho
concreto (o sobre una persona o un fenómeno). Es difícil memorizarlo todo, y
aunque pudiera hacerlo, se me olvidaría enseguida. Por tanto, trato de
simplificar los recuerdos a través de detalles concretos. A eso me refiero
cuando hablo de proceso de selección.&lt;/p&gt;

  &lt;p&gt;¿Cómo y cuáles son esos detalles? Deberían ser cosas concretas e interesantes
que sorprendan. A ser posible, mejor algo que no tenga una clara explicación
y más aún si se trata de algo no razonable. Si es algo que encierra una
contradicción, de inmediato suscita un pensamiento o aviva un misterio. Yo
colecciono ese tipo de detalles, los clasifico con un etiquetado sencillo,
fecha, lugar, circunstancia y los guardo en mi mente. Se puede decir que es
casi como si los guardara en una taquilla personal. Para este ejercicio
convendría apuntarlo todo en un cuaderno, por supuesto, pero yo prefiero
confiar en la memoria porque la disciplina del cuaderno me da pereza y al
escribir en él me relajo y de inmediato lo olvido todo. Cuando uno confía en
la memoria, tiene lugar un proceso de selección natural que conserva lo
importante y elimina lo superfluo. Yo me decanto por ese procedimiento.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;em&gt;De qué hablo cuando hablo de escribir&lt;/em&gt;, Haruki Murakami.&lt;/p&gt;
</description>
        <pubDate>Sun, 02 May 2021 00:00:00 +0000</pubDate>
        <link>https://arturoherrero.com/memoria-selectiva/</link>
        <guid isPermaLink="true">https://arturoherrero.com/memoria-selectiva/</guid>
        
        <category>ideas</category>
        
        
      </item>
    
      <item>
        <title>Improving Bash performance</title>
        <description>&lt;p&gt;I have gradually noticed the degradation of my terminal’s performance when
working with relatively large Git repositories. I use Bash as my Unix shell and
keep &lt;a href=&quot;https://github.com/arturoherrero/dotfiles&quot; target=&quot;_blank&quot; rel=&quot;noreferrer&quot;&gt;my dotfiles&lt;/a&gt; organised, so it’s relatively easy to
investigate and improve performance.&lt;/p&gt;

&lt;h3 id=&quot;improving-git-status&quot;&gt;Improving git-status&lt;/h3&gt;

&lt;p&gt;The first thing I noticed was the poor performance when showing the working
tree status with &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;git status&lt;/code&gt;.&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;It took 2.34 seconds to enumerate untracked files. &apos;status -uno&apos;
may speed it up, but you have to be careful not to forget to add
new files yourself (see &apos;git help status&apos;).
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;I’d still like to show untracked files, so the solution was not to use other
options but to improve the performance. I tried some commands like &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;git prune&lt;/code&gt; or
&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;git gc&lt;/code&gt; with no improvement. I also discovered some relevant options when working
with large repositories, one of the most interesting being &lt;a href=&quot;https://git-scm.com/docs/git-config#Documentation/git-config.txt-featuremanyFiles&quot; target=&quot;_blank&quot; rel=&quot;noreferrer&quot;&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;feature.manyFiles&lt;/code&gt;&lt;/a&gt;,
which enables config options that optimize for repositories with many files in
the working directory.&lt;/p&gt;

&lt;div class=&quot;language-sh highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;git config feature.manyFiles &lt;span class=&quot;nb&quot;&gt;true&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;But what really has made a substantial difference is &lt;a href=&quot;https://github.com/microsoft/scalar&quot; target=&quot;_blank&quot; rel=&quot;noreferrer&quot;&gt;Scalar&lt;/a&gt;.
&lt;a href=&quot;https://devblogs.microsoft.com/devops/introducing-scalar/&quot; target=&quot;_blank&quot; rel=&quot;noreferrer&quot;&gt;Scalar was created by Microsoft&lt;/a&gt; and they want to
accelerate the Git workflow, no matter the size of the repository. The tool sets
advanced Git config options, maintains the repositories in the background,
and helps reducing data sent across the network.&lt;/p&gt;

&lt;p&gt;I’ve installed the following tools:&lt;/p&gt;

&lt;div class=&quot;language-sh highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;brew tap microsoft/git
&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;brew &lt;span class=&quot;nb&quot;&gt;install&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;--cask&lt;/span&gt; scalar
&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;brew &lt;span class=&quot;nb&quot;&gt;install &lt;/span&gt;watchman
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;And then, from the working directory of the Git repository, I’ve registered it:&lt;/p&gt;

&lt;div class=&quot;language-sh highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;scalar register
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Although I sometimes have &lt;a href=&quot;https://github.com/microsoft/scalar/issues/386&quot; target=&quot;_blank&quot; rel=&quot;noreferrer&quot;&gt;problems with watchman invocations&lt;/a&gt;.&lt;/p&gt;

&lt;h3 id=&quot;improving-git-prompt-status-performance&quot;&gt;Improving Git prompt status performance&lt;/h3&gt;

&lt;p&gt;Another element with very poor performance is my prompt &lt;sup&gt;(&lt;a href=&quot;https://github.com/arturoherrero/dotfiles/blob/f982e10/system/prompt.sh&quot; target=&quot;_blank&quot; rel=&quot;noreferrer&quot;&gt;f982e10&lt;/a&gt;)&lt;/sup&gt;,
which uses the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;__git_ps1&lt;/code&gt; function:&lt;/p&gt;

&lt;div class=&quot;language-sh highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nv&quot;&gt;PROMPT_COMMAND&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;__git_ps1 &quot;&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;&apos;${USR_COLOR}${USR}${OFF}@${HOST}:${LPURPLE}${DIR}${OFF} &quot;\$ &quot; &quot;{%s}&quot;&apos;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;The main problem is that if you want to see if there are untracked files,
then you have to set &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;GIT_PS1_SHOWUNTRACKEDFILES&lt;/code&gt; to a nonempty value, but this check
consumes a lot of time.&lt;/p&gt;

&lt;p&gt;Since git-status now has a good performance, I’ve created a custom function
which provides similar functionality to &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;__git_ps1&lt;/code&gt; based on the output from
&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;git status&lt;/code&gt;. This is my new prompt &lt;sup&gt;(&lt;a href=&quot;https://github.com/arturoherrero/dotfiles/blob/1d0df6d/system/prompt.sh&quot; target=&quot;_blank&quot; rel=&quot;noreferrer&quot;&gt;1d0df6d&lt;/a&gt;)&lt;/sup&gt;:&lt;/p&gt;

&lt;div class=&quot;language-sh highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nv&quot;&gt;PROMPT_COMMAND&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;__system_prompt_command&quot;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h3 id=&quot;improving-bash-startup-time&quot;&gt;Improving Bash startup time&lt;/h3&gt;

&lt;p&gt;The last thing I’ve improved is the startup time of the shell. As I have my
dotfiles split in several files, I’ve reused an idea from &lt;a href=&quot;https://work.lisk.in/2020/11/20/even-faster-bash-startup.html&quot; target=&quot;_blank&quot; rel=&quot;noreferrer&quot;&gt;even faster bash
startup&lt;/a&gt; to profile each file:&lt;/p&gt;

&lt;div class=&quot;language-sh highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;k&quot;&gt;for &lt;/span&gt;file &lt;span class=&quot;k&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;si&quot;&gt;$(&lt;/span&gt;__system_dotfiles_dir&lt;span class=&quot;si&quot;&gt;)&lt;/span&gt;/system/&lt;span class=&quot;k&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;do
  &lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;TIMEFORMAT&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$file&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;: %R&quot;&lt;/span&gt;
  &lt;span class=&quot;nb&quot;&gt;time source&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;$file&lt;/span&gt;
  &lt;span class=&quot;nb&quot;&gt;unset &lt;/span&gt;TIMEFORMAT
&lt;span class=&quot;k&quot;&gt;done&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Finally, I’ve removed redundant Bash completions that I was loading, changed
&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;$(brew --prefix)&lt;/code&gt; with the absolute path, and updated the rbenv initialization:&lt;/p&gt;

&lt;div class=&quot;language-diff highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;gd&quot;&gt;- eval &quot;$(rbenv init -)&quot;
&lt;/span&gt;&lt;span class=&quot;gi&quot;&gt;+ eval &quot;$(rbenv init --no-rehash -)&quot;
+ (rbenv rehash &amp;amp;) 2&amp;gt; /dev/null
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

</description>
        <pubDate>Sat, 13 Feb 2021 00:00:00 +0000</pubDate>
        <link>https://arturoherrero.com/improving-bash-performance/</link>
        <guid isPermaLink="true">https://arturoherrero.com/improving-bash-performance/</guid>
        
        <category>programming</category>
        
        
      </item>
    
      <item>
        <title>La geometría del diseño</title>
        <description>&lt;p&gt;&lt;img src=&quot;/assets/images/notes/47/geometria-diseno-1.jpeg&quot; alt=&quot;Proporción y naturaleza&quot; /&gt;&lt;/p&gt;

&lt;blockquote&gt;
  &lt;p&gt;No sabemos por qué, pero podemos demostrar que el ser humano encuentra los planos
de proporciones definidas e intencionales más placenteros o más bellos que
aquellos de proporciones aleatorias.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Jan Tschichold, &lt;em&gt;La forma del libro&lt;/em&gt;, 1975.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/assets/images/notes/47/geometria-diseno-2.jpeg&quot; alt=&quot;Tauromaquia 20, Goya&quot; /&gt;&lt;/p&gt;

&lt;blockquote&gt;
  &lt;p&gt;[…] nada aborrece tanto el sano juicio como una imagen perpetrada sin pericia técnica alguna, por mucho cuidado
y diligencia que se aplique en su factura. Ahora bien, la única razón por la que los pintores de esta clase no
son conscientes de su propio error es la de no haber aprendido geometría, sin la cual nadie puede ser o llegar a
ser un verdadero artista. La culpa de esta falta debe serle atribuida, sin embargo, a sus maestros, ignorantes,
ellos mismos, de esta arte.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Alberto Durero, &lt;em&gt;De la correcta forma de las letras&lt;/em&gt;, 1535.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/assets/images/notes/47/geometria-diseno-3.jpeg&quot; alt=&quot;Silla Barcelona, Mies van der Rohe&quot; /&gt;&lt;/p&gt;

&lt;blockquote&gt;
  &lt;p&gt;Soy de la opinión de que es posible desarrollar un arte mayormente basado en el pensamiento matemático.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Max Bill (entrevista de 1949), en &lt;em&gt;Typographic Communications Today&lt;/em&gt;, 1989.&lt;/p&gt;

&lt;hr /&gt;

&lt;p&gt;Referencia: &lt;em&gt;La geometría del diseño&lt;/em&gt;, Kimberly Elam.&lt;/p&gt;

</description>
        <pubDate>Fri, 01 Jan 2021 00:00:00 +0000</pubDate>
        <link>https://arturoherrero.com/la-geometria-del-diseno/</link>
        <guid isPermaLink="true">https://arturoherrero.com/la-geometria-del-diseno/</guid>
        
        <category>design</category>
        
        
      </item>
    
      <item>
        <title>Amor por el detalle</title>
        <description>&lt;p&gt;Dos anécdotas que expresan muy bien el amor por el detalle.&lt;/p&gt;

&lt;h5 id=&quot;la-perfección-de-steve-jobs-por-walter-isaacson&quot;&gt;La perfección de Steve Jobs por Walter Isaacson.&lt;/h5&gt;

&lt;blockquote&gt;
  &lt;p&gt;De su padre, Jobs había aprendido que el sello de cualquier artesano apasionado
consiste en asegurarse de que incluso las partes que van a quedar ocultas están
acabadas con gusto. Una de las aplicaciones más extremas —y reveladoras— de esa
filosofía llegó cuando inspeccionó el circuito impreso sobre el que irían
colocados los chips y demás componentes en el interior del Macintosh. Ningún
consumidor iba a verlo nunca, pero Jobs comenzó a criticarlo desde un punto de
vista estético. «Esta parte es preciosa —opinó—, pero fíjate en todos esos
chips de memoria. Esto es muy feo, las líneas están demasiado juntas».&lt;/p&gt;

  &lt;p&gt;Uno de los nuevos ingenieros lo interrumpió y le preguntó qué importancia tenía
aquello. «Lo único que importa es si funciona bien. Nadie va a ver la placa
base».&lt;/p&gt;

  &lt;p&gt;Jobs reaccionó como de costumbre: «Quiero que sea tan hermoso como se pueda,
incluso si va a ir dentro de la caja. Un gran carpintero no utiliza madera mala
para la parte trasera de una vitrina, aunque nadie vaya a verla». En una
entrevista realizada unos años más tarde, después de que el Macintosh saliera a
la venta, Jobs volvió a repetir aquella lección aprendida de su padre: «Cuando
eres carpintero y estás fabricando un hermoso arcón, no utilizas un trozo de
contrachapado en la parte de atrás, aunque vaya a estar colocado contra la
pared y nadie lo vea nunca. Tú sí que sabes que está ahí, así que utilizas una
buena pieza de madera para la parte trasera. Para poder dormir bien por las
noches, la estética y la calidad tienen que mantenerse durante todo el
proceso».&lt;/p&gt;
&lt;/blockquote&gt;

&lt;hr /&gt;

&lt;h5 id=&quot;dios-sí-lo-ve-de-edwin-lutyens-por-oscar-tusquets-blanca&quot;&gt;‘Dios sí lo ve’ de Edwin Lutyens por Oscar Tusquets Blanca.&lt;/h5&gt;

&lt;blockquote&gt;
  &lt;p&gt;Parece ser que en una ocasión uno de los jóvenes colaboradores de Lutyens se
encontraba grafiando la fachada trasera de una de las casas que se estaban
proyectando en el estudio. El maestro, tras estudiarla con detenimiento,
observó que la posición de una de las ventanas alteraba la composición
geométrica general, a lo que su colaborador objetó:&lt;/p&gt;

  &lt;p&gt;—Esto no es un problema: el muro que cierra el patio de servicio está tan
próximo que esta apertura no se puede relacionar con el resto de la fachada.
Nadie podrá ver esta falta de rigor geométrico.&lt;/p&gt;

  &lt;p&gt;A lo que el arquitecto respondió impasible:&lt;/p&gt;

  &lt;p&gt;—Dios sí lo ve.&lt;/p&gt;
&lt;/blockquote&gt;
</description>
        <pubDate>Fri, 27 Nov 2020 00:00:00 +0000</pubDate>
        <link>https://arturoherrero.com/amor-por-el-detalle/</link>
        <guid isPermaLink="true">https://arturoherrero.com/amor-por-el-detalle/</guid>
        
        <category>design</category>
        
        
      </item>
    
      <item>
        <title>Hominem unius libri timeo</title>
        <description>&lt;p&gt;Desde hace muchos años voy apuntando todos los &lt;a href=&quot;/books/&quot;&gt;libros que leo&lt;/a&gt;. Alcanzar 50
lecturas en un mismo año me parecía algo casi imposible, sin embargo, llevo ya
varios años superando esa cifra fácilmente. Resulta que aprender a leer no es
simplemente entender el significado de un texto sino saber utilizar el libro
como herramienta. Hay libros que necesitan un tempo pausado, otros no requieren
más que una hojeada, mientras que algunos hay que estudiarlos.&lt;/p&gt;

&lt;p&gt;Al margen de los libros leídos, también son relevantes los libros no leídos. En
mi caso, leer 50 libros implica descartar al menos otros 150 libros, de los
cuales conozco su premisa principal, probablemente he leído algún artículo o
reseña, y finalmente, quizás lo haya comprado o descargado.&lt;/p&gt;

&lt;p&gt;La relación entre los libros no leídos—&lt;strong&gt;antilibrary&lt;/strong&gt;—y el saber la describe
Nassim Taleb en &lt;em&gt;The Black Swan: The Impact of the Highly Improbable&lt;/em&gt;:&lt;/p&gt;

&lt;blockquote&gt;
  &lt;p&gt;The writer Umberto Eco belongs to that small class of scholars who are
encyclopedic, insightful, and nondull. He is the owner of a large personal
library (containing thirty thousand books), and separates visitors into two
categories: those who react with “Wow! &lt;em&gt;Signore professore dottore&lt;/em&gt; Eco, what a
library you have! How many of these books have you read?” and the others—a very
small minority—who get the point that a private library is not an ego-boosting
appendage but a research tool. Read books are far less valuable than unread
ones. The library should contain as much of &lt;em&gt;what you do not know&lt;/em&gt; as your
financial means, mortgage rates, and the currently tight real-estate market
allows you to put there. You will accumulate more knowledge and more books as
you grow older, and the growing number of unread books on the shelves will look
at you menacingly. Indeed, the more you know, the larger the rows of unread
books. Let us call this collection of unread books an &lt;em&gt;antilibrary&lt;/em&gt;.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;La historia de mi vida es la historia de los libros que he leído, pero también
la de los libros que no he leído, y todos ellos han contribuido en mi
formación. Puede que cada libro sólo suponga un pequeño avance—o uno muy
grande, según se mire, hay libros que te pueden cambiar la vida—, pero cuando se
empieza a manejar cierto volumen de bibliografía es cuando empieza a surgir la
magia. He aprendido que el conocimiento no es ese conjunto de categorías
parceladas que me habían enseñado, sino que se parece más a un vasto prado
donde todo—absolutamente todo—está interrelacionado. También ha sido
revelador darme cuenta de que siempre hay que leer con mucha distancia—la
historia la escriben los que se sientan a escribirla—, el conocimiento siempre
es escurridizo y la mayoría de las veces algo temporal.&lt;/p&gt;

&lt;p&gt;Me gusta la expresión latina &lt;strong&gt;«Hominem unius libri timeo»&lt;/strong&gt; («Teme al hombre
de un sólo libro») atribuida a Tomás de Aquino, porque captura de forma
magistral estas simples lecciones a las que yo he llegado después de tantas
lecturas. Actualmente, nos referimos a la frase para criticar a alguien cuyos
horizontes mentales están limitados a un único libro y—yo añadiría también—a
aquellos que aún leyendo muchos libros, lo hacen siempre sobre el mismo tema.&lt;/p&gt;

&lt;p&gt;Teme al hombre de un sólo libro.&lt;/p&gt;

</description>
        <pubDate>Thu, 26 Nov 2020 00:00:00 +0000</pubDate>
        <link>https://arturoherrero.com/hominem-unius-libri-timeo/</link>
        <guid isPermaLink="true">https://arturoherrero.com/hominem-unius-libri-timeo/</guid>
        
        <category>reading</category>
        
        
      </item>
    
      <item>
        <title>Clasicismo vs Barroco</title>
        <description>&lt;table&gt;
  &lt;thead&gt;
    &lt;tr&gt;
      &lt;th style=&quot;text-align: left&quot;&gt;Lo Clásico&lt;/th&gt;
      &lt;th style=&quot;text-align: left&quot;&gt;Lo Barroco&lt;/th&gt;
    &lt;/tr&gt;
  &lt;/thead&gt;
  &lt;tbody&gt;
    &lt;tr&gt;
      &lt;td style=&quot;text-align: left&quot;&gt;Geometría&lt;/td&gt;
      &lt;td style=&quot;text-align: left&quot;&gt;Organicidad&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td style=&quot;text-align: left&quot;&gt;Estático&lt;/td&gt;
      &lt;td style=&quot;text-align: left&quot;&gt;En movimiento&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td style=&quot;text-align: left&quot;&gt;Gravita&lt;/td&gt;
      &lt;td style=&quot;text-align: left&quot;&gt;Se eleva&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td style=&quot;text-align: left&quot;&gt;La Razón&lt;/td&gt;
      &lt;td style=&quot;text-align: left&quot;&gt;La Emoción&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td style=&quot;text-align: left&quot;&gt;La Razón&lt;/td&gt;
      &lt;td style=&quot;text-align: left&quot;&gt;La Percepción&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td style=&quot;text-align: left&quot;&gt;Símbolos abstractos&lt;/td&gt;
      &lt;td style=&quot;text-align: left&quot;&gt;Realidades concretas&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td style=&quot;text-align: left&quot;&gt;Un futuro único&lt;/td&gt;
      &lt;td style=&quot;text-align: left&quot;&gt;Futuros contradictorios&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td style=&quot;text-align: left&quot;&gt;La obra imita al espíritu&lt;/td&gt;
      &lt;td style=&quot;text-align: left&quot;&gt;La obra imita a la naturaleza&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td style=&quot;text-align: left&quot;&gt;Seguro de si mismo&lt;/td&gt;
      &lt;td style=&quot;text-align: left&quot;&gt;Roto en sus contradiciones&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td style=&quot;text-align: left&quot;&gt;Monoteísta&lt;/td&gt;
      &lt;td style=&quot;text-align: left&quot;&gt;Panteísta&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td style=&quot;text-align: left&quot;&gt;Humanista&lt;/td&gt;
      &lt;td style=&quot;text-align: left&quot;&gt;Panteísta&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td style=&quot;text-align: left&quot;&gt;Ortodoxo&lt;/td&gt;
      &lt;td style=&quot;text-align: left&quot;&gt;Pagano&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td style=&quot;text-align: left&quot;&gt;Se proyecta en una línea&lt;/td&gt;
      &lt;td style=&quot;text-align: left&quot;&gt;Se proyecta en un plano&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td style=&quot;text-align: left&quot;&gt;Apolo&lt;/td&gt;
      &lt;td style=&quot;text-align: left&quot;&gt;Dioniso&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td style=&quot;text-align: left&quot;&gt;Unidad&lt;/td&gt;
      &lt;td style=&quot;text-align: left&quot;&gt;Dispersión&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td style=&quot;text-align: left&quot;&gt;Alineación&lt;/td&gt;
      &lt;td style=&quot;text-align: left&quot;&gt;Confrontación&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td style=&quot;text-align: left&quot;&gt;Logos&lt;/td&gt;
      &lt;td style=&quot;text-align: left&quot;&gt;Pathos&lt;/td&gt;
    &lt;/tr&gt;
  &lt;/tbody&gt;
&lt;/table&gt;

&lt;p&gt;&lt;a href=&quot;https://www.terremoto.net/blog/clasicismo-versus-barroco&quot; target=&quot;_blank&quot; rel=&quot;noreferrer&quot;&gt;Clasicismo versus Barroco, una clasificación para lo humano&lt;/a&gt;, Javier Cañada.&lt;/p&gt;

</description>
        <pubDate>Fri, 12 Jun 2020 00:00:00 +0000</pubDate>
        <link>https://arturoherrero.com/clasicismo-vs-barroco/</link>
        <guid isPermaLink="true">https://arturoherrero.com/clasicismo-vs-barroco/</guid>
        
        <category>art</category>
        
        
      </item>
    
      <item>
        <title>It Doesn&apos;t Have to Be Crazy at Work</title>
        <description>&lt;p class=&quot;side-image&quot;&gt;&lt;img src=&quot;/assets/images/notes/calm.jpg&quot; alt=&quot;It Doesn&apos;t Have to Be Crazy at Work&quot; /&gt;&lt;/p&gt;

&lt;p&gt;Two interesting ideas from reading &lt;em&gt;&lt;a href=&quot;https://basecamp.com/books/calm&quot; target=&quot;_blank&quot; rel=&quot;noreferrer&quot;&gt;It Doesn’t Have to Be Crazy at Work&lt;/a&gt;&lt;/em&gt;, Jason Fried &amp;amp; David Heinemeier Hansson.&lt;/p&gt;

&lt;h5 id=&quot;the-trust-battery&quot;&gt;The Trust Battery&lt;/h5&gt;

&lt;blockquote&gt;
  &lt;p&gt;[…] “Another concept we talk a lot about is something called a ‘trust battery.’ It’s
charged at 50 percent when people are first hired. And then every time you work
with someone at the company, the trust battery between the two of you is either
charged or discharged, based on things like whether you deliver on what you
promise.”&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h5 id=&quot;disagree-and-commit&quot;&gt;Disagree and commit&lt;/h5&gt;

&lt;blockquote&gt;
  &lt;p&gt;Jeff Bezos put it well in his 2017 letter to shareholders:&lt;/p&gt;

  &lt;blockquote&gt;
    &lt;p&gt;I disagree and commit all the time. We recently greenlit a particular Amazon
Studios original. I told the team my view: debatable whether it would be
interesting enough, complicated to produce, the business terms aren’t that
good, and we have lots of other opportunities. They had a completely
different opinion and wanted to go ahead. I wrote back right away with “I
disagree and commit and hope it becomes the most watched thing we’ve ever
made.” Consider how much slower this decision cycle would have been if the
team had actually had to convince me rather than simply get my commitment.&lt;/p&gt;
  &lt;/blockquote&gt;

  &lt;p&gt;We totally agree. We’ve been practicing disagree and commit since the
beginning, but it took Bezos’s letter to name the practice. Now we even use
that exact term in our discussions. “I disagree, but let’s commit” is something
you’ll hear at Basecamp after heated debates about specific products or
strategy decisions.&lt;/p&gt;
&lt;/blockquote&gt;

</description>
        <pubDate>Thu, 11 Jun 2020 00:00:00 +0000</pubDate>
        <link>https://arturoherrero.com/it-doesnt-have-to-be-crazy-at-work/</link>
        <guid isPermaLink="true">https://arturoherrero.com/it-doesnt-have-to-be-crazy-at-work/</guid>
        
        <category>ideas</category>
        
        
      </item>
    
      <item>
        <title>Tria iuris praecepta</title>
        <description>&lt;p&gt;De todas las definiciones que se han dado de justicia, quizás, la más conocida
es aquella expresada en el siglo III por el jurista Ulpiano, quien decía que
«la justicia es la constante y perpetua voluntad de dar (conceder) a cada uno
su propio derecho».&lt;/p&gt;

&lt;p&gt;«Los preceptos o mandatos del derecho son: vivir honestamente, no hacer daño a
nadie y dar a cada uno lo que le corresponde».&lt;/p&gt;

&lt;blockquote&gt;
  &lt;p&gt;Iuris praecepta sunt haec: honeste vivere, alterum non laedere, suum cuique
tribuere.&lt;/p&gt;
&lt;/blockquote&gt;
</description>
        <pubDate>Mon, 25 May 2020 00:00:00 +0000</pubDate>
        <link>https://arturoherrero.com/tria-iuris-praecepta/</link>
        <guid isPermaLink="true">https://arturoherrero.com/tria-iuris-praecepta/</guid>
        
        <category>quotes</category>
        
        
      </item>
    
      <item>
        <title>Ulises y la comadreja</title>
        <description>&lt;p class=&quot;side-image&quot;&gt;&lt;img src=&quot;/assets/images/notes/26/ulises-y-la-comadreja.jpg&quot; alt=&quot;Ulises y la comadreja&quot; /&gt;&lt;/p&gt;

&lt;p&gt;He leído &lt;em&gt;Ulises y la comadreja: Una simpática introducción a los mercados
financieros&lt;/em&gt; de Georg von Wallwitz. Una lectura bastante ligera sobre los
mercados financieros; mezcla de filosofía, psicología inversora e historia.&lt;/p&gt;

&lt;p&gt;El libro comienza describiendo el nacimiento de la banca moderna en Amsterdam y
los primeros mercados financieros con la Compañía Holandesa de las Indias
Orientales. Continúa con la historia de John Law, que introdujo el uso del papel
moneda en Francia como sustituto del metal, ocasionando una de las mayores
burbujas económicas de todos los tiempos.&lt;/p&gt;

&lt;p&gt;El aumento de la masa monetaria o el control de los precios han sido temas
recurrentes entre los gobernantes a lo largo de la historia, casi siempre con
terribles consecuencias. También lo ha sido la búsqueda de una teoría para
explicar los mercados financieros por parte de los inversores, fórmula que John
Keynes trató de encontrar a lo largo de su vida.&lt;/p&gt;

&lt;p&gt;El autor define dos arquetipos de inversores: &lt;em&gt;Ulises&lt;/em&gt;, el hombre de buen
juicio y &lt;em&gt;la comadreja&lt;/em&gt;, que se aleja del ideal homérico.&lt;/p&gt;

&lt;blockquote&gt;
  &lt;p&gt;La combinación de conocimiento, experiencia, psicología, cálculo,
inteligencia y &lt;em&gt;animal spirit&lt;/em&gt; define a Ulises frente a las comadrejas. No
basta con saber psicología o matemáticas, ni tampoco con tener experiencia.
Hay que tenerlo todo y combinarlo en su justa medida.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Temor, riesgo, ambición y el lado moral de los mercados; la psicología
inversora y los sesgos individuales nos permiten intuir por qué el &lt;em&gt;Sr. Mercado&lt;/em&gt;
se comporta de forma maníaco-depresiva.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/assets/images/notes/26/buy-sell.jpg&quot; alt=&quot;Buy - Sell&quot; /&gt;&lt;/p&gt;

</description>
        <pubDate>Sun, 10 May 2020 00:00:00 +0000</pubDate>
        <link>https://arturoherrero.com/ulises-y-la-comadreja/</link>
        <guid isPermaLink="true">https://arturoherrero.com/ulises-y-la-comadreja/</guid>
        
        <category>economy</category>
        
        
      </item>
    
      <item>
        <title>Iteration</title>
        <description>&lt;p&gt;I recently read &lt;a href=&quot;https://www.nytimes.com/2014/08/11/technology/-inside-apples-internal-training-program-.html&quot; target=&quot;_blank&quot; rel=&quot;noreferrer&quot;&gt;&lt;em&gt;Simplifying the Bull: How Picasso Helps to Teach Apple’s Style&lt;/em&gt;&lt;/a&gt;,
an article about how Apple uses Picasso’s process of eliminating details to
teach its designers about striving for simplicity when creating their products.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/assets/images/posts/le-taureau-picasso.jpg&quot; alt=&quot;Le Taureau. Picasso&quot; /&gt;
&lt;sup&gt;Le Taureau (The Bull). Pablo Picasso, 1945.&lt;/sup&gt;&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/assets/images/posts/apple-mouse-evolution.jpg&quot; alt=&quot;Apple Mouse Evolution&quot; /&gt;
&lt;sup&gt;Lisa Mouse, 1983 | ADB Mouse II, 1993 | Mighty Mouse, 2006 | Magic Mouse, 2009.&lt;/sup&gt;&lt;/p&gt;

&lt;blockquote&gt;
  &lt;p&gt;Simplicity is the ultimate sophistication.&lt;br /&gt;
—Leonardo da Vinci&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;It’s fascinating to see such clear visual evolution—whether in art or product
design—where each iteration eliminates the superfluous and reduces the work to
its essence. A designer understands that &lt;em&gt;“less is more”&lt;/em&gt; and &lt;em&gt;“perfection is
finally attained not when there is no longer anything to add, but when there is
no longer anything to take away”&lt;/em&gt;, although striving towards simplicity on one
level &lt;a href=&quot;/mental-models-complexity-and-software/&quot;&gt;may increase the complexity of the system on a different level&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;However, the important thing for me in these cases is the idea of
&lt;strong&gt;iteration&lt;/strong&gt;. This pattern of iterative refinement appears across industries
and applies to absolutely everything, from writing, public speaking, cooking,
designing and programming to business strategy or process.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/assets/images/posts/porsche-911-evolution.png&quot; alt=&quot;Porsche 911 Evolution&quot; /&gt;
&lt;sup&gt;Porsche 911 Evolution&lt;/sup&gt;&lt;/p&gt;

&lt;blockquote&gt;
  &lt;p&gt;Change is easy. Improvement is far more difficult.&lt;br /&gt;
—Ferdinand Porsche&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;img src=&quot;/assets/images/posts/spacex-raptor-evolution.png&quot; alt=&quot;SpaceX Raptor Evolution&quot; /&gt;
&lt;sup&gt;SpaceX Raptor Evolution&lt;/sup&gt;&lt;/p&gt;

&lt;p&gt;Being able to do good work involves learning, correcting and improving during
each iteration based on the feedback you get, and every intermediate step is
necessary to reach the final solution.&lt;/p&gt;

&lt;p&gt;That’s why I believe &lt;strong&gt;iteration is the ultimate sophistication&lt;/strong&gt;.&lt;/p&gt;

</description>
        <pubDate>Tue, 28 Apr 2020 00:00:00 +0000</pubDate>
        <link>https://arturoherrero.com/iteration/</link>
        <guid isPermaLink="true">https://arturoherrero.com/iteration/</guid>
        
        <category>ideas</category>
        
        
      </item>
    
      <item>
        <title>Evolution of the Alphabet</title>
        <description>&lt;p&gt;&lt;img src=&quot;/assets/images/notes/evolution-of-the-alphabet.png&quot; alt=&quot;Evolution of the Alphabet&quot; /&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;https://usefulcharts.com/blogs/charts/evolution-of-the-english-alphabet&quot; target=&quot;_blank&quot; rel=&quot;noreferrer&quot;&gt;Evolution of the Alphabet&lt;/a&gt;, Matt Baker.&lt;/p&gt;

</description>
        <pubDate>Sun, 02 Feb 2020 00:00:00 +0000</pubDate>
        <link>https://arturoherrero.com/evolution-of-the-alphabet/</link>
        <guid isPermaLink="true">https://arturoherrero.com/evolution-of-the-alphabet/</guid>
        
        <category>writing</category>
        
        
      </item>
    
      <item>
        <title>De lo bello</title>
        <description>&lt;blockquote&gt;
  &lt;p&gt;El alma debe ir ascendiendo en la contemplación de la belleza de manera
gradual. Primero viendo las obras bellas, no las de arte, sino las de los
hombres de bien. Luego es necesario ver el alma de aquellos que realizan las
obras bellas.¿Y cómo puede hacerse esto? Mirando sobre uno mismo. «Si tú no
ves todavía la belleza en ti, haz como el escultor de una estatua, que debe
ser bella; toma una parte, la esculpe, la pule, y va tanteando hasta que saca
líneas bellas del mármol. Como aquél, quita lo superfluo, endereza lo que es
oblicuo, limpia lo que está oscuro para hacerlo brillante, y no ceses de
esculpir tu propia estatua, hasta que el resplandor divino de la virtud se
manifieste, hasta que veas la temperancia sentada sobre un trono sagrado.»&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;em&gt;Enéadas: De lo bello&lt;/em&gt;, Plotino.&lt;/p&gt;
</description>
        <pubDate>Sun, 08 Dec 2019 00:00:00 +0000</pubDate>
        <link>https://arturoherrero.com/de-lo-bello/</link>
        <guid isPermaLink="true">https://arturoherrero.com/de-lo-bello/</guid>
        
        <category>quotes</category>
        
        
      </item>
    
      <item>
        <title>Pyramids vs Cathedrals</title>
        <description>&lt;blockquote&gt;
  &lt;p&gt;In many ways, the medieval cathedrals embody what is best about the human
spirit. They were the first man-made structures to go higher than the pyramids,
and this fact alone says a lot about the difference between the Ancient, Pagan
world and the Christian world. A pyramid is a fat structure with a heavy base,
while a cathedral soars towards the sky. A society that builds pyramids is a
society based on slave labor: building a pyramid is pretty much about using as
much raw muscle strength as possible to take many rocks from point A and pile
them up on point B. Meanwhile, a society that builds a cathedral is replete
with scientists, mathematicians, engineers, craftsmen, artists… A pyramid is a
monument dedicated to death–it is a tomb. A cathedral is a monument dedicated
to the triumph over death.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;a href=&quot;https://www.patheos.com/blogs/inebriateme/2014/06/peter-thiel-and-the-cathedral/&quot; target=&quot;_blank&quot; rel=&quot;noreferrer&quot;&gt;Peter Thiel and the Cathedral&lt;/a&gt;, Pascal-Emmanuel Gobry.&lt;/p&gt;

</description>
        <pubDate>Wed, 14 Aug 2019 00:00:00 +0000</pubDate>
        <link>https://arturoherrero.com/pyramids-vs-cathedrals/</link>
        <guid isPermaLink="true">https://arturoherrero.com/pyramids-vs-cathedrals/</guid>
        
        <category>ideas</category>
        
        
      </item>
    
      <item>
        <title>The Sarcophagus Room</title>
        <description>&lt;p&gt;&lt;img src=&quot;/assets/images/notes/soane-the-sarcophagus-room-iln-1864.jpg&quot; alt=&quot;The Sarcophagus Room&quot; /&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;The sarcophagus of Seti I&lt;/em&gt;, as shown in the Illustrated London News. 1864.&lt;br /&gt;
Sir John Soane’s Museum. London, England.&lt;/p&gt;

</description>
        <pubDate>Sun, 23 Jun 2019 00:00:00 +0000</pubDate>
        <link>https://arturoherrero.com/the-sarcophagus-room/</link>
        <guid isPermaLink="true">https://arturoherrero.com/the-sarcophagus-room/</guid>
        
        <category>art</category>
        
        
      </item>
    
      <item>
        <title>Trivium et Quadrivium</title>
        <description>&lt;p&gt;The seven liberal arts, are those subjects or skills that in classical
antiquity were considered essential for a free person (&lt;em&gt;liberalis&lt;/em&gt;, “worthy of
a free person”) to know in order to take an active part in civic life,
something that (for ancient Greece) included participating in public debate,
defending oneself in court, serving on juries, and most importantly, military
service.&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;em&gt;Trivium&lt;/em&gt;
    &lt;ul&gt;
      &lt;li&gt;Grammar&lt;/li&gt;
      &lt;li&gt;Logic&lt;/li&gt;
      &lt;li&gt;Rhetoric&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;&lt;em&gt;Quadrivium&lt;/em&gt;
    &lt;ul&gt;
      &lt;li&gt;Arithmetic&lt;/li&gt;
      &lt;li&gt;Geometry&lt;/li&gt;
      &lt;li&gt;Music&lt;/li&gt;
      &lt;li&gt;Astronomy&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
&lt;/ul&gt;
</description>
        <pubDate>Fri, 21 Jun 2019 00:00:00 +0000</pubDate>
        <link>https://arturoherrero.com/trivium-et-quadrivium/</link>
        <guid isPermaLink="true">https://arturoherrero.com/trivium-et-quadrivium/</guid>
        
        <category>ideas</category>
        
        
      </item>
    
      <item>
        <title>New representations of thought</title>
        <description>&lt;blockquote&gt;
  &lt;p&gt;New &lt;strong&gt;representations of thought&lt;/strong&gt; — written language, numerals, mathematical
notation, data graphics — have been responsible for some of the most
significant leaps in the progress of civilization, by expanding humanity’s
collectively-thinkable territory.&lt;/p&gt;

  &lt;h5 id=&quot;definition&quot;&gt;Definition&lt;/h5&gt;

  &lt;p&gt;A &lt;em&gt;representation&lt;/em&gt; captures some aspect of a concept or phenomenon in a
human-understandable form, thereby enabling a person to perceive and think
about it.&lt;/p&gt;

  &lt;p&gt;For example, a piece of music can be represented as a verbal description or as
a page of music notation (&lt;em&gt;symbolic&lt;/em&gt;); a waveform plot or spectrograph (&lt;em&gt;visual&lt;/em&gt;);
an audio recording or click track (&lt;em&gt;aural&lt;/em&gt;), the pattern of finger movements
while playing the piano (&lt;em&gt;tangible&lt;/em&gt;), or the experience of walking around an
orchestra (&lt;em&gt;spatial&lt;/em&gt;).&lt;/p&gt;

  &lt;h5 id=&quot;parables&quot;&gt;Parables&lt;/h5&gt;

  &lt;ul&gt;
    &lt;li&gt;
      &lt;p&gt;Before the 14th century, multiplication was considered a highly abstract
concept, only for the mathematical elite. Once place-value Arabic numerals
replaced Roman numerals, multiplication and division became mundane. It was
this representation which made universal &lt;strong&gt;arithmetic literacy&lt;/strong&gt; possible.&lt;/p&gt;
    &lt;/li&gt;
    &lt;li&gt;
      &lt;p&gt;Before the 17th century, mathematical calculation was described in prose. The
invention of algebraic notation made mathematical structure visible, and
allowed for abstracting beyond numbers. This representation was the birth of
&lt;strong&gt;modern mathematics&lt;/strong&gt;.&lt;/p&gt;
    &lt;/li&gt;
    &lt;li&gt;
      &lt;p&gt;Before the 19th century, data was presented in tables. Playfair invented the
data plot. Without this form of representation, modern &lt;strong&gt;scientific discovery
and communication&lt;/strong&gt; would be inconceivable.&lt;/p&gt;
    &lt;/li&gt;
    &lt;li&gt;
      &lt;p&gt;Faraday’s representation of magnetism as “lines of force” inspired Maxwell’s
theory, which he wrote as twenty differential equations. Heaviside invented
the language of vector analysis specifically to rewrite Maxwell’s equations
in four simple lines. This representation was the birth of &lt;strong&gt;electrodynamics&lt;/strong&gt;.&lt;/p&gt;
    &lt;/li&gt;
    &lt;li&gt;
      &lt;p&gt;Dalton’s elements were a grab-bag, with no coherent framework or predictive
power. Mendeleev found a way to represent the patterns of chemical
properties with a “periodic table”. This representation enabled, for the
first time, a theory of &lt;strong&gt;chemistry&lt;/strong&gt;.&lt;/p&gt;
    &lt;/li&gt;
  &lt;/ul&gt;

  &lt;h5 id=&quot;why-representations-matter&quot;&gt;Why representations matter&lt;/h5&gt;

  &lt;p&gt;These representations weren’t mere scientific “discoveries”. Each of them essentially
&lt;em&gt;enabled all subsequent scientific breakthroughs thereafter&lt;/em&gt;. A powerful new form of
representation affects everything, forever.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;a href=&quot;http://worrydream.com/cdg/ResearchAgenda-v0.19-poster.pdf&quot; target=&quot;_blank&quot; rel=&quot;noreferrer&quot;&gt;Research agenda and former floor plan&lt;/a&gt;, Bret Victor.&lt;/p&gt;

</description>
        <pubDate>Sun, 09 Jun 2019 00:00:00 +0000</pubDate>
        <link>https://arturoherrero.com/new-representations-of-thought/</link>
        <guid isPermaLink="true">https://arturoherrero.com/new-representations-of-thought/</guid>
        
        <category>design</category>
        
        
      </item>
    
      <item>
        <title>Sketchplanations</title>
        <description>&lt;p&gt;Learn something new with &lt;a href=&quot;https://sketchplanations.com/&quot; target=&quot;_blank&quot; rel=&quot;noreferrer&quot;&gt;sketchplanations&lt;/a&gt;.&lt;/p&gt;

&lt;p class=&quot;grid-container&quot;&gt;&lt;img src=&quot;/assets/images/notes/2/sketchplanations-accuracy-and-precision.jpg&quot; alt=&quot;Accuracy and precision&quot; /&gt;
&lt;img src=&quot;/assets/images/notes/2/sketchplanations-dunbars-number.jpg&quot; alt=&quot;Dunbar&apos;s number: 150&quot; /&gt;
&lt;img src=&quot;/assets/images/notes/2/sketchplanations-coastline-paradox.jpg&quot; alt=&quot;The coastline paradox&quot; /&gt;
&lt;img src=&quot;/assets/images/notes/2/sketchplanations-mercator-projection.jpg&quot; alt=&quot;Mercator projection&quot; /&gt;&lt;/p&gt;

</description>
        <pubDate>Tue, 21 May 2019 00:00:00 +0000</pubDate>
        <link>https://arturoherrero.com/sketchplanations/</link>
        <guid isPermaLink="true">https://arturoherrero.com/sketchplanations/</guid>
        
        <category>ideas</category>
        
        
      </item>
    
      <item>
        <title>Leonardo&apos;s To-Do List</title>
        <description>&lt;p class=&quot;side-image&quot;&gt;&lt;img src=&quot;/assets/images/notes/leonardo-da-vinci-walter-isaacson.jpg&quot; alt=&quot;Leonardo da Vinci by Walter Isaacson&quot; /&gt;&lt;/p&gt;

&lt;blockquote&gt;
  &lt;p&gt;My starting point for this book was not Leonardo’s art masterpieces but his
notebooks. His mind, I think, is best revealed in the more than 7,200 pages of
his notes and scribbles that, miraculously, survive to this day. Paper turns
out to be a superb information-storage technology, still readable after five
hundred years, which our own tweets likely won’t be.&lt;/p&gt;

  &lt;p&gt;Fortunately, Leonardo could not afford to waste paper, so he crammed every inch
of his pages with miscellaneous drawings and looking-glass jottings that seem
random but provide intimations of his mental leaps. Scribbled alongside each
other, with rhyme if not reason, are math calculations, sketches of his
devilish young boyfriend, birds, flying machines, theater props, eddies of
water, blood valves, grotesque heads, angels, siphons, plant stems, sawed-apart
skulls, tips for painters, notes on the eye and optics, weapons of war, fables,
riddles, and studies for paintings. The cross-disciplinary brilliance whirls
across every page, providing a delightful display of a mind dancing with
nature. His notebooks are the greatest record of curiosity ever created, a
wondrous guide to the person whom the eminent art historian Kenneth Clark
called &lt;em&gt;“the most relentlessly curious man in history”&lt;/em&gt;.&lt;/p&gt;

  &lt;p&gt;My favorite gems in his notebooks are his to-do lists, which sparkle with his
curiosity. One of them, dating from the 1490s in Milan, is that day’s list of
things he wants to learn. &lt;em&gt;“The measurement of Milan and its suburbs”&lt;/em&gt; is the
first entry. This has a practical purpose, as revealed by an item later in the
list: &lt;em&gt;“Draw Milan”&lt;/em&gt;. Others show him relentlessly seeking out people whose
brains he could pick: &lt;em&gt;“Get the master of arithmetic to show you how to square a
triangle […] Ask Giannino the Bombardier about how the tower of Ferrara is
walled […] Ask Benedetto Protinari by what means they walk on ice in Flanders
[…] Get a master of hydraulics to tell you how to repair a lock, canal and
mill in the Lombard manner […] Get the measurement of the sun promised me by
Maestro Giovanni Francese, the Frenchman”&lt;/em&gt;. He is insatiable.&lt;/p&gt;

  &lt;p&gt;Over and over again, year after year, Leonardo lists things he must do and
learn. Some involve the type of close observation most of us rarely pause to
do. &lt;em&gt;“Observe the goose’s foot: if it were always open or always closed the
creature would not be able to make any kind of movement”&lt;/em&gt;. Others involve
why-is-the- sky-blue questions about phenomena so commonplace that we rarely
pause to wonder about them. &lt;em&gt;“Why is the fish in the water swifter than the bird
in the air when it ought to be the contrary since the water is heavier and
thicker than the air?”&lt;/em&gt;.&lt;/p&gt;

  &lt;p&gt;Best of all are the questions that seem completely random. &lt;em&gt;“Describe the tongue
of the woodpecker”&lt;/em&gt;, he instructs himself. Who on earth would decide one day,
for no apparent reason, that he wanted to know what the tongue of a woodpecker
looks like? How would you even find out? It’s not information Leonardo needed
to paint a picture or even to understand the flight of birds. But there it is,
and, as we shall see, there are fascinating things to learn about the tongue of
the woodpecker. The reason he wanted to know was because he was Leonardo:
curious, passionate, and always filled with wonder.&lt;/p&gt;

  &lt;p&gt;Oddest of all, there is this entry: &lt;em&gt;“Go every Saturday to the hot bath where
you will see naked men”&lt;/em&gt;. We can imagine Leonardo wanting to do that, for
reasons both anatomical and aesthetic. But did he really need to remind himself
to do it? The next item on the list is &lt;em&gt;“Inflate the lungs of a pig and observe
whether they increase in width and in length, or only in width”&lt;/em&gt;. As the New
Yorker art critic Adam Gopnik once wrote, &lt;em&gt;“Leonardo remains weird, matchlessly
weird, and nothing to be done about it”&lt;/em&gt;.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;em&gt;Leonardo da Vinci&lt;/em&gt;, Walter Isaacson.&lt;/p&gt;

</description>
        <pubDate>Mon, 06 May 2019 00:00:00 +0000</pubDate>
        <link>https://arturoherrero.com/leonardos-to-do-list/</link>
        <guid isPermaLink="true">https://arturoherrero.com/leonardos-to-do-list/</guid>
        
        <category>writing</category>
        
        
      </item>
    
      <item>
        <title>Mental models, complexity and software</title>
        <description>&lt;p&gt;I was invited to speak at &lt;a href=&quot;http://2018.pamplonaswcraft.com/&quot; target=&quot;_blank&quot; rel=&quot;noreferrer&quot;&gt;Pamplona Software Crafters 2018&lt;/a&gt;,
and I’m glad to have contributed with my talk about mental models, complexity and software.&lt;/p&gt;

&lt;h3 id=&quot;software-is-complex&quot;&gt;Software is complex&lt;/h3&gt;

&lt;p&gt;There are several ways in which we can approach complexity from a developer’s point of view.&lt;/p&gt;

&lt;p&gt;For example, we can look at it from the perspective of &lt;strong&gt;computational
complexity&lt;/strong&gt; (big O notation) or the perspective of &lt;strong&gt;programming complexity&lt;/strong&gt;
(cyclomatic complexity, ABC metric or cognitive complexity).&lt;/p&gt;

&lt;p&gt;We can also think of complexity in terms of &lt;strong&gt;&lt;a href=&quot;http://curtclifton.net/papers/MoseleyMarks06a.pdf&quot; target=&quot;_blank&quot; rel=&quot;noreferrer&quot;&gt;accidental complexity vs.
essential complexity&lt;/a&gt;&lt;/strong&gt;, and the difficulty of handling
states in object-oriented programming compared to functional programming.&lt;/p&gt;

&lt;p&gt;And of course, &lt;strong&gt;the lifecycle of a software project&lt;/strong&gt; involves significant
complexity as well; software teams, repositories, continuous integration, testing,
deployments, monitoring, alerts, methodologies, etc…&lt;/p&gt;

&lt;h3 id=&quot;the-world-is-complex&quot;&gt;The world is complex&lt;/h3&gt;

&lt;p&gt;However, if we think beyond software development, we can find
complexity in everything around us, much of which we don’t yet understand. And
we may think that chaos is order yet undeciphered. The history of humankind is
the history of understanding the world and doing reverse engineering to try to
understand that chaos. We are &lt;strong&gt;&lt;a href=&quot;https://arxiv.org/abs/0812.4360&quot; target=&quot;_blank&quot; rel=&quot;noreferrer&quot;&gt;driven by compression
progress&lt;/a&gt;&lt;/strong&gt; to try to decipher the world and uncover the
simplicity that we believe is underneath all the chaos.&lt;/p&gt;

&lt;p&gt;This is something we also look for when programming in increasingly higher
level languages. For example, this Ruby on Rails line expresses something on a
level easily understood by anyone, hiding many of the details that occur by
convention or in layers of abstraction below it. We can understand &lt;strong&gt;code as
compression progress&lt;/strong&gt;.&lt;/p&gt;

&lt;div class=&quot;language-ruby highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;no&quot;&gt;User&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;create&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;ss&quot;&gt;name: &lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;Arturo&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;We like to come up with &lt;strong&gt;abstractions that hide the details&lt;/strong&gt;, but complexity
is not free. &lt;strong&gt;It increases the hidden risks and the fragility of the system&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;I believe the solution is not simply to understand one level below your normal
abstraction layer, but also to understand one level above it.&lt;/p&gt;

&lt;h3 id=&quot;mental-models&quot;&gt;Mental models&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;A mental model is a concept, a framework or a vision of the world that you
carry in your mind to help you interpret what surrounds you and understand the
relationship between things&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;The software craftsmanship community has a clear idea of what mastery is, taken
to the extremes by the inspiring &lt;a href=&quot;https://youtu.be/Q3Ve7ec1HpY&quot; target=&quot;_blank&quot; rel=&quot;noreferrer&quot;&gt;Jiro Dreams of Sushi&lt;/a&gt;
documentary. However, I am also interested in the idea of mastering a
specialization yet also having a broad understanding of many other disciplines.
This is known as having &lt;strong&gt;T-shaped skills&lt;/strong&gt; or being an &lt;strong&gt;expert-generalist&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;At the end of the day, we can understand &lt;a href=&quot;https://www.fs.blog/mental-models/&quot; target=&quot;_blank&quot; rel=&quot;noreferrer&quot;&gt;multiple mental models&lt;/a&gt;
from Charlie Munger as a collection of big ideas from big disciplines that contains
a checklist for decision-making. You can explore some of them in this infographic of &lt;a href=&quot;/assets/images/posts/mental-models.jpg&quot; target=&quot;_blank&quot; rel=&quot;noreferrer&quot;&gt;the
top 12 most useful &amp;amp; universal mental models&lt;/a&gt; by Michael Simmons.&lt;/p&gt;

&lt;p&gt;But, &lt;strong&gt;why should you care about mental models?&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;They help you see the world more accurately and make better predictions of the future.&lt;/li&gt;
  &lt;li&gt;They can help you come up with more innovative ideas.&lt;/li&gt;
  &lt;li&gt;You can build more and better connections with people who are different&lt;/li&gt;
  &lt;li&gt;You can increase (self-)awareness.&lt;/li&gt;
  &lt;li&gt;They provide ways to work more collaboratively by understanding your coworkers.&lt;/li&gt;
  &lt;li&gt;They also provide ways to improve yourself so you can be more effective&lt;/li&gt;
&lt;/ul&gt;

&lt;h3 id=&quot;summary&quot;&gt;Summary&lt;/h3&gt;

&lt;ol&gt;
  &lt;li&gt;The world/reality is complex&lt;/li&gt;
  &lt;li&gt;We’re driven by compression progress&lt;/li&gt;
  &lt;li&gt;Complexity is not free&lt;/li&gt;
  &lt;li&gt;Mental models&lt;/li&gt;
&lt;/ol&gt;

&lt;blockquote&gt;
  &lt;p&gt;Remember, always, that everything you know, and everything everyone knows, is
only a model. Get your model out there where it can be viewed. Invite others
to challenge your assumptions and add their own.&lt;br /&gt;
—Donella H. Meadows&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h3 id=&quot;bibliography&quot;&gt;Bibliography&lt;/h3&gt;

&lt;ul&gt;
  &lt;li&gt;Thinking in Systems: A Primer. &lt;em&gt;Donella H. Meadows&lt;/em&gt;&lt;/li&gt;
  &lt;li&gt;Poor Charlie’s Almanack: The Wit and Wisdom of Charles T. Munger. &lt;em&gt;Charles T. Munger&lt;/em&gt;&lt;/li&gt;
  &lt;li&gt;Sapiens: A Brief History of Humankind. &lt;em&gt;Yuval Noah Harari&lt;/em&gt;&lt;/li&gt;
  &lt;li&gt;The Gene: An Intimate History. &lt;em&gt;Siddhartha Mukherjee&lt;/em&gt;&lt;/li&gt;
  &lt;li&gt;Why Information Grows: The Evolution of Order, from Atoms to Economies. &lt;em&gt;César Hidalgo&lt;/em&gt;&lt;/li&gt;
  &lt;li&gt;Organize for Complexity: How to Get Life Back Into Work to Build the High-Performance Organization. &lt;em&gt;Niels Pflaeging&lt;/em&gt;&lt;/li&gt;
  &lt;li&gt;Antifragile: Things That Gain from Disorder. &lt;em&gt;Nassim Nicholas Taleb&lt;/em&gt;&lt;/li&gt;
  &lt;li&gt;Skin in the Game: Hidden Asymmetries in Daily Life. &lt;em&gt;Nassim Nicholas Taleb&lt;/em&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;div class=&quot;iframe-container iframe-443&quot;&gt;
  &lt;iframe src=&quot;https://www.slideshare.net/slideshow/embed_code/key/bKchRh0iIDMIJO&quot; width=&quot;720&quot; height=&quot;443&quot; frameborder=&quot;0&quot; marginwidth=&quot;0&quot; marginheight=&quot;0&quot; scrolling=&quot;no&quot;&gt;&lt;/iframe&gt;
&lt;/div&gt;

</description>
        <pubDate>Wed, 13 Jun 2018 00:00:00 +0000</pubDate>
        <link>https://arturoherrero.com/mental-models-complexity-and-software/</link>
        <guid isPermaLink="true">https://arturoherrero.com/mental-models-complexity-and-software/</guid>
        
        <category>ideas</category>
        
        
      </item>
    
      <item>
        <title>gvar</title>
        <description>&lt;p&gt;I used to have a problem when setting an environment variable; I couldn’t make
the variable immediately available in a different shell or subshell without the
need to source any file. As a result, I’ve created
&lt;strong&gt;&lt;a href=&quot;https://github.com/arturoherrero/gvar&quot; target=&quot;_blank&quot; rel=&quot;noreferrer&quot;&gt;gvar&lt;/a&gt;&lt;/strong&gt; to solve the problem. This project was
featured on &lt;a href=&quot;http://email.changelog.com/t/t-83CE969FE2428422&quot; target=&quot;_blank&quot; rel=&quot;noreferrer&quot;&gt;issue #109 of Changelog Weekly newsletter&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;http://arturoherrero.github.io/gvar/gvar.1.html&quot;&gt;gvar(1)&lt;/a&gt; – display, set, or remove global variables*.&lt;/p&gt;

&lt;p&gt;&lt;sup&gt;* I define global variable as a key-value pair you can read/write at any time
in any terminal session. This is similar to environment variables because it’s a
set of dynamic-named values but they are not session-wide or system-wide
related.&lt;/sup&gt;&lt;/p&gt;

&lt;p&gt;gvar is a pure Bash key-value store where each user has a different collection
of data. The records are stored in the user’s home directory as &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;~/.gvar&lt;/code&gt; file.&lt;/p&gt;

&lt;p&gt;By working on this project, I’ve used the following tools for the first time.&lt;/p&gt;

&lt;h3 id=&quot;bats&quot;&gt;Bats&lt;/h3&gt;

&lt;p&gt;&lt;a href=&quot;https://github.com/sstephenson/bats/&quot; target=&quot;_blank&quot; rel=&quot;noreferrer&quot;&gt;Bats: Bash Automated Testing System&lt;/a&gt; is a testing
framework for Bash.&lt;/p&gt;

&lt;div class=&quot;language-shell highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;c&quot;&gt;#!/usr/bin/env bats&lt;/span&gt;

@test &lt;span class=&quot;s2&quot;&gt;&quot;invoking gvar VARIABLE prints the value of the global variable&quot;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
  run &lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$gvar&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt; TEST
  &lt;span class=&quot;o&quot;&gt;[&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$status&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-eq&lt;/span&gt; 0 &lt;span class=&quot;o&quot;&gt;]&lt;/span&gt;
  &lt;span class=&quot;o&quot;&gt;[&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$output&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;test&quot;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;]&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h4 id=&quot;bats-with-travis-ci&quot;&gt;Bats with Travis CI&lt;/h4&gt;

&lt;p&gt;I usually test my open source projects with Travis CI, but in this case we have
to install Bats, which is not included in the default environment. Here’s my
&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;.travis.yml&lt;/code&gt; file.&lt;/p&gt;

&lt;div class=&quot;language-yaml highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;na&quot;&gt;language&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;bash&lt;/span&gt;
&lt;span class=&quot;na&quot;&gt;before_install&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
  &lt;span class=&quot;pi&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;sudo add-apt-repository ppa:duggan/bats --yes&lt;/span&gt;
  &lt;span class=&quot;pi&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;sudo apt-get update -qq&lt;/span&gt;
  &lt;span class=&quot;pi&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;sudo apt-get install -qq bats&lt;/span&gt;
&lt;span class=&quot;na&quot;&gt;script&lt;/span&gt;&lt;span class=&quot;pi&quot;&gt;:&lt;/span&gt;
  &lt;span class=&quot;pi&quot;&gt;-&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;bats test/gvar.bats&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h3 id=&quot;ronn&quot;&gt;Ronn&lt;/h3&gt;

&lt;p&gt;I was building a command line tool, so I created a man page documenting it.&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;http://rtomayko.github.io/ronn/&quot; target=&quot;_blank&quot; rel=&quot;noreferrer&quot;&gt;Ronn&lt;/a&gt; builds manuals. It converts simple,
human readable textfiles—&lt;em&gt;markdown-like&lt;/em&gt;—to roff for terminal display, and
also to HTML for the web.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/assets/images/posts/gvar-man-page.jpg&quot; alt=&quot;gvar man page&quot; /&gt;&lt;/p&gt;

&lt;h3 id=&quot;shellcheck&quot;&gt;ShellCheck&lt;/h3&gt;

&lt;p&gt;&lt;a href=&quot;http://www.shellcheck.net/&quot; target=&quot;_blank&quot; rel=&quot;noreferrer&quot;&gt;ShellCheck&lt;/a&gt; is a static analysis tool for shell scripts.
Since I like to use Code Climate with my projects, ShellCheck gives warnings
and suggestions for bash/sh shell scripts.&lt;/p&gt;

&lt;h3 id=&quot;homebrew-formulae&quot;&gt;Homebrew formulae&lt;/h3&gt;

&lt;p&gt;The last thing I did was my own &lt;a href=&quot;https://github.com/arturoherrero/homebrew-formulae&quot; target=&quot;_blank&quot; rel=&quot;noreferrer&quot;&gt;Homebrew formulae for my packages&lt;/a&gt;.
Now, I can install gvar on OS X without any pain.&lt;/p&gt;

&lt;div class=&quot;language-shell highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;brew tap arturoherrero/formulae
&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;brew &lt;span class=&quot;nb&quot;&gt;install &lt;/span&gt;gvar
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

</description>
        <pubDate>Sat, 28 May 2016 00:00:00 +0000</pubDate>
        <link>https://arturoherrero.com/gvar/</link>
        <guid isPermaLink="true">https://arturoherrero.com/gvar/</guid>
        
        <category>programming</category>
        
        
      </item>
    
      <item>
        <title>Powercore</title>
        <description>&lt;p&gt;During the last few weeks, I have been working on &lt;strong&gt;&lt;a href=&quot;https://github.com/arturoherrero/powercore&quot; target=&quot;_blank&quot; rel=&quot;noreferrer&quot;&gt;PowerCore&lt;/a&gt;&lt;/strong&gt;,
which enhances the Ruby Core with useful extensions. This project was featured on
&lt;a href=&quot;http://rubyweekly.com/issues/293&quot; target=&quot;_blank&quot; rel=&quot;noreferrer&quot;&gt;issue #293 of Ruby Weekly newsletter&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;There are Ruby gems that do something similar, such as
&lt;a href=&quot;http://edgeguides.rubyonrails.org/active_support_core_extensions.html&quot; target=&quot;_blank&quot; rel=&quot;noreferrer&quot;&gt;Active Support Core Extensions&lt;/a&gt; or &lt;a href=&quot;https://github.com/bbatsov/powerpack&quot; target=&quot;_blank&quot; rel=&quot;noreferrer&quot;&gt;Powerpack&lt;/a&gt;.
In this case, this is just a collection of extensions for reference, &lt;em&gt;not&lt;/em&gt; a
Ruby gem. Who wants a new dependency in the code base? Just borrow the code
that you consider useful, but be careful;&lt;/p&gt;

&lt;p&gt;…most of the time I have created new methods:&lt;/p&gt;

&lt;div class=&quot;language-ruby highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;s2&quot;&gt;&quot;abc&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;first&lt;/span&gt;  &lt;span class=&quot;c1&quot;&gt;# =&amp;gt; &quot;a&quot;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;…but sometimes I have overridden the default Ruby implementation:&lt;/p&gt;

&lt;div class=&quot;language-ruby highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;3&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;4&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;].&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;take&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;  &lt;span class=&quot;c1&quot;&gt;# =&amp;gt; [3, 4]&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;…or even worse, I have removed Ruby methods to do some tricks:&lt;/p&gt;

&lt;div class=&quot;language-ruby highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;3&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;|&lt;/span&gt;
  &lt;span class=&quot;o&quot;&gt;-&amp;gt;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;array&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;  &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;array&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;first&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;|&lt;/span&gt;
  &lt;span class=&quot;o&quot;&gt;-&amp;gt;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;int&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;    &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;int&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;to_s&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;|&lt;/span&gt;
  &lt;span class=&quot;o&quot;&gt;-&amp;gt;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;string&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;string&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;2&quot;&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;c1&quot;&gt;# =&amp;gt; &quot;12&quot;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

</description>
        <pubDate>Tue, 05 Apr 2016 00:00:00 +0000</pubDate>
        <link>https://arturoherrero.com/powercore/</link>
        <guid isPermaLink="true">https://arturoherrero.com/powercore/</guid>
        
        <category>programming</category>
        
        
      </item>
    
      <item>
        <title>Organizing my photos with a shell script</title>
        <description>&lt;p&gt;I’ve been taking a lot of pictures since last year. As a consequence of my
newly acquired hobby, I now have tens of gigabytes of data stored on my
computer. I decided to organize and store all those files in a remote hard
drive.&lt;/p&gt;

&lt;p&gt;My plan was to organize my photo library by using the EXIF data stored in each
file, following this structure: &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;YYYY/MM/Photographs&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;This is my current directory:&lt;/p&gt;

&lt;div class=&quot;language-shell highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;tree
&lt;span class=&quot;nb&quot;&gt;.&lt;/span&gt;
├── IMG_3039.JPG
├── IMG_3383.jpg
└── IMG_3909.JPG
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Here is how I’d like to structure it:&lt;/p&gt;

&lt;div class=&quot;language-shell highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;tree
&lt;span class=&quot;nb&quot;&gt;.&lt;/span&gt;
├── 2015
│   └── 09
│       └── IMG_3039.JPG
└── 2016
    ├── 01
    │   └── IMG_3383.jpg
    └── 03
        └── IMG_3909.JPG
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Finally, the shell script that’s going to do the job:&lt;/p&gt;

&lt;div class=&quot;language-shell highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;c&quot;&gt;#!/usr/bin/env bash&lt;/span&gt;

&lt;span class=&quot;nb&quot;&gt;shopt&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-s&lt;/span&gt; nocaseglob

&lt;span class=&quot;k&quot;&gt;for &lt;/span&gt;file &lt;span class=&quot;k&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;*&lt;/span&gt;.jpg&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;do
  &lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;dir&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;$(&lt;/span&gt;identify &lt;span class=&quot;nt&quot;&gt;-format&lt;/span&gt; %[exif:DateTime] &lt;span class=&quot;nv&quot;&gt;$file&lt;/span&gt; | &lt;span class=&quot;nb&quot;&gt;cut&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-d&lt;/span&gt;: &lt;span class=&quot;nt&quot;&gt;-f1&lt;/span&gt;,2 | &lt;span class=&quot;nb&quot;&gt;tr&lt;/span&gt; : /&lt;span class=&quot;si&quot;&gt;)&lt;/span&gt;
  &lt;span class=&quot;nb&quot;&gt;mkdir&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-p&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;$dir&lt;/span&gt;
  &lt;span class=&quot;nb&quot;&gt;mv&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;$file&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;$dir&lt;/span&gt;/&lt;span class=&quot;nv&quot;&gt;$file&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;done

&lt;/span&gt;rsync &lt;span class=&quot;nt&quot;&gt;-rh&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;--progress&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;--stats&lt;/span&gt; ./ remote:/media/Photos
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
</description>
        <pubDate>Mon, 21 Mar 2016 00:00:00 +0000</pubDate>
        <link>https://arturoherrero.com/organizing-my-photos-with-a-shell-script/</link>
        <guid isPermaLink="true">https://arturoherrero.com/organizing-my-photos-with-a-shell-script/</guid>
        
        <category>programming</category>
        
        
      </item>
    
      <item>
        <title>Agile For Non Developers</title>
        <description>&lt;p&gt;Agile methodology is an alternative to traditional project management,
typically used in software development. This collaborative approach between
self-organizing and cross-functional teams could be valid for other non-software
teams, or even your personal life.&lt;/p&gt;

&lt;p&gt;I gave a talk about applying Agile methodology beyond software development at
the Mastered Summer Event. These are the slides.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/assets/images/posts/agile-for-non-developers.jpg&quot; alt=&quot;agile&quot; /&gt;&lt;/p&gt;

</description>
        <pubDate>Mon, 17 Aug 2015 00:00:00 +0000</pubDate>
        <link>https://arturoherrero.com/agile-for-non-developers/</link>
        <guid isPermaLink="true">https://arturoherrero.com/agile-for-non-developers/</guid>
        
        <category>projects</category>
        
        
      </item>
    
      <item>
        <title>OpenFastStruct</title>
        <description>&lt;p&gt;After having a lot of fun building &lt;a href=&quot;/yarr-yet-another-ruby-repl/&quot;&gt;YARR&lt;/a&gt;, I have built a new Ruby gem.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;a href=&quot;https://github.com/arturoherrero/ofstruct&quot; target=&quot;_blank&quot; rel=&quot;noreferrer&quot;&gt;OpenFastStruct&lt;/a&gt;&lt;/strong&gt; is a
data structure, similar to an OpenStruct, that allows the definition of
arbitrary attributes with their accompanying values. It benchmarks ~3x slower
than a Hash, but &lt;strong&gt;it’s ~4x faster than OpenStruct&lt;/strong&gt;. It’s faster because it
uses simple hash storage with &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;method_missing&lt;/code&gt; instead of expensive
&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;define_method&lt;/code&gt; calls.&lt;/p&gt;

&lt;p&gt;The project was featured on &lt;a href=&quot;http://rubyweekly.com/issues/239&quot; target=&quot;_blank&quot; rel=&quot;noreferrer&quot;&gt;issue #239 of Ruby Weekly newsletter&lt;/a&gt;
and was a Ruby trending repository on GitHub for two days.&lt;/p&gt;

&lt;h3 id=&quot;examples&quot;&gt;Examples&lt;/h3&gt;

&lt;h4 id=&quot;basic-usage&quot;&gt;Basic usage&lt;/h4&gt;

&lt;div class=&quot;language-ruby highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nb&quot;&gt;require&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;ofstruct&quot;&lt;/span&gt;

&lt;span class=&quot;n&quot;&gt;person&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;no&quot;&gt;OpenFastStruct&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;new&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;person&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;name&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;John Smith&quot;&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;person&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;age&lt;/span&gt;  &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;70&lt;/span&gt;

&lt;span class=&quot;nb&quot;&gt;puts&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;person&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;name&lt;/span&gt;     &lt;span class=&quot;c1&quot;&gt;# -&amp;gt; &quot;John Smith&quot;&lt;/span&gt;
&lt;span class=&quot;nb&quot;&gt;puts&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;person&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;age&lt;/span&gt;      &lt;span class=&quot;c1&quot;&gt;# -&amp;gt; 70&lt;/span&gt;
&lt;span class=&quot;nb&quot;&gt;puts&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;person&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;address&lt;/span&gt;  &lt;span class=&quot;c1&quot;&gt;# -&amp;gt; #&amp;lt;OpenFastStruct&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h4 id=&quot;initialize-and-update-from-a-hash&quot;&gt;Initialize and update from a Hash&lt;/h4&gt;

&lt;p&gt;An OpenFastStruct uses a Hash internally to store the methods and values, and
can even be initialized or updated with one:&lt;/p&gt;

&lt;div class=&quot;language-ruby highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nb&quot;&gt;require&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;ofstruct&quot;&lt;/span&gt;

&lt;span class=&quot;n&quot;&gt;person&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;no&quot;&gt;OpenFastStruct&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;new&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;ss&quot;&gt;:name&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&amp;gt;&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;John Smith&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;nb&quot;&gt;puts&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;person&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;name&lt;/span&gt;  &lt;span class=&quot;c1&quot;&gt;# -&amp;gt; &quot;John Smith&quot;&lt;/span&gt;

&lt;span class=&quot;n&quot;&gt;person&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;update&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;ss&quot;&gt;:name&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&amp;gt;&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;David Smith&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;ss&quot;&gt;:age&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&amp;gt;&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;70&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;nb&quot;&gt;puts&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;person&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;name&lt;/span&gt;  &lt;span class=&quot;c1&quot;&gt;# -&amp;gt; &quot;David Smith&quot;&lt;/span&gt;
&lt;span class=&quot;nb&quot;&gt;puts&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;person&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;age&lt;/span&gt;   &lt;span class=&quot;c1&quot;&gt;# -&amp;gt; 70&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h4 id=&quot;remove-attributes&quot;&gt;Remove attributes&lt;/h4&gt;

&lt;p&gt;Removing the presence of a method requires the execution of the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;#delete_field&lt;/code&gt;
method, which sets the property value to a new empty OpenFastStruct.&lt;/p&gt;

&lt;div class=&quot;language-ruby highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nb&quot;&gt;require&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;ofstruct&quot;&lt;/span&gt;

&lt;span class=&quot;n&quot;&gt;person&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;no&quot;&gt;OpenFastStruct&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;new&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;person&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;name&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;John Smith&quot;&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;person&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;delete_field&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;ss&quot;&gt;:name&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;nb&quot;&gt;puts&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;person&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;name&lt;/span&gt;  &lt;span class=&quot;c1&quot;&gt;# -&amp;gt; #&amp;lt;OpenFastStruct&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h4 id=&quot;black-hole-object&quot;&gt;&lt;em&gt;Black hole&lt;/em&gt; object&lt;/h4&gt;

&lt;p&gt;An OpenFastStruct instance is a &lt;em&gt;black hole&lt;/em&gt; object that supports infinite
chaining of attributes.&lt;/p&gt;

&lt;div class=&quot;language-ruby highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nb&quot;&gt;require&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;ofstruct&quot;&lt;/span&gt;

&lt;span class=&quot;n&quot;&gt;person&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;no&quot;&gt;OpenFastStruct&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;new&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;person&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;address&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;number&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;4&lt;/span&gt;
&lt;span class=&quot;nb&quot;&gt;puts&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;person&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;address&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;number&lt;/span&gt;  &lt;span class=&quot;c1&quot;&gt;# -&amp;gt; 4&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h3 id=&quot;benchmarks&quot;&gt;Benchmarks&lt;/h3&gt;

&lt;p&gt;You probably heard that you should never, ever use OpenStruct because the
performance penalty is prohibitive. You can use OpenFastStruct instead!&lt;/p&gt;

&lt;h4 id=&quot;comparison-between-hash-openfaststruct-and-openstruct&quot;&gt;Comparison between Hash, OpenFastStruct and OpenStruct&lt;/h4&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;Calculating -------------------------------------
                Hash    25.518k i/100ms
      OpenFastStruct    10.527k i/100ms
          OpenStruct     3.236k i/100ms
-------------------------------------------------
                Hash    487.517k (±11.9%) i/s -      2.399M
      OpenFastStruct    159.952k (± 4.0%) i/s -    800.052k
          OpenStruct     45.602k (± 4.7%) i/s -    229.756k

Comparison:
                Hash:   487516.9 i/s
      OpenFastStruct:   159952.4 i/s - 3.05x slower
          OpenStruct:    45601.6 i/s - 10.69x slower
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

</description>
        <pubDate>Thu, 02 Apr 2015 00:00:00 +0000</pubDate>
        <link>https://arturoherrero.com/open-fast-struct/</link>
        <guid isPermaLink="true">https://arturoherrero.com/open-fast-struct/</guid>
        
        <category>programming</category>
        
        
      </item>
    
      <item>
        <title>Intercept-Cache-Invoke pattern</title>
        <description>&lt;p&gt;I heard about the &lt;strong&gt;Intercept-Cache-Invoke pattern&lt;/strong&gt; for the first time from
&lt;a href=&quot;https://x.com/graemerocher&quot; target=&quot;_blank&quot; rel=&quot;noreferrer&quot;&gt;Graeme Rocher&lt;/a&gt;; he was explaining how he had implemented the dynamic finders on Grails.&lt;/p&gt;

&lt;p&gt;The idea is to dynamically figure out method behavior at invocation time,
so we can create new methods with flexible and dynamic names &lt;em&gt;on-the-fly&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;A synthesized method may not exist as a separate method until we call it. When
we call a nonexistent method, we can intercept the call, allow our
application to implement it on the fly, let us cache that implementation for
future invocation, and then invoke it. The first call takes a performance hit
but the next calls are faster.&lt;/p&gt;

&lt;div class=&quot;language-ruby highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nb&quot;&gt;require&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;benchmark/ips&quot;&lt;/span&gt;

&lt;span class=&quot;k&quot;&gt;class&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;Person&lt;/span&gt;
  &lt;span class=&quot;no&quot;&gt;PLAYS&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;sx&quot;&gt;%w[tennis volley basket]&lt;/span&gt;

  &lt;span class=&quot;k&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;method_missing&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;name&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;args&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;game&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;name&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;to_s&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;split&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;play_&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;).&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;last&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;no&quot;&gt;PLAYS&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;include?&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;game&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
      &lt;span class=&quot;s2&quot;&gt;&quot;playing &lt;/span&gt;&lt;span class=&quot;si&quot;&gt;#{&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;game&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;else&lt;/span&gt;
      &lt;span class=&quot;k&quot;&gt;super&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;end&lt;/span&gt;
  &lt;span class=&quot;k&quot;&gt;end&lt;/span&gt;

  &lt;span class=&quot;k&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;respond_to_missing?&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;name&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;include_private&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;kp&quot;&gt;false&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;game&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;name&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;to_s&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;split&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;play_&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;).&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;last&lt;/span&gt;
    &lt;span class=&quot;no&quot;&gt;PLAYS&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;include?&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;game&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;||&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;super&lt;/span&gt;
  &lt;span class=&quot;k&quot;&gt;end&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;end&lt;/span&gt;

&lt;span class=&quot;k&quot;&gt;class&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;PersonCached&lt;/span&gt;
  &lt;span class=&quot;no&quot;&gt;PLAYS&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;sx&quot;&gt;%w[tennis volley basket]&lt;/span&gt;

  &lt;span class=&quot;k&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;method_missing&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;name&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;args&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;game&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;name&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;to_s&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;split&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;play_&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;).&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;last&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;no&quot;&gt;PLAYS&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;include?&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;game&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
      &lt;span class=&quot;n&quot;&gt;cache_and_invoke&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;name&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;do&lt;/span&gt;
        &lt;span class=&quot;s2&quot;&gt;&quot;playing &lt;/span&gt;&lt;span class=&quot;si&quot;&gt;#{&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;game&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;
      &lt;span class=&quot;k&quot;&gt;end&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;else&lt;/span&gt;
      &lt;span class=&quot;k&quot;&gt;super&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;end&lt;/span&gt;
  &lt;span class=&quot;k&quot;&gt;end&lt;/span&gt;

  &lt;span class=&quot;k&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;cache_and_invoke&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;name&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
    &lt;span class=&quot;nb&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;class&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;class_eval&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;do&lt;/span&gt;
      &lt;span class=&quot;n&quot;&gt;define_method&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;name&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;do&lt;/span&gt;
        &lt;span class=&quot;k&quot;&gt;yield&lt;/span&gt;
      &lt;span class=&quot;k&quot;&gt;end&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;end&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;yield&lt;/span&gt;
  &lt;span class=&quot;k&quot;&gt;end&lt;/span&gt;

  &lt;span class=&quot;k&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;respond_to_missing?&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;name&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;include_private&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;kp&quot;&gt;false&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;game&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;name&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;to_s&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;split&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;play_&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;).&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;last&lt;/span&gt;
    &lt;span class=&quot;no&quot;&gt;PLAYS&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;include?&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;game&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;||&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;super&lt;/span&gt;
  &lt;span class=&quot;k&quot;&gt;end&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;end&lt;/span&gt;

&lt;span class=&quot;no&quot;&gt;Benchmark&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;ips&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;do&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;|&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;x&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;|&lt;/span&gt;
  &lt;span class=&quot;n&quot;&gt;x&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;report&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;Method Missing&quot;&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;do&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;person&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;no&quot;&gt;Person&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;new&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;person&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;play_tennis&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;person&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;play_tennis&lt;/span&gt;
  &lt;span class=&quot;k&quot;&gt;end&lt;/span&gt;

  &lt;span class=&quot;n&quot;&gt;x&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;report&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;Intercept-Cache-Invoke&quot;&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;do&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;person&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;no&quot;&gt;PersonCached&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;new&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;person&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;play_tennis&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;person&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;play_tennis&lt;/span&gt;
  &lt;span class=&quot;k&quot;&gt;end&lt;/span&gt;

  &lt;span class=&quot;n&quot;&gt;x&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;compare!&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;end&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h3 id=&quot;benchmark&quot;&gt;Benchmark&lt;/h3&gt;

&lt;p&gt;It benchmarks about ~2.5x to ~4.5x faster than the method missing version. The
result depends on how the solution has been implemented. For example, here
we are using a block to cache and invoke new methods. Blocks are slow, and their
performance depends on whether we use &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;block.call&lt;/code&gt; or just &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;yield&lt;/code&gt;
&lt;sup&gt;[&lt;a href=&quot;https://github.com/JuanitoFatas/fast-ruby#proccall-and-block-arguments-vs-yieldcode&quot; target=&quot;_blank&quot; rel=&quot;noreferrer&quot;&gt;benchmark&lt;/a&gt;]&lt;/sup&gt;.&lt;/p&gt;

&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;Calculating -------------------------------------
        Method Missing    20.758k i/100ms
Intercept-Cache-Invoke    48.562k i/100ms
-------------------------------------------------
        Method Missing    316.730k (± 8.0%) i/s -      1.578M
Intercept-Cache-Invoke      1.010M (± 5.2%) i/s -      5.050M

Comparison:
Intercept-Cache-Invoke:  1010089.5 i/s
        Method Missing:   316729.8 i/s - 3.19x slower
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

</description>
        <pubDate>Sun, 08 Mar 2015 00:00:00 +0000</pubDate>
        <link>https://arturoherrero.com/intercept-cache-invoke-pattern/</link>
        <guid isPermaLink="true">https://arturoherrero.com/intercept-cache-invoke-pattern/</guid>
        
        <category>programming</category>
        
        
      </item>
    
      <item>
        <title>YARR. Yet Another Ruby REPL</title>
        <description>&lt;p&gt;&lt;strong&gt;&lt;a href=&quot;https://github.com/arturoherrero/yarr/&quot; target=&quot;_blank&quot; rel=&quot;noreferrer&quot;&gt;YARR (Yet Another Ruby REPL)&lt;/a&gt;&lt;/strong&gt; is a
Ruby REPL (it’s just a hobby, it won’t be big and professional like Pry).
YARR was inspired by groovysh&lt;sup&gt;&lt;a href=&quot;https://groovy-lang.org/groovysh.html&quot; target=&quot;_blank&quot; rel=&quot;noreferrer&quot;&gt;1&lt;/a&gt;&lt;/sup&gt;,
IRB&lt;sup&gt;&lt;a href=&quot;https://ruby.github.io/irb/&quot; target=&quot;_blank&quot; rel=&quot;noreferrer&quot;&gt;2&lt;/a&gt;&lt;/sup&gt;, Pry&lt;sup&gt;&lt;a href=&quot;http://pry.github.io/&quot; target=&quot;_blank&quot; rel=&quot;noreferrer&quot;&gt;3&lt;/a&gt;&lt;/sup&gt;, Bash
&lt;sup&gt;&lt;a href=&quot;https://www.gnu.org/software/bash/&quot; target=&quot;_blank&quot; rel=&quot;noreferrer&quot;&gt;4&lt;/a&gt;&lt;/sup&gt; and Vim&lt;sup&gt;&lt;a href=&quot;https://www.vim.org/&quot; target=&quot;_blank&quot; rel=&quot;noreferrer&quot;&gt;5&lt;/a&gt;&lt;/sup&gt;.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/assets/images/posts/yarr.png&quot; alt=&quot;yarr&quot; /&gt;&lt;/p&gt;

&lt;p&gt;A read–eval–print loop (REPL) is an interactive environment that takes user
inputs, evaluates them, and returns the result to the user. A simple
REPL that evaluates single valid lines of Ruby code, could be something like this:&lt;/p&gt;

&lt;div class=&quot;language-ruby highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;kp&quot;&gt;loop&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;do&lt;/span&gt;
  &lt;span class=&quot;nb&quot;&gt;print&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;ruby&amp;gt; &quot;&lt;/span&gt;
  &lt;span class=&quot;n&quot;&gt;input&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;gets&lt;/span&gt;
  &lt;span class=&quot;nb&quot;&gt;puts&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;=&amp;gt; &lt;/span&gt;&lt;span class=&quot;si&quot;&gt;#{&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;eval&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;input&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;end&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;I started to play with this idea and finally I built YARR that is a command-line
application which allows you to easily evaluate Ruby expressions, define classes
and run simple experiments.&lt;/p&gt;

&lt;h3 id=&quot;interesting-things-in-the-source-code&quot;&gt;Interesting things in the source code&lt;/h3&gt;

&lt;p&gt;This project has been a good opportunity to explore new things. I also only
wanted to use the Ruby standard libraries without any external gem.&lt;/p&gt;

&lt;h4 id=&quot;1-method-names-dont-have-restrictions&quot;&gt;1. Method names don’t have restrictions&lt;/h4&gt;

&lt;p&gt;Method names in Ruby may contain upper-case and lower-case letters, numbers,
underscores &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;_&lt;/code&gt; and the punctuation signs &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;!&lt;/code&gt;, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;?&lt;/code&gt;, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;=&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;A method name can’t begin with a number and the characters &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;!&lt;/code&gt;, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;?&lt;/code&gt; and &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;=&lt;/code&gt; can
only appear at the end.&lt;/p&gt;

&lt;p&gt;That’s correct if we use the usual way of defining new methods with &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;def&lt;/code&gt;,
however there seems to be no restrictions on what can be used if we use
&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;define_method&lt;/code&gt; &lt;sup&gt;[&lt;a href=&quot;https://github.com/arturoherrero/yarr/blob/v0.0.1/lib/interpreter.rb#L82-L84&quot; target=&quot;_blank&quot; rel=&quot;noreferrer&quot;&gt;code&lt;/a&gt;]&lt;/sup&gt;.&lt;/p&gt;

&lt;div class=&quot;language-ruby highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;n&quot;&gt;define_method&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;!&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;do&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;|&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;args&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;|&lt;/span&gt;
  &lt;span class=&quot;sb&quot;&gt;`&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;#{&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;args&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;sb&quot;&gt;`&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;end&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h4 id=&quot;2-capture-stdout&quot;&gt;2. Capture STDOUT&lt;/h4&gt;

&lt;p&gt;It’s possible to redirect the standard output or store it into a variable. I
captured the STDOUT for a block of code and then restore it &lt;sup&gt;[&lt;a href=&quot;https://github.com/arturoherrero/yarr/blob/v0.0.1/lib/interpreter.rb#L104-L110&quot; target=&quot;_blank&quot; rel=&quot;noreferrer&quot;&gt;code&lt;/a&gt;]&lt;/sup&gt;.&lt;/p&gt;

&lt;div class=&quot;language-ruby highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;k&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;capture_stdout&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;block&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
  &lt;span class=&quot;n&quot;&gt;stdout&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;vg&quot;&gt;$stdout&lt;/span&gt;
  &lt;span class=&quot;vg&quot;&gt;$stdout&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;no&quot;&gt;StringIO&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;new&lt;/span&gt;
  &lt;span class=&quot;n&quot;&gt;block&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;call&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;ensure&lt;/span&gt;
  &lt;span class=&quot;vg&quot;&gt;$stdout&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;stdout&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;end&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h4 id=&quot;3-arrange-act-assert-pattern&quot;&gt;3. Arrange-Act-Assert pattern&lt;/h4&gt;

&lt;p&gt;Arrange-Act-Assert is a pattern for arranging and formatting code in test methods.
It is very popular from the Given-When-Then style of representing tests.&lt;/p&gt;

&lt;p&gt;I used the RSpec syntax with some private methods, so each method should group
these functional sections &lt;sup&gt;[&lt;a href=&quot;https://github.com/arturoherrero/yarr/blob/v0.0.1/spec/lib/interpreter_spec.rb#L22-L26&quot; target=&quot;_blank&quot; rel=&quot;noreferrer&quot;&gt;code&lt;/a&gt;]&lt;/sup&gt;:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Arrange all necessary preconditions and inputs (&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;setup&lt;/code&gt;).&lt;/li&gt;
  &lt;li&gt;Act on the object or method under test (&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;given&lt;/code&gt;).&lt;/li&gt;
  &lt;li&gt;Assert that the expected results have occurred (&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;expect&lt;/code&gt;).&lt;/li&gt;
&lt;/ul&gt;

&lt;div class=&quot;language-ruby highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;n&quot;&gt;it&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;executes multiline line declaration and invocation&quot;&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;do&lt;/span&gt;
  &lt;span class=&quot;n&quot;&gt;setup&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;def foo&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;1&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;end&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
  &lt;span class=&quot;n&quot;&gt;given&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;foo&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
  &lt;span class=&quot;n&quot;&gt;expect&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;interpreter&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;call&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;).&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;to&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;eq&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\e&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;[1m===&amp;gt;&lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\e&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;[0m 1&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;end&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

</description>
        <pubDate>Mon, 23 Feb 2015 00:00:00 +0000</pubDate>
        <link>https://arturoherrero.com/yarr-yet-another-ruby-repl/</link>
        <guid isPermaLink="true">https://arturoherrero.com/yarr-yet-another-ruby-repl/</guid>
        
        <category>projects</category>
        
        
      </item>
    
      <item>
        <title>Closure design patterns. Ruby edition</title>
        <description>&lt;p&gt;Back in 2012 I wrote an article about &lt;strong&gt;&lt;a href=&quot;/closure-design-patterns/&quot;&gt;closure design patterns&lt;/a&gt;&lt;/strong&gt;. I used
Groovy as a programming language but now I have decided to use Ruby (the
programming language that I have mainly been using for two years). This article
was featured on &lt;a href=&quot;http://rubyweekly.com/issues/231&quot; target=&quot;_blank&quot; rel=&quot;noreferrer&quot;&gt;issue #231 of Ruby Weekly newsletter&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;I want to keep the same examples, so I have created a helper method to make
assertions.&lt;/p&gt;

&lt;div class=&quot;language-ruby highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;k&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;assert&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;expression&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
  &lt;span class=&quot;k&quot;&gt;raise&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;Assertion failed&quot;&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;unless&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;expression&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;end&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h4 id=&quot;execute-around-method&quot;&gt;Execute Around Method&lt;/h4&gt;

&lt;p&gt;A pair of operations that need to be performed before and after operations.&lt;/p&gt;

&lt;div class=&quot;language-ruby highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;k&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;operations&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;block&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
  &lt;span class=&quot;nb&quot;&gt;puts&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;Open&quot;&lt;/span&gt;
  &lt;span class=&quot;n&quot;&gt;block&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;call&lt;/span&gt;
  &lt;span class=&quot;nb&quot;&gt;puts&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;Close&quot;&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;end&lt;/span&gt;

&lt;span class=&quot;n&quot;&gt;operations&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;puts&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;Operation&quot;&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;

&lt;span class=&quot;o&quot;&gt;=&amp;gt;&lt;/span&gt; &lt;span class=&quot;no&quot;&gt;Open&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;=&amp;gt;&lt;/span&gt; &lt;span class=&quot;no&quot;&gt;Operation&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;=&amp;gt;&lt;/span&gt; &lt;span class=&quot;no&quot;&gt;Close&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h4 id=&quot;pluggable-behavior&quot;&gt;Pluggable Behavior&lt;/h4&gt;

&lt;p&gt;Specifies the behavior of an object at runtime.&lt;/p&gt;

&lt;div class=&quot;language-ruby highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;k&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;select_values&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;number&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;block&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
  &lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;upto&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;number&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;).&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;select&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;block&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;end&lt;/span&gt;

&lt;span class=&quot;n&quot;&gt;assert&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;4&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;6&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;8&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;10&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;==&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;select_values&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;10&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;|&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;i&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;|&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;i&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;%&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;2&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;==&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;  &lt;span class=&quot;c1&quot;&gt;# even&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;assert&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;3&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;5&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;7&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;9&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt;  &lt;span class=&quot;o&quot;&gt;==&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;select_values&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;10&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;|&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;i&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;|&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;i&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;%&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;2&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;!=&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;  &lt;span class=&quot;c1&quot;&gt;# odd&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h4 id=&quot;iterator-pattern&quot;&gt;Iterator Pattern&lt;/h4&gt;

&lt;p&gt;Allows sequential access to the elements.&lt;/p&gt;

&lt;div class=&quot;language-ruby highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;k&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;list_numbers&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;block&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
  &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;..&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;3&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;).&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;each&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;block&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;end&lt;/span&gt;

&lt;span class=&quot;n&quot;&gt;list_numbers&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;do&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;|&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;i&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;|&lt;/span&gt;
  &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;i&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;2&lt;/span&gt;
    &lt;span class=&quot;nb&quot;&gt;puts&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;#{&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;i&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt; is a little number&quot;&lt;/span&gt;
  &lt;span class=&quot;k&quot;&gt;else&lt;/span&gt;
    &lt;span class=&quot;nb&quot;&gt;puts&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;#{&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;i&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt; is a big number&quot;&lt;/span&gt;
  &lt;span class=&quot;k&quot;&gt;end&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;end&lt;/span&gt;

&lt;span class=&quot;o&quot;&gt;=&amp;gt;&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;is&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;a&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;little&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;number&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;=&amp;gt;&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;is&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;a&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;little&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;number&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;=&amp;gt;&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;2&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;is&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;a&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;big&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;number&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;=&amp;gt;&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;3&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;is&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;a&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;big&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;number&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h4 id=&quot;dynamical-conditional-execution&quot;&gt;Dynamical Conditional Execution&lt;/h4&gt;

&lt;p&gt;Creates and executes a conditional operation.&lt;/p&gt;

&lt;div class=&quot;language-ruby highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;k&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;greet&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;user&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;success_block&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;fail_block&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
  &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;user&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;is_admin?&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;success_block&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;call&lt;/span&gt;
  &lt;span class=&quot;k&quot;&gt;else&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;fail_block&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;call&lt;/span&gt;
  &lt;span class=&quot;k&quot;&gt;end&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;end&lt;/span&gt;

&lt;span class=&quot;n&quot;&gt;greet&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;user&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;-&amp;gt;&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;puts&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;Hi Admin!&quot;&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;},&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;-&amp;gt;&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;puts&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;Hello User&quot;&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;})&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h4 id=&quot;template-method-pattern&quot;&gt;Template Method Pattern&lt;/h4&gt;

&lt;p&gt;Defines common algorithm steps (getting a customer) and customizations (passed
as a block).&lt;/p&gt;

&lt;div class=&quot;language-ruby highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;k&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;with_customer&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;id&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;block&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
  &lt;span class=&quot;n&quot;&gt;customer&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;get_customer&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;id&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
  &lt;span class=&quot;n&quot;&gt;block&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;call&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;customer&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;end&lt;/span&gt;

&lt;span class=&quot;n&quot;&gt;with_customer&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1234&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;do&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;|&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;customer&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;|&lt;/span&gt;
  &lt;span class=&quot;nb&quot;&gt;puts&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;Found customer &lt;/span&gt;&lt;span class=&quot;si&quot;&gt;#{&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;customer&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;name&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;end&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h4 id=&quot;loan-pattern&quot;&gt;Loan Pattern&lt;/h4&gt;

&lt;p&gt;Ensures that a resource is deterministically disposed of once it goes out of scope.&lt;/p&gt;

&lt;div class=&quot;language-ruby highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;k&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;with_list_of_words_for_each_line&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;file&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;block&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
  &lt;span class=&quot;no&quot;&gt;File&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;open&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;file&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;do&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;|&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;f&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;|&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;f&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;each_line&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;|&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;line&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;|&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;block&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;call&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;line&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;split&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;&apos; &apos;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;))&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
  &lt;span class=&quot;k&quot;&gt;end&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;end&lt;/span&gt;

&lt;span class=&quot;n&quot;&gt;with_list_of_words_for_each_line&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;file&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;do&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;|&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;word_list&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;|&lt;/span&gt;
  &lt;span class=&quot;nb&quot;&gt;puts&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;word_list&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;end&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h4 id=&quot;command-design-pattern&quot;&gt;Command Design Pattern&lt;/h4&gt;

&lt;p&gt;Encapsulates all the information needed to call a method at a later time.&lt;/p&gt;

&lt;div class=&quot;language-ruby highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;n&quot;&gt;count&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;commands&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;[]&lt;/span&gt;

&lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;upto&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;10&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;do&lt;/span&gt;
  &lt;span class=&quot;n&quot;&gt;commands&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;-&amp;gt;&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;count&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+=&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;end&lt;/span&gt;

&lt;span class=&quot;nb&quot;&gt;puts&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;count is initially &lt;/span&gt;&lt;span class=&quot;si&quot;&gt;#{&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;count&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;commands&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;each&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;do&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;|&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;cmd&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;|&lt;/span&gt;
  &lt;span class=&quot;n&quot;&gt;cmd&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;call&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;end&lt;/span&gt;
&lt;span class=&quot;nb&quot;&gt;puts&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;did all commands, count is &lt;/span&gt;&lt;span class=&quot;si&quot;&gt;#{&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;count&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;

&lt;span class=&quot;o&quot;&gt;=&amp;gt;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;count&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;is&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;initially&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;=&amp;gt;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;did&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;all&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;commands&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;count&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;is&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;10&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h4 id=&quot;strategy-pattern&quot;&gt;Strategy Pattern&lt;/h4&gt;

&lt;p&gt;Defines a family of interchangeable algorithms.&lt;/p&gt;

&lt;div class=&quot;language-ruby highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;n&quot;&gt;calc_mult&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;-&amp;gt;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;n&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;m&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;n&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;*&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;m&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;calc_adds&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;-&amp;gt;&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;n&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;m&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;do&lt;/span&gt;
  &lt;span class=&quot;n&quot;&gt;result&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;
  &lt;span class=&quot;n&quot;&gt;n&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;times&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;result&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;m&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
  &lt;span class=&quot;n&quot;&gt;result&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;end&lt;/span&gt;

&lt;span class=&quot;n&quot;&gt;calc_strategies&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;calc_mult&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;calc_adds&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;calc_strategies&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;each&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;do&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;|&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;calc&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;|&lt;/span&gt;
  &lt;span class=&quot;n&quot;&gt;assert&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;10&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;==&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;calc&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;call&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;5&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;end&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h4 id=&quot;factory-pattern&quot;&gt;Factory Pattern&lt;/h4&gt;

&lt;p&gt;Abstracts the object creation process (currying as a function factory).&lt;/p&gt;

&lt;div class=&quot;language-ruby highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;n&quot;&gt;adder&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;-&amp;gt;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;x&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;y&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;x&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;y&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;}.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;curry&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;incrementer&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;adder&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;call&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;

&lt;span class=&quot;n&quot;&gt;assert&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;5&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;==&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;incrementer&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;call&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;4&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h4 id=&quot;method-combination&quot;&gt;Method Combination&lt;/h4&gt;

&lt;p&gt;Builds a method from components.&lt;/p&gt;

&lt;div class=&quot;language-ruby highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;n&quot;&gt;sum&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;-&amp;gt;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;collection&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;collection&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;inject&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(:&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;+&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;first2&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;-&amp;gt;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;collection&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;collection&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;take&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;take2_and_add&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;-&amp;gt;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;collection&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;sum&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;call&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;first2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;call&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;collection&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;))&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;

&lt;span class=&quot;n&quot;&gt;assert&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;3&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;==&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;take2_and_add&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;call&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;([&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;3&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;4&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;5&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;])&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h4 id=&quot;closure-composition&quot;&gt;Closure Composition&lt;/h4&gt;

&lt;p&gt;Since Ruby doesn’t have closure composition I’d like to update my previous
example with it.&lt;/p&gt;

&lt;div class=&quot;language-ruby highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;k&quot;&gt;class&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;Proc&lt;/span&gt;
  &lt;span class=&quot;k&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;&amp;gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;f&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
    &lt;span class=&quot;o&quot;&gt;-&amp;gt;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;args&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;f&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;call&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;call&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;args&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;))&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
  &lt;span class=&quot;k&quot;&gt;end&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;end&lt;/span&gt;

&lt;span class=&quot;n&quot;&gt;sum&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;-&amp;gt;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;collection&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;collection&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;inject&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(:&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;+&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;first2&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;-&amp;gt;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;collection&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;collection&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;take&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;take2_and_add&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;first2&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;sum&lt;/span&gt;

&lt;span class=&quot;n&quot;&gt;assert&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;3&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;==&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;take2_and_add&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;call&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;([&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;3&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;4&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;5&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;])&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

</description>
        <pubDate>Mon, 26 Jan 2015 00:00:00 +0000</pubDate>
        <link>https://arturoherrero.com/closure-design-patterns-ruby-edition/</link>
        <guid isPermaLink="true">https://arturoherrero.com/closure-design-patterns-ruby-edition/</guid>
        
        <category>programming</category>
        
        
      </item>
    
      <item>
        <title>Command line one-liners</title>
        <description>&lt;p&gt;I attended the &lt;a href=&quot;http://socratesuk.org/&quot; target=&quot;_blank&quot; rel=&quot;noreferrer&quot;&gt;SoCraTes UK 2013&lt;/a&gt; unconference.
We had a space for lightning talks and I did a presentation about command line one-liners.&lt;/p&gt;

&lt;p&gt;I love Unix and I talked about terminal commands so I used &lt;a href=&quot;https://github.com/fxn/tkn&quot; target=&quot;_blank&quot; rel=&quot;noreferrer&quot;&gt;Terminal Keynote&lt;/a&gt;,
a hack for terminal-based talks.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/assets/images/posts/command-line-one-liners.png&quot; alt=&quot;Terminal Keynote&quot; /&gt;&lt;/p&gt;

&lt;h2 id=&quot;command-line-one-liners&quot;&gt;Command line one-liners&lt;/h2&gt;

&lt;p&gt;Run the last command&lt;/p&gt;

&lt;div class=&quot;language-shell highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;&lt;span class=&quot;o&quot;&gt;!!&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Run the last command as root&lt;/p&gt;

&lt;div class=&quot;language-shell highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;sudo&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;!!&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Create a script of the last executed command&lt;/p&gt;

&lt;div class=&quot;language-shell highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;echo&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;!!&quot;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt; script.sh
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Reuse all parameters of the previous command line&lt;/p&gt;

&lt;div class=&quot;language-shell highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;echo cd&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;.&lt;/span&gt;
&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;&lt;span class=&quot;o&quot;&gt;!&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;*&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Run the last command with some argument&lt;/p&gt;

&lt;div class=&quot;language-shell highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;echo &lt;/span&gt;a b c d e
&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;echo&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;!!&lt;/span&gt;:2
&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;echo&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;!!&lt;/span&gt;:3-&lt;span class=&quot;err&quot;&gt;$&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Insert the last argument of the previous command&lt;/p&gt;

&lt;div class=&quot;language-shell highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;cp &lt;/span&gt;script.sh /usr/bin/
&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;cd&lt;/span&gt; &amp;lt;ESC&amp;gt; &lt;span class=&quot;nb&quot;&gt;.&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Run previous command but replacing&lt;/p&gt;

&lt;div class=&quot;language-shell highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;echo &lt;/span&gt;no typos
&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;^typos^errors
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Escape any command aliases&lt;/p&gt;

&lt;div class=&quot;language-shell highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;alias ls&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;ls -a&quot;&lt;/span&gt;
&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;&lt;span class=&quot;se&quot;&gt;\l&lt;/span&gt;s
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Quickly rename a file&lt;/p&gt;

&lt;div class=&quot;language-shell highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;mv &lt;/span&gt;filename.&lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;old,new&lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;mv &lt;/span&gt;filename.&lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;png,jpg&lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Create a quick back-up copy of a file&lt;/p&gt;

&lt;div class=&quot;language-shell highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;cp &lt;/span&gt;file.txt&lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;,.bak&lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Run a command from the history&lt;/p&gt;

&lt;div class=&quot;language-shell highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;history&lt;/span&gt;
 ...
 1225  &lt;span class=&quot;nb&quot;&gt;ls&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-l&lt;/span&gt;
 1226  git status
 1227  &lt;span class=&quot;nb&quot;&gt;history&lt;/span&gt;
&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;&lt;span class=&quot;o&quot;&gt;!&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;-3&lt;/span&gt;
&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;&lt;span class=&quot;o&quot;&gt;!&lt;/span&gt;1225
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Search the history for the most recent command beginning with ‘text’&lt;/p&gt;

&lt;div class=&quot;language-shell highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;&lt;span class=&quot;o&quot;&gt;!&lt;/span&gt;text
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;List of commands you use most often&lt;/p&gt;

&lt;div class=&quot;language-shell highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;history&lt;/span&gt; | &lt;span class=&quot;nb&quot;&gt;awk&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;&apos;{print $2}&apos;&lt;/span&gt; | &lt;span class=&quot;nb&quot;&gt;sort&lt;/span&gt; | &lt;span class=&quot;nb&quot;&gt;uniq&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-c&lt;/span&gt; | &lt;span class=&quot;nb&quot;&gt;sort&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-rn&lt;/span&gt; | &lt;span class=&quot;nb&quot;&gt;head&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Execute a command without saving it in the history&lt;/p&gt;

&lt;div class=&quot;language-shell highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;&amp;lt;space&amp;gt;command
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Make directory including intermediate directories&lt;/p&gt;

&lt;div class=&quot;language-shell highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;mkdir&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-p&lt;/span&gt; a/long/directory/path
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Create a directory and change into it&lt;/p&gt;

&lt;div class=&quot;language-shell highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;mkdir dir&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;cd&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;$_&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Change to the previous working directory&lt;/p&gt;

&lt;div class=&quot;language-shell highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;cd&lt;/span&gt; -
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Jump to a directory. Execute a command. Jump back to current directory&lt;/p&gt;

&lt;div class=&quot;language-shell highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;cd&lt;/span&gt; /tmp &lt;span class=&quot;o&quot;&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;ls&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Create simple text file from command line&lt;/p&gt;

&lt;div class=&quot;language-shell highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;cat&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt; file.txt
&lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;your text here&lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;your text here&lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;
&amp;lt;ctrl-d&amp;gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Empty a file&lt;/p&gt;

&lt;div class=&quot;language-shell highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt; file.txt
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Show PATH in a human-readable way&lt;/p&gt;

&lt;div class=&quot;language-shell highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;echo&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;$PATH&lt;/span&gt; | &lt;span class=&quot;nb&quot;&gt;tr&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;&apos;:&apos;&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;&apos;\n&apos;&lt;/span&gt;
&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;tr&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;&apos;:&apos;&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;&apos;\n&apos;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;lt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;$PATH&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Make ‘less’ behave like ‘tail -f’&lt;/p&gt;

&lt;div class=&quot;language-shell highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;less +F somelogfile
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Redirect standard input to a file. Print it to standard output&lt;/p&gt;

&lt;div class=&quot;language-shell highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;command&lt;/span&gt; | &lt;span class=&quot;nb&quot;&gt;tee &lt;/span&gt;file.txt | less

┌─────────┐  ┌─────────┐  ┌─────────┐
│ &lt;span class=&quot;nb&quot;&gt;command&lt;/span&gt; │─▸│   &lt;span class=&quot;nb&quot;&gt;tee&lt;/span&gt;   │─▸│ stdout  │
└─────────┘  └────┬────┘  └─────────┘
                  │
                  ▾
            ┌───────────┐
            │   file    │
            └───────────┘
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Search for a &lt;pattern&gt; string inside all files in the current directory&lt;/pattern&gt;&lt;/p&gt;

&lt;div class=&quot;language-shell highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;grep&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-RnsI&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;--color&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;auto &amp;lt;pattern&amp;gt; &lt;span class=&quot;k&quot;&gt;*&lt;/span&gt;
&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;ack &amp;lt;pattern&amp;gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Recursively remove all empty directories&lt;/p&gt;

&lt;div class=&quot;language-shell highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;find &lt;span class=&quot;nb&quot;&gt;.&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-type&lt;/span&gt; d &lt;span class=&quot;nt&quot;&gt;-empty&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-delete&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Count your commits&lt;/p&gt;

&lt;div class=&quot;language-shell highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;git shortlog &lt;span class=&quot;nt&quot;&gt;-sn&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Serve current directory tree at http://$HOSTNAME:8000/&lt;/p&gt;

&lt;div class=&quot;language-shell highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;python &lt;span class=&quot;nt&quot;&gt;-m&lt;/span&gt; SimpleHTTPServer
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Share a file between two computers&lt;/p&gt;

&lt;div class=&quot;language-shell highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;nc &lt;span class=&quot;nt&quot;&gt;-l&lt;/span&gt; 5566 &lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt; data-dump.sql
&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;nc &amp;lt;his-ip-address&amp;gt; 5566 &amp;lt; data-dump.sql
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Download an entire website&lt;/p&gt;

&lt;div class=&quot;language-shell highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;wget &lt;span class=&quot;nt&quot;&gt;-m&lt;/span&gt; http://website.com
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Clear the terminal screen&lt;/p&gt;

&lt;div class=&quot;language-shell highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&amp;lt;ctrl-l&amp;gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Salvage a borked terminal&lt;/p&gt;

&lt;div class=&quot;language-shell highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;reset
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Close shell keeping all subprocess running&lt;/p&gt;

&lt;div class=&quot;language-shell highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;disown&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-a&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;exit&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Run a command immune to hangups&lt;/p&gt;

&lt;div class=&quot;language-shell highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;nohup command&lt;/span&gt; &amp;amp;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Attach screen over ssh&lt;/p&gt;

&lt;div class=&quot;language-shell highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;ssh user@host &lt;span class=&quot;nt&quot;&gt;-t&lt;/span&gt; screen &lt;span class=&quot;nt&quot;&gt;-r&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Compare a remote file with a local file&lt;/p&gt;

&lt;div class=&quot;language-shell highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;ssh user@host &lt;span class=&quot;nb&quot;&gt;cat&lt;/span&gt; /path/to/remotefile | diff /path/to/localfile -
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Get your public IP address&lt;/p&gt;

&lt;div class=&quot;language-shell highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;curl ifconfig.me
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Set audible alarm when an IP address comes online&lt;/p&gt;

&lt;div class=&quot;language-shell highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;ping &lt;span class=&quot;nt&quot;&gt;-a&lt;/span&gt; IP_address
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;List programs with open ports and connections&lt;/p&gt;

&lt;div class=&quot;language-shell highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;lsof &lt;span class=&quot;nt&quot;&gt;-i&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Currently mounted filesystems in nice layout&lt;/p&gt;

&lt;div class=&quot;language-shell highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;mount | column &lt;span class=&quot;nt&quot;&gt;-t&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Display free disk space&lt;/p&gt;

&lt;div class=&quot;language-shell highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;df&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-h&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Display disk usage statistics for the current directory&lt;/p&gt;

&lt;div class=&quot;language-shell highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;du&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-sh&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;*&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Display 10 biggest files/folders for the current directory&lt;/p&gt;

&lt;div class=&quot;language-shell highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;du&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-s&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;*&lt;/span&gt; | &lt;span class=&quot;nb&quot;&gt;sort&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-nr&lt;/span&gt; | &lt;span class=&quot;nb&quot;&gt;head&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Execute a command at a given time&lt;/p&gt;

&lt;div class=&quot;language-shell highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;echo&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;ls -l&quot;&lt;/span&gt; | at midnight
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Simple stopwatch&lt;/p&gt;

&lt;div class=&quot;language-shell highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;time read&lt;/span&gt;
&amp;lt;ctrl-d&amp;gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Put a console clock in top right corner&lt;/p&gt;

&lt;div class=&quot;language-shell highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;&lt;span class=&quot;k&quot;&gt;while &lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;sleep &lt;/span&gt;1&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;do &lt;/span&gt;tput sc&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;tput cup 0 &lt;span class=&quot;k&quot;&gt;$((&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;$(&lt;/span&gt;tput cols&lt;span class=&quot;si&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;m&quot;&gt;29&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;))&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;date&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;tput rc&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;done&lt;/span&gt; &amp;amp;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Display the top ten running processes. (Sorted by memory usage)&lt;/p&gt;

&lt;div class=&quot;language-shell highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;ps aux | &lt;span class=&quot;nb&quot;&gt;sort&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-nk&lt;/span&gt; +4 | &lt;span class=&quot;nb&quot;&gt;tail&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Kill all Ruby processes&lt;/p&gt;

&lt;div class=&quot;language-shell highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;ps aux | &lt;span class=&quot;nb&quot;&gt;grep &lt;/span&gt;ruby | &lt;span class=&quot;nb&quot;&gt;awk&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;&apos;{ print $2 }&apos;&lt;/span&gt; | xargs &lt;span class=&quot;nb&quot;&gt;kill&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-9&lt;/span&gt;
&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;ps aux | &lt;span class=&quot;nb&quot;&gt;awk&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;&apos;/ruby/ &amp;amp;&amp;amp; ! /awk/ { system(&quot;kill -9 &quot;$2) }&apos;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;32 bits or 64 bits?&lt;/p&gt;

&lt;div class=&quot;language-shell highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;getconf LONG_BIT
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Displays a calendar&lt;/p&gt;

&lt;div class=&quot;language-shell highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;cal 12 1984
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;What day is today?&lt;/p&gt;

&lt;div class=&quot;language-shell highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;cal | &lt;span class=&quot;nb&quot;&gt;sed&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;s/.*/ &amp;amp; /;s/ &lt;/span&gt;&lt;span class=&quot;si&quot;&gt;$(&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;date&lt;/span&gt; +%d&lt;span class=&quot;si&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt; / [] /&quot;&lt;/span&gt;
&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;cal | &lt;span class=&quot;nb&quot;&gt;sed&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;s/.*/ &amp;amp; /;s/ &lt;/span&gt;&lt;span class=&quot;si&quot;&gt;$(&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;date&lt;/span&gt; +%d&lt;span class=&quot;si&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt; / &lt;/span&gt;&lt;span class=&quot;si&quot;&gt;$(&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;printf&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;&apos;\e[0;31m[]\e[0m&apos;&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt; /&quot;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Show file system hierarchy&lt;/p&gt;

&lt;div class=&quot;language-shell highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;man hier
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Quick access to the ascii table&lt;/p&gt;

&lt;div class=&quot;language-shell highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;man ascii
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Russian Roulette in Bash&lt;/p&gt;

&lt;div class=&quot;language-shell highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;$[&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;$RANDOM&lt;/span&gt; % 6 &lt;span class=&quot;o&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;==&lt;/span&gt; 0 &lt;span class=&quot;o&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;rm&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-rf&lt;/span&gt; / &lt;span class=&quot;o&quot;&gt;||&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;echo&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;You live&quot;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Watch Star Wars via telnet&lt;/p&gt;

&lt;div class=&quot;language-shell highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;telnet towel.blinkenlights.nl
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

</description>
        <pubDate>Fri, 29 Nov 2013 00:00:00 +0000</pubDate>
        <link>https://arturoherrero.com/command-line-one-liners/</link>
        <guid isPermaLink="true">https://arturoherrero.com/command-line-one-liners/</guid>
        
        <category>programming</category>
        
        
      </item>
    
      <item>
        <title>iShows</title>
        <description>&lt;p&gt;I’m happy to announce the latest project that I participated in: &lt;strong&gt;iShows&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;We love TV shows, we love programming, we love design, and we believed that we
could create the best TV show tracking app for iOS. Users enjoyed the
application and the first version had such good reviews.
The second release also had &lt;a href=&quot;http://lifehacker.com/ishows-2-tracks-your-favorite-tv-shows-1720013136&quot; target=&quot;_blank&quot; rel=&quot;noreferrer&quot;&gt;very&lt;/a&gt; &lt;a href=&quot;http://www.macstories.net/reviews/tracking-tv-shows-with-ishows-2-welding-great-design-with-extensive-customization/&quot; target=&quot;_blank&quot; rel=&quot;noreferrer&quot;&gt;good&lt;/a&gt;
&lt;a href=&quot;http://beautifulpixels.com/ipad/ishows-2-is-a-phenomenal-tv-show-tracking-app-for-ios/&quot; target=&quot;_blank&quot; rel=&quot;noreferrer&quot;&gt;reviews&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/assets/images/posts/ishows.png&quot; alt=&quot;iShows&quot; /&gt;&lt;/p&gt;

&lt;p&gt;We wanted to provide an image-based UI and one of the strengths of the app was
the customization of the images. The credits go to &lt;a href=&quot;https://x.com/luisrecuenco&quot; target=&quot;_blank&quot; rel=&quot;noreferrer&quot;&gt;Luis Recuenco&lt;/a&gt;
and &lt;a href=&quot;https://x.com/luishj&quot; target=&quot;_blank&quot; rel=&quot;noreferrer&quot;&gt;Luis Herrero&lt;/a&gt; for the iOS development
and UI/UX design.&lt;/p&gt;

&lt;p&gt;I developed an image server that provided all the images and was responsible for
resizing and cropping, so the clients downloaded the images with the correct
dimensions. The &lt;a href=&quot;/ishows-server/&quot;&gt;iShows server&lt;/a&gt; handled over a billion images throughout the
app’s lifetime. It was an exciting project to be part of.&lt;/p&gt;

</description>
        <pubDate>Tue, 03 Sep 2013 00:00:00 +0000</pubDate>
        <link>https://arturoherrero.com/ishows/</link>
        <guid isPermaLink="true">https://arturoherrero.com/ishows/</guid>
        
        <category>projects</category>
        
        
      </item>
    
      <item>
        <title>Managing Notebooks</title>
        <description>&lt;p&gt;There are a lot of tools to organize and get work done, some are more focused
on task management like &lt;del&gt;Wunderlist&lt;/del&gt; To Do, and others are more
focused on project management like Trello.&lt;/p&gt;

&lt;p&gt;These are great tools, but I prefer notebooks over other devices and media.
I feel the same way with books and e-readers. I love the feel of paper and it
gives me a better user experience.&lt;/p&gt;

&lt;p&gt;In many ways it’s more versatile than software because I can organize my daily
tasks, communicate ideas through drawing, sketchnotes, create lists, project
planning, journal, quotes, random thoughts…&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/assets/images/posts/bulletjournal.png&quot; alt=&quot;Bullet Journal&quot; /&gt;&lt;/p&gt;

&lt;p&gt;Do you know &lt;a href=&quot;https://en.wikipedia.org/wiki/Bullet_journal&quot; target=&quot;_blank&quot; rel=&quot;noreferrer&quot;&gt;bullet journal&lt;/a&gt; note-taking system?&lt;/p&gt;

</description>
        <pubDate>Tue, 04 Dec 2012 00:00:00 +0000</pubDate>
        <link>https://arturoherrero.com/managing-notebooks/</link>
        <guid isPermaLink="true">https://arturoherrero.com/managing-notebooks/</guid>
        
        <category>personal</category>
        
        
      </item>
    
      <item>
        <title>sparky</title>
        <description>&lt;p&gt;I have played with the idea of displaying statistics about version control
systems in a Unix shell, and I also wanted to improve my command line skills.&lt;/p&gt;

&lt;p&gt;Before starting, I remembered &lt;a href=&quot;https://github.com/holman/spark&quot; target=&quot;_blank&quot; rel=&quot;noreferrer&quot;&gt;spark&lt;/a&gt;, a
project that generates sparklines for a set of data, so I became
interested in trying an alternative Groovy implementation to have fun.&lt;/p&gt;

&lt;h3 id=&quot;sparklines-for-your-shell-groovy-flavored&quot;&gt;Sparklines for your shell: Groovy flavored&lt;/h3&gt;

&lt;p&gt;My project is &lt;strong&gt;&lt;a href=&quot;https://github.com/arturoherrero/sparky&quot; target=&quot;_blank&quot; rel=&quot;noreferrer&quot;&gt;sparky&lt;/a&gt;&lt;/strong&gt;, a Groovy
script that lets you graph tiny sparkline graphs from your command line.&lt;/p&gt;

&lt;p&gt;sparky takes a list of numbers—comma-delimited or spaces—and then prints a
sparkline out of it. It’s designed to be used in conjunction with other scripts
that can output in that format.&lt;/p&gt;

&lt;div class=&quot;language-shell highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;sparky 1 5 22 13 53
▁▁▃▂▇

&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;sparky 0,30,55,80,33,150
▁▂▃▅▂▇

&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;echo &lt;/span&gt;9 13 5 17 1 | sparky
▄▆▂█▁
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h4 id=&quot;practical-examples&quot;&gt;Practical examples&lt;/h4&gt;

&lt;p&gt;There are many possibilities. Here are two examples.&lt;/p&gt;

&lt;p&gt;Number of commits to the groovy-core Git repository, by author:&lt;/p&gt;

&lt;div class=&quot;language-shell highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;git shortlog &lt;span class=&quot;nt&quot;&gt;-s&lt;/span&gt; |
&lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;awk&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;&apos;{print $1}&apos;&lt;/span&gt; |
&lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt; sparky
▁▁▁▁▁▁▁▁▁▁▁▃▁▁▁▁▁▁▁▁▁▁▁▁▂▁▁▄▁▁▁▁▁▁▁▅▁▁▁▁▁▁▁▁▁▁▁▁█▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Code visualization. The number of characters of &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;sparky&lt;/code&gt; itself, by line, ignoring empty lines:&lt;/p&gt;

&lt;div class=&quot;language-shell highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;awk&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;&apos;{ print length($0) }&apos;&lt;/span&gt; sparky |
&lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;grep&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-v&lt;/span&gt; ^0&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;|
&lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt; sparky
▂▂▁▁▃▁▃▂▃▃▃▂▁▁▂▄▁▄▅▅█▅▂▁▁▃▃▅▁▁▃▂▁▁▇▃▁
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Try it!&lt;/p&gt;

</description>
        <pubDate>Sun, 17 Jun 2012 00:00:00 +0000</pubDate>
        <link>https://arturoherrero.com/sparky/</link>
        <guid isPermaLink="true">https://arturoherrero.com/sparky/</guid>
        
        <category>programming</category>
        
        
      </item>
    
      <item>
        <title>Closure design patterns</title>
        <description>&lt;h3 id=&quot;design-patterns&quot;&gt;Design patterns&lt;/h3&gt;

&lt;p&gt;I’m learning design patterns. There is a lot of documentation about software
design patterns, but I’m interested in &lt;strong&gt;closure design patterns&lt;/strong&gt;.*&lt;/p&gt;

&lt;p&gt;Many patterns imply object-orientation, so may not be as applicable in dynamic
languages. Peter Norvig demonstrates that 16 out of 23 patterns in the Design
Patterns book are simplified or eliminated, &lt;a href=&quot;http://norvig.com/design-patterns/&quot; target=&quot;_blank&quot; rel=&quot;noreferrer&quot;&gt;Design Patterns in Dynamic
Languages&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;I’ve found an interesting presentation of Venkat Subramaniam about
&lt;a href=&quot;http://www.agiledeveloper.com/presentations/design_patterns_in_java_and_groovy.pdf&quot; target=&quot;_blank&quot; rel=&quot;noreferrer&quot;&gt;Design Patterns in Java and Groovy&lt;/a&gt;,
and another presentation of Neal Ford about &lt;a href=&quot;https://github.com/nealford/presentations/blob/master/Design%20Patterns%20in%20Dynamic%20Languages%20(Neal%20Ford).pdf&quot; target=&quot;_blank&quot; rel=&quot;noreferrer&quot;&gt;Design Patterns in Dynamic Languages&lt;/a&gt;.
Here, I extract some patterns of these presentations that involve closures and
add others patterns based on my own experience.&lt;/p&gt;

&lt;p&gt;You can also find the same examples for Ruby here: &lt;a href=&quot;/closure-design-patterns-ruby-edition/&quot;&gt;Closure Design Patterns. Ruby Edition&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;&lt;sup&gt;* Groovy makes no such distinction between closures or anonymous functions.
What I’m really trying to get at is how we can use tools such as first-class
functions, lambdas and closures when implementing design patterns.&lt;/sup&gt;&lt;/p&gt;

&lt;h3 id=&quot;closure-design-patterns&quot;&gt;Closure design patterns&lt;/h3&gt;

&lt;h4 id=&quot;execute-around-method&quot;&gt;Execute Around Method&lt;/h4&gt;

&lt;p&gt;A pair of operations that need to be performed before and after operations.&lt;/p&gt;

&lt;div class=&quot;language-groovy highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;kt&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;operations&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;closure&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;println&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;Open&quot;&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;closure&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;()&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;println&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;Close&quot;&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;

&lt;span class=&quot;n&quot;&gt;operations&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;println&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;Operation&quot;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;

&lt;span class=&quot;o&quot;&gt;===&amp;gt;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;Open&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;===&amp;gt;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;Operation&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;===&amp;gt;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;Close&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h4 id=&quot;pluggable-behavior&quot;&gt;Pluggable Behavior&lt;/h4&gt;

&lt;p&gt;Specify the behavior of an object at runtime.&lt;/p&gt;

&lt;div class=&quot;language-groovy highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;kt&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;selectValues&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;number&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;closure&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;kt&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;list&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;[]&lt;/span&gt;
    &lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;upto&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;number&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
        &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;closure&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;it&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;))&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;list&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;it&lt;/span&gt;
    &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;list&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;

&lt;span class=&quot;k&quot;&gt;assert&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;4&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;6&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;8&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;10&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;==&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;selectValues&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;10&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;it&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;%&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;2&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;==&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;  &lt;span class=&quot;c1&quot;&gt;// even&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;assert&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;3&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;5&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;7&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;9&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;]&lt;/span&gt;  &lt;span class=&quot;o&quot;&gt;==&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;selectValues&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;10&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;it&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;%&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;2&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;!=&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;  &lt;span class=&quot;c1&quot;&gt;// odd&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h4 id=&quot;iterator-pattern&quot;&gt;Iterator Pattern&lt;/h4&gt;

&lt;p&gt;Allows sequential access to the elements.&lt;/p&gt;

&lt;div class=&quot;language-groovy highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;kt&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;listNumbers&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;closure&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;..&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;3&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;).&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;each&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;closure&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;it&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;

&lt;span class=&quot;n&quot;&gt;listNumbers&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;it&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;println&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;$it is a little number&quot;&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;else&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;println&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;$it is a big number&quot;&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;

&lt;span class=&quot;o&quot;&gt;===&amp;gt;&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;is&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;a&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;little&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;number&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;===&amp;gt;&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;is&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;a&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;little&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;number&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;===&amp;gt;&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;2&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;is&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;a&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;big&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;number&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;===&amp;gt;&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;3&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;is&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;a&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;big&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;number&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h4 id=&quot;dynamical-conditional-execution&quot;&gt;Dynamical Conditional Execution&lt;/h4&gt;

&lt;p&gt;Create and execute a conditional operation.&lt;/p&gt;

&lt;div class=&quot;language-groovy highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;kt&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;greet&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;user&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;successClosure&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;failClosure&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;isAdmin&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;user&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;))&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;successClosure&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;()&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;else&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;failClosure&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;()&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;

&lt;span class=&quot;n&quot;&gt;greet&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;user&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;println&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;Hi Admin!&quot;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;},&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;println&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;Hello User&quot;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;})&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h4 id=&quot;template-method-pattern&quot;&gt;Template Method Pattern&lt;/h4&gt;

&lt;p&gt;Define common algorithm steps (getting a customer) and customizations (passed as a closure).&lt;/p&gt;

&lt;div class=&quot;language-groovy highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;kt&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;withCustomer&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;id&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;closure&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;kt&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;customer&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;getCustomer&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;id&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;closure&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;customer&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;

&lt;span class=&quot;n&quot;&gt;withCustomer&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1234&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;customer&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;-&amp;gt;&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;println&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;Found customer $customer.name&quot;&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h4 id=&quot;loan-pattern&quot;&gt;Loan Pattern&lt;/h4&gt;

&lt;p&gt;Ensures that a resource is deterministically disposed of once it goes out of scope.&lt;/p&gt;

&lt;div class=&quot;language-groovy highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;kt&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;withListOfWordsForEachLine&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;file&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;closure&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;kt&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;reader&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;file&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;newReader&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;()&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;try&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
        &lt;span class=&quot;n&quot;&gt;reader&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;splitEachLine&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;&apos; &apos;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;closure&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt;
    &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;finally&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
        &lt;span class=&quot;n&quot;&gt;reader&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;?.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;close&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;()&lt;/span&gt;
    &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;

&lt;span class=&quot;n&quot;&gt;withListOfWordsForEachLine&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;file&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;wordList&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;-&amp;gt;&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;println&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;wordList&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h4 id=&quot;command-design-pattern&quot;&gt;Command Design Pattern&lt;/h4&gt;

&lt;p&gt;Encapsulate all the information needed to call a method at a later time.&lt;/p&gt;

&lt;div class=&quot;language-groovy highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;kt&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;count&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;
&lt;span class=&quot;kt&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;commands&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;[]&lt;/span&gt;

&lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;upto&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;10&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;commands&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;add&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;count&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;++&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;

&lt;span class=&quot;n&quot;&gt;println&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;count is initially ${count}&quot;&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;commands&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;each&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;cmd&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;-&amp;gt;&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;cmd&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;()&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;println&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;did all commands, count is ${count}&quot;&lt;/span&gt;

&lt;span class=&quot;o&quot;&gt;===&amp;gt;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;count&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;is&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;initially&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;===&amp;gt;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;did&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;all&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;commands&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;count&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;is&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;10&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h4 id=&quot;strategy-pattern&quot;&gt;Strategy Pattern&lt;/h4&gt;

&lt;p&gt;Define a family of interchangeable algorithms.&lt;/p&gt;

&lt;div class=&quot;language-groovy highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;n&quot;&gt;calcMult&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;n&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;m&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;-&amp;gt;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;n&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;*&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;m&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;calcAdds&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;n&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;m&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;-&amp;gt;&lt;/span&gt;
    &lt;span class=&quot;kt&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;result&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;n&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;times&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;result&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;m&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;result&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;

&lt;span class=&quot;kt&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;calcStrategies&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;calcMult&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;calcAdds&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;]&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;calcStrategies&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;each&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;calc&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;-&amp;gt;&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;assert&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;10&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;==&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;calc&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;5&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h4 id=&quot;factory-pattern&quot;&gt;Factory Pattern&lt;/h4&gt;

&lt;p&gt;Abstract the object creation process (currying as a function factory).&lt;/p&gt;

&lt;div class=&quot;language-groovy highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;kt&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;adder&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;x&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;y&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;-&amp;gt;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;x&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;y&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;kt&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;incrementer&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;adder&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;curry&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt;

&lt;span class=&quot;k&quot;&gt;assert&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;5&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;==&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;incrementer&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;4&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h4 id=&quot;method-combination&quot;&gt;Method Combination&lt;/h4&gt;

&lt;p&gt;Build a method from components.&lt;/p&gt;

&lt;div class=&quot;language-groovy highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;kt&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;sum&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;Collection&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;collection&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;-&amp;gt;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;collection&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;sum&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;()&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;kt&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;first2&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;Collection&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;collection&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;-&amp;gt;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;collection&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;take&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;kt&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;take2andAdd&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;first2&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;sum&lt;/span&gt;

&lt;span class=&quot;k&quot;&gt;assert&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;3&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;==&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;take2andAdd&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;([&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;3&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;4&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;5&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;])&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

</description>
        <pubDate>Wed, 25 Apr 2012 00:00:00 +0000</pubDate>
        <link>https://arturoherrero.com/closure-design-patterns/</link>
        <guid isPermaLink="true">https://arturoherrero.com/closure-design-patterns/</guid>
        
        <category>programming</category>
        
        
      </item>
    
      <item>
        <title>Polyglot programming</title>
        <description>&lt;p&gt;Most programmers know several languages. As a web developer, I work on a daily
basis with Groovy, SQL, Bash Scripting, HTML, CSS, and JavaScript.&lt;/p&gt;

&lt;p&gt;Learning different languages allows us to solve problems with the most
appropriate tool and to explore new paths of thinking about computational
problems.&lt;/p&gt;

&lt;p&gt;Neal Ford coined the term polyglot programming to express this concept:&lt;/p&gt;

&lt;blockquote&gt;
  &lt;p&gt;I think it’s important in this day and age of polyglot programming to
understand a variety of different languages, as they are the design tools we
use to craft software. Just like regular engineers must understand the
physical properties of different materials, we should understand the
capabilities, strengths, and weaknesses of different languages. And when to
apply them.&lt;br /&gt;
—Neal Ford&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h3 id=&quot;polyglot-jvm&quot;&gt;Polyglot JVM&lt;/h3&gt;

&lt;p&gt;Java has long been known simply as a programming language. But today, when
thinking of Java we also refer to a robust and mature development platform.
Currently, the &lt;a href=&quot;http://en.wikipedia.org/wiki/List_of_JVM_languages&quot; target=&quot;_blank&quot; rel=&quot;noreferrer&quot;&gt;Java Virtual Machine (JVM) supports over 200 different
programming languages&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;I have been exploring different languages on the JVM—Java, Groovy, Scala and
Clojure—and I shared my experiences with other developers at &lt;a href=&quot;https://www.codemotion.com/&quot; target=&quot;_blank&quot; rel=&quot;noreferrer&quot;&gt;Codemotion
2012&lt;/a&gt;. Hope you enjoy the slides.&lt;/p&gt;

&lt;div class=&quot;iframe-container iframe-579&quot;&gt;
  &lt;iframe src=&quot;https://www.slideshare.net/slideshow/embed_code/12150303&quot; width=&quot;720&quot; height=&quot;579&quot; frameborder=&quot;0&quot; marginwidth=&quot;0&quot; marginheight=&quot;0&quot; scrolling=&quot;no&quot;&gt;&lt;/iframe&gt;
&lt;/div&gt;

</description>
        <pubDate>Tue, 27 Mar 2012 00:00:00 +0000</pubDate>
        <link>https://arturoherrero.com/polyglot-programming/</link>
        <guid isPermaLink="true">https://arturoherrero.com/polyglot-programming/</guid>
        
        <category>programming</category>
        
        
      </item>
    
      <item>
        <title>Create your own Groovy type conversion</title>
        <description>&lt;h3 id=&quot;type-conversion-standard-way&quot;&gt;Type conversion. Standard way&lt;/h3&gt;

&lt;p&gt;&lt;em&gt;Type conversion&lt;/em&gt;—or &lt;em&gt;casting&lt;/em&gt;—is a programming language technique for changing an
object’s data type into another.&lt;/p&gt;

&lt;p&gt;The following code converts a String to an Integer.&lt;/p&gt;

&lt;div class=&quot;language-groovy highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;kt&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;number&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Integer&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;&apos;1&apos;&lt;/span&gt;
&lt;span class=&quot;kt&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;number&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;&apos;1&apos;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;toInteger&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;()&lt;/span&gt;
&lt;span class=&quot;kt&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;number&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;&apos;1&apos;&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;as&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;Integer&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;If we want to change the type of our own objects, we need to create a method to
achieve this goal. We can copy object properties to another object in a generic way;
if a property exists on the target object, we can copy it from the source object.&lt;/p&gt;

&lt;div class=&quot;language-groovy highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;kd&quot;&gt;class&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;User&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;String&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;name&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;String&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;city&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;Integer&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;age&lt;/span&gt;

    &lt;span class=&quot;kt&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;toAdminUser&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;()&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
        &lt;span class=&quot;kt&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;adminUser&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;AdminUser&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;()&lt;/span&gt;
        &lt;span class=&quot;n&quot;&gt;copyProperties&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;this&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;adminUser&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt;
        &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;adminUser&lt;/span&gt;
    &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;

    &lt;span class=&quot;kt&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;copyProperties&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;source&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;target&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
        &lt;span class=&quot;n&quot;&gt;source&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;properties&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;each&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;key&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;value&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;-&amp;gt;&lt;/span&gt;
            &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;target&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;hasProperty&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;key&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;!(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;key&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;&apos;class&apos;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;&apos;metaClass&apos;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;]))&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
                &lt;span class=&quot;n&quot;&gt;target&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;key&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;value&lt;/span&gt;
            &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;
        &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;
    &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;

&lt;span class=&quot;kd&quot;&gt;class&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;AdminUser&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;String&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;name&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;String&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;city&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;Integer&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;age&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Now, it is possible to do something like this:&lt;/p&gt;

&lt;div class=&quot;language-groovy highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;n&quot;&gt;adminUser&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;user&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;toAdminUser&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;()&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h3 id=&quot;type-conversion-groovy-way&quot;&gt;Type conversion. Groovy way&lt;/h3&gt;

&lt;p&gt;That approach was great, but we may want to use the Groovy way to coerce one
type into another:&lt;/p&gt;

&lt;div class=&quot;language-groovy highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;n&quot;&gt;adminUser&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;user&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;as&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;AdminUser&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;It’s simple because &lt;a href=&quot;http://groovy-lang.org/operators.html#Operator-Overloading&quot; target=&quot;_blank&quot; rel=&quot;noreferrer&quot;&gt;Groovy supports operator overloading&lt;/a&gt;
and, therefore, creating your own type conversion is really easy—we can override the
&lt;a href=&quot;http://docs.groovy-lang.org/latest/html/groovy-jdk/java/lang/Object.html#asType(java.lang.Class)&quot; target=&quot;_blank&quot; rel=&quot;noreferrer&quot;&gt;asType() method&lt;/a&gt;.&lt;/p&gt;

&lt;div class=&quot;language-groovy highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;kd&quot;&gt;class&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;User&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;String&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;name&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;String&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;city&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;Integer&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;age&lt;/span&gt;

    &lt;span class=&quot;n&quot;&gt;Object&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;asType&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;Class&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;clazz&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
        &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;clazz&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;==&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;AdminUser&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
            &lt;span class=&quot;kt&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;adminUser&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;AdminUser&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;()&lt;/span&gt;
            &lt;span class=&quot;n&quot;&gt;copyProperties&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;this&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;adminUser&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt;
            &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;adminUser&lt;/span&gt;
        &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;
        &lt;span class=&quot;k&quot;&gt;else&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
            &lt;span class=&quot;kd&quot;&gt;super&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;asType&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;clazz&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt;
        &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;
    &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;

    &lt;span class=&quot;kt&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;copyProperties&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;source&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;target&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
        &lt;span class=&quot;n&quot;&gt;source&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;properties&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;each&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;key&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;value&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;-&amp;gt;&lt;/span&gt;
            &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;target&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;hasProperty&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;key&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;!(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;key&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;&apos;class&apos;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;&apos;metaClass&apos;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;]))&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
                &lt;span class=&quot;n&quot;&gt;target&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;key&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;value&lt;/span&gt;
            &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;
        &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;
    &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

</description>
        <pubDate>Mon, 06 Feb 2012 00:00:00 +0000</pubDate>
        <link>https://arturoherrero.com/create-your-own-groovy-type-conversion/</link>
        <guid isPermaLink="true">https://arturoherrero.com/create-your-own-groovy-type-conversion/</guid>
        
        <category>programming</category>
        
        
      </item>
    
      <item>
        <title>Functional programming with Groovy</title>
        <description>&lt;p&gt;The diversity of languages and programming paradigms allows us to solve
existing problems by thinking of solutions from very different approaches.&lt;/p&gt;

&lt;p&gt;But why should a Groovy developer learn functional programming?&lt;/p&gt;

&lt;p&gt;As I learned about functional programming, I found good ideas and discovered
that it brought new clarity to my thinking about the design of classes and
methods. It also allowed me to write more concise code that was easier to reuse.&lt;/p&gt;

&lt;p&gt;A few weeks ago, I spoke about functional programming with Groovy at
Greach Conference 2011. I presented basic concepts of the functional programming
paradigm and then focused on how to apply them to improve the code that we
write with Groovy. Here are the slides from the talk.&lt;/p&gt;

&lt;div class=&quot;iframe-container iframe-579&quot;&gt;
  &lt;iframe src=&quot;https://www.slideshare.net/slideshow/embed_code/10041168&quot; width=&quot;720&quot; height=&quot;579&quot; frameborder=&quot;0&quot; marginwidth=&quot;0&quot; marginheight=&quot;0&quot; scrolling=&quot;no&quot;&gt;&lt;/iframe&gt;
&lt;/div&gt;
</description>
        <pubDate>Mon, 28 Nov 2011 00:00:00 +0000</pubDate>
        <link>https://arturoherrero.com/functional-programming-with-groovy/</link>
        <guid isPermaLink="true">https://arturoherrero.com/functional-programming-with-groovy/</guid>
        
        <category>programming</category>
        
        
      </item>
    
      <item>
        <title>Clean Code</title>
        <description>&lt;p class=&quot;side-image&quot;&gt;&lt;img src=&quot;/assets/images/posts/clean-code.jpg&quot; alt=&quot;Clean Code&quot; /&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;https://www.pearson.com/us/higher-education/program/Martin-Clean-Code-A-Handbook-of-Agile-Software-Craftsmanship/PGM63937.html&quot; target=&quot;_blank&quot; rel=&quot;noreferrer&quot;&gt;Clean Code: A Handbook of Agile Software Craftsmanship&lt;/a&gt; is a book that every developer should read, especially at the
beginning of their careers when many basic programming concepts need to be
settled.&lt;/p&gt;

&lt;p&gt;The following is a short summary with the main ideas from the book. Below you
can also find my talk from the Agile Madrid User Group about this book, which
covers many different examples.&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;
    &lt;h4 id=&quot;meaningful-names&quot;&gt;Meaningful names&lt;/h4&gt;

    &lt;p&gt;The first step to writing good code is that names have meaning. The
  variables, methods and classes should have a good name to know why they
  exist and what they do. &lt;a href=&quot;https://drupal.star.bnl.gov/STAR/book/export/html/5692&quot; target=&quot;_blank&quot; rel=&quot;noreferrer&quot;&gt;Tim Ottinger’s &lt;em&gt;Rules for Variable and Class Naming&lt;/em&gt;&lt;/a&gt;.&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;h4 id=&quot;functions&quot;&gt;Functions&lt;/h4&gt;

    &lt;p&gt;The functions have to be small, should do one thing and do it well,
  maintaining a single level of abstraction. Also, we must try to reduce the
  number of arguments.&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;h4 id=&quot;comments&quot;&gt;Comments&lt;/h4&gt;

    &lt;p&gt;Don’t comment bad code, rewrite it.&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;h4 id=&quot;formatting&quot;&gt;Formatting&lt;/h4&gt;

    &lt;p&gt;The formatting of the code has one purpose: readability. The newspaper
  metaphor: when reading code, the main functions should appear first, and we
  can go into details below.&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;h4 id=&quot;objects-and-data-structures&quot;&gt;Objects and data structures&lt;/h4&gt;

    &lt;p&gt;Objects hide their data and expose functions to operate with them, on the
  other hand, data structures expose their data directly.&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;h4 id=&quot;error-handling&quot;&gt;Error handling&lt;/h4&gt;

    &lt;p&gt;Try to separate the logic of our application from the exception handler and
  don’t pass or return null values from functions.&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;h4 id=&quot;unit-test&quot;&gt;Unit test&lt;/h4&gt;

    &lt;p&gt;Tests are a very important part of building applications. Ideally, do TDD
  and create test code as good as the code of the rest of the application.&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;h4 id=&quot;classes&quot;&gt;Classes&lt;/h4&gt;

    &lt;p&gt;Classes must be small with high cohesion.&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;h4 id=&quot;emergence&quot;&gt;Emergence&lt;/h4&gt;

    &lt;p&gt;To create a good emergent design we should run all tests, eliminate duplication,
  express the intention in the code, and minimize the number of classes and methods.
  These are &lt;a href=&quot;https://martinfowler.com/bliki/BeckDesignRules.html&quot; target=&quot;_blank&quot; rel=&quot;noreferrer&quot;&gt;Kent Beck’s &lt;em&gt;Four Rules of Simple Design&lt;/em&gt;&lt;/a&gt;.&lt;/p&gt;
  &lt;/li&gt;
&lt;/ul&gt;

&lt;div class=&quot;iframe-container iframe-519&quot;&gt;
  &lt;iframe src=&quot;https://www.slideshare.net/slideshow/embed_code/8036914&quot; width=&quot;720&quot; height=&quot;519&quot; frameborder=&quot;0&quot; marginwidth=&quot;0&quot; marginheight=&quot;0&quot; scrolling=&quot;no&quot;&gt;&lt;/iframe&gt;
&lt;/div&gt;

</description>
        <pubDate>Mon, 11 Jul 2011 00:00:00 +0000</pubDate>
        <link>https://arturoherrero.com/clean-code/</link>
        <guid isPermaLink="true">https://arturoherrero.com/clean-code/</guid>
        
        <category>programming</category>
        
        
      </item>
    
      <item>
        <title>10 Groovy one-liners to impress your friends</title>
        <description>&lt;p&gt;I believe that comparing programming languages is a worthwhile exercise mainly
because of the different techniques and styles that you are exposed to.&lt;/p&gt;

&lt;p&gt;After 10 &lt;a href=&quot;https://gist.github.com/mkaz/d11f8f08719d6d27bab5&quot; target=&quot;_blank&quot; rel=&quot;noreferrer&quot;&gt;Scala&lt;/a&gt; / &lt;a href=&quot;http://ricardo.cc/2011/06/02/10-CoffeeScript-One-Liners-to-Impress-Your-Friends.html&quot; target=&quot;_blank&quot; rel=&quot;noreferrer&quot;&gt;CoffeeScript&lt;/a&gt; /
&lt;a href=&quot;https://gist.github.com/ouyangzhiping/1058219&quot; target=&quot;_blank&quot; rel=&quot;noreferrer&quot;&gt;Ruby&lt;/a&gt; / &lt;a href=&quot;http://blog.fogus.me/2011/06/03/10-haskell-one-liners-to-impress-your-friends/&quot; target=&quot;_blank&quot; rel=&quot;noreferrer&quot;&gt;Haskell&lt;/a&gt; /
&lt;a href=&quot;https://gist.github.com/klang/1007697&quot; target=&quot;_blank&quot; rel=&quot;noreferrer&quot;&gt;Clojure&lt;/a&gt; / &lt;a href=&quot;https://gist.github.com/1004837&quot; target=&quot;_blank&quot; rel=&quot;noreferrer&quot;&gt;C#&lt;/a&gt; /
&lt;a href=&quot;http://willwhim.wpengine.com/2011/06/02/fsharp-one-liners-to-impress-your-friends/&quot; target=&quot;_blank&quot; rel=&quot;noreferrer&quot;&gt;F#&lt;/a&gt; / &lt;a href=&quot;https://ubergarm.com/article/archive/archive-ten-nim-one-liners/&quot; target=&quot;_blank&quot; rel=&quot;noreferrer&quot;&gt;Nim&lt;/a&gt; /
&lt;a href=&quot;https://www.uraimo.com/2016/01/06/10-Swift-One-Liners-To-Impress-Your-Friends/&quot; target=&quot;_blank&quot; rel=&quot;noreferrer&quot;&gt;Swift&lt;/a&gt; one-liners to impress your friends, here are the Groovy one-liners.&lt;/p&gt;

&lt;h4 id=&quot;1-multiply-each-item-in-a-list-by-2&quot;&gt;1. Multiply each item in a list by 2&lt;/h4&gt;

&lt;div class=&quot;language-groovy highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;..&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;10&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)*.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;multiply&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h4 id=&quot;2-sum-a-list-of-numbers&quot;&gt;2. Sum a list of numbers&lt;/h4&gt;

&lt;div class=&quot;language-groovy highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;..&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1000&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;).&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;sum&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;()&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h4 id=&quot;3-verify-if-exists-in-a-string&quot;&gt;3. Verify if exists in a string&lt;/h4&gt;

&lt;div class=&quot;language-groovy highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;kt&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;wordList&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;&apos;groovy&apos;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;&apos;akka&apos;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;&apos;grails framework&apos;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;&apos;spock&apos;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;&apos;typesafe&apos;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;]&lt;/span&gt;
&lt;span class=&quot;kt&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;tweet&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;&apos;This is an example tweet talking about groovy and spock.&apos;&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;wordList&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;any&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;word&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;-&amp;gt;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;tweet&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;contains&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;word&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h4 id=&quot;4-read-in-a-file&quot;&gt;4. Read in a file&lt;/h4&gt;

&lt;div class=&quot;language-groovy highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;kt&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;fileText&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;File&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;&apos;data.txt&apos;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;).&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;text&lt;/span&gt;
&lt;span class=&quot;kt&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;fileLines&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;File&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;&apos;data.txt&apos;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;).&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;readLines&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;()&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h4 id=&quot;5-happy-birthday-to-you&quot;&gt;5. Happy Birthday to You&lt;/h4&gt;

&lt;div class=&quot;language-groovy highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;..&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;4&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;).&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;each&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;println&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;&apos;Happy Birthday &apos;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;+&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;((&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;it&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;==&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;3&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;?&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;&apos;dear Arturo&apos;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;&apos;to You&apos;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h4 id=&quot;6-filter-list-of-numbers&quot;&gt;6. Filter list of numbers&lt;/h4&gt;

&lt;div class=&quot;language-groovy highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;kt&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;passed&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;failed&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;49&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;58&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;76&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;82&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;88&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;90&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;].&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;split&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;{&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;it&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;60&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h4 id=&quot;7-fetch-and-parse-an-xml-web-service&quot;&gt;7. Fetch and parse an XML web service&lt;/h4&gt;

&lt;div class=&quot;language-groovy highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;kt&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;results&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;XmlSlurper&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;().&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;parse&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;&apos;http://arturoherrero.com/index.xml&apos;&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h4 id=&quot;8-find-minimum-or-maximum-in-a-list&quot;&gt;8. Find minimum (or maximum) in a list&lt;/h4&gt;

&lt;div class=&quot;language-groovy highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;14&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;35&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;7&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;46&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;98&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;].&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;min&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;()&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;14&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;35&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;7&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;46&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;98&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;].&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;max&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;()&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h4 id=&quot;9-parallel-processing&quot;&gt;9. Parallel processing&lt;/h4&gt;

&lt;div class=&quot;language-groovy highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;kn&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;nn&quot;&gt;groovyx.gpars.*&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;GParsPool&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;withPool&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt; &lt;span class=&quot;kt&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;result&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;dataList&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;collectParallel&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;processItem&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;it&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;&lt;sup&gt;Using &lt;a href=&quot;http://www.gpars.org/&quot; target=&quot;_blank&quot; rel=&quot;noreferrer&quot;&gt;Gpars&lt;/a&gt; that offers intuitive and
safe ways to handle Groovy tasks concurrently.&lt;/sup&gt;&lt;/p&gt;

&lt;h4 id=&quot;10-sieve-of-eratosthenes&quot;&gt;10. Sieve of Eratosthenes&lt;/h4&gt;

&lt;div class=&quot;language-groovy highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;kt&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;t&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;..&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;100&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;..&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;Math&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;sqrt&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;t&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;last&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;())).&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;each&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;n&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;-&amp;gt;&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;t&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;-=&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;((&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;*&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;n&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)..(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;t&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;last&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;())).&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;step&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;n&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;println&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;t&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h4 id=&quot;bonus-fizzbuzz&quot;&gt;Bonus: FizzBuzz&lt;/h4&gt;

&lt;div class=&quot;language-groovy highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;k&quot;&gt;for&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;i&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;..&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;100&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;println&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;${i%3?&apos;&apos;:&apos;Fizz&apos;}${i%5?&apos;&apos;:&apos;Buzz&apos;}&quot;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;?:&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;i&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

</description>
        <pubDate>Sat, 04 Jun 2011 00:00:00 +0000</pubDate>
        <link>https://arturoherrero.com/10-groovy-one-liners-to-impress-your-friends/</link>
        <guid isPermaLink="true">https://arturoherrero.com/10-groovy-one-liners-to-impress-your-friends/</guid>
        
        <category>programming</category>
        
        
      </item>
    
      <item>
        <title>Blogging like a hacker</title>
        <description>&lt;p&gt;Hacking is an overused term for a simple concept: to explore the limits of what
is possible by doing something in a different way.&lt;/p&gt;

&lt;p&gt;I want to write and share some ideas, but traditional blogging platforms lock
you into their complex ecosystem. I’ve chosen to hack my way to a simpler and
more refreshing approach. That’s the reason this site is built with &lt;a href=&quot;https://github.com/cloudhead/toto&quot; target=&quot;_blank&quot; rel=&quot;noreferrer&quot;&gt;&lt;s&gt;toto&lt;/s&gt;&lt;/a&gt;
&lt;a href=&quot;https://jekyllrb.com/&quot; target=&quot;_blank&quot; rel=&quot;noreferrer&quot;&gt;Jekyll&lt;/a&gt;, a static site generator that
transforms Markdown text into HTML code. It is hosted on &lt;s&gt;Heroku&lt;/s&gt;
&lt;a href=&quot;https://pages.github.com/&quot; target=&quot;_blank&quot; rel=&quot;noreferrer&quot;&gt;GitHub Pages&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;For me, writing is simply the act of putting some ideas in order. This is why
I’ve tried to focus on what truly matters and avoid all sorts of distractions. I
can use my &lt;a href=&quot;/editor/&quot;&gt;editor&lt;/a&gt; of choice, and LiveReload is available during development
to automatically reload the content in the browser when files are modified.
What You Write Is What You See.&lt;/p&gt;

&lt;p&gt;Another thing I have always valued is owning the content. My content is
open-source, under &lt;a href=&quot;https://github.com/arturoherrero/arturoherrero.com&quot; target=&quot;_blank&quot; rel=&quot;noreferrer&quot;&gt;version control&lt;/a&gt;, and
will be accessible despite future redesigns because Markdown is readable as-is.&lt;/p&gt;

&lt;p&gt;The effort of blogging like a hacker is worth it.&lt;/p&gt;

</description>
        <pubDate>Mon, 20 Dec 2010 00:00:00 +0000</pubDate>
        <link>https://arturoherrero.com/blogging-like-a-hacker/</link>
        <guid isPermaLink="true">https://arturoherrero.com/blogging-like-a-hacker/</guid>
        
        <category>writing</category>
        
        
      </item>
    
  </channel>
</rss>
