<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
 
 <title>Luís Armando Bianchin</title>
 <link href="http://blog.labianchin.me//" rel="self"/>
 <link href="http://blog.labianchin.me/"/>
 <updated>2016-02-16T12:54:10+00:00</updated>
 <id>http://blog.labianchin.me/</id>
 <author>
   <name>Luís Armando Bianchin</name>
   <email>blog@labianchin.me</email>
 </author>

 
 <entry>
   <title>Docker Tips And Tricks</title>
   <link href="http://blog.labianchin.me//2016/02/15/docker-tips-and-tricks"/>
   <updated>2016-02-15T00:00:00+00:00</updated>
   <id>http://blog.labianchin.me//2016/02/15/docker-tips-and-tricks</id>
   <content type="html">&lt;p&gt;So you know the Docker basics, but when using it more often some things might miss. As every tool, Docker has its own tips and tricks to be effective.&lt;/p&gt;

&lt;p&gt;I have been using Docker for a long time and noticed that some tricks and practices are recurrent. The goal of this is to document tips, tricks and best practices I gathered along my journey of learning and using Docker. Notice that the information here is very dense, so you might come back to look to specific items when needed.&lt;/p&gt;

&lt;p&gt;This document is separated in two sections: running (&lt;code&gt;docker run&lt;/code&gt;) and building (&lt;code&gt;docker build&lt;/code&gt;/&lt;code&gt;Dockerfile&lt;/code&gt;).&lt;/p&gt;

&lt;h3 id=&quot;running&quot;&gt;Running&lt;/h3&gt;

&lt;p&gt;Remember every &lt;code&gt;docker run&lt;/code&gt; creates a new container with the specified image and starts a command inside of it (&lt;code&gt;CMD&lt;/code&gt; specified in the Dockerfile).
When using this command many times, use the &lt;code&gt;--rm&lt;/code&gt; flag, so that the container data is removed after it finishes. By default, I tend to use the run command as in the following example:&lt;/p&gt;
&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-sh&quot; data-lang=&quot;sh&quot;&gt;docker run --rm -it debian /bin/bash
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Notice here that &lt;code&gt;-it&lt;/code&gt; means &lt;code&gt;--interactive --tty&lt;/code&gt;. It is used to attach the command line to the container after it has started. Those are very useful params when running a container in foreground mode.&lt;/p&gt;

&lt;h4 id=&quot;check-the-env&quot;&gt;Check the env&lt;/h4&gt;

&lt;p&gt;Sometimes it is worth to check what metadata is defined as env vars in a image. Use the &lt;code&gt;env&lt;/code&gt; command to get this information:&lt;/p&gt;
&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-sh&quot; data-lang=&quot;sh&quot;&gt;docker run --rm -it debian env
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;To check the env vars passed to an already created container use:&lt;/p&gt;
&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-sh&quot; data-lang=&quot;sh&quot;&gt;docker inspect --format &lt;span class=&quot;s1&quot;&gt;&#39;{{.Config.Env}}&#39;&lt;/span&gt; &amp;lt;container&amp;gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;h4 id=&quot;logs&quot;&gt;Logs&lt;/h4&gt;

&lt;p&gt;If a container was started in detached mode (&lt;code&gt;-d&lt;/code&gt;), the logs of it can be retrieved using the following:&lt;/p&gt;
&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-sh&quot; data-lang=&quot;sh&quot;&gt;docker logs -f &amp;lt;container_name&amp;gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Also notice the &lt;code&gt;-f&lt;/code&gt; tag to follow the upcoming log messages. When you are done, hit &lt;code&gt;Ctrl-c&lt;/code&gt;.&lt;/p&gt;

&lt;h4 id=&quot;backup&quot;&gt;Backup&lt;/h4&gt;

&lt;p&gt;Data in Docker containers is exposed and shared via volumes flags passed when creating/starting the container. Another good approach is to store data inside Volume Containers. Nevertheless, it is important to backup that data and sometimes it might be necessary to move that data to other host.&lt;/p&gt;

&lt;p&gt;Backup using a command like the following:&lt;/p&gt;
&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-sh&quot; data-lang=&quot;sh&quot;&gt;docker run --rm -v /tmp:/backup --volumes-from &amp;lt;container-name&amp;gt; busybox tar -cvf /backup/backup.tar &amp;lt;path-to-data&amp;gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;And restore using:&lt;/p&gt;
&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-sh&quot; data-lang=&quot;sh&quot;&gt;docker run --rm -v /tmp:/backup --volumes-from &amp;lt;container-name&amp;gt; busybox tar -xvf /backup/backup.tar &amp;lt;path-to-data&amp;gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;This (mine) &lt;a href=&quot;http://stackoverflow.com/a/34776997/1046584&quot;&gt;StackOverflow answer&lt;/a&gt; has some aliases for these two commands. You can also find them below in the &lt;em&gt;Aliases&lt;/em&gt; section.&lt;/p&gt;

&lt;h4 id=&quot;use-docker-exec-to-quot-enter-into-a-container-quot&quot;&gt;Use docker exec to &amp;quot;enter into a container&amp;quot;&lt;/h4&gt;

&lt;p&gt;Never install SSH daemon in a container. Use &lt;code&gt;docker exec&lt;/code&gt; to enter into a container:&lt;/p&gt;
&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-sh&quot; data-lang=&quot;sh&quot;&gt;docker &lt;span class=&quot;nb&quot;&gt;exec&lt;/span&gt; -it ubuntu_bash bash
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Use it to inspect and debug running containers. But, ideally, avoid creating automated tooling around it.&lt;/p&gt;

&lt;p&gt;Check the documentation of it: &lt;a href=&quot;https://docs.docker.com/engine/reference/commandline/exec/&quot;&gt;https://docs.docker.com/engine/reference/commandline/exec/&lt;/a&gt;&lt;/p&gt;

&lt;h4 id=&quot;no-space-disk-left&quot;&gt;No space disk left&lt;/h4&gt;

&lt;p&gt;When running containers and build images several times, disk space may become scarce. When that happens, clear some containers, images and logs.&lt;/p&gt;

&lt;p&gt;In order to clean up containers and images, use the following commands:&lt;/p&gt;
&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-sh&quot; data-lang=&quot;sh&quot;&gt;docker ps -aq | xargs docker rm &lt;span class=&quot;c&quot;&gt;# to remove all containers&lt;/span&gt;
docker images -aq -f &lt;span class=&quot;nv&quot;&gt;dangling&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;true&lt;/span&gt; | xargs docker rmi &lt;span class=&quot;c&quot;&gt;# to remove unused images&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Cleaning up logs is trickier. Still, it can be achieved by running the following command inside the docker host:&lt;/p&gt;
&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-sh&quot; data-lang=&quot;sh&quot;&gt;&lt;span class=&quot;nb&quot;&gt;echo&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;&quot;&lt;/span&gt; &amp;gt; &lt;span class=&quot;k&quot;&gt;$(&lt;/span&gt;docker inspect --format&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;&#39;{{.LogPath}}&#39;&lt;/span&gt; &amp;lt;container_name_or_id&amp;gt;&lt;span class=&quot;k&quot;&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;ul&gt;
&lt;li&gt;The feature to clear log history was actually rejected: &lt;a href=&quot;https://github.com/docker/compose/issues/1083&quot;&gt;https://github.com/docker/compose/issues/1083&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;Consider specifying the &lt;code&gt;max-size&lt;/code&gt; option to the logging driver on &lt;code&gt;docker run&lt;/code&gt;: &lt;a href=&quot;https://docs.docker.com/engine/reference/logging/overview/#json-file-options&quot;&gt;https://docs.docker.com/engine/reference/logging/overview/#json-file-options&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h4 id=&quot;aliases&quot;&gt;Aliases&lt;/h4&gt;

&lt;p&gt;Use these aliases in &lt;code&gt;.zshrc&lt;/code&gt; or &lt;code&gt;.bashrc&lt;/code&gt; to clean images and containers, do backup and restore, etc.&lt;/p&gt;
&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-sh&quot; data-lang=&quot;sh&quot;&gt;&lt;span class=&quot;nb&quot;&gt;alias &lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;dockercleancontainers&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;docker ps -aq | xargs docker rm&quot;&lt;/span&gt;
&lt;span class=&quot;nb&quot;&gt;alias &lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;dockercleanimages&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;docker images -aq -f dangling=true | xargs docker rmi&quot;&lt;/span&gt;
&lt;span class=&quot;nb&quot;&gt;alias &lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;dockerclean&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;dockercleancontainers &amp;amp;&amp;amp; dockercleanimages&quot;&lt;/span&gt;
&lt;span class=&quot;nb&quot;&gt;alias &lt;/span&gt;docker-killall&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;docker ps -q | xargs docker kill&quot;&lt;/span&gt;

&lt;span class=&quot;c&quot;&gt;# runs docker exec in the latest container&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;function &lt;/span&gt;docker-exec-last &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
  docker &lt;span class=&quot;nb&quot;&gt;exec&lt;/span&gt; -ti &lt;span class=&quot;k&quot;&gt;$(&lt;/span&gt; docker ps -a -q -l&lt;span class=&quot;k&quot;&gt;)&lt;/span&gt; /bin/bash
&lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;

&lt;span class=&quot;k&quot;&gt;function &lt;/span&gt;docker-get-ip &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;c&quot;&gt;# Usage: docker-get-ip (name or sha)&lt;/span&gt;
  &lt;span class=&quot;o&quot;&gt;[&lt;/span&gt; -n &lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$1&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;amp;&amp;amp;&lt;/span&gt; docker inspect --format &lt;span class=&quot;s2&quot;&gt;&quot;{{ .NetworkSettings.IPAddress }}&quot;&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;$1&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;

&lt;span class=&quot;k&quot;&gt;function &lt;/span&gt;docker-get-id &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;c&quot;&gt;# Usage: docker-get-id (friendly-name)&lt;/span&gt;
  &lt;span class=&quot;o&quot;&gt;[&lt;/span&gt; -n &lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$1&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;amp;&amp;amp;&lt;/span&gt; docker inspect --format &lt;span class=&quot;s2&quot;&gt;&quot;{{ .ID }}&quot;&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$1&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;

&lt;span class=&quot;k&quot;&gt;function &lt;/span&gt;docker-get-image &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;c&quot;&gt;# Usage: docker-get-image (friendly-name)&lt;/span&gt;
  &lt;span class=&quot;o&quot;&gt;[&lt;/span&gt; -n &lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$1&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;amp;&amp;amp;&lt;/span&gt; docker inspect --format &lt;span class=&quot;s2&quot;&gt;&quot;{{ .Image }}&quot;&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$1&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;

&lt;span class=&quot;k&quot;&gt;function &lt;/span&gt;docker-get-state &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;c&quot;&gt;# Usage: docker-get-state (friendly-name)&lt;/span&gt;
  &lt;span class=&quot;o&quot;&gt;[&lt;/span&gt; -n &lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$1&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;amp;&amp;amp;&lt;/span&gt; docker inspect --format &lt;span class=&quot;s2&quot;&gt;&quot;{{ .State.Running }}&quot;&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$1&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;

&lt;span class=&quot;k&quot;&gt;function &lt;/span&gt;docker-memory &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;k&quot;&gt;for &lt;/span&gt;line &lt;span class=&quot;k&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;sb&quot;&gt;`&lt;/span&gt;docker ps | awk &lt;span class=&quot;s1&quot;&gt;&#39;{print $1}&#39;&lt;/span&gt; | grep -v CONTAINER&lt;span class=&quot;sb&quot;&gt;`&lt;/span&gt;; &lt;span class=&quot;k&quot;&gt;do &lt;/span&gt;docker ps | grep &lt;span class=&quot;nv&quot;&gt;$line&lt;/span&gt; | awk &lt;span class=&quot;s1&quot;&gt;&#39;{printf $NF&quot; &quot;}&#39;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;echo&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;$((&lt;/span&gt; &lt;span class=&quot;sb&quot;&gt;`&lt;/span&gt;cat /sys/fs/cgroup/memory/docker/&lt;span class=&quot;nv&quot;&gt;$line&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;*&lt;/span&gt;/memory.usage_in_bytes&lt;span class=&quot;sb&quot;&gt;`&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;/&lt;/span&gt; &lt;span class=&quot;m&quot;&gt;1024&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;/&lt;/span&gt; &lt;span class=&quot;m&quot;&gt;1024&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;))&lt;/span&gt;MB ; &lt;span class=&quot;k&quot;&gt;done&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;c&quot;&gt;# keeps the commmand history when running a container&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;function &lt;/span&gt;basher&lt;span class=&quot;o&quot;&gt;()&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;[[&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;$1&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;&#39;run&#39;&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;]]&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;then
        &lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;shift
        &lt;/span&gt;docker run -e &lt;span class=&quot;nv&quot;&gt;HIST_FILE&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;/root/.bash_history -v &lt;span class=&quot;nv&quot;&gt;$HOME&lt;/span&gt;/.bash_history:/root/.bash_history &lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$@&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;else
        &lt;/span&gt;docker &lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$@&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;fi&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;c&quot;&gt;# backup files from a docker volume into /tmp/backup.tar.gz&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;function &lt;/span&gt;docker-volume-backup-compressed&lt;span class=&quot;o&quot;&gt;()&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
  docker run --rm -v /tmp:/backup --volumes-from &lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$1&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt; debian:jessie tar -czvf /backup/backup.tar.gz &lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;${&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;@&lt;/span&gt;:2&lt;span class=&quot;k&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;c&quot;&gt;# restore files from /tmp/backup.tar.gz into a docker volume&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;function &lt;/span&gt;docker-volume-restore-compressed&lt;span class=&quot;o&quot;&gt;()&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
  docker run --rm -v /tmp:/backup --volumes-from &lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$1&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt; debian:jessie tar -xzvf /backup/backup.tar.gz &lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;${&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;@&lt;/span&gt;:2&lt;span class=&quot;k&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;
  &lt;span class=&quot;nb&quot;&gt;echo&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;Double checking files...&quot;&lt;/span&gt;
  docker run --rm -v /tmp:/backup --volumes-from &lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$1&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt; debian:jessie ls -lh &lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;${&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;@&lt;/span&gt;:2&lt;span class=&quot;k&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;c&quot;&gt;# backup files from a docker volume into /tmp/backup.tar&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;function &lt;/span&gt;docker-volume-backup&lt;span class=&quot;o&quot;&gt;()&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
  docker run --rm -v /tmp:/backup --volumes-from &lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$1&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt; busybox tar -cvf /backup/backup.tar &lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;${&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;@&lt;/span&gt;:2&lt;span class=&quot;k&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;c&quot;&gt;# restore files from /tmp/backup.tar into a docker volume&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;function &lt;/span&gt;docker-volume-restore&lt;span class=&quot;o&quot;&gt;()&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;{&lt;/span&gt;
  docker run --rm -v /tmp:/backup --volumes-from &lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$1&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt; busybox tar -xvf /backup/backup.tar &lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;${&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;@&lt;/span&gt;:2&lt;span class=&quot;k&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;
  &lt;span class=&quot;nb&quot;&gt;echo&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;Double checking files...&quot;&lt;/span&gt;
  docker run --rm -v /tmp:/backup --volumes-from &lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$1&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt; busybox ls -lh &lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;${&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;@&lt;/span&gt;:2&lt;span class=&quot;k&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Sources:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;https://zwischenzugs.wordpress.com/2015/06/14/my-favourite-docker-tip/&quot;&gt;https://zwischenzugs.wordpress.com/2015/06/14/my-favourite-docker-tip/&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://website-humblec.rhcloud.com/docker-tips-and-tricks/&quot;&gt;https://website-humblec.rhcloud.com/docker-tips-and-tricks/&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3 id=&quot;building-images&quot;&gt;Building Images&lt;/h3&gt;

&lt;p&gt;In Docker, images are traditionally built using a &lt;code&gt;Dockerfile&lt;/code&gt;. There is already some nice guides on best practices to build docker images. I recommend taking a look to them:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;https://docs.docker.com/engine/articles/dockerfile_best-practices/&quot;&gt;https://docs.docker.com/engine/articles/dockerfile_best-practices/&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://www.projectatomic.io/docs/docker-image-author-guidance/&quot;&gt;http://www.projectatomic.io/docs/docker-image-author-guidance/&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://crosbymichael.com/dockerfile-best-practices.html&quot;&gt;http://crosbymichael.com/dockerfile-best-practices.html&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://crosbymichael.com/dockerfile-best-practices-take-2.html&quot;&gt;http://crosbymichael.com/dockerfile-best-practices-take-2.html&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h4 id=&quot;use-a-linter&quot;&gt;Use a linter&lt;/h4&gt;

&lt;p&gt;A linter can provide warnings and tips about the Dockerfile. This space is quite new, with some simple solutions but not yet something solid.&lt;/p&gt;

&lt;p&gt;There are many options been discussed here: &lt;a href=&quot;https://stackoverflow.com/questions/28182047/is-there-a-way-to-lint-the-dockerfile&quot;&gt;https://stackoverflow.com/questions/28182047/is-there-a-way-to-lint-the-dockerfile&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;As of January 2016, the most complete seems to be &lt;a href=&quot;http://hadolint.lukasmartinelli.ch/&quot;&gt;hadolint&lt;/a&gt;. Available as online version and terminal version.
It also uses &lt;a href=&quot;http://www.shellcheck.net/about.html&quot;&gt;Shell Check&lt;/a&gt; to validate the shell commands.&lt;/p&gt;

&lt;h4 id=&quot;prefer-copy-over-add&quot;&gt;Prefer COPY over ADD&lt;/h4&gt;

&lt;p&gt;&lt;code&gt;ADD&lt;/code&gt; is very versatile, but generally too magical and hard to understand. &lt;code&gt;COPY&lt;/code&gt; is a much simpler command to insert files and folder from the build path into the Docker image, and so should be favored. Longer discussion here: &lt;a href=&quot;https://labs.ctl.io/dockerfile-add-vs-copy/&quot;&gt;https://labs.ctl.io/dockerfile-add-vs-copy/&lt;/a&gt;&lt;/p&gt;

&lt;h4 id=&quot;run-a-checksum-after-download-and-before-using-the-file&quot;&gt;Run a checksum after download and before using the file&lt;/h4&gt;

&lt;p&gt;Instead of using &lt;code&gt;ADD&lt;/code&gt; to download and add files to the image. Favor using &lt;code&gt;curl&lt;/code&gt; and running a checksum after the download.&lt;/p&gt;

&lt;p&gt;One nice example to take inspiration is the official &lt;a href=&quot;https://github.com/jenkinsci/docker/blob/83ce6f6070f1670563a00d0f61d04edd62b78f4f/Dockerfile#L36&quot;&gt;Jenkins Dockerfile&lt;/a&gt;:&lt;/p&gt;
&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-&quot; data-lang=&quot;&quot;&gt;ENV JENKINS_VERSION 1.625.3
ENV JENKINS_SHA 537d910f541c25a23499b222ccd37ca25e074a0c

RUN curl -fL http://mirrors.jenkins-ci.org/war-stable/$JENKINS_VERSION/jenkins.war -o /usr/share/jenkins/jenkins.war \
  &amp;amp;&amp;amp; echo &quot;$JENKINS_SHA /usr/share/jenkins/jenkins.war&quot; | sha1sum -c -
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;h4 id=&quot;use-a-minimal-base-image&quot;&gt;Use a minimal base image&lt;/h4&gt;

&lt;p&gt;Most of the official images use &lt;a href=&quot;https://hub.docker.com/_/debian/&quot;&gt;&lt;code&gt;debian&lt;/code&gt;&lt;/a&gt; as base image. Use this as a default. Remember to also use specific tags, e.g. &lt;code&gt;debian:jessie&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;If more tools and dependencies are needed, take a look at &lt;a href=&quot;https://hub.docker.com/_/buildpack-deps/&quot;&gt;&lt;code&gt;buildpack-deps&lt;/code&gt; images&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;If &lt;code&gt;debian&lt;/code&gt; stills seems too big, consider using &lt;a href=&quot;https://hub.docker.com/r/gliderlabs/alpine/&quot;&gt;&lt;code&gt;alpine&lt;/code&gt;&lt;/a&gt; or even &lt;a href=&quot;https://hub.docker.com/r/gliderlabs/alpine/&quot;&gt;&lt;code&gt;busybox&lt;/code&gt;&lt;/a&gt;. Avoid &lt;code&gt;alpine&lt;/code&gt; if DNS is needed, there are &lt;a href=&quot;https://github.com/gliderlabs/docker-alpine/blob/master/docs/caveats.md&quot;&gt;some issues&lt;/a&gt;. Also avoid it for languages that use GCC, such as Ruby, Node, Python, etc, this is because &lt;code&gt;alpine&lt;/code&gt; packs with musl libc which might produce different binaries.&lt;/p&gt;

&lt;p&gt;But please, do NOT use &lt;a href=&quot;https://hub.docker.com/r/phusion/baseimage/&quot;&gt;&lt;code&gt;phusion/baseimage&lt;/code&gt;&lt;/a&gt;. It is an image too big, and many of the things it includes are non essential on Docker containers, &lt;a href=&quot;https://blog.docker.com/2014/06/why-you-dont-need-to-run-sshd-in-docker/&quot;&gt;see more here&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Other sources:
&lt;a href=&quot;http://www.iron.io/microcontainers-tiny-portable-containers/&quot;&gt;http://www.iron.io/microcontainers-tiny-portable-containers/&lt;/a&gt;&lt;/p&gt;

&lt;h4 id=&quot;use-the-layer-cache&quot;&gt;Use the layer cache&lt;/h4&gt;

&lt;p&gt;One nice thing about the &lt;code&gt;Dockerfile&lt;/code&gt; is the fast rebuilds by using the layer cache. In order to take advantage of this feature, put things that change less often at the top of the &lt;code&gt;Dockerfile&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;For example, consider installing the code dependencies before adding the code. In NodeJS case:&lt;/p&gt;
&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-&quot; data-lang=&quot;&quot;&gt;COPY package.json /app/
RUN npm install
COPY . /app
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;More about this: &lt;a href=&quot;http://bitjudo.com/blog/2014/03/13/building-efficient-dockerfiles-node-dot-js/&quot;&gt;http://bitjudo.com/blog/2014/03/13/building-efficient-dockerfiles-node-dot-js/&lt;/a&gt;&lt;/p&gt;

&lt;h4 id=&quot;clean-up-in-the-same-layer&quot;&gt;Clean up in the same layer&lt;/h4&gt;

&lt;p&gt;When using a package manager to install some software, it is a good practice to clean up the cache generated by the package manager just after the installation. For example:&lt;/p&gt;
&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-&quot; data-lang=&quot;&quot;&gt;RUN apt-get update &amp;amp;&amp;amp; \
    apt-get install -y curl python-pip &amp;amp;&amp;amp; \
    pip install requests &amp;amp;&amp;amp; \
    apt-get remove -y python-pip curl &amp;amp;&amp;amp; \
    rm -rf /var/lib/apt/lists/*
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Also notice here, that &lt;code&gt;pip&lt;/code&gt; and &lt;code&gt;curl&lt;/code&gt; are also removed as they are not needed in for the production application. Remember that the clean up needs to be done in the same &lt;code&gt;RUN&lt;/code&gt; command, otherwise the data will be persisted in that layer, and removing it later will not have effect in the final image size.&lt;/p&gt;

&lt;p&gt;More about this:&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;http://blog.replicated.com/2016/02/05/refactoring-a-dockerfile-for-image-size/&quot;&gt;http://blog.replicated.com/2016/02/05/refactoring-a-dockerfile-for-image-size/&lt;/a&gt;
&lt;a href=&quot;https://docs.docker.com/engine/userguide/eng-image/dockerfile_best-practices/#apt-get&quot;&gt;https://docs.docker.com/engine/userguide/eng-image/dockerfile_best-practices/#apt-get&lt;/a&gt;&lt;/p&gt;

&lt;h4 id=&quot;use-a-wrapper-script-as-entrypoint-sometimes&quot;&gt;Use a wrapper script as ENTRYPOINT, sometimes&lt;/h4&gt;

&lt;p&gt;A wrapper script can help by taking environment configuration and setting the app configuration. It can even set defaults if environment config is not provided.&lt;/p&gt;

&lt;p&gt;Here is one example from &lt;a href=&quot;https://medium.com/@kelseyhightower/12-fractured-apps-1080c73d481c#.xn2cylwnk&quot;&gt;Kelsey Hightower&amp;#39;s 12 Fractured Apps&lt;/a&gt;:&lt;/p&gt;
&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-sh&quot; data-lang=&quot;sh&quot;&gt;&lt;span class=&quot;c&quot;&gt;#!/bin/sh&lt;/span&gt;
&lt;span class=&quot;nb&quot;&gt;set&lt;/span&gt; -e
&lt;span class=&quot;nv&quot;&gt;datadir&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;${&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;APP_DATADIR&lt;/span&gt;:&lt;span class=&quot;p&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;/var/lib/data&quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;nv&quot;&gt;host&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;${&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;APP_HOST&lt;/span&gt;:&lt;span class=&quot;p&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;127.0.0.1&quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;nv&quot;&gt;port&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;${&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;APP_PORT&lt;/span&gt;:&lt;span class=&quot;p&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;3306&quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;nv&quot;&gt;username&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;${&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;APP_USERNAME&lt;/span&gt;:&lt;span class=&quot;p&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;nv&quot;&gt;password&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;${&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;APP_PASSWORD&lt;/span&gt;:&lt;span class=&quot;p&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;nv&quot;&gt;database&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;${&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;APP_DATABASE&lt;/span&gt;:&lt;span class=&quot;p&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;}&lt;/span&gt;
cat &lt;span class=&quot;sh&quot;&gt;&amp;lt;&amp;lt;EOF &amp;gt; /etc/config.json
{
  &quot;datadir&quot;: &quot;${datadir}&quot;,
  &quot;host&quot;: &quot;${host}&quot;,
  &quot;port&quot;: &quot;${port}&quot;,
  &quot;username&quot;: &quot;${username}&quot;,
  &quot;password&quot;: &quot;${password}&quot;,
  &quot;database&quot;: &quot;${database}&quot;
}
EOF
&lt;/span&gt;mkdir -p &lt;span class=&quot;k&quot;&gt;${&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;APP_DATADIR&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;nb&quot;&gt;exec&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;/app&quot;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Note: &lt;strong&gt;always&lt;/strong&gt; use &lt;code&gt;exec&lt;/code&gt; in shell scripts wrapping the application. In this way, the application becomes PID 1 and it can receive Unix signals.&lt;/p&gt;

&lt;p&gt;Also consider using a &lt;a href=&quot;https://github.com/Yelp/dumb-init&quot;&gt;dumb init&lt;/a&gt; as the base CMD, in this way unix signals can be properly handled. Read more about it here: &lt;a href=&quot;http://engineeringblog.yelp.com/2016/01/dumb-init-an-init-for-docker.html&quot;&gt;http://engineeringblog.yelp.com/2016/01/dumb-init-an-init-for-docker.html&lt;/a&gt;&lt;/p&gt;

&lt;h4 id=&quot;log-to-stdout&quot;&gt;Log to stdout&lt;/h4&gt;

&lt;p&gt;Applications inside Docker should log to &lt;code&gt;stdout&lt;/code&gt;. But some application only log to files. In these cases, a workaround is to symlink that file to stdout.&lt;/p&gt;

&lt;p&gt;One example is the official &lt;a href=&quot;https://github.com/nginxinc/docker-nginx/blob/master/Dockerfile&quot;&gt;nginx Dockerfile&lt;/a&gt;:&lt;/p&gt;
&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-&quot; data-lang=&quot;&quot;&gt;# forward request and error logs to docker log collector
RUN ln -sf /dev/stdout /var/log/nginx/access.log
RUN ln -sf /dev/stderr /var/log/nginx/error.log
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;More about it: &lt;a href=&quot;https://serverfault.com/questions/599103/make-a-docker-application-write-to-stdout&quot;&gt;https://serverfault.com/questions/599103/make-a-docker-application-write-to-stdout&lt;/a&gt;&lt;/p&gt;

&lt;h4 id=&quot;careful-with-adding-data-in-a-volume-in-dockerfile&quot;&gt;Careful with adding data in a volume in Dockerfile&lt;/h4&gt;

&lt;p&gt;Avoid adding too much data to a folder and then turning it into a &lt;code&gt;VOLUME&lt;/code&gt;, it will be slow.
Also, still in build time, do not add data to paths that have been previously declared as &lt;code&gt;VOLUME&lt;/code&gt;, it will not work, data will not be persisted.&lt;/p&gt;

&lt;p&gt;Read more about it here in &lt;a href=&quot;https://jpetazzo.github.io/2015/01/19/dockerfile-and-data-in-volumes/&quot;&gt;Jérôme Petazzoni&amp;#39;s explanation&lt;/a&gt;.&lt;/p&gt;

&lt;h3 id=&quot;conclusion&quot;&gt;Conclusion&lt;/h3&gt;

&lt;p&gt;That was my list of tips and tricks for Docker. Please, feel free to provide feedback and share your tips and tricks in the comments below.&lt;/p&gt;

&lt;p&gt;I would also like to thank &lt;a href=&quot;https://twitter.com/bltavares&quot;&gt;Bruno Tavares&lt;/a&gt; and &lt;a href=&quot;https://twitter.com/tanob&quot;&gt;Adriano Bonat&lt;/a&gt; for the review of this article.&lt;/p&gt;
</content>
 </entry>
 
 <entry>
   <title>Raspberry Pi Media Center</title>
   <link href="http://blog.labianchin.me//2014/04/13/raspberry-pi-media-center"/>
   <updated>2014-04-13T00:00:00+00:00</updated>
   <id>http://blog.labianchin.me//2014/04/13/raspberry-pi-media-center</id>
   <content type="html">&lt;h2 id=&quot;raspberry-pi-as-a-media-center&quot;&gt;Raspberry Pi as a Media Center&lt;/h2&gt;

&lt;p&gt;In 2013, I bought a Raspberry Pi with the goal of using it as a media center. I also bought other accessories, the full list is the following:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;http://www.amazon.com/RASPBERRY-MODEL-756-8308-Raspberry-Pi/dp/B009SQQF9C/&quot;&gt;Raspberry Pi&lt;/a&gt; &lt;em&gt;US$ 44.00&lt;/em&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://www.amazon.com/SB-Raspberry-Pi-Case-Clear/dp/B008TCUXLW/&quot;&gt;Case&lt;/a&gt; &lt;em&gt;US$ 13.50&lt;/em&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://www.amazon.com/Transcend-Class-Flash-Memory-TS8GSDHC10E/dp/B003VNKNEG/&quot;&gt;16 GB SD Class 10&lt;/a&gt; &lt;em&gt;US$ 13.50&lt;/em&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://www.amazon.com/AmazonBasics-High-Speed-HDMI-Cable-Meters/dp/B003L1ZYYM&quot;&gt;HDMI Cable&lt;/a&gt; &lt;em&gt;US$ 6.00&lt;/em&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://www.amazon.com/Plugable-Port-Speed-Power-Adapter/dp/B003Z4G3I6/&quot;&gt;USB HUB 7 port&lt;/a&gt; &lt;em&gt;US$ 21.00&lt;/em&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://www.amazon.com/Cirago-Bluetooth-Speed-Adapter-BTA7300/dp/B005QUQPDA/&quot;&gt;WIFI+Bluetooth dongle&lt;/a&gt; &lt;em&gt;US$ 30.00&lt;/em&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://www.amazon.com/SANOXY%C2%AE-Wireless-Remote-Control-Mouse/dp/B0050PUGZE/&quot;&gt;IR Remote Control&lt;/a&gt; &lt;em&gt;US$ 15.00&lt;/em&gt;&lt;/li&gt;
&lt;li&gt;External hard drive, monitor and keyboard (already had)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The USB HUB I have is also used as power source for the RP. You can see in the image below how things are connected:&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;http://blog.labianchin.me//assets/raspberry-pi1.jpg&quot; alt=&quot;My Raspberry Pi&quot;&gt; Raspberry Pi Setup: USB Hub, Hidden Raspberry Pi and HD&lt;/p&gt;

&lt;p&gt;For software I am using the distro &lt;a href=&quot;http://www.raspbmc.com/download/&quot;&gt;Raspbmc&lt;/a&gt;. It is based on Raspibian, a debian distro for Raspberry Pi. So it comes with &lt;em&gt;apt&lt;/em&gt; and you can download packages from debian repositories. &lt;em&gt;Raspbmc&lt;/em&gt; includes &lt;a href=&quot;http://xbmc.org/&quot;&gt;XBMC&lt;/a&gt;, which is a cool interface for using it as a media center. Also there are some nice services such as samba, FTP, SSH and SFTP.&lt;/p&gt;

&lt;h3 id=&quot;wifi&quot;&gt;Wifi&lt;/h3&gt;

&lt;p&gt;I have struggle a bit to configure the wifi. So, I am providing below the links I&amp;#39;ve used as a resource:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;http://anup.info/blog/2012/07/29/raspbmc-wifi&quot;&gt;http://anup.info/blog/2012/07/29/raspbmc-wifi&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://wiki.debian.org/WiFi/HowToUse&quot;&gt;http://wiki.debian.org/WiFi/HowToUse&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://pt.kioskea.net/faq/2545-configurar-o-wifi-no-linux&quot;&gt;http://pt.kioskea.net/faq/2545-configurar-o-wifi-no-linux&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://www.raspberrypi.org/phpBB3/viewtopic.php?f=27&amp;amp;t=7592&quot;&gt;http://www.raspberrypi.org/phpBB3/viewtopic.php?f=27&amp;amp;t=7592&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Also here it is my &lt;em&gt;/etc/network/interfaces&lt;/em&gt; configuration file. Note that I am using static IP address.&lt;/p&gt;
&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-&quot; data-lang=&quot;&quot;&gt;iface lo inet loopback #localhost config

auto eth0 #ethernet config
iface eth0 inet static
    address 192.168.2.3
    netmask 255.255.255.0
    gateway 192.168.2.1 #use this IP in the PC when connecting

allow-hotplug wlan0
iface wlan0 inet static #wi-fi config
    wpa-ssid wirelessname #place your wifi ssid
    wpa-psk wirelesspassword #place your password
    address 192.168.1.100
    netmask 255.255.255.0
    gateway 192.168.1.1

iface default inet dhcp
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;h3 id=&quot;backup&quot;&gt;Backup&lt;/h3&gt;

&lt;p&gt;It is possible to backup the entire SD card. Plug the SD card in your Linux or OSX and run the following command:&lt;/p&gt;
&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-&quot; data-lang=&quot;&quot;&gt;dd if=/dev/sdx of=/path/to/image bs=1M
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Where /dev/sdx is the SD card device point.&lt;/p&gt;

&lt;h3 id=&quot;other-tips&quot;&gt;Other tips&lt;/h3&gt;

&lt;p&gt;Some other details of my configuration:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;I have a 16 GB SD card, but 8 GB would also be fine.&lt;/li&gt;
&lt;li&gt;Media files are stored in the external hard drive.&lt;/li&gt;
&lt;li&gt;XBMC has a &lt;a href=&quot;http://wiki.xbmc.org/?title=Subtitles&quot;&gt;subtitles plugin&lt;/a&gt;, so you can easily download subtiles for the video you are watching.&lt;/li&gt;
&lt;li&gt;Use the app &lt;a href=&quot;https://play.google.com/store/apps/details?id=org.leetzone.android.yatsewidgetfree&quot;&gt;Yatse&lt;/a&gt; in android to control XBMC. It is not just a remote control, you can navigate through your library in it.&lt;/li&gt;
&lt;li&gt;Use &lt;a href=&quot;http://maild.org/wordpress/?p=57&quot;&gt;ramlog&lt;/a&gt; to make SD card last longer.&lt;/li&gt;
&lt;li&gt;Stream from XBMC, trough Android, to a Chromecast, by using Yatse or &lt;a href=&quot;https://play.google.com/store/apps/details?id=com.bubblesoft.android.bubbleupnp&quot;&gt;BubbleUPnP&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;The hard drive I use stops spinning if it is not used for a while.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3 id=&quot;other-ideas&quot;&gt;Other ideas&lt;/h3&gt;

&lt;p&gt;Here are some ideas that I have, but did not tried yet:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Buy a full &lt;a href=&quot;http://www.amazon.com/iPazzport-Wireless-Entertainment-Handheld-Keyboard/dp/B0093GTVNO&quot;&gt;keyboard remote control&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;Backup only XBMC configuration.&lt;/li&gt;
&lt;li&gt;Use as server for backup using &lt;a href=&quot;http://backintime.le-web.org/&quot;&gt;backintime&lt;/a&gt;, &lt;a href=&quot;http://www.apple.com/support/timemachine/&quot;&gt;timemachine&lt;/a&gt; or &lt;a href=&quot;https://launchpad.net/deja-dup&quot;&gt;Déjà Dup&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;Host a protected web site with an albums of photos.&lt;/li&gt;
&lt;li&gt;Download (backup) e-mails using &lt;a href=&quot;http://pyropus.ca/software/getmail/&quot;&gt;getmail&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;Connect a webcam and use as securtiy camera.&lt;/li&gt;
&lt;/ul&gt;
</content>
 </entry>
 
 <entry>
   <title>Git Deployment</title>
   <link href="http://blog.labianchin.me//2013/11/11/git-deployment"/>
   <updated>2013-11-11T00:00:00+00:00</updated>
   <id>http://blog.labianchin.me//2013/11/11/git-deployment</id>
   <content type="html">&lt;h2 id=&quot;using-git-for-production-deployment&quot;&gt;Using git for production deployment&lt;/h2&gt;

&lt;p&gt;This week I have made a git setup for deployment. I would like to share the way I did. Feel free to comment about it.&lt;/p&gt;

&lt;p&gt;So, when doing web development (e.g. PHP, Ruby, Python, …) with dynamic languages, what you really need to put the code in production is (generally) just copy to the production server. You could do that by using SCP, rsync or just using git and pulling the changes from inside the server.&lt;/p&gt;

&lt;p&gt;What if you could just push your changes to the server and automacaly get your changes live?&lt;/p&gt;

&lt;p&gt;The idea is that you could have a git remote pointing to the production server. So, when you push to this remote, it would automacally update the production server.&lt;/p&gt;

&lt;p&gt;This is very similar with how one deploy to Heroku (&lt;a href=&quot;https://devcenter.heroku.com/articles/git&quot;&gt;https://devcenter.heroku.com/articles/git&lt;/a&gt;)&lt;/p&gt;

&lt;h3 id=&quot;how-to-do-it&quot;&gt;How to do it&lt;/h3&gt;

&lt;p&gt;Say you have the following repository on Github:&lt;/p&gt;
&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-&quot; data-lang=&quot;&quot;&gt;git@github.com:luisarmando/demo.git
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;In the production server create a mirror for this repository:&lt;/p&gt;
&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-&quot; data-lang=&quot;&quot;&gt;$ git clone --mirror git@github.com:luisarmando/demo.git ~/demo.git
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;The actual production source code would be a clone for that mirror, also lets name this remote as &amp;quot;hub&amp;quot;:&lt;/p&gt;
&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-&quot; data-lang=&quot;&quot;&gt;$ git clone ~/demo.git --origin hub /var/www/demo
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Then we setup a post-update hook on the hub repository (mirror). Edit the file ~/demo.git/hooks/post-update:&lt;/p&gt;
&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-&quot; data-lang=&quot;&quot;&gt;&lt;span class=&quot;c&quot;&gt;#!/bin/sh&lt;/span&gt;
&lt;span class=&quot;nv&quot;&gt;ROOT&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;/var/www/demo

&lt;span class=&quot;nb&quot;&gt;echo
echo&lt;/span&gt; &lt;span class=&quot;se&quot;&gt;\&quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;****&lt;/span&gt; Pulling changes into Live &lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;Hub&lt;span class=&quot;s1&quot;&gt;&#39;s post-update hook]: $ROOT\&quot;
echo

cd $ROOT || exit
unset GIT_DIR
git pull hub

exec git-update-server-info
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Now on your local git repository you can add a new remote to this hub repository:&lt;/p&gt;
&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-&quot; data-lang=&quot;&quot;&gt;$ git remote add production user@production-server:/home/user/demo.git
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;And everytime you push to &lt;em&gt;production&lt;/em&gt; you will be updating the production server.&lt;/p&gt;
&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-&quot; data-lang=&quot;&quot;&gt;$ git push production master
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;PS: You can also run &lt;em&gt;git remote update&lt;/em&gt; on the hub repository, so that you sync with your github repository.&lt;/p&gt;

&lt;h3 id=&quot;final-remarks&quot;&gt;Final Remarks&lt;/h3&gt;

&lt;p&gt;Now you can both push to origin to share the code with the team, or accually push to production.&lt;/p&gt;

&lt;p&gt;Find more details in:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;http://joemaller.com/990/a-web-focused-git-workflow/&quot;&gt;A web focused git workflow&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://danbarber.me/using-git-for-deployment/&quot;&gt;Using git for deployment&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;You might also want to check some &lt;a href=&quot;http://www.amazon.com/Continuous-Delivery-Deployment-Automation-Addison-Wesley/dp/0321601912&quot;&gt;continuous delivery&lt;/a&gt; practices. However this idea makes pushing code to production very easy, it would be nice to consider having a continuous integration (CI) pipeline with several tests. Also, at the end of the CI pipeline an &amp;quot;artifcact&amp;quot; with the production code would be generated and deployed to production.&lt;/p&gt;
</content>
 </entry>
 
 <entry>
   <title>Maratona De Programacao</title>
   <link href="http://blog.labianchin.me//2013/01/31/maratona-de-programacao"/>
   <updated>2013-01-31T00:00:00+00:00</updated>
   <id>http://blog.labianchin.me//2013/01/31/maratona-de-programacao</id>
   <content type="html">&lt;p&gt;Aqui eu coloco algumas dicas sobre Maratonas de Programação, uma das atividades que considero das mais importantes para cientistas da computação.&lt;/p&gt;

&lt;h2 id=&quot;background&quot;&gt;Background&lt;/h2&gt;

&lt;p&gt;Entrei na UFRGS em 2008. Lá em todo semestre há maratonas de programação na semana acadêmica, participei já no primeiro. A primeira maratona sempre há alguns tropeços em como tratar entrada e saída. &lt;/p&gt;

&lt;p&gt;Em 2009, montamos um time: eu, Kauê Silveira e Bruno Fiss. Nosso time chegou a final nacional. Infelizmente, não participei tanto pois estava mais focado em escrever um artigo para a bolsa :/&lt;/p&gt;

&lt;p&gt;Fiz a cadeira de Desafios de Programação em 2012/1. A cadeira é básica, mas fundamental para entender (e revisar) os principais fundamentos cobrados em maratonas.&lt;/p&gt;

&lt;p&gt;Em 2012, formamos outro time. Duas semanas antes da regional, começamos a treinar pelas regionais passadas. Na regional em Pelotas/RS ficamos em primeiros colocados. Porém não ficamos contentes com nosso desempenho: eu travei num problema (que resolvi sem muito esforço mais tarde), não lemos todos os problemas com cuidado (havia um fácil que foi mal interpretado) e num problema deveriamos saber sobre Euler Totient. :/&lt;/p&gt;

&lt;p&gt;Continuamos praticando para a final. Alguns tópicos praticados foram: Suffix Array, LCP, Segment Tree, Rolling Hash, ... A final foi em Londrina/PR, ficamos em 12º. Entre os problemas, fiz um de Segment Tree rapidamente, porém por descuido eviei sem verificar alguns casos, tomamos uma penalidade. Em 2h de competição estavamos travados, resolvemos fazer um de grafos. Demoramos o resto da competição para fazer, sendo o André quem mais puxou nesse problema. Passamos nos últimos 3 minutos. Como nos últimos minutos de competição não dá para saber os resultados, só ficamos sabendo quando o placar foi anunciado no final da competição. &lt;/p&gt;

&lt;h2 id=&quot;livros-e-material&quot;&gt;Livros e Material&lt;/h2&gt;

&lt;h4 id=&quot;art-of-programming-contest-ahmed-shamsul-arefin&quot;&gt;Art of Programming Contest, Ahmed Shamsul Arefin&lt;/h4&gt;

&lt;p&gt;&lt;a href=&quot;http://acm.uva.es/problemset/Art_of_Programming_Contest_SE_for_uva.pdf&quot;&gt;Link para o livro&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Livro bem básico e rápido. Problemas simples (e também antigos). Ótimo para começar.&lt;/p&gt;

&lt;h4 id=&quot;the-hitchhiker’s-guide-to-the-programming-contests-nite-nimajneb&quot;&gt;The Hitchhiker’s Guide to the Programming Contests, Nite Nimajneb&lt;/h4&gt;

&lt;p&gt;Livro mais avançado, possuí vários conceitos básicos, mas que não caem diretamente em competições. Ler, entender e &lt;strong&gt;levar para competições&lt;/strong&gt;.&lt;/p&gt;

&lt;h4 id=&quot;competitive-programming-steven-halin&quot;&gt;Competitive Programming, Steven Halin&lt;/h4&gt;

&lt;p&gt;Livro da cadeira de Desafios e Programação. Os problemas desse livro são dividos em nível de dificuldade e podem ser encontrados no &lt;a href=&quot;http://uhunt.felix-halim.net/&quot;&gt;uHunt&lt;/a&gt;.&lt;/p&gt;

&lt;h4 id=&quot;cs-97si-introduction-to-competitive-programming-contests&quot;&gt;CS 97SI: Introduction to Competitive Programming Contests&lt;/h4&gt;

&lt;p&gt;Curso da Universidade de Stanford. Na página há slides com muito conteúdo para estudar: &lt;a href=&quot;http://www.stanford.edu/class/cs97si/&quot;&gt;http://www.stanford.edu/class/cs97si/&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Há também a cola usada pela equipe de Stanford: &lt;a href=&quot;http://stanford.edu/%7Eliszt90/acm/notebook.html&quot;&gt;http://stanford.edu/~liszt90/acm/notebook.html&lt;/a&gt;.&lt;/p&gt;

&lt;h4 id=&quot;curso-algorithms-robert-sedgewick-kevin-wayne&quot;&gt;Curso: Algorithms, Robert Sedgewick, Kevin Wayne&lt;/h4&gt;

&lt;p&gt;Curso online da Universidade de Princeton. Baseado no livro &lt;a href=&quot;http://www.amazon.com/gp/product/032157351X&quot;&gt;Algorithms (4th Edition)&lt;/a&gt;. Curso impotante para solidificar o conhecimento em algorítimos.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;https://www.coursera.org/course/algs4partI&quot;&gt;Parte I do curso&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://www.coursera.org/course/algs4partII&quot;&gt;Parte II do curso&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h4 id=&quot;topcoder-algorithm-tutorials&quot;&gt;TopCoder Algorithm Tutorials&lt;/h4&gt;

&lt;p&gt;&lt;a href=&quot;https://community.topcoder.com/tc?module=Static&amp;amp;d1=tutorials&amp;amp;d2=alg_index&quot;&gt;https://community.topcoder.com/tc?module=Static&amp;amp;d1=tutorials&amp;amp;d2=alg_index&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Lista com artigos sobre os principais algoritimos e técnicas cobrados em competições de programação. Alguns são mais avaçados. O interessante é que os artigos são inteiramente focados em competições.&lt;/p&gt;

&lt;h4 id=&quot;algoritimos-mais-importantes&quot;&gt;Algoritimos mais importantes&lt;/h4&gt;

&lt;p&gt;&lt;a href=&quot;http://www.quora.com/Algorithms/What-are-10-algorithms-one-must-know-in-order-to-solve-most-algorithm-challenges-puzzles/&quot;&gt;http://www.quora.com/Algorithms/What-are-10-algorithms-one-must-know-in-order-to-solve-most-algorithm-challenges-puzzles/&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Discussa feita no Quora sobre quais são os principais algoritmos para resolver desafios de programação.&lt;/p&gt;

&lt;h2 id=&quot;sites-de-desafios&quot;&gt;Sites de desafios&lt;/h2&gt;

&lt;p&gt;Alguns sites com desafios para praticar são:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;http://uhunt.felix-halim.net/id/52491&quot;&gt;uHunt&lt;/a&gt; - Usa o banco de problemas do &lt;a href=&quot;http://uva.onlinejudge.org/&quot;&gt;UVa&lt;/a&gt; e sugere outros problemas para serem resolvidos&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://www.topcoder.com/&quot;&gt;Topcoder&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://codeforces.com/&quot;&gt;Codeforces&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://www.hackerrank.com&quot;&gt;Hacker Rank Challenges&lt;/a&gt; - Tem problemas interessantes e bem desafiadores. Algumas empresas usam esse site para recrutamento.&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://www.hacker.org/&quot;&gt;Hacker.org&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://projecteuler.net/&quot;&gt;Project Euler&lt;/a&gt; - Desafios matemáticos&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Algumas sites de competições são:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;https://code.google.com/codejam/&quot;&gt;Google Code Jam&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://www.facebook.com/hackercup&quot;&gt;Facebook Hackercup&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://ipsc.ksp.sk/&quot;&gt;Internet Problem Solving Contest - IPSC&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://ch24.org/&quot;&gt;Challenge 24&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2 id=&quot;o-que-estudar&quot;&gt;O que estudar&lt;/h2&gt;

&lt;p&gt;Há uma discussão interessante no Quora sobre quais são os principais algoritmos: &lt;a href=&quot;http://www.quora.com/Algorithms/What-are-10-algorithms-one-must-know-in-order-to-solve-most-algorithm-challenges-puzzles&quot;&gt;Quora - What are 10 algorithms one must know in order to solve most algorithm challenges/puzzles?&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Abaixo coloco minha lista de tópicos que considero importante.&lt;/p&gt;

&lt;h3 id=&quot;data-strucutres&quot;&gt;Data Strucutres&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Stacks/Queues/Heaps/...&lt;/li&gt;
&lt;li&gt;Segment Tree&lt;/li&gt;
&lt;li&gt;BitVec&lt;/li&gt;
&lt;/ul&gt;

&lt;h3 id=&quot;graph&quot;&gt;Graph&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;DFS&lt;/li&gt;
&lt;li&gt;BFS&lt;/li&gt;
&lt;li&gt;Topological Sort&lt;/li&gt;
&lt;li&gt;Kruskal&lt;/li&gt;
&lt;li&gt;Prim&lt;/li&gt;
&lt;li&gt;Dijkstra (with previous nodes)&lt;/li&gt;
&lt;li&gt;Bellman Ford&lt;/li&gt;
&lt;li&gt;Floyd-Warshall (minimax, maximin, safest path, transitive hull)&lt;/li&gt;
&lt;/ul&gt;

&lt;h3 id=&quot;dynamic-programming-dp&quot;&gt;Dynamic Programming (DP)&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Knaspack&lt;/li&gt;
&lt;li&gt;LIS/LDS (n^2 e n log n)&lt;/li&gt;
&lt;li&gt;LCS&lt;/li&gt;
&lt;li&gt;Counting Change&lt;/li&gt;
&lt;/ul&gt;

&lt;h3 id=&quot;math-and-number-theory&quot;&gt;Math and Number Theory&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Base Convertion&lt;/li&gt;
&lt;li&gt;GCD/LCM&lt;/li&gt;
&lt;li&gt;Primes, sieve&lt;/li&gt;
&lt;li&gt;powMod&lt;/li&gt;
&lt;li&gt;Fibonacci Mod&lt;/li&gt;
&lt;li&gt;Polar coordinate system&lt;/li&gt;
&lt;li&gt;LatlongDistance&lt;/li&gt;
&lt;li&gt;Modular arithmetics&lt;/li&gt;
&lt;li&gt;Combinatorics&lt;/li&gt;
&lt;li&gt;Totient&lt;/li&gt;
&lt;li&gt;Carmichael Number&lt;/li&gt;
&lt;li&gt;Catalan Formula&lt;/li&gt;
&lt;li&gt;Recursion as matrix exponentiation&lt;/li&gt;
&lt;/ul&gt;

&lt;h3 id=&quot;geometry&quot;&gt;Geometry&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Point, distance, triangle area, collinear, counter-clockwise&lt;/li&gt;
&lt;li&gt;Line, parallel&lt;/li&gt;
&lt;li&gt;Convex Hull: Graham Scan&lt;/li&gt;
&lt;/ul&gt;

&lt;h3 id=&quot;strings&quot;&gt;Strings&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Suffix array&lt;/li&gt;
&lt;li&gt;LCP&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;* A lista está incompleta, ainda deve ser finalizada!!&lt;/strong&gt;&lt;/p&gt;
</content>
 </entry>
 
 <entry>
   <title>Recommended Books</title>
   <link href="http://blog.labianchin.me//2013/01/31/recommended-books"/>
   <updated>2013-01-31T00:00:00+00:00</updated>
   <id>http://blog.labianchin.me//2013/01/31/recommended-books</id>
   <content type="html">&lt;h2 id=&quot;recommended-books&quot;&gt;Recommended Books&lt;/h2&gt;

&lt;h3 id=&quot;books-already-read-and-recommended&quot;&gt;Books Already Read (and recommended)&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt; Zen To Done: The Ultimate Simple Productivity System, Leo Babauta &lt;/li&gt;
&lt;li&gt; Rich Dad, Poor Dad, Robert T. Kiyosaki&lt;/li&gt;
&lt;li&gt; Secrets of the Millionaire Mind: Mastering the Inner Game of Wealth, T. Harv Eker&lt;/li&gt;
&lt;li&gt; How to Win Friends and Influence People, Dale Carnegie &lt;/li&gt;
&lt;li&gt; Getting Things Done: The Art of Stress-Free Productivity, David Allen&lt;/li&gt;
&lt;li&gt; The Pragmatic Programmer: From Journeyman to Master, Andrew Hunt and David Thomas &lt;a href=&quot;http://www.codinghorror.com/blog/2004/10/a-pragmatic-quick-reference.html&quot;&gt;Quick Reference&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;Getting Real: The smarter, faster, easier way to build a successful web application, Jason Fried, David Heinemeier&lt;/li&gt;
&lt;/ul&gt;

&lt;h3 id=&quot;books-to-read&quot;&gt;Books to Read&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt; Pomodoro Technique Book, Francesco Cirillo&lt;/li&gt;
&lt;li&gt; The 4-hour workweek, Tim Ferriss&lt;/li&gt;
&lt;li&gt; The E-Myth Revisited, Michael Gerber&lt;/li&gt;
&lt;li&gt; The Seven Habits of Highly Effective People, Stephen R. Covey&lt;/li&gt;
&lt;li&gt; Refactoring: Improving the Design of Existing Code, Martin Fowler&lt;/li&gt;
&lt;/ul&gt;
</content>
 </entry>
 
 <entry>
   <title>Friends Links</title>
   <link href="http://blog.labianchin.me//2013/01/01/friends-links"/>
   <updated>2013-01-01T00:00:00+00:00</updated>
   <id>http://blog.labianchin.me//2013/01/01/friends-links</id>
   <content type="html">&lt;h2 id=&quot;links-to-friends-webpages&quot;&gt;Links to Friends Webpages&lt;/h2&gt;

&lt;h2 id=&quot;undergraduate-colleagues&quot;&gt;Undergraduate Colleagues&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;http://www.inf.ufrgs.br/%7Ebjurkovski&quot;&gt;Bruno Jurkovski&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://inf.ufrgs.br/%7Eggvaldez&quot;&gt;Gustavo Garcia Valdez&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://kaue.me/&quot;&gt;Kauê Silveira&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://inf.ufrgs.br/%7Ergsilva&quot;&gt;Ricardo Gomes da Silva&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2 id=&quot;computer-networks-group-colleagues&quot;&gt;Computer Networks Group Colleagues&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;http://www.dalmazo.com&quot;&gt;Bruno Dalmazo&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://www.inf.ufrgs.br/%7Efrsantos/&quot;&gt;Flávio Roberto dos Santos&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://www.inf.ufrgs.br/%7Ejwickboldt&quot;&gt;Juliano Araujo Wickboldt&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://www.inf.ufrgs.br/%7Emblehmann&quot;&gt;Matheus Brenner Lehmann&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://inf.ufrgs.br/%7Erlsantos&quot;&gt;Ricardo Luis do Santos&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://www.inf.ufrgs.br/%7Erclunardi&quot;&gt;Roben Castagna Lunardi&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://www.inf.ufrgs.br/%7Ewlccordeiro/&quot;&gt;Weverton Cordeiro&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
</content>
 </entry>
 
 <entry>
   <title>About Me</title>
   <link href="http://blog.labianchin.me//2013/01/01/about-me"/>
   <updated>2013-01-01T00:00:00+00:00</updated>
   <id>http://blog.labianchin.me//2013/01/01/about-me</id>
   <content type="html">&lt;h2 id=&quot;about-me&quot;&gt;About me&lt;/h2&gt;

&lt;p&gt;Some of my interests and skills&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Programming: Bash, C/C++, Delphi, Java, ML, PHP, Python, Ruby, Scala, Scheme, SQL.&lt;/li&gt;
&lt;li&gt;Frameworks: CakePHP, jQuery, SQLAlchemy.&lt;/li&gt;
&lt;li&gt;Tools and Others: [[&lt;a href=&quot;https://www.dropbox.com/referrals/NTQ3NjYzOTk%7CDropbox%5D&quot;&gt;https://www.dropbox.com/referrals/NTQ3NjYzOTk|Dropbox]&lt;/a&gt;], Latex, Git, SVN, XMPP.&lt;/li&gt;
&lt;li&gt;Certifications: Sun Certified Java Associate (SCJA).&lt;/li&gt;
&lt;li&gt;Speaking: Portuguese (Native), English, German, Spanish.&lt;/li&gt;
&lt;li&gt;Research Topics: Change Management, Network Management, Risk Management, Information Retrieval. &lt;/li&gt;
&lt;li&gt;Lattes Curriculum: &lt;a href=&quot;http://lattes.cnpq.br/0191788451207759&quot;&gt;http://lattes.cnpq.br/0191788451207759&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
</content>
 </entry>
 
 <entry>
   <title>Vagrant</title>
   <link href="http://blog.labianchin.me//2012/11/22/vagrant"/>
   <updated>2012-11-22T00:00:00+00:00</updated>
   <id>http://blog.labianchin.me//2012/11/22/vagrant</id>
   <content type="html">&lt;h2 id=&quot;vagrant&quot;&gt;Vagrant&lt;/h2&gt;

&lt;p&gt;As described in: &lt;a href=&quot;http://www.vagrantbox.es/&quot;&gt;http://www.vagrantbox.es/&lt;/a&gt; Must have VirtualBox installed.&lt;/p&gt;
&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-&quot; data-lang=&quot;&quot;&gt; $ sudo apt-get install vagrant
 $ gem install vagrant
 $ vagrant box add {title} {url}
 $ vagrant init {title}
 $ vagrant up
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href=&quot;http://net.tutsplus.com/tutorials/php/vagrant-what-why-and-how/&quot;&gt;http://net.tutsplus.com/tutorials/php/vagrant-what-why-and-how/&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Configure forwarding on Vagrantfile:&lt;/p&gt;

&lt;p&gt;config.vm.forward_port 80, 8080&lt;/p&gt;

&lt;p&gt;config.vm.provision :shell, :inline ⇒ “apt-get update; apt-get -y install apache2 mysql-server mysql-client php5 php5-mysql php-apc phpmyadmin php-pear subversion ntp”&lt;/p&gt;
</content>
 </entry>
 
 <entry>
   <title>Apache Configuration Tips</title>
   <link href="http://blog.labianchin.me//2012/08/31/apache-configuration-tips"/>
   <updated>2012-08-31T00:00:00+00:00</updated>
   <id>http://blog.labianchin.me//2012/08/31/apache-configuration-tips</id>
   <content type="html">&lt;h2 id=&quot;improve-apache-perfomance&quot;&gt;Improve apache perfomance&lt;/h2&gt;

&lt;p&gt;Here are some ideas in improving apache performance by adding some lines in a .htaccess file. I used this in a CakePHP project recently.&lt;/p&gt;
&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-&quot; data-lang=&quot;&quot;&gt;&amp;lt;IfModule mod_rewrite.c&amp;gt; #url rewrite used by cakephp
    RewriteEngine On
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^(.*)$ index.php?url=$1 [QSA,L]
&amp;lt;/IfModule&amp;gt;
IndexIgnore *
&amp;lt;IfModule mod_headers.c&amp;gt;
    # 1 YEAR
    &amp;lt;FilesMatch &quot;\.(ico|pdf|flv)$&quot;&amp;gt;
    Header set Cache-Control &quot;max-age=29030400, public&quot;
    &amp;lt;/FilesMatch&amp;gt;
    # 1 WEEK
    &amp;lt;FilesMatch &quot;\.(jpg|jpeg|png|gif|swf)$&quot;&amp;gt;
    Header set Cache-Control &quot;max-age=604800, public&quot;
    &amp;lt;/FilesMatch&amp;gt;
    # 2 DAYS
    &amp;lt;FilesMatch &quot;\.(xml|txt|css|js)$&quot;&amp;gt;
    Header set Cache-Control &quot;max-age=172800, proxy-revalidate&quot;
    &amp;lt;/FilesMatch&amp;gt;
&amp;lt;/IfModule&amp;gt;
&amp;lt;IfModule mod_deflate.c&amp;gt;
        AddOutputFilterByType DEFLATE text/text text/plain text/css application/x-javascript application/javascript text/javascript
&amp;lt;/IfModule&amp;gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;The additional lines basically set some cache and compression (mod_deflate) headers for the static content.&lt;/p&gt;

&lt;p&gt;More info: &lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;http://www.howtoforge.com/apache2_mod_deflate&quot;&gt;http://www.howtoforge.com/apache2_mod_deflate&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;http://www.askapache.com/htaccess/speed-up-sites-with-htaccess-caching.html&quot;&gt;http://www.askapache.com/htaccess/speed-up-sites-with-htaccess-caching.html&lt;/a&gt;&lt;/p&gt;
</content>
 </entry>
 
 <entry>
   <title>Cakephp Faster Url Generation</title>
   <link href="http://blog.labianchin.me//2012/08/28/cakephp-faster-url-generation"/>
   <updated>2012-08-28T00:00:00+00:00</updated>
   <id>http://blog.labianchin.me//2012/08/28/cakephp-faster-url-generation</id>
   <content type="html">&lt;h2 id=&quot;cakephp-faster-url-generation&quot;&gt;CakePHP faster URL generation&lt;/h2&gt;

&lt;p&gt;CakePHP framework provides a series of helpers to facilitate the creation of views of web systems. But one must note that each time you put a link in your view using a helper method, the Router::url() method is called and the URL string is computed.&lt;/p&gt;

&lt;p&gt;The problem is when there is a page with many links. This links might have a common prefix (i.e. targeting the same controller/action). For example, the typical index actions shows a list of rows, and in each row there is a link to edit and delete. Generally this links follow the pattern /:controller/:action/:id. &lt;/p&gt;

&lt;p&gt;The idea here is that is not necessary to compute the part /:controler/:action each time a URL is generated. We could cache this part.&lt;/p&gt;

&lt;p&gt;In order to do that, we can rewrite the method url() of the app/AppHelper.php.&lt;/p&gt;
&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-&quot; data-lang=&quot;&quot;&gt;var $urls = array();
/* increases url performance in 50%, by &quot;caching&quot; urls */
function url($url = null, $full = false){
    if (
        $full || 
        !is_array($url) || 
        array_diff(
            array_keys($url), 
            array(&#39;controller&#39;, &#39;action&#39;, 0, 1, 2, 3, 4))){
        return parent::url($url, $full);
    }
    if (!isset($url[&#39;controller&#39;])){
        $url[&#39;controller&#39;] = $this-&amp;gt;params[&#39;controller&#39;];
    }
    if (!isset($url[&#39;action&#39;])){
        $url[&#39;action&#39;] = $this-&amp;gt;params[&#39;action&#39;];
    }
    $key = $url[&#39;controller&#39;].&#39;#&#39;.$url[&#39;action&#39;];
    if (!isset($this-&amp;gt;urls[$key])){
        $pre = $this-&amp;gt;urls[$key] = parent::url(array(
            &#39;controller&#39; =&amp;gt; $url[&#39;controller&#39;], 
            &#39;action&#39; =&amp;gt; $url[&#39;action&#39;]));
    } else {
        $pre = $this-&amp;gt;urls[$key];
    }
    for ($i=0; $i&amp;lt;4; $i++)
        if (isset($url[$i]))
            $pre.=DS.$url[$i];
    return $pre; 
}
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;</content>
 </entry>
 
 <entry>
   <title>Postgresql</title>
   <link href="http://blog.labianchin.me//2012/06/19/postgresql"/>
   <updated>2012-06-19T00:00:00+00:00</updated>
   <id>http://blog.labianchin.me//2012/06/19/postgresql</id>
   <content type="html">&lt;h2 id=&quot;postgresql&quot;&gt;PostgreSQL&lt;/h2&gt;

&lt;h3 id=&quot;instalação-de-pacotes&quot;&gt;Instalação de Pacotes&lt;/h3&gt;
&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-&quot; data-lang=&quot;&quot;&gt;sudo apt-get install postgresql php5-pgsql phppgadmin
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;h3 id=&quot;habilitar-o-acesso-remoto-ao-servidor&quot;&gt;Habilitar o acesso remoto ao servidor&lt;/h3&gt;

&lt;p&gt;No arquivo:&lt;/p&gt;
&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-&quot; data-lang=&quot;&quot;&gt;/etc/postgresql/8.x/main/postgresql.conf
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Editar o parâmetro:&lt;/p&gt;
&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-&quot; data-lang=&quot;&quot;&gt;listen_addresses = &#39;*&#39;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;h3 id=&quot;habilitar-acesso-de-usuários-a-bancos-de-dados&quot;&gt;Habilitar acesso de usuários a bancos de dados&lt;/h3&gt;

&lt;p&gt;No arquivo:&lt;/p&gt;
&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-&quot; data-lang=&quot;&quot;&gt;/etc/postgresql/8.x/main/pg_hba.conf
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Editar as linhas:&lt;/p&gt;
&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-&quot; data-lang=&quot;&quot;&gt;# TYPE  DATABASE    USER        CIDR-ADDRESS          METHOD
host    all         all         127.0.0.1/8           password
host    all         all         143.54.12.0/24        md5
host    all         all         10.0.2.0/24           md5
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Obs: 
O mais importante é o method: password utiliza senha sem criptografar melhor se o acesso for local (127.0.0.1/8), md5 força o envio da senha criptografada via Internet (143.54.12.0/24).&lt;/p&gt;

&lt;h3 id=&quot;otimizações&quot;&gt;Otimizações&lt;/h3&gt;

&lt;p&gt;&lt;a href=&quot;http://pt.wikibooks.org/wiki/PostgreSQL_Pr%C3%A1tico/Ap%C3%AAndices/Dicas_sobre_Desempenho_e_Otimiza%C3%A7%C3%B5es_do_PostgreSQL&quot;&gt;http://pt.wikibooks.org/wiki/PostgreSQL_Pr%C3%A1tico/Ap%C3%AAndices/Dicas_sobre_Desempenho_e_Otimiza%C3%A7%C3%B5es_do_PostgreSQL&lt;/a&gt;&lt;/p&gt;
</content>
 </entry>
 
 <entry>
   <title>Apache</title>
   <link href="http://blog.labianchin.me//2012/06/19/apache"/>
   <updated>2012-06-19T00:00:00+00:00</updated>
   <id>http://blog.labianchin.me//2012/06/19/apache</id>
   <content type="html">&lt;h2 id=&quot;apache-php&quot;&gt;Apache/PHP&lt;/h2&gt;

&lt;h3 id=&quot;instalar-pacotes-e-habilitar-o-módulo-rewrite&quot;&gt;Instalar pacotes e Habilitar o módulo rewrite&lt;/h3&gt;

&lt;p&gt;Em Debian/Ubuntu:&lt;/p&gt;
&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-&quot; data-lang=&quot;&quot;&gt;apt-get install apache2 php5 php-apc ssh postgresql php5-pgsql phppgadmin language-pack-pt svn a2enmod rewrite 
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Em Fedora/CentOS:&lt;/p&gt;
&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-&quot; data-lang=&quot;&quot;&gt;yum install apache2 php5 php-apc ssh postgresql php5-pgsql phppgadmin language-pack-pt svn 
ln -s /etc/apache2/mods-available/rewrite.load
/etc/apache2/rewrite.load
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;h3 id=&quot;criar-uma-entrada-para-a-pasta-do-sistema-ou-um-virtual-host-com-modrewrite-habilitado&quot;&gt;Criar uma entrada para a pasta do sistema (ou um virtual host) com modrewrite habilitado&lt;/h3&gt;

&lt;p&gt;No arquvivo: /etc/apache2/sites-available/default 
Adicionar as linhas:&lt;/p&gt;
&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-&quot; data-lang=&quot;&quot;&gt;Alias / /var/www/systems 
&amp;lt;Directory /var/www/systems&amp;gt;
    AllowOverride All
&amp;lt;/Directory&amp;gt; 
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Obs: O importante é ter o AllowOverride All, tanto faz se for dentro do default ou num outro virtual host configurado.&lt;/p&gt;

&lt;p&gt;Reiniciar Apache: 
    sudo /etc/init.d/apache2 restart&lt;/p&gt;

&lt;h2 id=&quot;configuração-do-php&quot;&gt;Configuração do PHP&lt;/h2&gt;

&lt;p&gt;Em algumas instalações alguns desses módulos ou extensões do PHP podem vir instalados por padrão, então é preciso verificar quais não estão instalados e depois executar os procedimentos. Esses módulos listados aqui são os que se sabe que faltaram em alguma instalação do sistema, podem haver outros módulos que desabilitados dependendo da configuração de cada host e sistema operacional.&lt;/p&gt;

&lt;h3 id=&quot;instalação-do-apc&quot;&gt;Instalação do APC&lt;/h3&gt;

&lt;p&gt;Módulo necessário para o funcionamento do Cache do Cake.
&lt;a href=&quot;http://www.php.net/manual/en/book.apc.php&quot;&gt;http://www.php.net/manual/en/book.apc.php&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;A instalação pode ser feita pelo apt-get no caso de ubuntu ou similar:&lt;/p&gt;
&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-&quot; data-lang=&quot;&quot;&gt;apt-get install php-apc 
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Ou através do instalador do PECL, nesse caso, instalando via PEAR:&lt;/p&gt;

&lt;p&gt;apt-get (ou yum) install php-pear 
pecl install apc &lt;/p&gt;

&lt;p&gt;Depois é preciso habilitar o modulo no php.ini&lt;/p&gt;

&lt;p&gt;extension=apc.so&lt;/p&gt;

&lt;h3 id=&quot;pcre&quot;&gt;PCRE&lt;/h3&gt;

&lt;p&gt;&lt;a href=&quot;http://chrisjean.com/2009/01/31/unicode-support-on-centos-52-with-php-and-pcre/&quot;&gt;http://chrisjean.com/2009/01/31/unicode-support-on-centos-52-with-php-and-pcre/&lt;/a&gt;&lt;/p&gt;

&lt;h2 id=&quot;apacheotimizacoes&quot;&gt;ApacheOtimizacoes&lt;/h2&gt;

&lt;h3 id=&quot;security&quot;&gt;Security&lt;/h3&gt;

&lt;p&gt;There are two directives that you need to add, or edit in your&lt;/p&gt;

&lt;p&gt;httpd.conf file:&lt;/p&gt;

&lt;p&gt;ServerSignature Off ServerTokens Prod
&lt;a href=&quot;http://www.petefreitag.com/item/505.cfm&quot;&gt;http://www.petefreitag.com/item/505.cfm&lt;/a&gt;&lt;/p&gt;

&lt;h3 id=&quot;mod_pagespeed&quot;&gt;mod_pagespeed&lt;/h3&gt;

&lt;p&gt;Mais importante. Há pacotes para Debian/Ubuntu e CentOS/Fedora, 32 e 64
bits. &lt;a href=&quot;http://code.google.com/intl/pt-BR/speed/page-speed/download.html&quot;&gt;http://code.google.com/intl/pt-BR/speed/page-speed/download.html&lt;/a&gt;&lt;/p&gt;

&lt;h3 id=&quot;mod_expires&quot;&gt;mod_expires&lt;/h3&gt;

&lt;p&gt;Serve para fazer cache pelo browser de arquivos estáticos como png, jpg, gif, css, ... Evitando requisições ao servidor.&lt;/p&gt;

&lt;p&gt;sudo a2enmod expires sudo nano /etc/apache2/httpd.conf&lt;/p&gt;
&lt;div class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-&quot; data-lang=&quot;&quot;&gt;&amp;lt;IfModule mod_expires.c&amp;gt;
    ExpiresActive on 
    ExpiresByType image/gif &quot;access plus 12 month&quot; 
    ExpiresByType image/jpeg &quot;access plus 12 month&quot;
    ExpiresByType image/png &quot;access plus 12 month&quot; 
    ExpiresByType text/css &quot;access plus 12 month&quot; 
    ExpiresByType application/x-javascript &quot;access plus 1 month&quot; 
    ExpiresByType application/pdf &quot;access plus 1 day&quot;

    &amp;lt;IfModule mod_headers.c&amp;gt; 
    \# Turn on Expires and set default to 0, nao usado ExpiresDefault A0 
    \# Set up caching on media files for 1 month
    &amp;lt;FilesMatch &quot;\.(gif|jpg|jpeg|png|css|js|swf|flv|ico|pdf|avi|mov|ppt|doc|mp3|wmv|wav)$&quot;&amp;gt;
        ExpiresDefault &quot;access plus 12 month&quot; 
        Header append Cache-Control &quot;public&quot; 
    &amp;lt;/FilesMatch&amp;gt;

    &amp;lt;/IfModule&amp;gt;

&amp;lt;/IfModule&amp;gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;h3 id=&quot;mod_deflate&quot;&gt;mod_deflate&lt;/h3&gt;

&lt;p&gt;Faz compressão dos dados ao enviar para o browser, implica em maior carga para o servidor, mas menor tempo de carregamento para o usuário.&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;http://www.howtoforge.com/apache2%5C_mod%5C_deflate&quot;&gt;http://www.howtoforge.com/apache2\_mod\_deflate&lt;/a&gt;&lt;/p&gt;
</content>
 </entry>
 
 <entry>
   <title>Publications</title>
   <link href="http://blog.labianchin.me//2011/12/03/publications"/>
   <updated>2011-12-03T00:00:00+00:00</updated>
   <id>http://blog.labianchin.me//2011/12/03/publications</id>
   <content type="html">&lt;h2 id=&quot;scientific-publications&quot;&gt;Scientific Publications&lt;/h2&gt;

&lt;h3 id=&quot;international-publications&quot;&gt;International Publications&lt;/h3&gt;

&lt;h4 id=&quot;2011&quot;&gt;2011&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;Juliano Araujo Wickboldt, &lt;strong&gt;Luís Armando Bianchin&lt;/strong&gt;, Roben Castagna Lunardi, Lisandro Zambenedetti Granville,  Luciano Paschoal Gaspary, and Claudio Bartolini. &lt;strong&gt;A Framework for Risk Assessment Based on Analysis of Historical Information of Workflow Execution in IT Systems.&lt;/strong&gt; Elsevier Computer Networks 55 (13) (2011), pp. 2954-2975.&lt;/li&gt;
&lt;/ul&gt;

&lt;h4 id=&quot;2010&quot;&gt;2010&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Luís Armando Bianchin&lt;/strong&gt;, Juliano Araujo Wickboldt, Lisandro Zambenedetti Granville, Luciano Paschoal Gaspary, Claudio Bartolini, Maher Rahmouni. &lt;strong&gt;Similarity Metric for Risk Assessment in IT Change Plans.&lt;/strong&gt; Proceedings of 6th International Conference on Network and Service Management (CNSM 2010), 25-29 October 2010, Niagara Falls, Canada, ISBN: 978-1-4244-8910-7, pp 25-32.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Juliano Araujo Wickboldt, &lt;strong&gt;Luís Armando Bianchin&lt;/strong&gt;, Roben Castagna Lunardi, Fabrício Girardi Andreis, Ricardo Luis dos Santos, Bruno Lopes Dalmazo, Weverton Luis da Costa Cordeiro, Abraham Lincoln Rabelo de Sousa, Lisandro Zambenedetti Granville, Luciano Paschoal Gaspary, Claudio Bartolini. &lt;strong&gt;Computer-Generated Comprehensive Risk Assessment for IT Project Management.&lt;/strong&gt; Proceedings of 12th IEEE/IFIP Network Operations and Management Symposium (NOMS 2010), 19-23 April 2010, Osaka, Japan, ISBN: 978-1-4244-5367-2, pp. 400-407.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Roben Castagna Lunardi, Fabrício Girardi Andreis, Weverton Luis da Costa Cordeiro, Juliano Araujo Wickboldt, Bruno Lopes Dalmazo, Ricardo Luis dos Santos, &lt;strong&gt;Luís Armando Bianchin&lt;/strong&gt;, Luciano Paschoal Gaspary, Lisandro Zambenedetti Granville, Claudio Bartolini. &lt;strong&gt;On Strategies for Planning the Assignment of Human Resources to IT Change Activities.&lt;/strong&gt; Proceedings of 12th IEEE/IFIP Network Operations and Management Symposium (NOMS 2010), 19-23 April 2010, Osaka, Japan, ISBN: 978-1-4244-5367-2, pp. 248-255.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h4 id=&quot;2009&quot;&gt;2009&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;Juliano Araujo Wickboldt, &lt;strong&gt;Luís Armando Bianchin&lt;/strong&gt;, Roben Castagna Lunardi, Fabrício Girardi Andreis, Weverton Luis da Costa Cordeiro, Cristiano Bonato Both, Lisandro Zambenedetti Granville, Luciano Paschoal Gaspary, David Trastour, Claudio Bartolini. &lt;strong&gt;Improving IT Change Management Processes with Automated Risk Assessment.&lt;/strong&gt; Proceedings of 20th International Workshop on Distributed Systems: Operations and Management (DSOM 2009), 27-28 October 2009, Venice, Italy, ISBN: 978-3-642-04988-0, pp. 71-84.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3 id=&quot;brazilian-publications&quot;&gt;Brazilian Publications&lt;/h3&gt;

&lt;h4 id=&quot;2010&quot;&gt;2010&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Luís Armando Bianchin&lt;/strong&gt;, Juliano Araujo Wickboldt, Ricardo Luis Santos, Roben Castagna Lunardi, Bruno Lopes Dalmazo, Fabrício Girardi Andreis, Weverton Luis Costa Cordeiro, Abraham Lincoln Rabelo Sousa, Lisandro Zambenedetti Granville, and Luciano Paschoal Gaspary. &lt;strong&gt;Similaridade para Avalição de Riscos em Planos de Mudança de TI.&lt;/strong&gt; Proceedings of Workshop de Gerência e Operação de Redes e Serviços (WGRS/SBRC 2010), 24-28 May 2010, Gramado, Brazil. ISSN: 2177-496X, pp. 103-116.&lt;/li&gt;
&lt;/ul&gt;

&lt;h4 id=&quot;2009&quot;&gt;2009&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Luís Armando Bianchin&lt;/strong&gt;, Juliano Araujo Wickboldt, Lisandro Zambenedetti Granville, Luciano Paschoal Gaspary. &lt;strong&gt;Afinidade de Risco em Workflows de Mudanças de Tecnologia da Informação.&lt;/strong&gt; XXI Salão de Iniciação Científica UFRGS, 2009, Porto Alegre.&lt;/li&gt;
&lt;/ul&gt;
</content>
 </entry>
 
 
</feed>