<?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 Massimiliano Marcon on Medium]]></title>
        <description><![CDATA[Stories by Massimiliano Marcon on Medium]]></description>
        <link>https://medium.com/@mmarcon?source=rss-e5bf57064312------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*2La2Joi2Pu2QWb0n.jpeg</url>
            <title>Stories by Massimiliano Marcon on Medium</title>
            <link>https://medium.com/@mmarcon?source=rss-e5bf57064312------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 30 Nov 2026 04:03:43 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@mmarcon/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[Smoking ribs with a Weber Q 2200: a retrospective]]></title>
            <link>https://medium.com/bbq-hq/smoking-ribs-with-a-weber-2200-a-retrospective-8d48c740d25c?source=rss-e5bf57064312------2</link>
            <guid isPermaLink="false">https://medium.com/p/8d48c740d25c</guid>
            <category><![CDATA[bbq]]></category>
            <category><![CDATA[grilling]]></category>
            <category><![CDATA[cooking]]></category>
            <category><![CDATA[recipe]]></category>
            <category><![CDATA[food]]></category>
            <dc:creator><![CDATA[Massimiliano Marcon]]></dc:creator>
            <pubDate>Mon, 07 May 2018 09:43:11 GMT</pubDate>
            <atom:updated>2018-05-07T19:25:26.261Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*AhHBhEKS1-phOF72W6HtuQ.jpeg" /></figure><p>The forecast for last Saturday in Berlin was “nice and sunny”, perfect for BBQ.</p><p>This time I wanted to try something different than what I usually do, so I did some research on whether it is possible to smoke ribs on the Weber Q 2200. I found <a href="https://youtu.be/599_WAMdW_M">some videos</a> on youtube, I found some recipes online, and I looked for tips and additional material in one of my BBQ recipe books.</p><p>I came up with a to do list, visited the Weber shop to buy the accessories for my Weber Q 2200, and planned for a relaxing Saturday afternoon where I’d prepare the ribs and slowly smoke them while enjoying some beer and music.</p><p>This post is about how it went and what I’ll try to do different next time.</p><p>Short summary: <strong>the ribs were delicious</strong>, with some room for improvement.</p><h3>The “battle plan”</h3><p>I cook quite often, and fairly often I look up recipes depending on the ingredients I have at home. Usually, I find inspiration in cooking blogs, where there are beautiful and inspiring photos, a list of ingredients and some instructions. This is ok for simple things like pasta or side dishes, but I find it difficult to follow for more complex recipes or for things that require several steps spanned across a long time.</p><p>My smoked ribs had the additional challenge of having input from different sources (videos, blogs, recipe books).</p><p>Therefore, I decided to collect all the information I needed in one “battle plan”, a foolproof checklist of ingredients and steps that as long as I followed, nothing could go wrong.</p><p>I opened up Google Docs, created a new presentation, set the page size to A3 and noted down all the ingredients and steps, including waiting time in between steps, to ensure I’d not forget to set a timer.</p><p>When I was done, I printed it out in A3 and kept it next to me on the working area in the kitchen.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*JIshmEh_B24RE18vbMArng@2x.jpeg" /></figure><p>In retrospective, having this plan really helped. First of all, having it all in front of me helped with figuring out more or less when to start preparing the ingredients and the ribs in order to eat at a reasonable time.</p><p>Having it on paper also meant that I did not need to reach for my phone with dirty hands, and had the additional advantage of being able to simply add notes next to each step to improve the plan for next time.</p><p>You can have a look at <a href="https://docs.google.com/presentation/d/1m3HMsek4QiQrt1mSBoPi0R0uDHfSpjL_1Ddo46nLZic/edit?usp=sharing">the <em>improved</em> battle plan</a> and download it if you want to give it a try. Feel free to comment directly on the Google Docs document if you have improvements to suggest.</p><h3>Challenges of smoking on the Weber Q 2200</h3><h4>Indirect cooking</h4><p>Usually, when you smoke on a gas grill, you go for indirect cooking by switching on one burner on one side and placing the meat on the other side.</p><p>This is unfortunately not possible with the Weber Q, which is designed with the direct grilling use-case in mind and only has one burner. As a workaround for this, Weber sells (at least in Europe) a <a href="https://www.weber.com/DE/de/zubehoer/grillen/spare-rib--und-gefluegelhalter/6562.html?cgid=2034#start=1"><strong>roasting shield</strong> that reflects the heat away</a> from the meat and a <a href="https://www.weber.com/DE/de/zubehoer/grillen/spare-rib--und-gefluegelhalter/6564.html?cgid=2034#start=1"><strong>roasting rack</strong> that keeps the meat a couple of centimeters from the grate</a>. As Weber explains in their blog, <a href="https://www.weber.com/US/en/blog/burning-questions/how-to-do-indirect-grilling-on-a-weber-q/weber-29746.html">it is possible to replace the roasting shield and the roasting rack with a foil pan and a grilling pan</a>, but because I don’t have a grilling pan either, I just bought roasting rack and shield.</p><h4>Cooking at low temperature</h4><p>The other challenge is temperature-related: the minimum temperature inside the Weber Q 2200 is too high for smoking ribs. I am still trying to figure out how to address it for next time.</p><p>Here’s what happened. As prescribed by my battle plan, I put the smoking pouch on the grate and preheated the grill on high. As expected, after 10 minutes, the wood chips were producing smoke. I put the ribs on the roasting rack and with the roasting shield I put them on the grate and lowered the temperature to low.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*OivxXnENu0nkbpPXaAzvfw@2x.jpeg" /></figure><p>Ribs should be smoked at 120°C (250F), but I couldn’t get the temperature lower than 150°C (302F). This means <strong>my ribs cooked a bit too quickly</strong> (about 2 and a half hours) <strong>and they weren’t as tender as they should have been</strong>. Doesn’t mean they were bad, not at all, I just would have wanted to make them more tender. One thing that I did try, was to keep the lid slightly open with a small ball made of aluminum foil: didn’t help at all, the temperature did not noticeably decrease.</p><p>I read somewhere that the porcelain enamel grates are really good at retaining heat. For this reason, <strong>it is recommended to pre-heat on low</strong> instead of on high. This is something I’m definitely going to try next time, so I updated the battle plan accordingly.</p><h3>Improvements to the recipe and the battle plan</h3><h4>Dry rub</h4><p>For this recipe, I used a brown-sugar-based rub, more or less with the same ingredients listed in <a href="https://youtu.be/599_WAMdW_M">this video</a>. You can see the dosage in the <a href="https://docs.google.com/presentation/d/1m3HMsek4QiQrt1mSBoPi0R0uDHfSpjL_1Ddo46nLZic/edit?usp=sharing">battle plan</a>. The quantity was perfect for the amount of ribs, but then a lot of the sugar just melted on the roasting shield, which now is far from being reusable. In the video there isn’t that much melted sugar, I wonder why. Maybe it’s because I forgot to open very well the holes at the bottom of the shield, however I’d rather have all that burned sugar on the roasting shield than all over my bbq. Maybe, if I figure out how to solve the low temperature issue above, the sugar will also melt less.</p><p>Other than that, the rub gave a very nice flavor to the ribs. The only small problem was that with that amount of chilly powder the ribs were a bit too spicy for my 3 years old daughter. I just removed the outside part of the ribs for her (and ate it myself, it’s the most delicious part!) and she was fine. Next time I might however try a different, less spicy, rub.</p><h4>Side dish</h4><p>We had a guest for dinner, so I decided we also needed a side to go with the ribs. My wife was out for the whole afternoon, so the side was also for me to make.</p><p>I went for some <strong>grilled vegetables</strong> (yellow and green zucchini and bell peppers) <strong>marinated in beer and spices</strong>. I took the recipe from <a href="http://draftmag.com/recipes/detail/162">here</a>, replacing the lemon I forgot to buy with a spoon of brandy.</p><p>The result was good and tasty, although not so much improvement over the grilled vegetables I usually make, marinated with just olive oil, salt, pepper and oregano. Having to prepare also a side made, however, the ribs smoking experience not as relaxing and zen as I thought it’d be. I had to use the 30 minutes breaks in between brushings to wash and cut vegetables, prepare the marinade, marinate the vegetables, etc.</p><p>The final phase was also a bit rushed, as I had to remove the ribs from the grill, heat it up on high and while the ribs were kept warm at 80°C (175F) in the oven, grill the veggies.</p><p>Next time, I may try a different side, have someone else help me and maybe pick something that doesn’t need to go on the grill at the end. Either that, or I am thinking of making the ribs as appetizers and then grill some other meat with some veggies or corn.</p><h3>What went well</h3><p>After the extensive analysis of what I would like to improve for next time, I am going to wrap up by talking about what went well.</p><h4>BBQ Sauce</h4><p>For the BBQ sauce I chose the <a href="https://www.sweetbabyrays.com/Sauces/Barbecue-Sauces/Original-Barbecue-Sauce">Sweet Baby Ray’s Original BBQ sauce</a>. They had it at the Weber shop and had very good reviews on Amazon, and I have to say it was a great choice.</p><h4>Taste</h4><p>The taste was magnificent. It was the perfect balance between sweet, spicy and smoky. The pairing with grilled vegetables was also quite good, although, if I really need to find something to complain about, I would say corn is probably a better side for this kind of ribs.</p><h4>Beer Pairing</h4><p>I did some research on the right beer pairing for ribs and BBQ in general. I found that stouts and dark beers are a good pairing. I also found that a good pairing is the <a href="https://en.wikipedia.org/wiki/Schlenkerla">Aecht Schlenkerla Rauchbier</a>, a smoked beer that I had tried a couple of times and I really liked, so I thought I’d go for this one.</p><p>Unfortunately, at the local supermarket they did not have any, so I had to come up with a backup plan. After browsing the shelves back and forth for a while, I settled for a <a href="https://www.stoertebeker.com/de_de/stark-bier/">Störtebeker Starkbier</a>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2bMoAaFtw81nU1mQitS5CA.jpeg" /><figcaption>Störtebeker Starkbier</figcaption></figure><p>What a great choice! This dark beer enhanced the sweet and spicy flavor of the ribs, so it was really a good pairing.</p><h4>Music background</h4><p>For the musing background while cooking, I decided to go with Jazz. I found this album “Cooking with Jazz” on Spotify a while ago, and I thought it would be appropriate for a relaxed Saturday afternoon spent smoking ribs.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fopen.spotify.com%2Fembed%2Falbum%2F7yyKgOoD9sLl94g4sIL66w&amp;url=https%3A%2F%2Fopen.spotify.com%2Falbum%2F7yyKgOoD9sLl94g4sIL66w&amp;image=https%3A%2F%2Fi.scdn.co%2Fimage%2F79872fbbfd34281680dc55873fed2ad7f9f52cf3&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=spotify" width="300" height="380" frameborder="0" scrolling="no"><a href="https://medium.com/media/2eae69e038cc27136514cbaf28beccc8/href">https://medium.com/media/2eae69e038cc27136514cbaf28beccc8/href</a></iframe><h3>Final thoughts</h3><p>All in all, the 4 hours I spent on this weekend <em>project</em> were time well spent. The result was delicious, and I already have some learnings to improve next time. Some of these learnings are already included in the <a href="https://docs.google.com/presentation/d/1m3HMsek4QiQrt1mSBoPi0R0uDHfSpjL_1Ddo46nLZic/edit?usp=sharing">updated battle plan for smoking ribs on a Weber Q 2200</a> which you can download and print out when you want to try making these delicious ribs yourself.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8d48c740d25c" width="1" height="1" alt=""><hr><p><a href="https://medium.com/bbq-hq/smoking-ribs-with-a-weber-2200-a-retrospective-8d48c740d25c">Smoking ribs with a Weber Q 2200: a retrospective</a> was originally published in <a href="https://medium.com/bbq-hq">BBQ HQ</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[DevOps for your next Node.js project]]></title>
            <link>https://medium.com/@mmarcon/devops-for-your-next-node-js-project-8dccaaf620d1?source=rss-e5bf57064312------2</link>
            <guid isPermaLink="false">https://medium.com/p/8dccaaf620d1</guid>
            <category><![CDATA[nodejs]]></category>
            <category><![CDATA[devops]]></category>
            <category><![CDATA[ansible]]></category>
            <dc:creator><![CDATA[Massimiliano Marcon]]></dc:creator>
            <pubDate>Sat, 05 Sep 2015 16:51:29 GMT</pubDate>
            <atom:updated>2015-09-06T09:35:38.308Z</atom:updated>
            <content:encoded><![CDATA[<h4>Nginx and Node.js with PM2 deployed with Vagrant and Ansible on Virtualbox and Digital Ocean.</h4><p>So far I have not played much with <strong>automating configuration</strong> of IT infrastructures, <strong>deployments</strong>, <strong>reproducible development environments</strong> and <strong>monitoring</strong>. I work with people who do a lot of this for me, and while I do understand almost all the bits and pieces of it, I haven’t really done anything from scratch by myself.</p><p>For most of my side projects the deployment phase is somewhat manual, but now I have a some ideas for a couple of new projects that could really benefit from some automation and configuration management.</p><p>I had a few days off and I decided to do some research on what tools would make my life easier. The stack I will probably work with is going to be some HTML5 and vanilla JavaScript in the front-end with one or more services written in Node.js exposing REST APIs as the back-ends.</p><p>The goal of this investigation was to come up with a setup that would allow me to:</p><ul><li>develop my apps on my laptop;</li><li>test the overall setup in an environment as close as possible to production;</li><li>once I am done, deploy everything to a cloud provider, possibly Digital Ocean that I am already using for another project and has a good pricing model and a <a href="https://developers.digitalocean.com/">great API</a>;</li><li>keep an eye on the application to make sure it keeps running and does not die unexpectedly due to unexpected errors.</li></ul><h4>Tech Stack</h4><p>For this setup I chose to go with the following stack:</p><ul><li>Node.js: for the backend services and APIs.</li><li>Nginx: serves static pages and static files and acts as a <a href="https://en.wikipedia.org/wiki/Reverse_proxy">reverse proxy</a> in front of the Node.js services.</li><li><a href="https://github.com/Unitech/pm2">PM2</a>: a relatively new and very powerful process manager for Node.js. PM2 takes care of restarting the Node.js applications if they die and also provide facilities for load balancing, monitoring and logging.</li></ul><h4>Requirements</h4><p>To follow this article step by step, and to be able to run the same setup on your computer, make sure you have the following installed:</p><ul><li>Virtualbox</li><li>Vagrant</li><li><a href="https://github.com/smdahlen/vagrant-digitalocean">DigitalOcean plugin for Vagrant</a></li><li>Ansible</li></ul><p>You can try to run this yourself by cloning the example GitHub repository <a href="https://github.com/mmarcon/ubuntu-node-nginx-ansible">ubuntu-node-nginx-ansible</a>. This article is a guide that illustrates how I ended up with what you can see in that repository now.</p><h4>Local Environment</h4><p>The new buzzwords are Docker and containers. I gave Docker a quick try, but it just wasn’t doing it for me. I understand the idea of lightweight containers, but it is not very easy to setup and deploy, so I left that aside for now and I’ll try again in a few months.</p><p>I went for <a href="https://www.vagrantup.com/">Vagrant</a> + <a href="https://www.virtualbox.org/">Virtualbox</a>: they are both free and opensource projects, they are very easy to install and run on my Macbook Air and the setup just works very well. I started with a simple <em>Vagrantfile</em> that brings up an Ubuntu 14.04 virtual machine.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/33827abb775ff9ea41521665ea25571c/href">https://medium.com/media/33827abb775ff9ea41521665ea25571c/href</a></iframe><p>Next step: install the different packages for Nginx, Node.js and PM2.</p><p>Vagrant supports different ways of <a href="https://docs.vagrantup.com/v2/provisioning/index.html">provisioning</a> virtual machines. I have used the <em>shell provisioner</em> in the past which is simple but may become very verbose and hard to read when a lot of configuration is needed and several packages have to be installed. Among the other supported provisioners, I picked <a href="http://www.ansible.com/">Ansible</a>: I had no experience with it but I read good things about it and it seemed very simple to use.</p><h4>Provisioning with Ansible</h4><p>I will skip all the Ansible definitions. If you want to read more about <a href="http://docs.ansible.com/ansible/playbooks.html">playbooks</a>, roles, modules, etc., refer to the <a href="http://docs.ansible.com/ansible/index.html">Ansible documentation</a>. I will instead try to give you a basic understanding of how it works by explaining my playbook bit by bit.</p><p>A basic understanding of Ansible is certainly helpful to follow the rest of this article, however all you need to know is that Ansible is a software that connects via SSH to one or more nodes and runs a series of commands that are defined in what is called a <em>playbook</em>.</p><p>First of all, we need to tell Vagrant to use Ansible and look for a <a href="http://yaml.org/">YAML</a> file that contains the playbook.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/4ae02ffc1725592a2cc246b283d11e3b/href">https://medium.com/media/4ae02ffc1725592a2cc246b283d11e3b/href</a></iframe><p>We will begin with a simple playbook that ensures Nginx is installed and started on the box.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/28db6ce6cb0d43e9a1341326152429d8/href">https://medium.com/media/28db6ce6cb0d43e9a1341326152429d8/href</a></iframe><p>What this says is straightforward: for <a href="http://docs.ansible.com/ansible/intro_inventory.html">all the hosts</a> (there is only one in our case), become a super-user (sudo: yes) and then ensure that the Nginx apt package (we are on Ubuntu) is present. Once done, <em>notify</em> the “start nginx” <em>handler</em> that will take care of starting it.</p><p>This was easy. Now, Node.js. Node.js is available via apt and could be installed in the same we we installed Nginx, however the <a href="https://www.digitalocean.com/community/tutorials/how-to-install-node-js-on-an-ubuntu-14-04-server">current version available for Ubuntu 14.04 is 0.10</a>. To use a more recent version we have to do something different.</p><p>Luckily somebody has created a role for installing Node.js via Ansible, so you just need to fetch it from <a href="https://galaxy.ansible.com/">Ansible Galaxy</a> and use it. The best way to document and retrieve dependencies for your Ansible playbooks is to use a <a href="http://docs.ansible.com/ansible/galaxy.html">requirements file</a>.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/38b582307390f8863b2268be4de1769d/href">https://medium.com/media/38b582307390f8863b2268be4de1769d/href</a></iframe><p>To fetch all the dependencies listed in this file and store them locally you can use</p><pre>ansible-galaxy install -r requirements.yml</pre><p>At this point you have all you need and you can reference this role in your playbook. We also want to deploy the Node.js apps we are developing to the Vagrant box so they can be executed.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/e4e9706cb2998d2ae3e859c6875daa61/href">https://medium.com/media/e4e9706cb2998d2ae3e859c6875daa61/href</a></iframe><p>There is quite some new stuff here, but it is very easy to read. We have the <em>franklinkim.nodejs</em> role: that is the component that knows how to install Node.js. In the <em>vars</em> section we tell Ansible what version of node we want with <em>nodejs_version</em>. Additionally the role supports the automatic installation of a list of global node modules; with the variable <em>nodejs_packages </em>I am stating that I’d like PM2 to be installed globally.</p><p>Before Node.js is installed, with a list of <em>pre_tasks </em>I am also doing the following:</p><ul><li>Create a group called <em>apps</em></li><li>Create a user called <em>apps </em>in the group <em>apps</em> and its home set to <em>/var/apps</em></li><li>Create the directory <em>/var/apps</em></li><li>Copy the <em>services </em>directory on the local machine to <em>/var/app/services</em>. This directory contains all the Node.js apps that we want to run on the Vagrant box.</li></ul><p>The reason why we are creating the <em>apps</em> user, is that for security reasons we will run all the Node.js applications through PM2 as <strong>non-root</strong> user with no sudo privileges.</p><h4>PM2 Configuration</h4><p>The PM2 configuration using Ansible was the most time consuming in this little experiment, due to the fact that I want it to run the applications as non-root user. It took quite some poking around and digging into the service startup script to figure it out: I am writing it down here so you don’t have to do the same.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/169843b0b66810fd4aaa09cc297e9bfa/href">https://medium.com/media/169843b0b66810fd4aaa09cc297e9bfa/href</a></iframe><p>I have added a few new things here. First, at the top I included a new variable <em>pm2_apps</em>. It contains a list of JavaScript applications that will be launched by PM2.</p><p>There are also three new tasks.</p><pre>name: stop node apps</pre><p>If any application is already running (e.g. from a previous run of the provisioning script) this tasks kills all of them. The task is run impersonating the <em>apps</em> user, as that is the non-root user that owns the PS2 process.</p><pre>name: start node apps</pre><p>Iterates through the list of applications contained in the <em>pm2_apps</em> variable with the <em>with_items</em> statement and tell PM2 to start each of them. This task is also run impersonating the <em>apps</em> user.</p><pre>name: installing startup script</pre><p>PM2 provides a command that creates a shell script that is attached to Ubuntu’s upstart system, so PM2 is started when the OS is booted. This task tells PM2 to create the startup script and install it as a service. Once the task is completed it notifies a handler that starts the service.</p><p>This was the trickiest bit and the following section explains the issue I had and how I solved it. Feel free to skip it.</p><p>This task has to be run as root, but with the <em>-u</em> flag it is possible to specify what user should own the PM2 process. The problem was that Ansible runs the provisioning by opening a SSH session to the box as the <em>vagrant</em> user and then all the commands are executed with sudo.</p><p>Once the startup script is generated (<em>/etc/init.d/pm2-init.sh</em>) the $<em>PM2_HOME</em> variable is hardcoded to the value <em>$HOME</em> had when the script was generated, in this case <em>/home/vagrant</em>. However for this to run properly $<em>PM2_HOME</em> has to be set to <em>/var/apps</em>. For this reason I am forcing the task to set <em>$HOME</em> to <em>/var/apps</em>.</p><h4>Nginx Configuration</h4><p>As I mentioned at the beginning of this post, Nginx will serve static pages and act as a reverse proxy for the Node.js applications, that in this example are running on ports 3001 and 3o02. To accomplish this I created the following Nginx configuration.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/944784886167c8bf16cd53a6fed662e8/href">https://medium.com/media/944784886167c8bf16cd53a6fed662e8/href</a></iframe><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/444fa27ba1193eb5be11b368bb3292b6/href">https://medium.com/media/444fa27ba1193eb5be11b368bb3292b6/href</a></iframe><p>The default configuration includes the other configuration files, one for each of the Node.js applications I am deploying. I had never configured Nginx before, but with a quick Google search it was easy enough to figure out.</p><p>Again, these files are deployed to the Vagrant box by Ansible. Below are the relevant tasks and handlers.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/99c65ffe4b61ad1c4ce2bd77df0fedf8/href">https://medium.com/media/99c65ffe4b61ad1c4ce2bd77df0fedf8/href</a></iframe><pre>name: configure nginx</pre><p>Copies all the files in the local <em>nginx</em> directory to <em>/etc/nginx/sites-available</em> on the Vagrant box and notifies a handler that takes care of restarting Nginx to apply the new configuration.</p><h4>Monitoring with PM2 and Keymetrics</h4><p>PM2 has some built-in features to manage and monitor the running apps. If we login into the box and switch to the <em>apps </em>user we can see the list of active applications.</p><pre>$ vagrant ssh<br>$ sudo su - apps<br>$ pm2 list</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/511/1*OqGKOJxFcmDWXXDJiuM6Dw.png" /><figcaption>The list of running apps returned by PM2</figcaption></figure><p>We can also see some information about CPU and memory utilization of the active applications.</p><pre>$ pm2 monit</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/502/1*Lt5fQ5SdSMvjLbU0Di12aw.png" /><figcaption>CPU and memory utilization of the two running applications</figcaption></figure><p>In order to monitor all the available metrics and potential errors and exceptions it is possible to link PM2 to <a href="https://keymetrics.io/">Keymetrics</a>, an online service that provides a dashboard that displays all the relevant information about your running apps.</p><p>Connecting to Keymetrics is very simple. The configuration can once again be done with a simple task in Ansible.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/62d4f93a2bc4f023982678c8532058f2/href">https://medium.com/media/62d4f93a2bc4f023982678c8532058f2/href</a></iframe><p>This task relies on three variables that are set separately (see the complete playbook in the <a href="https://github.com/mmarcon/ubuntu-node-nginx-ansible/blob/master/playbook.yml">GitHub repository</a>):</p><pre>keymetrics</pre><p>is a boolean. The task runs only when this variable is set to <em>yes</em>.</p><pre>{{ keymetrics_secret_key }}<br>{{ keymetrics_public_key }}</pre><p>These are provided by Keymetrics when you signup for an account and create a bucket.</p><p>The result is shown in the screenshot below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5D-p7_L3YmYCFBD_0wGCOA.png" /><figcaption>The two Node.js apps are visualized on the Keymetrics dashboard</figcaption></figure><h4>Deployment to Digital Ocean</h4><p>Everything we have discussed so far was about creating an environment where to test Node.js applications locally during development.</p><p>Now it’s time to deploy our box to production. In particular I recommend Digital Ocean. What they promise is <em>simple cloud hosting<br>built for developers </em>and the ability to <em>deploy an SSD cloud server in 55 seconds</em>, and I really think they deliver on this promise.</p><p><a href="https://github.com/smdahlen">Somebody</a> made a nice <a href="https://github.com/smdahlen/vagrant-digitalocean">plugin for Vagrant</a> that makes the deployment to Digital Ocean a piece of cake.</p><p>The first step is to install the plugin:</p><pre>$ vagrant plugin install vagrant-digitalocean</pre><p>The next step is to add a few lines to the <em>Vagrantfile</em> to describe how to deploy to Digital Ocean.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/5e8182f97f951108e93dcc716dc6d92e/href">https://medium.com/media/5e8182f97f951108e93dcc716dc6d92e/href</a></iframe><p>Replace <em>DigitalOceanSecretToken</em> with the token that you created on Digital Ocean and run</p><pre>$ vagrant up --provider=digital_ocean</pre><p>This will connect to Digital Ocean, create a new droplet with the configuration specified in the <em>Vagrantfile</em> and run the provisioning with Ansible. In about a minute you applications will be up and running in production and the command will return the IP address of the new droplet.</p><pre>$ vagrant destroy</pre><p>will tell Digital Ocean to destroy the droplet.</p><p>Something very similar is also possible with AWS. Download the corresponding <a href="https://github.com/mitchellh/vagrant-aws">Vagrant plugin</a> and in theory everything should work out of the box.</p><p>This was a very nice experiment, and what I have in the resulting <a href="https://github.com/mmarcon/ubuntu-node-nginx-ansible">GitHub repository</a> will certainly be useful for future projects. Vagrant and Ansible together are very helpful to quickly define and spin up environments that can be used both locally as well as with a cloud provider for production deployments.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8dccaaf620d1" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[A Travel Diary App]]></title>
            <link>https://medium.com/@mmarcon/a-travel-diary-app-d9c9c12ee833?source=rss-e5bf57064312------2</link>
            <guid isPermaLink="false">https://medium.com/p/d9c9c12ee833</guid>
            <category><![CDATA[travel]]></category>
            <category><![CDATA[location]]></category>
            <category><![CDATA[web-development]]></category>
            <dc:creator><![CDATA[Massimiliano Marcon]]></dc:creator>
            <pubDate>Fri, 24 Apr 2015 15:44:14 GMT</pubDate>
            <atom:updated>2015-04-24T15:44:14.933Z</atom:updated>
            <content:encoded><![CDATA[<h4>No code required. Almost.</h4><p>Lots of people write blog posts about their trips around the world, where they describe the amazing places they have seen, the food they ate and the people they have met. Many travelers create photo albums on Flickr, post articles on Medium, or simply have a series of check-ins on Facebook to make their friends jealous.</p><p>Unfortunately, writing a blog post, taking the perfect photo or checking-in on Facebook is often more of a distraction than anything else. For this reason I have been thinking for a while about building a tool that would do all of this for you. You walk around, visit a place, enjoy the experience, and there will be someone else that will take care of building some sort of <strong>travel diary </strong>for you.</p><p>In a world where almost everybody has a smartphone in their pocket, and more and more people wear smart watches and smart bracelets this is actually quite easy to accomplish. It can be made super fancy and super customizable, but creating the core functionality is really not that hard.</p><p>This week I had a few spare hours in the evening and I thought it would be nice to see what I could hack together in a short period of time. The idea was to create some sort of <em>auto-checkin</em> functionality by leveraging as much as possible services and APIs that are publicly and freely available on the Internet and limit the amount of code as much as possible.</p><p>The final result is visible here: <a href="http://mmarcon.github.io/contentful2cards/">http://mmarcon.github.io/contentful2cards/</a>. In about 5 hours I managed to glue together 4 different services with 281 lines of code and obtain the first proof of concept for my idea. Below are the details.</p><h3>Triggers</h3><p>The ideal scenario would be that when you are visiting a city, a park or any other place, every time you stop to admire something interesting (landmarks, buildings, sculptures) or to rest in a park, an event with a location attached is triggered.</p><p>This would be easy to accomplish with a simple mobile application, however for my prototype I wanted to write almost no code. Therefore I decided that even tapping a button would be fine for now, and I went with <a href="https://ifttt.com/products/do/button">IFTTT Do</a>.</p><p>There may be wearables that can be used together with IFTTT and trigger the same event automatically, replacing the need for the button.</p><p>IFTTT has unfortunately one big issue: it does not POST data to custom endpoints. Somebody found <a href="https://github.com/captn3m0/ifttt-webhook">a way to work around this issue</a>, but the workaround wasn’t really working for me, so I had to think of another one. The safest bet is obviously email. IFTTT can use your Gmail account to send a message to any email address, and with Do for Android the message can include the current GPS location.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*uTWRLczPNCP1lw3ncf7qiA.png" /><figcaption>IFTTT Do location email configuration</figcaption></figure><p>Now, this email needs to get to the core component of my tool. Of course I did not want to setup a mail server that receives these emails. Luckily there are services out there that can be configured to receive emails and transform them into API calls to any endpoint. I went with <a href="https://mailgun.com/">Mailgun</a>, configured a custom subdomain for it, waited a few hours for DNS propagation, <a href="https://documentation.mailgun.com/quickstart-receiving.html#inbound-routes-and-parsing">configured a route</a>, and that bit was done. I can now receive any type of event from IFTTT and send it anywhere.</p><h3>The smart bit</h3><p>All the pieces that constitute this tool are fairly dumb. They trigger events, forward data from one place to another, store data, and show data. However there is <a href="https://github.com/mmarcon/mailgun2contentful">one component that does something more</a>: it exposes an API endpoint that receives a location (latitude and longitude) and fetches some information about it. In this first version of my travel diary application this service uses <a href="https://developer.here.com/rest-apis/documentation/geocoder/topics/request-first-reverse-geocode.html">HERE’s reverse geocoder</a> to guess what such location may be and to assign a name to it. If a search for landmarks does not produce any results it falls back to just using the address to label the location.</p><p>With some more coding this step can be made a lot smarter and used to combine together multiple services to retrieve more precise and richer information about the detected location (photos, Wikipedia articles, tweets, etc.), but goes beyond the scope of this first prototype.</p><p>Once the place is identified, the information is posted somewhere else so it can be stored, edited later on and extracted to be displayed in a pretty web page.</p><p>This components was developed as a quick and dirty node.js application that is running on <a href="https://www.heroku.com/">Heroku</a>. <a href="https://github.com/mmarcon/mailgun2contentful">The code</a> is available on Github.</p><h3>Storage</h3><p>For storage I signed up for <a href="https://www.contentful.com/">Contentful</a>. Contenful define themselves as an <em>API-first content management system for multi-device online publishing</em>. Essentially they provide a REST API to create, manage and retrieve content along with a convenient CMS-like user interface. API-first CMSs are a very interesting approach to managing content, and it is a very good fit for my use case. In addition to that, Contentful is part of the Berlin startup scene and that is yet another reason for giving it a try.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*dhRcQ3Efim51I7GWslGsFg.png" /><figcaption>Contentful CMS user interface</figcaption></figure><p>Contentful provides <a href="https://github.com/contentful">open source SDKs</a> for several platforms. I decided to call the REST API directly though, and almost everything worked at the first attempt. It took some trial and error iterations to figure out that location fields are also treated as localizable fields and therefore need to be associated with a locale when creating the payload for the API, but I guess this is taken care of by the SDKs that I deliberately decided not to use.</p><p>As shown in the screenshot above, all the data from the <em>auto-chekins</em> and the information that is fetched by <em>the smart bit</em> is safely stored in Contentful where it can be manually edited, curated and if needed, unpublished and deleted.</p><h3>Front-end</h3><p>The final piece is <a href="http://mmarcon.github.io/contentful2cards/">the front-end</a>. It is a very simple, front-end only web application. It fetches the published items from my Contentful space using their <a href="https://www.contentful.com/developers/documentation/content-delivery-api/">Content Delivery API</a> and display them on a very <a href="http://www.google.com/design/spec/material-design/introduction.html"><em>material</em></a> web page.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*GZLBBjYOk99nyl1niYXzLA.png" /></figure><p>The location field is used to render map tiles for places by using, once again, <a href="https://developer.here.com/rest-apis/documentation/enterprise-map-image/topics/introduction.html">one of HERE’s APIs</a>.</p><p>This page was built with a bit of jQuery, mustache.js and looks <em>material</em> because of <a href="http://materializecss.com/">Materialize</a>.</p><p>This little experiment proves that this concept that I’ve had in mind for a while can actually be implemented fairly easily and quite cheaply. It also shows that there are really no reason for IFTTT to keep not implementing WebHooks. Developers will find a way to obtain the same thing. I had the chance to play with Contentful and their API, and gave me some more insights into it: who knows, I may try to use it for one of my future work projects. Last, but not least, my first web application with material design!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d9c9c12ee833" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>