<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Óscar de Arriba on Medium]]></title>
        <description><![CDATA[Stories by Óscar de Arriba on Medium]]></description>
        <link>https://medium.com/@odarriba?source=rss-ff2508be75f8------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*DYEYz7uSCpQ3tSKM64jsBg.jpeg</url>
            <title>Stories by Óscar de Arriba on Medium</title>
            <link>https://medium.com/@odarriba?source=rss-ff2508be75f8------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Wed, 18 Nov 2026 22:56:00 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@odarriba/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Sending notifications in Elixir with Ravenx]]></title>
            <link>https://medium.com/acutario/sending-notifications-in-elixir-with-ravenx-1f2502a1f272?source=rss-ff2508be75f8------2</link>
            <guid isPermaLink="false">https://medium.com/p/1f2502a1f272</guid>
            <category><![CDATA[elixir]]></category>
            <category><![CDATA[mobile]]></category>
            <category><![CDATA[development]]></category>
            <category><![CDATA[push-notification]]></category>
            <category><![CDATA[software-development]]></category>
            <dc:creator><![CDATA[Óscar de Arriba]]></dc:creator>
            <pubDate>Tue, 25 Apr 2017 13:01:03 GMT</pubDate>
            <atom:updated>2017-04-25T14:28:27.067Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*DlIi3tZirr1_-AoPipaaRQ.jpeg" /></figure><p>During the development of the new version of <a href="http://www.acutar.io/">Acutario</a> in Elixir, we had some issues related to notification dispatching.</p><p>One of the improvements we are working on is the possibility of sending notifications to multiple services, like e-mail, Slack, push notifications to mobile apps…</p><p>That functionality make us face with the problem of using different strategies depending on a concrete scenario that can be different for each user we want to notify, so we decided to develop a library that help us to manage all that cases. <strong>And we called it </strong><a href="https://github.com/acutario/ravenx"><strong>Ravenx</strong></a><strong>.</strong></p><h3>How Ravenx works</h3><p>The library is made of <strong>strategies</strong>, which define a way of sending a notification (Slack, e-mail, APNS, etc), and they have an <a href="https://github.com/acutario/ravenx/blob/master/lib/ravenx/strategy_behaviour.ex">standard interface</a>, so its internal behaviour is abstracted from the outside.</p><p>Currently, Ravenx has two different strategies:</p><ul><li><strong>Slack:</strong> provides sending slack messages using webhooks URLs.</li><li><strong>E-mail:</strong> provides sending emails using different strategies (the ones included in <a href="https://github.com/thoughtbot/bamboo">bamboo</a>).</li></ul><p>But, as we are going to see at the end of this article, new strategies can be easily implemented to manage sending notifications to other systems and platforms.</p><p>Also, there are several ways of defining <strong>configurations</strong> which the strategies will use to know how to send the notification.</p><p>Configurations are per strategy, so they defines how a notification is sent (for example, Mailgun’s configuration to send e-mails).</p><h4>Global configuration</h4><p>This approach includes two kinds of configuration:</p><ul><li><strong>General Ravenx configuration:</strong> like the custom strategies to use, or the configuration module of our app (we will see this two aspects in a few moments).</li><li><strong>Per-strategy configuration:</strong> <em>strategy-specific</em> configuration (Mailgun’s config, Slack’s webhook URL…)</li></ul><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/c2fede8e9b1b04360b66d92f2d7d3490/href">https://medium.com/media/c2fede8e9b1b04360b66d92f2d7d3490/href</a></iframe><h4>Configuration module</h4><p>A module that have a function for each strategy that receives the payload and returns a map with configurations that apply to that specific payload.</p><p>These configuration modules are useful to automatise the configuration generation, for example, if we need to retrieve the slack username of each user in each notification.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/4cc7ab426b5aecfc6ac0c879e60f9df7/href">https://medium.com/media/4cc7ab426b5aecfc6ac0c879e60f9df7/href</a></iframe><h4>Particular configuration</h4><p>This is a configuration map sent when a notification is dispatched. Useful to add configuration generated right before sending the notification.</p><pre>Ravenx.dispatch(strategy, payload, %{url: &quot;...&quot;, icon: &quot;:bird:&quot;})</pre><h4>Mixing configurations</h4><p>For a given notification dispatch we can have configurations of the three kinds. In that case, configurations are merged with this priorities:</p><blockquote>Global &lt; Module &lt; Particular</blockquote><p>So a particular configuration key is used even if it’s defined in the configuration returned by a configuration module or by the app configuration.</p><h3>Sending a notification</h3><p><strong>Ravenx</strong> allows to send a notification in a <strong>synchronous or asynchronous</strong> way. In case you want to send a notification in an asynchronous way, a Task will be launched to perform the operation under the hood.</p><p>To send a notification, the only action needed is a call to the library:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/c6ef8d41cda35db90a51cb92ad26f75e/href">https://medium.com/media/c6ef8d41cda35db90a51cb92ad26f75e/href</a></iframe><h3>Sending multiple notifications</h3><p>Sending a standalone notification is cool, but no one needs another library for that. <strong>The true functionality in Ravenx is sending a notification using multiple strategies in an easy way.</strong></p><p>To do that, the library defines a macro that can be used to generate <strong>notification modules</strong>, which can be used to define how to send a particular notification using multiple strategies.</p><p>That modules must define a function called <em>get_notifications_config</em> that receives an object and returns a Keyword list with information of which strategies and which payloads will be used:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/ed83ebc9a48228a3a3fea28085b0092a/href">https://medium.com/media/ed83ebc9a48228a3a3fea28085b0092a/href</a></iframe><p>So that allows to define all the logic behind a notification generation in a particular module.</p><p>That modules can be used (as seen above) to dispatch the notifications in both synchronous and asynchronous way, as when we dispatched simple notifications.</p><h3><strong>Custom strategies</strong></h3><p>Anyone can create custom strategies and integrate them with Ravenx. To do that, the only requirement is to implement the interface needed and tell Ravenx which modules should use as strategies:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/e7ffffe28425f744b36381a29697359f/href">https://medium.com/media/e7ffffe28425f744b36381a29697359f/href</a></iframe><h3>What Ravenx doesn’t do</h3><p><strong>Ravenx doesn’t take care of dispatching schedule</strong> (limiting the amount of notifications sent simultaneously). As Erlang VM can virtually take care of a lot (<em>really, a lot</em>) of internal processes, this is not a real issue.</p><p>You can send a lot of notifications asynchronously and the Erlang VM will be able to manage them without much problem.</p><h3>Wrapping up</h3><p>Ravenx is not the perfect solution for all the notification scenarios (and it is not intended to be that), but in <a href="http://www.acutar.io/">Acutario</a> we think this can solve some complex scenarios in which you can have to deal with changing configurations, multiple strategies and massive dispatches of notifications.</p><p>Using notification modules alongside with the configuration options, the code related to notifications can be organised and reused, avoiding repetitions in multiple places of your code.</p><p><strong>If you have any question about Ravenx</strong>, you can read its <a href="https://hexdocs.pm/ravenx/">documentation</a> here, ask any question here or just <a href="https://github.com/acutario/ravenx">open an issue</a>! (Pull requests are welcome too :)</p><p>Hope you enjoyed this article and see you soon (in <a href="http://www.elixirconf.eu/">ElixirConf.EU</a> if you assist!)</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1f2502a1f272" width="1" height="1" alt=""><hr><p><a href="https://medium.com/acutario/sending-notifications-in-elixir-with-ravenx-1f2502a1f272">Sending notifications in Elixir with Ravenx</a> was originally published in <a href="https://medium.com/acutario">Acutario</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Integrating CircleCI with Elixir/Phoenix]]></title>
            <link>https://medium.com/coding-code/integrating-circleci-with-elixir-phoenix-e8a1733201e?source=rss-ff2508be75f8------2</link>
            <guid isPermaLink="false">https://medium.com/p/e8a1733201e</guid>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[phoenix]]></category>
            <category><![CDATA[elixir]]></category>
            <category><![CDATA[circleci]]></category>
            <category><![CDATA[continuous-integration]]></category>
            <dc:creator><![CDATA[Óscar de Arriba]]></dc:creator>
            <pubDate>Fri, 12 Aug 2016 17:38:01 GMT</pubDate>
            <atom:updated>2016-08-13T20:06:37.512Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*wrHAaZotEyQPixQfpmjF4A.png" /></figure><p>Having automated tests in a repository can be considered a <em>must-do</em> in any kind of project. In Elixir/Phoenix we can create complex and maintainable tests in a short time but, how can we integrate it with CircleCI?</p><h4>Getting in touch with CircleCI</h4><p><a href="https://circleci.com/">CircleCI</a> is just another continuous integration platform, free for both public and private repositories. The main advantage is that, as it’s based on top of containers, you can can access via SSH to the container where your tests are running and debug environment/build issues easily.</p><h4>So, what’s the matter with Elixir in CircleCI?</h4><p><strong>CircleCI doesn’t have native support for Elixir/Phoenix projects</strong>, so the only option left is trying to automatise the installation of the environment needed to run the tests.</p><p>This shouldn&#39;t be a real trouble since they allow you to define the shell commands executed at each step, so the process can be customised as much as you want.</p><p>In my case, I have decided to install the environment using <a href="https://github.com/asdf-vm"><strong><em>asdf</em></strong></a>, a new lightweight version manager that can handle multiple languages/platforms using plugins.</p><p>The idea is to install it (if it’s not previously installed) and apply the plugins needed. Then, we can use <em>.tool_versions</em> file (the default one used by <em>asdf</em>) to install required dependencies and use them to run the actual tests.</p><p>So here is the <em>circle.yml</em> that does it:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/e2f51ad0c8b08b393363a1bf4a963a74/href">https://medium.com/media/e2f51ad0c8b08b393363a1bf4a963a74/href</a></iframe><p>Also, some adjustments are made:</p><ul><li>Various environment variables, like the <em>$PATH</em> including <em>asdf</em> paths</li><li>Copying CircleCI specific project config to use it on tests</li><li>Install required dependencies</li><li>Clean the database</li><li>Only notify the builds on <em>master</em> branch (to avoid flooding of notifications on <em>non-master</em> commits).</li></ul><p>Note that, by adding <em>asdf</em> directory to the cache list, we can avoid reinstalling and rebuilding Erlang and Elixir, which will take (<em>really</em>) long time on first execution.</p><h4>Benchmarking</h4><p>Thanks to the cache between builds, the build times of one of the projects we use at work are:</p><ul><li>~3 minutes on regular builds.</li><li>~13 minutes on the first build (download and build Erlang &amp; Elixir).</li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e8a1733201e" width="1" height="1" alt=""><hr><p><a href="https://medium.com/coding-code/integrating-circleci-with-elixir-phoenix-e8a1733201e">Integrating CircleCI with Elixir/Phoenix</a> was originally published in <a href="https://medium.com/coding-code">Coding Code</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Acelerando APIs con Grape, Entities y Redis]]></title>
            <link>https://medium.com/the-cocktail-engineering/acelerando-apis-con-grape-entities-y-redis-6f73f79d0423?source=rss-ff2508be75f8------2</link>
            <guid isPermaLink="false">https://medium.com/p/6f73f79d0423</guid>
            <category><![CDATA[api]]></category>
            <category><![CDATA[backend-development]]></category>
            <category><![CDATA[ruby-on-rails]]></category>
            <dc:creator><![CDATA[Óscar de Arriba]]></dc:creator>
            <pubDate>Thu, 16 Jun 2016 11:46:27 GMT</pubDate>
            <atom:updated>2016-06-16T11:46:27.026Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*UGuioUhGIk1yQw0ta8MYEQ.jpeg" /></figure><p>Una de las arquitecturas más populares actualmente es la de centralizar los datos en APIs, separándolos de su representación y haciéndolos disponibles para todo tipo de clientes.</p><p>Si bien en ocasiones los contenidos de dichas APIs no necesitan ser consultados en tiempo real, también nos encontraremos casos en los que la respuesta tiene que ser lo más rápida posible y actualizada a los últimos datos disponibles. Para este último caso se puede llegar a una solución intermedia empleando las posibilidades de caché que nos aporta Ruby on Rails junto con <strong>Grape</strong>, <strong>Grape-Entity</strong> y <strong>Redis</strong>.</p><h4>Grape y Entities para nuestras APIs</h4><p>Si bien no es estrictamente necesario, hay bastantes posibilidades de que en una API desarrollada con Ruby on Rails se utilice <a href="https://github.com/ruby-grape/grape"><strong>grape</strong></a> para encargarse de la creación de los <em>endpoints</em>, el versionado, autenticación, etc.</p><p>En caso de que sea así, existe una gema que nos permite modelar cómo se van a ver nuestros objetos una vez que los devolvamos en la respuesta. Su nombre es <a href="https://github.com/ruby-grape/grape-entity"><strong>grape-entity</strong></a>.</p><p>Gracias a esta gema podemos definir los campos que queremos publicar (y cómo) para cada modelo de nuestra aplicación. Por poner un ejemplo, suponiendo que tengamos un objeto <em>User</em>, podemos crear un <em>entity</em> que exponga los campos del modelo que queramos:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/62e3c50d080997c1ef9516144a5a3077/href">https://medium.com/media/62e3c50d080997c1ef9516144a5a3077/href</a></iframe><p>Esto nos permite generar un hash de cualquier objeto <em>User</em> con los campos que le hemos especificado. Al ser un hash, su conversión a JSON o XML es trivial (además, al usar <em>Grape</em>, ni siquiera tenemos que preocuparnos por ello).</p><p>Un ejemplo de cómo usar este <em>entity</em> podría ser:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/24466c7eace4b426a627a734de3a24bb/href">https://medium.com/media/24466c7eace4b426a627a734de3a24bb/href</a></iframe><h4>La caché puede ser nuestra amiga</h4><p>La caché puede ser nuestra amiga, hasta en una API en la que se actualicen los datos en tiempo real.</p><p>Uno de los mayores cuellos de botella, especialmente cuando se tratan muchos datos, es la instanciación de objetos. Si además tenemos en cuenta que hay que añadirle el procesamiento necesario para generar el hash de cada uno de esos objetos a través de los <em>entities</em>, el cuello de botella puede ser aún peor.</p><p>Aquí es donde llega la caché, y la solución por defecto aportada por Rails, es genial para actualizar los datos en tiempo real: <strong>la caché de bloques basada en timestamps</strong>. Esto permite invalidar la caché de un objeto si este ha cambiado en la base de datos y, en ese caso, regenerarla. Esta técnica es la usada por defecto en Rails a la hora de generar el <em>cache_key</em> de los objetos de <em>ActiveRecord</em>.</p><p>Si además queremos que nuestra caché vaya lo más rápido posible, <strong>Redis</strong> es el aliado perfecto (gracias a <a href="https://github.com/redis-store/redis-rails"><strong>redis-rails</strong></a>). Usando <em>Redis</em> como almacenamiento de la caché podemos usar la acción <em>fetch_multi</em> para pedir múltiples bloques en una sola petición, minimizando los retardos de comunicación y haciendo todo el trabajo de una vez. Si aplicamos todo esto a nuestro código podríamos tener la función <em>apply_entity</em> tal que:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/0fd3b23e01a696fd4bdb6a96465285ef/href">https://medium.com/media/0fd3b23e01a696fd4bdb6a96465285ef/href</a></iframe><p>Podemos ver como <strong>ahora nuestro código es más eficiente</strong>, cacheando la generación del hash del objeto (y, de paso, convirtiéndolo a un objeto JSON, lo que ahorrará bastante tiempo).</p><p>En este momento nuestro endpoint de <em>Users</em> contestará, en el peor de los casos, igual que al principio. Una vez que la primera petición se complete, los objetos estarán almacenados en <em>Redis</em> en su forma final y no hará falta regenerarlos, ahorrando mucho tiempo (más ahorro cuantos más objetos que devolvamos estén cacheados).</p><h4>Reduciendo aún más los tiempos</h4><p>Si aún así queremos reducir más los tiempos de respuesta, podemos reducir la cantidad de objetos <em>completos</em> que obtenemos de la base de datos.</p><p>Esto lo podemos conseguir dividiendo en dos la obtención de datos desde nuestro modelo <em>User</em>: primero obtendremos los datos necesarios para saber qué hay en caché y qué no. Sabiendo qué objetos necesitan ser procesados, podremos obtener todos sus campos:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/e4e16959561b2e7bad72a2fe5dd61348/href">https://medium.com/media/e4e16959561b2e7bad72a2fe5dd61348/href</a></iframe><p>De esta manera inicialmente sólo obtenemos los campos <em>id</em> y <em>updated_at</em> de los usuarios (ya que son necesarios para generar la <em>cache_key</em>) para verificar qué usuarios nos falta y poder obtener en una segunda consulta sus datos, para posteriormente procesarlos y añadirlos a nuestra caché.</p><p><strong>Es importante tener en cuenta</strong> que esta última parte puede mejorar los tiempos o empeorarlos, dependiendo de ciertos factores como la latencia de red con el servidor de base de datos, la cantidad de objetos que manejemos o la volatilidad de la caché, ya que mejora los tiempos cuantos más objetos necesitemos y más respuestas válidas obtengamos de caché.</p><h4>Bola extra: optimizar la generación JSON con Oj</h4><p>Si bien es cierto que hace ya varias versiones de Rails que la generación de JSON ha mejorado notablemente, es posible conseguir unos <em>milisegundos</em> más utilizando una gema que use <strong>extensiones nativas</strong> para formatear nuestras respuestas. Una gema que permite hacer esto es <a href="https://github.com/ohler55/oj"><strong>Oj</strong></a>.</p><p><strong>Oj</strong> nos permite parsear y formatear JSON utilizando una extensión nativa en C, lo que será bastante más rápido. Sin embargo, al encargarse <em>Grape</em> de dicha conversión, no es trivial reemplazar al generador JSON de Rails por Oj. Para ello, <strong>podemos indicarle a ActiveSupport que use Oj</strong>:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/97e36d08172a3b77937511f73c8ef63a/href">https://medium.com/media/97e36d08172a3b77937511f73c8ef63a/href</a></iframe><p>Esto mejorará el tiempo de respuesta especialmente cuando se trate de documentos JSON muy grandes o complejos.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6f73f79d0423" width="1" height="1" alt=""><hr><p><a href="https://medium.com/the-cocktail-engineering/acelerando-apis-con-grape-entities-y-redis-6f73f79d0423">Acelerando APIs con Grape, Entities y Redis</a> was originally published in <a href="https://medium.com/the-cocktail-engineering">The Cocktail Engineering</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Using CloudFlare as a Dynamic DNS service]]></title>
            <link>https://medium.com/coding-code/using-cloudflare-as-a-dynamic-dns-service-c0d797f32794?source=rss-ff2508be75f8------2</link>
            <guid isPermaLink="false">https://medium.com/p/c0d797f32794</guid>
            <category><![CDATA[clouflare]]></category>
            <category><![CDATA[sysadmin]]></category>
            <category><![CDATA[ddns]]></category>
            <category><![CDATA[dynamic-dns]]></category>
            <dc:creator><![CDATA[Óscar de Arriba]]></dc:creator>
            <pubDate>Sun, 07 Feb 2016 15:19:40 GMT</pubDate>
            <atom:updated>2016-08-02T21:25:40.514Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/772/1*6UJel0BmjxrbkIUwG5tOQg.png" /></figure><p>I’m a big fan of <a href="https://www.cloudflare.com/"><strong>CloudFlare</strong></a>, but I always have to use a third party service to map my domains to a dynamic IP.</p><p>But thanks to the <strong>JSON API that CloudFlare uses</strong>, now we can update the IP address used in a domain by just issuing a request.</p><h4>First, get the data needed</h4><p>To use this cool feature, you will need a few things:</p><ol><li><strong>A computer</strong> (like a <em>home server</em>), in order to periodically check the external IP.</li><li><strong>A free CloudFlare account</strong> (configured in your domain) and it’s <strong>API key</strong> (which you can <a href="https://www.cloudflare.com/a/account/my-account">find here</a>)</li></ol><p>Also, you’d need to know the ID of the record that you want to update. To obtain it, you only need to issue a command to the API:</p><pre>curl <a href="https://www.cloudflare.com/api_json.html">https://www.cloudflare.com/api_json.html</a> -d ‘a=rec_load_all’ \<br> -d ‘tkn=your-api-key’ \<br> -d ‘email=your_account@email-address.com’ \<br> -d ‘z=your-domain.com’</pre><p>You only need to change the API key, your account’s e-mail address and the domain registered (the root domain, without <em>www</em> or similar).</p><p>You will obtain a JSON response with all the records. Just search the one you want to update and get it’s <strong><em>rec_id</em></strong> value.</p><p><strong>Note:</strong> the record must be an <em>A</em> record in order to update it with an IP address.</p><h4>Updating the IP assigned</h4><p>Now we are going to create a script that automatically updates the IP address in the DNS record if it has changed since the last check was performed.</p><p>The script I use is very similar to this:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/191881dbaedc7183c758ee09557b94d9/href">https://medium.com/media/191881dbaedc7183c758ee09557b94d9/href</a></iframe><p>You just need to change:</p><ul><li>your API key</li><li>your account’s e-mail address</li><li>your domain’s name</li><li>the record ID</li><li>the subdomain of that record.</li></ul><p>Then, save the script and change it’s permissions:</p><pre>sudo chmod +x /path/to/script.sh</pre><p>Now, you can try the script just by running it like any other system binary:</p><pre>sudo /path/to/script.sh</pre><p>And if everything was fine, the record should be updated.</p><h4>Run the script automatically</h4><p>This kind of functionality is useful only if it’s periodically checking for changes.</p><p>In order to run the script every five minutes, you only need to add this line to your crontab:</p><pre>*/5 * * * * /path/to/script.sh</pre><p><strong>And that’s all!</strong> Hope this help anyone looking for a free dynamic DNS service, because CloudFlare is very useful and provides other services like preventing DoS or HTTPS protection.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c0d797f32794" width="1" height="1" alt=""><hr><p><a href="https://medium.com/coding-code/using-cloudflare-as-a-dynamic-dns-service-c0d797f32794">Using CloudFlare as a Dynamic DNS service</a> was originally published in <a href="https://medium.com/coding-code">Coding Code</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Introducing PipedBeats]]></title>
            <link>https://medium.com/coding-code/introducing-pipedbeats-b66260b3eb3?source=rss-ff2508be75f8------2</link>
            <guid isPermaLink="false">https://medium.com/p/b66260b3eb3</guid>
            <category><![CDATA[pipedbeats]]></category>
            <category><![CDATA[angularjs]]></category>
            <category><![CDATA[development]]></category>
            <dc:creator><![CDATA[Óscar de Arriba]]></dc:creator>
            <pubDate>Wed, 09 Dec 2015 19:01:45 GMT</pubDate>
            <atom:updated>2016-08-02T21:29:24.675Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*teLr5_YAyyfoi_v-Mzm-BQ.png" /></figure><p>A few days ago I was trying to find my perfect playlist for work, and I realised that there wasn’t only one. <strong>Some times you just want a continuous stream of songs</strong>, related to a genre or a search. That’s how <strong>PipedBeats</strong> idea came to my mind.</p><p><a href="https://pipedbeats.com/"><strong>PipedBeats</strong></a> is a <strong>radio streaming web application that let you to define a genre or some keywords to create a random stream of tracks</strong> (generously provided by <a href="https://developers.soundcloud.com/"><em>SoundCloud API</em></a>) to help you concentrate (or not, it’s up to you!) during your work (or relax) hours.</p><p>It’s built on pure <a href="https://angularjs.org/"><em>AngularJS</em></a>, so the application doesn’t need a backend. And the best part, it’s free and you can access right now on <a href="https://pipedbeats.com/">https://pipedbeats.com</a></p><h4>Main features</h4><ul><li><strong>Listen to music for free:</strong> just choose a genre or a search keywords and start listening.</li><li><strong>Responsive UI:</strong> it’s possible that it won’t fit 100% of screens, but I can assure that I have made our best effort to try. Really :)</li><li><strong>Completely browser-based:</strong> your data is yours and your computer do all the work, so no data is exposed to our server.</li><li><strong>SSL support:</strong> provided by <a href="https://www.cloudflare.com/"><em>CloudFlare</em></a>, a shiny DNS provider. Whenever you access the application, it will be over secure connections.</li></ul><h4>Known limitations</h4><p>The client hasn’t got limitations itself (except features not implemented yet), but at the moment <a href="https://soundcloud.com/"><em>SoundCloud</em></a> limits each application to a maximum of <em>15,000</em> plays per day.</p><p>Also, I have some problems with the bandwidth usage on mobile devices. As <em>SoundCloud</em> doesn’t offer different qualities, the data usage can be a problem.</p><h4>Personal experience and coding problems</h4><p>As I have mentioned in precious posts, this is my first real project on <em>AngularJS</em>. As it has to be, I have found some problems during the development:</p><p><strong>1. Sharing information between controllers</strong></p><p>This can be done using three different approaches:</p><ul><li>Storing the information in the <em>$rootScope</em>.</li><li>Creating a <a href="https://docs.angularjs.org/guide/services"><em>Service</em></a> to share variables and functions.</li><li>Passing information through events.</li></ul><p>Well, the first one is obvious: if the <em>$rootScope</em> is a shared variable between controllers, storing information on it is the first thought.</p><p>On the other hand, <a href="https://docs.angularjs.org/guide/services"><em>Services</em></a> are instantiated once, so every controller making use of it will access the same variables. It’s a kind of <em>$rootScope</em> but specialised.</p><p>Finally, the events can be emitted in a scope. If you have access to a different controller’s scope, you can emit an event to it. Otherwise, you can emit a broadcast event to all the controllers using:</p><pre><em>$rootScope.$broadcast(‘eventName’, args);</em></pre><p><strong>2. Update the User Interface when variables are changed</strong></p><p>I encounter some problems when asynchronously changing variables that are used in the UI. The just doesn’t get updated.</p><p>To solve it, you only need to do your stuff inside an `$apply` call like this:</p><pre>$scope.$apply(function(){<br> // Do your stuff here<br>});</pre><p>An the variables will be updated on the UI as soon as changed.</p><p><strong>3. Send current page to Google Tag Manager</strong></p><p>Using virtual paths is perfect for a browser-only application, but <em>Google Analytics</em> doesn’t recognise it as it should.</p><p>To avoid this, I have created a <em>Google Tag Manager</em> configuration (<strong>thanks Nico!</strong>) and pushed a dataLayer object when the state of <em>ui-router</em> is changed:</p><pre>$rootScope.$on(‘$stateChangeStart’, function(event, toState, toParams, fromState, fromParams){<br> dataLayer.push({<br> “event” : “pageView”,<br> “pageName” : event.currentScope.$state.href(toState, toParams)<br> });<br>});</pre><h4>Conclussions</h4><p>This has been an amazing (and short) project that help me to discover small and valuable things about creating a real application using <em>AngularJS</em>.</p><p>I strongly recommend anyone who want to do a new step on the <em>AngularJS</em> world to create it’s own demo application to deal with real problems on your own.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b66260b3eb3" width="1" height="1" alt=""><hr><p><a href="https://medium.com/coding-code/introducing-pipedbeats-b66260b3eb3">Introducing PipedBeats</a> was originally published in <a href="https://medium.com/coding-code">Coding Code</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Playing around with custom routes in AngularJS]]></title>
            <link>https://medium.com/coding-code/playing-around-with-custom-routes-in-angularjs-6d0d226615d8?source=rss-ff2508be75f8------2</link>
            <guid isPermaLink="false">https://medium.com/p/6d0d226615d8</guid>
            <category><![CDATA[angularjs]]></category>
            <category><![CDATA[development]]></category>
            <category><![CDATA[ui-router]]></category>
            <category><![CDATA[code]]></category>
            <dc:creator><![CDATA[Óscar de Arriba]]></dc:creator>
            <pubDate>Sat, 28 Nov 2015 12:19:22 GMT</pubDate>
            <atom:updated>2016-08-02T21:30:27.411Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*XKaJh5P-nFAPfoBmf5oeXw.jpeg" /></figure><p>This week I have been playing a bit with custom routes using <a href="https://github.com/angular-ui/ui-router">ui-router</a>, one of the most popular routers available in the <em>AngularJS</em> ecosystem.</p><h4>An approach to the problem</h4><p>My first idea was to search some data using two optional variables (we will call them <em>var1 </em>and <em>var2</em>). This can be easy, but analysing the use cases we found that:</p><ul><li>User can give us both values.</li><li>User can give us <em>var1</em> value only.</li><li>User can give us <em>var2</em> value only.</li></ul><p>Now, we have three different scenarios that can be resolved in a few different ways:</p><ul><li>Passing variables as query parameters: <em>/search?var1=value1&amp;var2=value2</em>.</li><li>Creating routes that accept var values as part of the path: <em>/search/value1/value2</em>, <em>/search/vale1</em> or <em>/search/value2</em>.</li></ul><p>The first option works well and is easy to implement, but the second one is prettier. However, implementing the second one requires three different routes and repeating come code, which isn’t the best scenario.</p><h4>Creating routes with multiple optional variables</h4><p>The main idea is to create some piece of code that allow us to have multiple optional variables in one route.</p><p>This isn’t supported (<em>yet</em>) by <a href="https://github.com/angular-ui/ui-router">ui-router</a>, so we have to code it using the API exposed by the router.</p><p>The first thing we can do, is defining the route. But after that, I’d like to give you a general point of view of the solution:</p><ul><li>We are going to create a route with only one parameter.</li><li>That parameter will include all the parameters, which will need to be encoded and decoded.</li><li>We have to figure out how to parse the parameters and make them available at the controller.</li></ul><p>Also, I decided to identify the parameters following this schema: <em>/search/var1:value1/var2:value2</em>.</p><p>To start over, we will need to define a parameter type using <em>urlMatcherFactoryProvider</em>:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/6cbf91e74926fa5aa69b4454d5b233d9/href">https://medium.com/media/6cbf91e74926fa5aa69b4454d5b233d9/href</a></iframe><p>This code define how <a href="https://github.com/angular-ui/ui-router">ui-router</a> will manage my parameter (just convert it to string if it isn’t null) and ensure that it matches the pattern defined (which is the format I told you before).</p><p>The next step is to include the route using this custom type we’ve just created:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/2c76436b2152ec04c3b1b1ca7f038be5/href">https://medium.com/media/2c76436b2152ec04c3b1b1ca7f038be5/href</a></iframe><p>In this code we can see a <em>resolve</em> hash, that defines the services available to the controller of this route. In this case, we use a <em>urlParams</em> service that get the search query, remove the first / and split by / character, obtaining an array of parameters following the <em>key:value</em> convention.</p><p>Then, each parameter is read and inserted into an object, that will be returned to the controller.</p><h4>Generating the search query</h4><p>To generate a valid search query, the only thing you have to do is to put the params following the schema <em>/search/var1:variable1/var2:variable2</em> (and as many variables as you want).</p><p>To do this, I use this function, but it’s specific of my own case:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/a4ee95a9fbda557832389bec93514ebd/href">https://medium.com/media/a4ee95a9fbda557832389bec93514ebd/href</a></iframe><p>So I can change the state using the function:</p><pre>$state.go(‘search’, {searchQuery: $scope.buildSearchQuery()});</pre><h4>Known issues</h4><p>Passing the variables using the path is far from being perfect. For example, when your variable has a value that contains ‘:’ or ‘/’, the code may malfunction.</p><p>In the code of this example, the case of having ‘:’ on your value is controlled using <em>result[query.shift()] = query.join(‘:’);</em> in the <em>urlParams</em> service.</p><p>A possible workaround is encoding the variables using, for example, <em>encodeURIComponent()</em> function.</p><p>However, the result isn’t as good as we may think, because a <em>value1</em> equal to <em>hello world</em> will end in an URL like <em>/search/var1:hello%2520world</em>. This occurs because the browser encodes the % sign to it’s <em>URL-encode</em> equivalent, which is <em>%25</em>.</p><p>Another possible solution is to limit the characters used in the variable’s values, or replacing ‘/’ and ‘:’ with another symbol that doesn’t break the schema.</p><h4>Conclussions</h4><p>At the moment, <a href="https://github.com/angular-ui/ui-router">ui-router</a> doesn’t offer support for optional variables in routes if you don’t use the query-parameter schema.</p><p>You can use a workaround similar to this by encapsulating all the query string in one validated variable, but I’m not really sure about if the effort and the amount of lines worth it.</p><p>Also, know problems with typical URL symbols and it’s encoding is far from making this solution a perfect one, so use it with care.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6d0d226615d8" width="1" height="1" alt=""><hr><p><a href="https://medium.com/coding-code/playing-around-with-custom-routes-in-angularjs-6d0d226615d8">Playing around with custom routes in AngularJS</a> was originally published in <a href="https://medium.com/coding-code">Coding Code</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Using Docker to run a one-time app]]></title>
            <link>https://medium.com/coding-code/using-docker-to-run-a-one-time-app-7c27a92a221d?source=rss-ff2508be75f8------2</link>
            <guid isPermaLink="false">https://medium.com/p/7c27a92a221d</guid>
            <category><![CDATA[docker]]></category>
            <category><![CDATA[build]]></category>
            <dc:creator><![CDATA[Óscar de Arriba]]></dc:creator>
            <pubDate>Mon, 23 Nov 2015 20:26:43 GMT</pubDate>
            <atom:updated>2016-08-02T21:29:58.152Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0qKsya9C-cI5gYt73mDiGQ.jpeg" /></figure><p>Sometimes you may want to do one specific task that requires to build/install some software and/or libraries just to run it once.</p><p>Normally it’s very painful to do it in your computer/server because it could left some files that you aren’t going to use, or just because you want to keep your system clean.</p><p>I’ve found myself with this problem this weekend, and the solution was very easy: use a specific <a href="https://www.docker.com/"><em>Docker</em></a> instance for that.</p><h4>Creating a docker instance</h4><p>We want to create a <strong>Docker container</strong> for the application we need and it’s libraries.</p><p><strong>In a normal situation we would create a <em>Dockerfile</em></strong> with instructions to build the whole container, exposing some ports (if it’s a network service) and some mount points. <strong>But due to the fact that this machine is going to be use once, it doesn’t care if we do a more <em>manual</em> work.</strong></p><p>To <strong>start a new container</strong>, you can use:</p><pre>user@host:~# docker run -i -t ubuntu:latest -name my_machine /bin/bash</pre><pre>root@73931cc4a735:/#</pre><p>With this simple command we have downloaded, created and attached a new container using the latest <em>Ubuntu</em> image available at <em>Docker Hub</em>.</p><p>We can now do whatever we want, but my personal advice is to update the repositories and upgrade the system first. You can do it with this commands:</p><pre>root@73931cc4a735:/# apt-get update<br>[…batch of information…]</pre><pre>root@73931cc4a735:/# apt-get dist-upgrade<br>[…batch of information…]</pre><p>Then we can proceed to build and install our libraries/software to do the task we want to do.</p><h4>Leaving and recovering the working container</h4><p>Right now we should be inside the container shell. But <strong>one benefit of using <em>Docker </em>is the ability to leave the container working and come back later</strong>, being able even to close the SSH connection.</p><p><strong>To de-attach from the Docker container</strong>, you can use this key combination: <em>Control+P - Control+Q</em> (in this precise order). After pressing that combination, we should be returned to the host’s shell, but the Docker container will be running on the background.</p><p><strong>To attach to the container again</strong>, we con do something like:</p><pre>user@host:~# docker attach my_machine</pre><p><em>Note:</em> if you can’t remember the name of the container, you can retrieve it with <em>docker ps</em>.</p><h4>Removing the container</h4><p>If you have finished your work with the container, you can stop it:</p><pre>user@host:~# docker stop my_machine</pre><p>or just kill it (violently):</p><pre>user@host:~# docker kill my_machine</pre><p>and the remove it:</p><pre>user@host:~# docker rm my_machine</pre><h4>More information</h4><p>If you want to know more about Docker (<em>specially the run command</em>), you can take a look at the <a href="https://docs.docker.com/">Docker reference site</a> (<em>or just leave a comment!</em>).</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7c27a92a221d" width="1" height="1" alt=""><hr><p><a href="https://medium.com/coding-code/using-docker-to-run-a-one-time-app-7c27a92a221d">Using Docker to run a one-time app</a> was originally published in <a href="https://medium.com/coding-code">Coding Code</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Rails-like Node.js application skeleton]]></title>
            <link>https://medium.com/coding-code/rails-like-node-js-application-skeleton-337a08b3dce5?source=rss-ff2508be75f8------2</link>
            <guid isPermaLink="false">https://medium.com/p/337a08b3dce5</guid>
            <category><![CDATA[nodejs]]></category>
            <category><![CDATA[mongodb]]></category>
            <category><![CDATA[expressjs]]></category>
            <category><![CDATA[code]]></category>
            <category><![CDATA[mean]]></category>
            <dc:creator><![CDATA[Óscar de Arriba]]></dc:creator>
            <pubDate>Tue, 17 Nov 2015 18:32:51 GMT</pubDate>
            <atom:updated>2016-08-02T21:31:23.391Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*aeWo6e6FC8InJwBl3TmpDw.jpeg" /></figure><p>During the last weeks I have been working in building my first real Node.js application (in fact, I’m currently using a <a href="https://en.wikipedia.org/wiki/MEAN_(software_bundle)"><em>MEAN</em></a> stack). So the first step was to look for a good application structure.</p><p><strong>TD;LR:</strong> if you want to go directly to the code, you can go to <a href="https://github.com/odarriba/nodejs-express-skeleton">this GitHub repository</a></p><p><strong>But.. Why?</strong> The short answer is to be able to create a <em>maintainable project</em>, in which anyone can find a specific piece of the app without having to kill me first.</p><p>To achieve that, the first step was to look at well known structure for me: <strong>the project tree used in a Rails application.</strong></p><p>So I decided to create a simple skeleton (you can look and download it from my <a href="https://github.com/odarriba/nodejs-express-skeleton">GitHub repo</a>) that can be used by anyone who wants to build a <a href="https://nodejs.org/en/"><em>Node.js</em></a> application. It has been built with an <em>API-oriented</em> application in mind, but it can be easily used for traditional apps.</p><p>The app skeleton uses some actual technologies like:</p><ul><li><a href="http://expressjs.com/"><em>Express.js</em></a> as the web framework.</li><li><a href="http://mongoosejs.com/"><em>Mongoose</em></a> as the <em>ODM</em> (<em>Object Document Model</em>).</li><li><a href="https://www.mongodb.org/"><em>MongoDB</em></a> as the non-relational database.</li></ul><p>The main goals of this skeleton are:</p><ul><li><strong>Have all the initialization code in one place:</strong> this place is <em>/initializers/</em> (very original, I know). This code is loaded using the file that can be found on <a href="https://github.com/odarriba/nodejs-express-skeleton/blob/master/initializers/index.js"><em>/initializers/index.js</em></a>.</li><li><strong>Environment usage and configuration:</strong> three different environments: <em>development</em>, <em>production</em> and <em>testing</em>.</li></ul><p>Per-environment configuration is available (and automatically loaded during boot) under <em>/config/</em>. There is also the file <a href="https://github.com/odarriba/nodejs-express-skeleton/blob/master/config/index.js"><em>/config/index.js</em></a> that includes a configuration hash used as a default one.</p><ul><li><strong>Models and controllers automatic loading and registration:</strong> placed under <em>/models/</em> and <em>/controllers/</em>, they are loaded during boot time and registered in the application global variable.</li><li><strong>Routes configuration in one place:</strong> located in <a href="https://github.com/odarriba/nodejs-express-skeleton/blob/master/routes.js"><em>/routes.js</em></a>, the routes configuration file is loaded at the end of the application boot and it’s function is to load the routes of each controller and register it on the <em>Express.js</em> router.</li><li><strong>Per-environment logging:</strong> by doing use of the environments available, the logging of the application’s output console is made on different files and using different formats.</li></ul><p>I would like to mention that any improvement or comment is welcome (by doing a pull-request in the repository or just here) :D</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=337a08b3dce5" width="1" height="1" alt=""><hr><p><a href="https://medium.com/coding-code/rails-like-node-js-application-skeleton-337a08b3dce5">Rails-like Node.js application skeleton</a> was originally published in <a href="https://medium.com/coding-code">Coding Code</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Installing rbenv in OSX El Capitán]]></title>
            <link>https://medium.com/coding-code/installing-rbenv-in-osx-el-capit%C3%A1n-170445e29425?source=rss-ff2508be75f8------2</link>
            <guid isPermaLink="false">https://medium.com/p/170445e29425</guid>
            <category><![CDATA[homebrew]]></category>
            <category><![CDATA[os-x]]></category>
            <category><![CDATA[ruby]]></category>
            <category><![CDATA[rbenv]]></category>
            <category><![CDATA[el-capitan]]></category>
            <dc:creator><![CDATA[Óscar de Arriba]]></dc:creator>
            <pubDate>Thu, 08 Oct 2015 19:32:13 GMT</pubDate>
            <atom:updated>2016-08-02T21:32:53.494Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*anr9RqodeM9sjf3cAq1hEg.jpeg" /></figure><h3>Installing Rbenv in OSX El Capitán</h3><p>Last weekend I made a fresh installation of OSX in my personal computer. As the latest version of OSX, El Capitán (10.11), has been released the past week, it was the version I installed.</p><p>Also, I decided to look after <strong>Rbenv</strong> and compare it with <strong>RVM</strong> (<em>Ruby Version Manager</em>). After looking in some pages <a href="https://github.com/sstephenson/rbenv/wiki/Why-rbenv%3F">like this</a>, it’s clear that <strong>the best option (maybe the best structured) is <em>Rbenv</em></strong>, while <em>RVM</em> provides a more comfortable way of managing Ruby versions and <em>gemsets</em>.</p><p>In a few words, <em>Rbenv</em> provides:</p><ul><li>Easy <em>Ruby</em> version management <strong>without rewrites of shell functions, </strong>so other programs can use it’s functions without patches.</li><li>No <em>gemset</em> management (because <em>Bundle</em> can do this pretty well by it’s own).</li></ul><h4>El Capitán with Rbenv</h4><p>To install <strong>Rbenv</strong> in OSX, the easiest way is to install it through <a href="http://brew.sh/"><strong>Homebrew</strong></a>, the OSX package management tool.</p><p><em>Disclaimer:</em> Because of the SIP (<a href="https://en.wikipedia.org/wiki/System_Integrity_Protection">more info here</a>), a new security feature of OSX, there could be issues installing <em>Homebrew</em> on OSX 10.11. If this is your case, please check <a href="http://digitizor.com/2015/10/06/install-homebrew-osx-el-capitan/">this wiki page</a>.</p><h4>Prerequisites</h4><p>To install *Ruby* versions on OSX El Capitán, you will need an updated version of <strong>OpenSSL</strong> with it’s development libraries.</p><p>To install and link it:</p><pre>$&gt; brew install openssl<br>$&gt; brew link — force openssl</pre><h4>Installing Rbenv</h4><p>To install <em>Rbenv</em> using <em>Homebrew</em>:</p><pre>$&gt; brew install rbenv ruby-build rbenv-default-gems</pre><p>This command will install <em>rbenv</em>, <em>ruby-build</em> (a tool to help installing new rubies) and <em>rbenv-default-gems</em> (an extension to define default gems when installing new rubies).</p><p>Then, we have to make some symlinks:</p><pre>$&gt; export RBENV_ROOT=/usr/local/var/rbenv<br>$&gt; ln -s $RBENV_ROOT ~/.rbenv</pre><h4>Defining default gems to install</h4><p>To make use of <em>rbenv-default-gems</em> utility, you only have to edit the file placed at <em>~/.rbenv/default-gems</em> including each gem you want to install per line.</p><p>Mine looks like this:</p><pre>bundler<br>tacoma<br>powder<br>mailcatcher</pre><h4>Installing new rubies</h4><p>To install new <em>Ruby</em> versions, you just have to execute <em>install</em> <em>Rbenv</em>’s command. For example:</p><pre>$&gt; rbenv install 2.0.0-p647</pre><p>You can also install versions of other compiles, like <em>jruby</em>.</p><h4>Defining ruby version to use</h4><p>You can define the ruby version globally or just in the folder you are in. And it will live change (it’s magic!).</p><p>To define the ruby version to use globally:</p><pre>$&gt; rbenv global &lt;version&gt;</pre><p>To define a specific version inside a folder (in a project, for example):</p><pre>$&gt; rbenv local &lt;version&gt;</pre><p>You can also define the version to use inside a folder by creating a file called <em>.ruby-version</em> with just the version inside it.</p><h4>Known problems</h4><p>There are several problems I have found while doing and using all of this stuff, for example:</p><ul><li><strong>Installing old versions of <em>Ruby</em></strong>: I had to install <em>Ruby 1.8.7</em>, but I haven’t found a way of doing it because it requires old libraries and compilers that aren’t available for El Capitán.</li><li><strong>Patch versions</strong>: when specifying the version to use, <strong><em>Rbenv</em> requires to specify the patch version</strong>, which is tedious. To fix it, I have used <a href="https://github.com/tpope/rbenv-aliases"><em>rbenv-aliases</em></a> to avoid using patch versions (and it will take the higher patch version available).</li></ul><p><strong>And that’s all!</strong> If you have any trouble and want to ask something, feel free to post a comment!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=170445e29425" width="1" height="1" alt=""><hr><p><a href="https://medium.com/coding-code/installing-rbenv-in-osx-el-capit%C3%A1n-170445e29425">Installing rbenv in OSX El Capitán</a> was originally published in <a href="https://medium.com/coding-code">Coding Code</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Installing OpenVPN Server]]></title>
            <link>https://medium.com/coding-code/installing-openvpn-server-e59ede0e924e?source=rss-ff2508be75f8------2</link>
            <guid isPermaLink="false">https://medium.com/p/e59ede0e924e</guid>
            <category><![CDATA[docker]]></category>
            <category><![CDATA[openvpn]]></category>
            <category><![CDATA[services]]></category>
            <dc:creator><![CDATA[Óscar de Arriba]]></dc:creator>
            <pubDate>Sun, 04 Oct 2015 10:36:42 GMT</pubDate>
            <atom:updated>2016-08-02T21:33:55.307Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*56CIS0PVdy_NnKAK5-Igiw.jpeg" /></figure><p>Today I’ve been installing <strong>OpenVPN server</strong> on my home server to being able to securely connect to my local network from anywhere. This can allow you to:</p><ul><li>Having access to local services on your local network , like a (in my case) a <a href="https://github.com/odarriba/docker-timemachine">Time Machine</a> docker service.</li><li>Access services only available from your country IP when travelling to other places.</li><li>Being able to use open hotspots while encrypting your whole network traffic.</li></ul><p>In order to get it, my first thought was to install the server on the bare metal machine (not on a <em>Docker</em> instance) because it may require some network privileges that can make it unable to work behind the <em>Docker</em> network layer.</p><p>But searching a bit over the Internet I’ve found <a href="https://github.com/kylemanna/docker-openvpn">this repository</a> that includes a functional Docker image. It doesn’t just works, but it includes a full documentation file with instructions to set the server up in two different containers (the one that has the daemon running and the one that stores the secure data).</p><p><strong>So, in less that 5 minutes my OpenVPN server was up and running!</strong> Also I have generated the CA file and the client certificates, so I can connect from anywhere like being at home.</p><h4>Clients</h4><p>In Mac OSX (10.11 — El Capitán) I installed <a href="https://tunnelblick.net/">Tunnelblink</a>, a free and open source alternative to OpenVPN client or Viscoso.app. It has an easy and lightweight GUI, perfect to avoid resource consumption and annoyance while using it.</p><p>In Windows 10 I used the official OpenVPN client, but it doesn’t work <em>out-of-the-box</em>. <strong>To make it works, it’s executables should be marked to be run with administrator privileges</strong>, so they can add the networking routes needed to route the traffic through the VPN.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e59ede0e924e" width="1" height="1" alt=""><hr><p><a href="https://medium.com/coding-code/installing-openvpn-server-e59ede0e924e">Installing OpenVPN Server</a> was originally published in <a href="https://medium.com/coding-code">Coding Code</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>