<?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[Time is a gentleman - Medium]]></title>
        <description><![CDATA[Claudio Sparpaglione on life, travels and software - Medium]]></description>
        <link>https://medium.com/time-is-a-gentleman?source=rss----5c14e1c1a96d---4</link>
        <image>
            <url>https://cdn-images-1.medium.com/proxy/1*TGH72Nnw24QL3iV9IOm4VA.png</url>
            <title>Time is a gentleman - Medium</title>
            <link>https://medium.com/time-is-a-gentleman?source=rss----5c14e1c1a96d---4</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 20 Nov 2026 06:20:12 GMT</lastBuildDate>
        <atom:link href="https://medium.com/feed/time-is-a-gentleman" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Zero downtime : hot code deployments]]></title>
            <link>https://medium.com/time-is-a-gentleman/zero-downtime-hot-code-deployments-ef9f02b44f07?source=rss----5c14e1c1a96d---4</link>
            <guid isPermaLink="false">https://medium.com/p/ef9f02b44f07</guid>
            <category><![CDATA[deployment]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[django]]></category>
            <category><![CDATA[high-availability]]></category>
            <category><![CDATA[docker]]></category>
            <dc:creator><![CDATA[Claudio Sparpaglione]]></dc:creator>
            <pubDate>Wed, 09 May 2018 12:06:07 GMT</pubDate>
            <atom:updated>2018-05-09T15:33:53.272Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*98Gn8UDc3s0JhLYpu1Ce_A.jpeg" /></figure><p>If you’re reading this, probably you’ve asked yourself this question many times:</p><blockquote><em>How can I minimize (ideally, avoid) downtimes when I deploy my web application?</em></blockquote><p>There are multiple ways to accomplish this task, depending on what type of computing infrastructure you use and what your technology stack is.</p><p>In this post, we’re going to talk about <strong>hot code reload</strong>: this means that you have an already running codebase and you reload modifications to that codebase on the fly — that is, without downtime.</p><p>In the past, I’ve worked on a high-traffic HTTP API backend that had to be released with almost no downtime, and I instrumented the deployment process to leverage hot code reload, so I want to share with you my experience with this technique.</p><h3>Requirements for hot code reload</h3><p>We need our web runtime environment to support a <em>hot</em> reloading, which means that we don’t want to stop the environment and launch it again, this is because we don’t obviously want to have downtimes in our website/API/whatever.</p><p>Also, we need it to support a <em>graceful</em> code reloading, meaning that any requests currently being serviced when the reload happens must be completed and during the reload operation no further requests must be accepted.</p><p>Some modern runtimes natively support hot reloading, but this is technology-dependent. The goal can be accomplished by simply relying on what we already have on our *nix boxes: <em>POSIX process signals</em>, specifically, the <em>SIGHUP</em> one.</p><p><a href="http://unix.stackexchange.com/a/15606">This Stackoverflow answer</a> clarifies very well the situation: the HUP signal was originally meant to be used to notify detached background processes to exit whenever users lost their terminal/frontend counterparts - but this is not the case for daemon-only processes like our web runtime environments. So these processes are free to implement the handling of the HUP signal as they want, and the generally accepted idea is to have it trigger a <em>reload configuration files and/or code</em>.</p><p>Say that our runtime has master process ID of $PID, then:</p><p>is a “portable” way to reload configuration/code changes in a graceful way (in a pre-fork model, this means that the process handles worker processes’ lifecycle) and without compromising uptime too much.</p><p>For instance, <a href="http://docs.gunicorn.org/en/stable/signals.html#master-process">this is what happens with Gunicorn</a> when SIGHUP is received.</p><p>More application runtimes supporting hot code reload are: Unicorn (Ruby), Nodemon (Javascript), Gin (Go), etc.. Also popular webservers such as Nginx and Apache Httpd support hot configuration reload.</p><h3>A sample webapp</h3><p>Let’s get our hands dirty with code, now!</p><p>For the sake of concreteness, we will use a sample Python webapp powered by the following techs:</p><ul><li>Python 3.5</li><li>Gunicorn 19.6 as a web runtime environment (WSGI), running Gevent 1.1.2 workers</li><li>Django 1.10 as a web framework</li><li>Docker 1.12 as a containerization platform</li></ul><p>You can find <a href="https://github.com/csparpa/blog-zero-downtime.git">the code on Github</a></p><h3>Operate the sample app</h3><p>Start with Git-cloning the app, say, into folder $SAMPLE_APP. Now, you can run the app in a Docker container or natively on your host.</p><p>Both scenarios rely on the run.bash script that is basically a shell wrapper launching Gunicorn in daemon mode and saving its PID into a file. This is important as we will use it later to send a HUP signal to the Gunicorn process.</p><p>Code reload will be performed by the reload.sh script, that basically calls kill -HUP on the running Gunicorn process.</p><h3>Run natively</h3><p>If you <em>do not want to use Docker</em>, then I suggest you to install the app’s dependencies under a <a href="https://virtualenv.pypa.io/">virtualenv</a> so that you don’t pollute your local host’s PYTHONPATH. Once inside the virtualenv, install the dependencies and run the app with:</p><pre>$ pip install -r requirements.txt $ bash run.sh</pre><p>Keep this terminal open for the moment. Open a new terminal and check that the app is running like this:</p><pre>$ curl <a href="http://localhost:1234/ping">http://localhost:1234/ping</a> {&quot;message&quot;: &quot;test&quot;}</pre><p>In the same terminal, run the polling client with:</p><pre>$ python3.5 poll.py<br>UP: response was {&#39;message&#39;: &#39;test&#39;} [2016-10-25 13:57:35.414]<br>UP: response was {&#39;message&#39;: &#39;test&#39;} [2016-10-25 13:57:35.578]<br>UP: response was {&#39;message&#39;: &#39;test&#39;} [2016-10-25 13:57:35.914]</pre><p>Keep it running.</p><p>The client polls the /ping endpoint for data and prints responses on screen.</p><p>The timestamp refers to the moment when the HTTP request has been issued to the server: a default timeout of 0.1 seconds is considered for responses. So, if any request takes more than 0.1 seconds to be fulfilled, we consider our app to be down.</p><p>If you see green then the server is up, if you see red then the server is down and if you see yellow then the server is up and a change in the response body has been detected: this will happen once we hot reload the code.</p><p>Open the file $PYTHONPATH/hot_code_reload/views.py and modify the message value in the dictionary that is returned by the endpoint, i.e. put abcd:</p><pre>class PingView(View):<br>  def get(self, request):<br>    data = { &quot;message&quot;: EXPECTED_MESSAGE_VALUE, # &lt;---- }<br>    return HttpResponse(json.dumps(data), content_type=&quot;application/json&quot;)</pre><p>Save, go back to the first terminal and perform the actual hot code reload magic with:</p><p>Now take a look at the second terminal, you should see something like this:</p><pre>UP: response was {&#39;message&#39;: &#39;test&#39;} [2016-10-25 08:16:17.860]<br>UP: response was {&#39;message&#39;: &#39;test&#39;} [2016-10-25 08:16:17.872]<br>DOWN [2016-10-25 08:16:17.882]<br>DOWN [2016-10-25 08:16:17.990]<br>DOWN [2016-10-25 08:16:18.095]<br>UP AND CHANGED: response was {&#39;message&#39;: &#39;abcd&#39;} [2016-10-25 08:16:18.204]<br>UP: response was {&#39;message&#39;: &#39;abcd&#39;} [2016-10-25 08:16:18.254]<br>UP: response was {&#39;message&#39;: &#39;abcd&#39;} [2016-10-25 08:16:18.266]</pre><p>As you can see from the printed timestamps, it looks like the reload took less than 1 second — that’s a very short downtime!</p><h3>Run using Docker</h3><p>We can perform hot code reload on dockerized applications by mounting its source code as a <em>container volume</em> and — after code changes — by issuing a SIGHUP with the docker exec subcommand.</p><p>That’s how to do it:</p><pre>$ docker run -d \ --name test_hcr \ -v $SAMPLE_APP:/hcr \ -p 0.0.0.0:1234:8000 \ python:3.5 \ tailf /dev/null</pre><p>This command</p><ul><li>creates a non-interactive container named test_hcr from Python3.5 official image (it will be downloaded from DockerHub if you don&#39;t already have it on your host)</li><li>mounts host folder $SAMPLE_APP to container folder /hcr</li><li>maps container port 8000 to host port 1234</li></ul><p>Good, now let’s install the Python dependencies on the container and start our app (I’m not doing this in a Dockerfile on purpose…):</p><pre>$ docker exec -it test_hcr pip3 install -r /hcr/requirements.txt $ docker exec -it hcr bash -c &#39;cd /hcr &amp;&amp; bash run.sh&#39;</pre><p>and test it’s online with:</p><pre>$ curl <a href="http://localhost:1234/ping">http://localhost:1234/ping</a> {&quot;message&quot;: &quot;test&quot;}</pre><p>Cool! The next steps are exactly the same as in the case of non-containerized apps: open a new terminal an run the polling client.</p><p>Now modify the source code in order to return a different message, and then cast the hot code reload magic with:</p><pre>docker exec -it hcr bash -c &#39;cd /hcr &amp;&amp; bash reload.sh&#39;</pre><p>Now look back in the other terminal, you should see the output as described in the section about non-containerised apps.</p><p>As you can notice, <em>we did not stop the container</em>, nor we stopped Gunicorn running inside of it!</p><h3>Deploying code changes and/or environment changes</h3><p>What are the pros/cons of mounting your application source code as a Docker volume? As said, no need to restart your container when you want to ship code changes to production. However, your code lives outside your Docker containers and is therefore subject to accidental or intentional modifications (typical risk: fixing a bug on production environment by patching the mounted code and restart it on-the-fly!).</p><p>But, wait!</p><blockquote><em>What if I need to also ship environment (read: Dockerfile) changes to production?</em></blockquote><p>and</p><blockquote><em>What if I need to ship only infrastructure changes?</em></blockquote><p>In such cases, <em>you are forced to ship a new Docker image to production</em> and mounting code volumes becomes pointless if you need to also ship images provided that you embed your source code inside the new Docker image every time you build it. The frequency of code vs infrastructure changes of course depends on your needs, but usually one delivers more software than software dependencies… so hot code reload still has the chances to be useful.</p><p>I would suggest not to pack your source code into the Docker image on new deployments, because the release of code-only changes means the unneeded generation of a new Docker image — which has nothing different in terms of “environment” things!</p><p>If you have a <strong>Continuous Deployment pipeline</strong>, you can instrument it so that:</p><ul><li>everytime a change in your Dockerfile is detected, a new Docker image is build, pushed to your image repository</li><li>everytime a change in your source code is detected, run your test suites and custom tasks on the top of it, then compile any binaries if needed</li><li>everytime <em>any</em> change is detected in both infrastructure or code, execute the following steps:</li></ul><ol><li>checkout code</li><li>checkout Docker image</li><li>if any new Docker image, instantiate again the containers from it and mount the code as volumes. If no new Docker images, then simply perform hot code reload</li></ol><h3>References</h3><ul><li>I was greatly inspired by this brilliant blog post by the Ionic team: it helped me a lot! Thanks guys!</li><li>For Gunicorn pros, take a look at the documentation about <a href="http://docs.gunicorn.org/en/stable/signals.html">signal handling with Gunicorn</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ef9f02b44f07" width="1" height="1" alt=""><hr><p><a href="https://medium.com/time-is-a-gentleman/zero-downtime-hot-code-deployments-ef9f02b44f07">Zero downtime : hot code deployments</a> was originally published in <a href="https://medium.com/time-is-a-gentleman">Time is a gentleman</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Setting up centralized logging on your Django apps using Logstash and Amazon EC2]]></title>
            <link>https://medium.com/time-is-a-gentleman/setting-up-centralized-logging-on-your-django-apps-using-logstash-and-amazon-ec2-cba0c7d19402?source=rss----5c14e1c1a96d---4</link>
            <guid isPermaLink="false">https://medium.com/p/cba0c7d19402</guid>
            <category><![CDATA[django]]></category>
            <category><![CDATA[docker]]></category>
            <category><![CDATA[elk-stack]]></category>
            <category><![CDATA[ec2]]></category>
            <category><![CDATA[logging]]></category>
            <dc:creator><![CDATA[Claudio Sparpaglione]]></dc:creator>
            <pubDate>Wed, 09 May 2018 11:54:59 GMT</pubDate>
            <atom:updated>2018-05-09T11:54:50.918Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*U4aFxcK-cNsKCuhLkY0MGA.jpeg" /></figure><p>This post is a step-by-step guide on how to realize a centralized logging solution for your Django apps.</p><p>We will instrument an Amazon EC2 instance running Ubuntu 14.04 to collect logs from a locally-running Django app through the use of the “ELK” stack, which includes Logstash as a log aggregator, and Docker as a containerization platform.</p><h3>Centralized logging</h3><p>Centralized logging is a monitoring technique that allows you to view all of your applications’ log messages on a single hub that acts as a collector and as unique storage provider for them, and also gives you some degree of “log-browsability”.</p><p>The centralized logging solution that we’ll setup gives you the following advantages:</p><ul><li>the setup is very easily and quickly reproducible</li><li>logs from different hosts flow to a single collector host</li><li>logs are persisted by the collector: no more need to logrotate on the hosts (you can always do it as a backup strategy) and fault-tolerance in case of complete failure of the origin hosts</li><li>logs are saved almost in real-time</li><li>logs are saved along with metadata that allows you to query them (eg: filter them by timespan, by origin host, by words in the log content, etc..)</li><li>you get a nice web-based UI to browse/query the logs</li><li>depending on what your log messages contain, you might be able to track down the full track of a high-level that gets decomposed into multiple sub-requests flowing through many parts of a complex system (eg: a microservices based architecture) with only one query. This for example can be done if you put correlation IDs into your requests: then you query for those IDs.</li></ul><p>And — as nothing comes completely free of charge — these are the cons:</p><ul><li>the collector is a Single Point of Failure unless you provide load balancing for it</li><li>the collector could quickly get out of disk space, depending on how many hosts you collect from and the logs flow rate</li><li>log centralization relies on network efficiency: no network, no centralized logging — so you need to provide a local backup where to write your logs just in case.</li></ul><p>It is worth mentioning that the solution we’re going to provide can be effectively used not only to track application-level logs but also to chunk and collect system-level logs (eg: syslog, dmesg, etc..)</p><h3>Logstash</h3><p><a href="https://www.elastic.co/products/logstash">Logstash</a> is the log aggregating solution we’re going to use. It is a daemon + command-line tool that just accepts and stores all the log messages that you send it, but provides no way of indexing and querying the logs. Furthermore, it comes without any graphical user interface.</p><p>So if we want to effectively leverage Logstash we need to bind it with another solution that allows to index and query for logs and possibly another solution that allows us to do all of this in a human-friendly fashion.</p><h3>Introducing the ELK stack</h3><p>“ELK” is the short of <a href="https://www.elastic.co/products/elasticsearch">Elasticsearch</a>, <a href="https://www.elastic.co/products/logstash">Logstash</a> and <a href="https://www.elastic.co/products/kibana">Kibana</a>. This application stack provides us exactly what we need:</p><ul><li><em>Logstash</em> — collects logs from hosts, these are handed over to…</li><li><em>Elasticsearch</em> — indexes and stores logs, that can be seen using…</li><li><em>Kibana</em> — a rich web-based user interface</li></ul><p>Installing and configuring three different applications is too much, we’ll use a quicker solution: Docker. But first, let’s setup our EC2 instance.</p><h3>Setup of EC2 instance</h3><p>When you setup the instance, make sure it instantiates Ubuntu 14.04 AMI and mounts a good capacity volume (this depends on the logs frequency of course, but I would advice at least 32 GB) and at least 2 GB of RAM (a t2.small could be fine)</p><p>Install Docker 1.9 by running the following commands as root user:</p><pre>$ apt-key adv --keyserver hkp://p80.pool.sks-keyservers.net:80 --recv-keys 58118E89F3A912897C070ADBF76221572C52609D<br>$ echo &quot;deb <a href="https://apt.dockerproject.org/repo">https://apt.dockerproject.org/repo</a> ubuntu-trusty main&quot; | sudo tee -a /etc/apt/sources.list.d/docker.list<br>$ apt-get update<br>$ apt-get install -y docker-engine python-pip<br>$ usermod -aG docker ubuntu</pre><p>Then logout and login again as user ubuntu.</p><p>Now install Docker-compose with the following commands:</p><pre>$ cd<br>$ curl -L <a href="https://github.com/docker/compose/releases/download/1.5.2/docker-compose-%60uname">https://github.com/docker/compose/releases/download/1.5.2/docker-compose-`uname</a> -s`-`uname -m` &gt; $ /usr/local/bin/docker-compose<br>$ chmod +x /usr/local/bin/docker-compose</pre><p>Now you need to edit the security groups for your instance. We will need to expose the following host ports to the machines that “produce” logs:</p><ul><li>TCP 5000 (Logstash)</li><li>TCP 9200 (Elasticsearch REST JSON interface)</li><li>TCP 9300 (Elasticsearch transport protocol)</li></ul><p>and the following port to the Internet (but be aware that our Kibana setup won’t provide any kind of authentication mechanism!):</p><p>Also, you may want to assign a DNS name to the EC2 instance so you can easily reach Kibana. Let’s assume that you use logs.mydomain.com.</p><p>Moreover, the Django hosts will need to publish their logs to Logstash possibly not through a public network. Encrypting logs is out of the scope of this tutorials: as a security measure we can bind a private DNS name to the private IP of your EC2 instance (you can use Route53 on AWS for that purpose) and have Django publish logs on that name. Let’s assume the private IP of our instance is: 13.0.0.13</p><h3>Setup Docker containers for ELK applications</h3><p>As I told before, we want to leverage Docker to quickly spin-up our ELK stack. I found a very good Github project by Anthony Lapenna: <a href="https://github.com/deviantony/docker-elk">docker-elk</a>, it basically is an out-of-the-box setup (YML file) for Docker-compose to run all the applications in the ELK stack, each one a separate Docker container. Containers are instrumented so they can communicate and the one running Kibana will get mapped to a public port of the EC2 host.</p><p>We can clone the repo with:</p><pre>$ cd $ git clone <a href="https://github.com/deviantony/docker-elk">https://github.com/deviantony/docker-elk</a></pre><p>In the repo you find subfolders for each ELK component, storing config files that you can modify according to your needs.</p><p>Bringing up all the ELK stack is as simple as:</p><pre>$ cd docker-elk $ docker-compose up -d</pre><p>After a while, you can test that the containers have been started:</p><pre>$ docker ps<br>    CONTAINER ID        IMAGE                  COMMAND                  CREATED             STATUS              PORTS                                             NAMES<br>    8f34a3f8d142        dockerelk_kibana       &quot;/docker-entrypoint.s&quot;   5 seconds ago       Up 2 seconds        0.0.0.0:5601-&gt;5601/tcp                            dockerelk_kibana_1<br>    d2530f2e0194        logstash:latest        &quot;/docker-entrypoint.s&quot;   8 seconds ago       Up 6 seconds        0.0.0.0:5000-&gt;5000/tcp                            dockerelk_logstash_1<br>    9c6580429bde        elasticsearch:latest   &quot;/docker-entrypoint.s&quot;   11 seconds ago      Up 9 seconds        0.0.0.0:9200-&gt;9200/tcp,  0.0.0.0:9300-&gt;9300/tcp   dockerelk_elasticsearch_1</pre><p>You can test if Kibana is running by pointint your browers to:</p><pre><a href="http://logs.mydomain.com:5601/">http://logs.mydomain.com:5601</a></pre><p>As you see, using Docker-compose makes it really easy to spin up again the whole stack just in case of errors. If you want to bring down the ELK stack, just do:</p><pre>$ docker-compose stop</pre><p>from inside the /home/ubuntu/docker-elk folder.</p><h3>Instrument Django to use centralized logging</h3><p>This will be very simple: we can use the python-logstash binding library developed by <a href="https://github.com/vklochan/python-logstash">GitHub user vklochan</a>. This library will tell Django to send logs also to Logstash via network, but it needs a bit of configuration before.</p><p>Switch to the host (eg: localhost) where your Django setup is, then install the library with:</p><pre>$ pip install python-logstash</pre><p>Let us assume your Django app is named <em>myapp</em>. Open the settings.py file where all the Django config settings live. You should spot a section about logging (the LOGGING dict):</p><pre>LOGGING = {</pre><pre># Put here formatters, etc...</pre><pre>&#39;handlers&#39;: {<br>        &#39;myhandler&#39;: {<br>            # Bla bla bla<br>        },<br>        &#39;logstash&#39;: {<br>            &#39;level&#39;: &#39;INFO&#39;,<br>            &#39;class&#39;: &#39;logstash.TCPLogstashHandler&#39;,<br>            &#39;host&#39;: &#39;13.0.0.13&#39;,   # IP/name of our Logstash EC2 instance<br>            &#39;port&#39;: 5000,<br>            &#39;version&#39;: 1,<br>            &#39;message_type&#39;: &#39;logstash&#39;,<br>            &#39;fqdn&#39;: True,<br>            &#39;tags&#39;: [&#39;myapp&#39;],<br>        }<br>    },<br>    &#39;loggers&#39;: {<br>        &#39;myapp&#39;: {<br>            &#39;handlers&#39;: [&#39;myhandler&#39;, &#39;logstash&#39;],<br>            &#39;level&#39;: &#39;INFO&#39;,<br>        }<br>    }<br>}</pre><p>The configuration is pretty straightforward to understand (for more info please take a look at python-logstash&#39;s&#39; GitHub project wiki)</p><p>Now all you need to do is restart Django and take a look at Kibana if logs get tracked.</p><p><strong>Update Jan 2016</strong>: as of today, python-logstash is still missing SSL support, but this is notified as an issue on the GitHub project repository.</p><p><a href="https://www.digitalocean.com/community/tutorials/how-to-install-elasticsearch-logstash-and-kibana-elk-stack-on-ubuntu-14-04">This</a> guide can be useful to setup authentication on Kibana.</p><p>If you need a comprehensive reference to the ELK stack (eg: how to write custom Logstash plugins or how build advanced queries and dashboards with Kibana) you can read <a href="https://www.packtpub.com/big-data-and-business-intelligence/learning-elk-stack">“Learning ELK Stack” by Packt Publishing</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=cba0c7d19402" width="1" height="1" alt=""><hr><p><a href="https://medium.com/time-is-a-gentleman/setting-up-centralized-logging-on-your-django-apps-using-logstash-and-amazon-ec2-cba0c7d19402">Setting up centralized logging on your Django apps using Logstash and Amazon EC2</a> was originally published in <a href="https://medium.com/time-is-a-gentleman">Time is a gentleman</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Geospatial Development By Example with Python]]></title>
            <link>https://medium.com/time-is-a-gentleman/geospatial-development-by-example-with-python-d239690a847d?source=rss----5c14e1c1a96d---4</link>
            <guid isPermaLink="false">https://medium.com/p/d239690a847d</guid>
            <category><![CDATA[python]]></category>
            <category><![CDATA[book-recommendations]]></category>
            <category><![CDATA[geospatial]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[gis]]></category>
            <dc:creator><![CDATA[Claudio Sparpaglione]]></dc:creator>
            <pubDate>Wed, 09 May 2018 11:44:12 GMT</pubDate>
            <atom:updated>2018-05-09T11:44:03.264Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/302/1*3FWfxPsSP6QApczzbBbLXg.jpeg" /></figure><p>Thanks to my work experience in geospatial applications development, last year I was selected as reviewer for a good introductory book on the topic, and that was a honor to me.</p><p>The book is:</p><p><a href="https://www.packtpub.com/application-development/geospatial-development-example-python">Geospatial Development By Example with Python — ISBN 13: 9781785282355</a></p><p>written by <a href="https://www.packtpub.com/books/info/authors/pablo-carreira">Pablo Carrera</a> and e-printed/printed by Packt Publishing.</p><p>I highly recommend this book if you’re new to geospatial data processing, GIS, map-oriented applications and things like and you want to learn more about it and use Python in all its glory as the de-facto king language in this sector.</p><p>The books is practice-oriented and contains lots of examples — and maps :)</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d239690a847d" width="1" height="1" alt=""><hr><p><a href="https://medium.com/time-is-a-gentleman/geospatial-development-by-example-with-python-d239690a847d">Geospatial Development By Example with Python</a> was originally published in <a href="https://medium.com/time-is-a-gentleman">Time is a gentleman</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Check truthiness values in Python]]></title>
            <link>https://medium.com/time-is-a-gentleman/check-truthiness-values-in-python-81f53b7c6ffe?source=rss----5c14e1c1a96d---4</link>
            <guid isPermaLink="false">https://medium.com/p/81f53b7c6ffe</guid>
            <category><![CDATA[python]]></category>
            <category><![CDATA[nonethiness]]></category>
            <category><![CDATA[truthiness]]></category>
            <category><![CDATA[programming]]></category>
            <dc:creator><![CDATA[Claudio Sparpaglione]]></dc:creator>
            <pubDate>Wed, 09 May 2018 11:39:21 GMT</pubDate>
            <atom:updated>2020-01-10T16:28:09.437Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6aQMxVnkqH8cyaZF7i5FjQ.png" /><figcaption>Bocca della Verità (truth oracle)</figcaption></figure><p>Today I just want to share with you how to check truth values in Python. <strong>Truthiness</strong> is the boolean meaning of a value, and sometimes checking it can save you a lot of hassle.</p><h3>In Python veritas</h3><p>Each Python built-in type has a truthiness value:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/280/1*KfTgf0EiWq4ytyNIlegp_Q.png" /><figcaption>Truthiness for Python types</figcaption></figure><h3>Checking truthiness</h3><p>You can explicitly check the truth value of a value using the bool built-in function:</p><pre>bool(4)         # True<br>bool(&#39;Hello&#39;)   # True<br>bool([1, 2, 3]) # True</pre><p>So this — funny fact — means that bool(&#39;False&#39;) isTrue`: in Python there are no such things as Java&#39;s</p><pre>Boolean b1 = Boolean.valueOf(&quot;false&quot;);       # b1 is false<br>Boolean b2 = Boolean.parseBoolean(&quot;false&quot;);  # b2 is false</pre><h3>Truthiness vs nonethiness</h3><p>In example, if you have a list and you want to check if it’s empty or not, you can do:</p><pre>my_list = []<br>if len(my_list) == 0:<br>  print(&#39;Empty&#39;)</pre><p>but also — more concisely and more Pythonically:</p><pre>my_list = []<br>if not my_list:<br>  print(&#39;Empty&#39;)</pre><p>this is because the truth value of an empty list is False. But, be aware that if you do:</p><pre>my_list = None<br>if not my_list:<br>  print(&#39;Empty&#39;)</pre><p>you will get the same result (“Empty” being printed)! This is because the truth value of None is False as well. So this raises a flag: <em>checks for truthiness and nonethiness overlap, and therefore must be differentiated on a syntactical base</em>. I usually do this by <em>explicitly</em> checking for nonethiness:</p><pre>my_list = None<br>if my_list is None: # explicit check for nonethiness<br>  print &#39;None&#39;</pre><pre>if not my_list: # check for emptiness<br>  print &#39;Empty&#39;</pre><h3>Defining truthiness for your class</h3><p>You can define the behaviour of your own objects when processed by the bool built-in. This is done by redefining the __bool__ hook</p><pre>class MyClass():<br>  def __bool__(self): return False</pre><pre>o = MyClass()<br>bool(o) # False, always</pre><p>What happens if you don’t redefine the hook? The Python documentation says:</p><blockquote><em>object.</em><strong><em>bool(self)</em></strong></blockquote><blockquote><em>Called to implement truth value testing and the built-in operation </em><em>bool(); should return </em><em>False or </em><em>True. When this method is not defined, </em><em>__len__() is called, if it is defined, and the object is considered true if its result is nonzero. If a class defines neither </em><em>__len__() nor </em><em>__bool__(), all its instances are considered true.</em></blockquote><h3>References</h3><p>For a complete reference on Python datamodel’s truthiness check out <a href="https://docs.python.org/3/reference/datamodel.html">the official documentation</a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=81f53b7c6ffe" width="1" height="1" alt=""><hr><p><a href="https://medium.com/time-is-a-gentleman/check-truthiness-values-in-python-81f53b7c6ffe">Check truthiness values in Python</a> was originally published in <a href="https://medium.com/time-is-a-gentleman">Time is a gentleman</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to minify CSS and Javascript content for serving with a Pelican-powered blog]]></title>
            <link>https://medium.com/time-is-a-gentleman/how-to-minify-css-and-javascript-content-for-serving-with-a-pelican-powered-blog-6e16ef2e67d7?source=rss----5c14e1c1a96d---4</link>
            <guid isPermaLink="false">https://medium.com/p/6e16ef2e67d7</guid>
            <category><![CDATA[blogging]]></category>
            <category><![CDATA[css]]></category>
            <category><![CDATA[pelicans]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[javascript]]></category>
            <dc:creator><![CDATA[Claudio Sparpaglione]]></dc:creator>
            <pubDate>Wed, 09 May 2018 11:26:10 GMT</pubDate>
            <atom:updated>2018-05-09T11:24:55.101Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*k5aZgN7B5npEufpIF7yvBA.jpeg" /></figure><p>In this short tutorial I’ll show you how to wire minified CSS and Javascript into your Pelican-powered blog — I did it on my own one (the one you’re currently reading!)</p><h3>How minification works</h3><p>“Minification” is the process of compressing the content of CSS and Javascript files by:</p><ul><li>removing characters (like whitespaces and tabs) the processor/interpreter is insensitive to</li><li>replacing long variable names with shorter ones (eg: naming variables with just one or two letters)</li></ul><p>This is helpful as it decreases the size of .css and .js files and therefore when these files will be sent over the wire they&#39;ll take less time (and bandwidth) to be delivered.</p><p>A shortcoming is that minified code is no longer readable by humans, but this seldom is a problem as minification is a one-way process and one can automate it in order to keep the unminified source files apart.</p><h3>Requirements</h3><p>You can read in <a href="https://medium.com/time-is-a-gentleman/setup-a-static-python-powered-blog-with-pelican-a119cca60256">my previous post</a> how to setup a weblog using the Pelican library.</p><p>In order to install the dependencies we’ll need, you need to install the pip package manager</p><h3>Install minifiers</h3><p>There are lots of CSS and Javascript minifiers out there.</p><p>I’ve looked specifically for Python minifiers and found jsmin for Javascript minification and csscompressor for CSS minification.</p><p>You can install them with:</p><pre>$&gt; pip install jsmin<br>$&gt; pip install csscompressor</pre><h3>Use minifiers</h3><p>Their usage is very simple:</p><pre># Minify a Javascript file<br>$&gt; python -m jsmin my.js &gt; my-minified.js </pre><pre># Minify a CSS file<br>$&gt; python -m csscompressor -o my-minified.css my.css</pre><p>The minifiers output shall be put into your blog’s css and js folders, getting served by your webserver.</p><p>You can (and you should) add the resource minification commands to your automatic blog-build script — and if you don’t have one, go make it! ;)</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6e16ef2e67d7" width="1" height="1" alt=""><hr><p><a href="https://medium.com/time-is-a-gentleman/how-to-minify-css-and-javascript-content-for-serving-with-a-pelican-powered-blog-6e16ef2e67d7">How to minify CSS and Javascript content for serving with a Pelican-powered blog</a> was originally published in <a href="https://medium.com/time-is-a-gentleman">Time is a gentleman</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Guidelines for writing a good CV in the software development industry]]></title>
            <link>https://medium.com/time-is-a-gentleman/guidelines-for-writing-a-good-cv-in-the-software-development-industry-a2e8338126da?source=rss----5c14e1c1a96d---4</link>
            <guid isPermaLink="false">https://medium.com/p/a2e8338126da</guid>
            <category><![CDATA[guidelines]]></category>
            <category><![CDATA[job-hunting]]></category>
            <category><![CDATA[cv]]></category>
            <category><![CDATA[resume]]></category>
            <category><![CDATA[software-jobs]]></category>
            <dc:creator><![CDATA[Claudio Sparpaglione]]></dc:creator>
            <pubDate>Wed, 09 May 2018 07:15:07 GMT</pubDate>
            <atom:updated>2018-05-09T07:13:18.508Z</atom:updated>
            <content:encoded><![CDATA[<p>Writing a good CV is the key to obtaining your dream job and successfully start/boost your career.<br> But if you’re a software craftsman, writing a good CV isn’t so easy and there is a plenty of reasons why you should give the maximum relevance to it.</p><p>Please note that in this post I’m talking about CV writing for <em>technical</em> positions: this means that the formats won’t be good for management/different kind of positions.</p><h3>…isn’t it enough to just write down my previous jobs and my skillset?</h3><p><strong>No!</strong> Keep on reading…</p><h3>What a CV really is: selling by differentiating</h3><p>A CV is an <em>advertisement</em>. It exists to blink an eye to potential customers, which in career development are employers. So the aim of your CV is: have the customers buy yourself.<br> And what would you do in order to sell yourself as a product?</p><p><strong>Believe in your product</strong>. You’re worth your skills, which have been built after years of studies, experience, abnegation. This is something that everyone, but first of all <em>you</em> must respect.</p><p><strong>Present the product in the better possible fashion</strong>. Many facets around that:</p><ul><li>have your <em>good parts</em> stand out — so everyone knows what you’re good at!</li><li>be <em>concrete</em>: provide facts, numbers, achievements</li><li>be <em>concise</em> and leave <em>cliffhangers</em>: don’t tell the whole story! Just provide fundamental facts, but let people come back to you to ask for more detail</li><li><em>never lie about yourself</em>: if you do, you are doomed to eternal unsuccess. What you need to do, instead, is try to hide as much as possible your weaknesses (in terms of technical, behavioural, organisational debts) or — even better — to show them under a positive view, as things you’re currently keen on improving.</li><li><em>let the advertisement be pleasant to the customer’s eyes</em>: the text should be clear and readable. So you need to use proper fonts, sizes, colours and to align contents consistently.</li><li>double-check for <em>typos</em> (if you still make grammar mistakes, please go back to school…)</li></ul><p><strong>Show your passion and hunger</strong>: show how much <em>passion</em> and <em>commitment</em> you put into the things you’ve made/built/worked on! This conveys your emotional status to the people so they can feel your enthusiasm. And also let people know that you’re not sitting down and waiting for change to come: give evidence that you <em>embrace change</em>, are <em>proactive</em> and <em>eager to improve yourself and your skills</em> in any possible way.</p><p><strong>Differentiate your product from the others</strong>: absolutely <em>avoid being uniformed</em>. If you become a number, your chances to smash the opponents will dramatically decrease: therefore, always strive to stand out of the crowd by formatting your CV in a smart and appealing way. This can be achieved using custom structure and graphics, but be careful not to exceed with your imagination…</p><h3>A possible CV format</h3><p>Unless explicitly requested by employers, you should avoid CV formats such as Europass who are meant to standardise candidate profiles for all potential employers to easily browse through: this is obviously against product differentiation. Besides that, compiling the endless Europass templates is a damn boring task!</p><p>After a bit of experimentation applying to job openings both in Italy and the UK, I’ve come up with a potentially good CV format (you tell me), that can be used as a start and admittedly <em>must</em> be modified!</p><h4>Overview</h4><p>I personally prefer minimalist CV formats: no colors, no icons, only one type of font.</p><p>Keep in mind that there will be a 99% probability that you’ll send your CV in PDF format, so don’t rely on features that are specific to your word processor.</p><p>The <strong>aims</strong> of this CV format — and of any CV targeting software jobs — are to tell your potential employer:</p><ol><li><em>what your technical skills are</em></li><li><em>what SW projects (either at work or in your spare time) you’ve been working on and under what roles</em></li></ol><p>String emphasis is put on <em>skills acquired through experience</em>, therefore this format is not a good match for recent-grads or persons with a little experience at work.</p><p>Also remember that this CV should be always sent out <strong>with a proper cover letter</strong> introducing it to the recipients (more about it in a while).</p><p>And finally… as diversification is fundamental, <strong>please do not dumbly copy/adapt the CV format!</strong>. I encourage you to <strong>change it according to your specific needs</strong>!</p><h4>The format</h4><p>Let’s take Cicero as candidate for a SW development job… :-)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/746/1*C_7HQ0PU2rFPkrpxiVYmOA.png" /><figcaption>CV format</figcaption></figure><h4>Length</h4><p>No more than 2 pages! Therefore you need to be sharp and concise. The more you write, the more chances are your reader gets bored and gives up only because of the CV length!</p><p>Also, absolutely avoid repetitions of any kind: every important fact/skill should be mentioned only once.</p><h4>Raw structure</h4><p><strong>Headline</strong>. All of your names and surnames, and a short [optional] tagline saying what your profession is (or what profession you desire to do in your life). I especially like to use eye-catching sentences for the tagline, as they create expectations/curiosity in readers. Any photos? The decision depends on you: if you choose to attach one, make sure you look professional!</p><p><strong>Contact points</strong>. Make sure you include at least your e-mail address and mobile number, then you can add your address and a few optional links: eg, to your Linkedin account (which should only complement — never replace — your full CV!), to your personal website, etc. I suggest to avoid putting your social network references, unless your employer specifically asks for them.</p><p><strong>Personal profile</strong> [optional]. This seems to be a very opinionated section: in my experience, this part is widely used in the UK and almost always neglected in Italy. It’s a concise and brilliant introduction to yourself, where you especially focus on your soft skills: think of it as a “speed-date” description of yourself as a professional. Provided you keep it brief, it can give a good reminder of your good parts (skills and potential), but the risk is to overlap the concepts you explain in the cover letter. So you might consider to avoid putting this when you have the chance to send a cover letter along with your CV.</p><p><strong>Skills</strong>. The most fundamental part in your CV, believe it or not. Put here <em>all the skills that match the ones required by the job spec</em> you’re addressing. Please note that <em>you must be ready to prove that you own each of the skills you list here</em>! So don’t exagerate. Advice: don’t list everything you can do/use (leave out the skills that are not pertaining to the job spec or the company’s business) and leave out the “obvious” things for a computer literate — like using Skype or the ability to browse the Internet… Also, this section is a good place where to talk about your soft and organisational skills, but consider to move your soft skills to the “Personal profile” section or to the cover letter. As one could have multiple cross-concerning skills, it’s a good practice to catalogue them into subsections. Of course many more could be added to the template (eg: mobile computing, operating systems, embedded systems, etc…). I recommend to put at least the following categories:</p><ul><li><em>Programming languages</em></li><li><em>Software development</em> (agile methodologies? OOP skills? design patterns?)</li><li><em>Software design</em> (Computer architectures? OOD? UML? ERD?)</li><li><em>Software testing</em> (continuous integration? TDD? testing libraries/framework?)</li><li><em>Development tools</em> (revision control tools? documentation tools? issue tracking tools?)</li><li><em>Frameworks/platforms</em> (web frameworks? ORMs?)</li><li><em>Cloud computing</em> (reference any PaaS/IaaS/BEaaS you’ve been using)</li><li><em>Open source contributions</em> (put references to your GitHub/BitBucket/etc.. contributions or projects)</li><li><em>Databases</em> (put here RDSs and NoSQL datastores you know)</li></ul><p><strong>Work experience</strong>. List the most important work experiences of your life relative to the job spec! You should also put the major roles you had in the projects you list. It’s better to list work experiences in reverse chronological order (along with start/end dates) and to add name, address and website link for each past employer. <em>Make any concrete achievements you had and SW projects you worked on stand out!</em> Achievements not only include writing working software systems but also improving the SW development practices, mentoring colleagues, boost to automatisation of repetitive tasks, documenting patterns/procedures, enforcing specific development/testing methodologies, focus attention on SW quality/security/usability.</p><p><strong>Education</strong> [optional but adviced]. I would say this section can be omitted, especially if you come from a non software-related background and/or you have ebough experience in the industry and therefore there is no need to show that you have a pertaining academic background. Usually, experience is exchanged 3:1 against knowledge! Nevertheless, please do add to this section any <em>certifications</em>, <em>master courses</em>, <em>MBAs</em>, etc.. you obtained along with marks.</p><p><strong>Spoken languages</strong>. List all the languages you currently speak/write along with a honest estimate of your proficiency.</p><p><strong>Hobbies</strong> [optional but adviced]. Work could be biggest thing in our life if we consider the amount of time we spend at it, but honestly should only be one half of it if we consider the passion and interest we put to itm the remaining part should be dedicated to personal hobbies. If you want to give a complete view on yourself, you need to tell about your major interests outside of work. Remember that people having lots of personal interests look dynamic and more interesting to potential employers than people “who just commit hard when working”: making the most out of diverse leisure activities helps to keep your mind and energies fresh and not to be overwhelmed by huge workloads when they occur!</p><h4>Styling</h4><ul><li>the font is Arial 10 for paragraph text and 12 for titles</li><li>I only use colour black for text</li><li>sections are clearly identifiable as they are kept separate one from each other</li><li>I use tables to align content: one table for each section. And I also make their borders invisible</li><li>all the provided web links have their corresponding URLs as text and are clickable</li><li>I use a lot of bullet lists (also indented): they’re clear and concise</li><li>the name+surname is repeated in the footer of each page, along with page number</li></ul><h3>The cover letter</h3><p>Think of a cover letter as the “positioning” of your advertisement: if you place an outstanding and appealing ad somewhere nobody can see, there’s no point in creating such a good ad as nobody will ever notice it. So a good cover letter is most of the times <strong>as important as a proper CV</strong>!</p><p>I won’t give examples of cover letter, as this really depends on the company you’re applying for (formal vs informal slant), the position you’re applying for and any possible costraint you have on its length and medium (eg: e-mail, web form, etc.).</p><p>The important points at it are telling to any potential employer:</p><ol><li><em>why you think you are the best possible fit for the job vacancy</em></li><li><em>what your motivations are as regards the job</em></li></ol><p>Generally speaking, the best advices for writing a smashing cover letter are:</p><ul><li>give the cover letter an “A-B-A” pattern : the “A” part consists of telling why you are suitable for the job (experience? knowledge? both of these?), the “B” part consists of telling what added value/skillsets you could bring to the company. Please notice that the “A” part is reiterated before closing the letter!</li><li>spot keywords/technologies in the job spec that you think are fundamental and the candidate needs to have: make sure each of these appear the first occurrence of the “A” part of your cover letter and briefly explain where you achieved them.</li></ul><h3>Strategies for CV+cover letter bullet-proofing</h3><ol><li>Write down your CV</li><li>Write down a proper cover letter</li><li>Compare both against the job spec and match job spec keywords. If your CV+cover are not matching at least 90% of the job spec’s keywords, then you need to change them accordingly</li><li>Have your CV+cover read by a fellow professional (eg: another developer, an IT manager, etc.)</li><li>Put yourself in the shoes of a potential employer: would you give a chance to someone with your profile? Sincerely. If the answer is not a full “yes!”, then somethig must be changed in your CV+cover.</li></ol><h3>Managing your online work profiles</h3><p>I’ve been tempted a lot of times to write down my CV using Markdown, compile it to plain HTML and host it as a page of my personal website. That is cool for sure, but this only helps the proliferation of duplicated work profiles I have on a plethora of websites (such as Linkedin, job notification boards, etc..): this means that every time I need to update my CV with — in example — a new job position or a new skill I’ve acquired, I need to add/modify each and every profile in a consistent way.</p><p>I don’t like it: <em>duplication is the root of evil</em>, in software development as in CV writing! The ideal situation would be: write once and deploy everywhere, so <em>try to keep at minimum the number of work profiles you have online</em>!</p><p>My advice is to only keep one profile on the most used work network, <em>Linkedin</em>, and keep it in sync with your “plain-old” CV on paper.</p><p>Then also <em>make sure your Linkedin profile is read by as many people as possible</em>! This involves building and managing your social networks, subscribing to user groups discussing thing you’ve worked with or would love to (this helps you to find like-minded people and also gives recruiters visibility on you)… and of course, again, selling your product: add the link to your Linkedin profile to your e-mail signature and share it on the social networks, also put it on your personal website pages!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a2e8338126da" width="1" height="1" alt=""><hr><p><a href="https://medium.com/time-is-a-gentleman/guidelines-for-writing-a-good-cv-in-the-software-development-industry-a2e8338126da">Guidelines for writing a good CV in the software development industry</a> was originally published in <a href="https://medium.com/time-is-a-gentleman">Time is a gentleman</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Setup a static Python-powered blog with Pelican]]></title>
            <link>https://medium.com/time-is-a-gentleman/setup-a-static-python-powered-blog-with-pelican-a119cca60256?source=rss----5c14e1c1a96d---4</link>
            <guid isPermaLink="false">https://medium.com/p/a119cca60256</guid>
            <category><![CDATA[markdown]]></category>
            <category><![CDATA[blogging]]></category>
            <category><![CDATA[how-to]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[pelicans]]></category>
            <dc:creator><![CDATA[Claudio Sparpaglione]]></dc:creator>
            <pubDate>Tue, 08 May 2018 21:08:22 GMT</pubDate>
            <atom:updated>2018-05-09T06:43:48.318Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Pd4hLn_2SRbAb2Jo9bK_rQ.jpeg" /><figcaption>A (non-blogging) pelican</figcaption></figure><p>Pelican is a Python library that allows static content generation from plain text files written using ReSructured Text or Markdown syntaxes. It is an efficient, easy to setup tool that can — in example — be used to create blogs in minutes.</p><p>More info on the <a href="http://blog.getpelican.com/">official Pelican blog</a>, and of course links to source code and docs.</p><p>In this tutorial we’ll be generating a blog and posting content using Markdown. We’ll call our blog: “blog”</p><h3>Requirements</h3><p>You will need Python 2.7+ and the pip package manager</p><h3>Install Pelican</h3><p>Install Pelican and Markdown syntax modules:</p><pre>$&gt; pip install pelican Markdown</pre><h3>Create a skeleton Pelican project</h3><pre>$&gt; cd <br>$&gt; mkdir blog <br>$&gt; cd blog <br>$&gt; pelican-quickstart <br>$&gt; tree <br>./ <br>+-- content # Place here source .md files <br>+-- output # Will contain the output .html files after generation<br>+-- develop_server.sh<br>+-- fabfile.py<br>+-- Makefile<br>+-- pelicanconf.py # Main settings file<br>+-- publishconf.py # Settings to use when ready to publish</pre><h3>Install themes</h3><p>You can modify Pelican’s default theme by installing (cloning) one or more of the <a href="https://github.com/getpelican/pelican-themes">themes you find on Github</a>:</p><pre>$&gt; cd pelican-test <br>$&gt; mkdir -p themes/fresh # I&#39;ve chosen to install the &#39;fresh&#39; theme $&gt; git clone git://github.com/jsliang/pelican-fresh themes/fresh</pre><h3>Write Pelican configuration file</h3><p>The configuration file is pelicanconf.py, it will be used by Pelican when generating HTML content from the Markdown sources:</p><pre>#!/usr/bin/env python<br># -*- coding: utf-8 -*- #<br>from __future__ import unicode_literals</pre><pre>AUTHOR = u&#39;me&#39;<br>SITENAME = u&#39;blog&#39;<br>SITEURL = &#39;&#39;</pre><pre># Pelican will take contents in this folder as sources<br>PATH = &#39;content&#39;</pre><pre>TIMEZONE = &#39;Europe/London&#39;</pre><pre>DEFAULT_LANG = u&#39;en&#39;</pre><pre># Feed generation<br>FEED_ALL_ATOM = None<br>CATEGORY_FEED_ATOM = None<br>TRANSLATION_FEED_ATOM = None</pre><pre># Blogroll links<br>LINKS = ((&#39;My link 1&#39;, &#39;<a href="http://mylink1.com&/#39;">http://mylink1.com&#39;</a>),<br>         (&#39;My link 2&#39;, &#39;<a href="http://mylink2.com&/#39;">http://mylink2.com&#39;</a>),)</pre><pre># Social widget links<br>SOCIAL = ((&#39;My social link 1&#39;, &#39;<a href="https://mysociallink1.com&/#39;">https://mysociallink1.com&#39;</a>),<br>          (&#39;My social link 2&#39;, &#39;<a href="https://mysociallink2.com&/#39;">https://mysociallink2.com&#39;</a>),)</pre><pre># Max Number of article previews per page<br>DEFAULT_PAGINATION = 5</pre><pre># Document-relative URLs ?<br>RELATIVE_URLS = True</pre><pre># Path to the theme you want to apply<br>THEME = &#39;themes/fresh&#39;</pre><h3>Write a blog post</h3><p>Now write a Markdown blog post like this one:</p><pre>Title: My test blog post<br>Date: 2014-11-01 13:49<br>Category: attempts<br>Tags: blogging, pelican, markdown<br>Slug: my-test-blog-post<br>Authors: me<br>Summary: This is a really deep and introspective test blog post</pre><pre>What is the meaning of life the universe and everything?<br>--------------------------------------------------------<br>42</pre><p>and save it into the content folder as test.md</p><h3>Generate HTML from Markdown</h3><p>You’re now ready to generate the corresponding HTML content:</p><pre>$&gt; pelican content -o output<br>$&gt; tree output<br>    output/<br>    +-- author/<br>    +-- category/<br>    +-- feeds/<br>    +-- images/<br>    +-- tag/<br>    +-- theme/<br>    +-- archives.html<br>    +-- authors.html<br>    +-- categories.html<br>    +-- index.html<br>    +-- my-test-blog-post.html<br>    +-- tags.html</pre><h3>Take a look!</h3><p>You can now preview your blog by launching a web server:</p><pre>$&gt; python -m SimpleHTTPServer 8888</pre><p>and pointing your browser to <a href="http://localhost:8888/">http://localhost:8888</a>.</p><p>Cool, isn’t it?</p><h3>Installing Pelican plugins</h3><p>Pelican is an extensible platform, which means you can add one or more <a href="https://github.com/getpelican/pelican-plugins">plugins</a> into it and add functionalities.<br> You can install community-provided plugins by cloning the plugins repository:</p><pre>$&gt; git clone <a href="https://github.com/getpelican/pelican-plugins">https://github.com/getpelican/pelican-plugins</a> plugins</pre><p>Now the plugins are in the plugins folder and you can enable/disable them and put their corresponding configuration data into your Pelican configuration file.</p><h3>Adding an XML sitemap</h3><p>You want your blog to be fully crawled by Google, dont’ you? So you need to generate a sitemap for it.<br> Generating a sitemap is easy if you use the sitemap plugin.<br> What you need to do is, once you&#39;ve installed all the plugins, add the following lines to the pelicanconf.py:</p><pre># Path to the folder containing the plugins<br>PLUGIN_PATHS = [u&#39;plugins&#39;]</pre><pre># The plugins you want to be enabled<br>PLUGINS = [u&#39;sitemap&#39;]</pre><pre># Configuration for the &quot;sitemap&quot; plugin<br>SITEMAP = {<br>    &#39;format&#39;: &#39;xml&#39;,<br>    &#39;priorities&#39;: {<br>        &#39;articles&#39;: 1,<br>        &#39;indexes&#39;: 0.5,<br>        &#39;pages&#39;: 0.5,<br>    },<br>    &#39;changefreqs&#39;: {<br>        &#39;articles&#39;: &#39;always&#39;,<br>        &#39;indexes&#39;: &#39;hourly&#39;,<br>        &#39;pages&#39;: &#39;monthly&#39;<br>    }<br>}</pre><p>Regenerate the output and you’ll notice your output folder now contains a sitemap.xml file.</p><h3>Where to go from here</h3><p>Now you can upload the contents of the output folder &#39;as are&#39; to your web hosting provider. Don&#39;t forget to setup your Google Analytics account to crawl to the domain you publish the pages under.</p><p>Visit the <a href="http://docs.getpelican.com/en/3.4.0/tips.html">Pelican tips page</a> which also explains how to integrate Pelican into GitHub pages.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a119cca60256" width="1" height="1" alt=""><hr><p><a href="https://medium.com/time-is-a-gentleman/setup-a-static-python-powered-blog-with-pelican-a119cca60256">Setup a static Python-powered blog with Pelican</a> was originally published in <a href="https://medium.com/time-is-a-gentleman">Time is a gentleman</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[The relativity of little green men]]></title>
            <link>https://medium.com/time-is-a-gentleman/the-relativity-of-little-green-men-3397a1d71594?source=rss----5c14e1c1a96d---4</link>
            <guid isPermaLink="false">https://medium.com/p/3397a1d71594</guid>
            <category><![CDATA[earth]]></category>
            <category><![CDATA[little-green-men]]></category>
            <category><![CDATA[earth-and-moon]]></category>
            <category><![CDATA[english]]></category>
            <category><![CDATA[curiosity]]></category>
            <dc:creator><![CDATA[Claudio Sparpaglione]]></dc:creator>
            <pubDate>Mon, 10 Feb 2014 10:12:20 GMT</pubDate>
            <atom:updated>2018-05-08T20:48:50.638Z</atom:updated>
            <content:encoded><![CDATA[<p>This is a photo of Earth and Moon taken from NASA’s Curiosity automated rover exploring the surface of Mars. They turn out to be the two micro-spots in the middle (yes, because they ARE two, didn’t you notice? Wear your glasses…)</p><figure><img alt="Earth as seen from Mars" src="https://cdn-images-1.medium.com/max/1024/0*WIYR7XvO9dXPW2-P.jpg" /><figcaption>Earth as seen from Mars</figcaption></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3397a1d71594" width="1" height="1" alt=""><hr><p><a href="https://medium.com/time-is-a-gentleman/the-relativity-of-little-green-men-3397a1d71594">The relativity of little green men</a> was originally published in <a href="https://medium.com/time-is-a-gentleman">Time is a gentleman</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Meditation on the Zen of Python]]></title>
            <link>https://medium.com/time-is-a-gentleman/meditation-on-the-zen-of-python-81d1b9c65f8a?source=rss----5c14e1c1a96d---4</link>
            <guid isPermaLink="false">https://medium.com/p/81d1b9c65f8a</guid>
            <category><![CDATA[this]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[design]]></category>
            <category><![CDATA[zen]]></category>
            <category><![CDATA[programming]]></category>
            <dc:creator><![CDATA[Claudio Sparpaglione]]></dc:creator>
            <pubDate>Wed, 22 Jan 2014 17:18:16 GMT</pubDate>
            <atom:updated>2018-05-09T17:25:00.061Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*L4fxNFhZZZkq5WG0-s4xeg.jpeg" /></figure><p>If you have ever programmed anything in Python, you probably used the “<em>import</em>” statement: the modules of the Python standard library can be imported into your code or into the interpreter. Take a look at the standard library folders and you’ll find the “<em>this.py</em>” module… what is that? Not much a self-explicative name for a Python module, huh? And you — Java lovers — forget about the Java “<em>this</em>” keyword: you’re far afield.</p><p>This module is the mystic “<strong>Zen of Python”</strong>:</p><pre>&gt;import this</pre><pre>The Zen of Python, by Tim Peters</pre><pre>Beautiful is better than ugly.<br>Explicit is better than implicit.<br>Simple is better than complex.<br>Complex is better than complicated.<br>Flat is better than nested.<br>Sparse is better than dense.<br>Readability counts.<br>Special cases aren’t special enough to break the rules.<br>Although practicality beats purity.<br>Errors should never pass silently.<br>Unless explicitly silenced.<br>In the face of ambiguity, refuse the temptation to guess.<br>There should be one — and preferably only one — obvious way to do it.<br>Although that way may not be obvious at first unless you’re Dutch.<br>Now is better than never.<br>Although never is often better than *right* now.<br>If the implementation is hard to explain, it’s a bad idea.<br>If the implementation is easy to explain, it may be a good idea.<br>Namespaces are one honking great idea — let’s do more of those!</pre><p>Woohaaaa!!! What?!?! A sort of mantra???</p><h4>The Pythonic view of the software universe</h4><p>Kidding apart, the Zen states the high-level development guidelines that were followed in the design of the Python language itself; it was formerly stated into the <a href="http://www.python.org/dev/peps/pep-0020/">PEP-20</a> by Tim Peters, one of the fathers of the language along with Guido Van Rossum (BDFL). Ok, I’m curious about it: I open the this.py code in my favourite text editor and I notice that…</p><h4>The Zen of Python does not obey the Zen of Python</h4><p>What??? Here is the source code:</p><pre>s = “””Gur Mra bs Clguba, ol Gvz Crgref<br>Ornhgvshy vf orggre guna htyl.<br>Rkcyvpvg vf orggre guna vzcyvpvg.<br>Fvzcyr vf orggre guna pbzcyrk.<br>Pbzcyrk vf orggre guna pbzcyvpngrq.<br>Syng vf orggre guna arfgrq.<br>Fcnefr vf orggre guna qrafr.<br>Ernqnovyvgl pbhagf.<br>Fcrpvny pnfrf nera’g fcrpvny rabhtu gb oernx gur ehyrf.<br>Nygubhtu cenpgvpnyvgl orngf chevgl.<br>Reebef fubhyq arire cnff fvyragyl.<br>Hayrff rkcyvpvgyl fvyraprq.<br>Va gur snpr bs nzovthvgl, ershfr gur grzcgngvba gb thrff.<br>Gurer fubhyq or bar — naq cersrenoyl bayl bar — boivbhf jnl gb qb vg.<br>Nygubhtu gung jnl znl abg or boivbhf ng svefg hayrff lbh’er Qhgpu.<br>Abj vf orggre guna arire.<br>Nygubhtu arire vf bsgra orggre guna *evtug* abj.<br>Vs gur vzcyrzragngvba vf uneq gb rkcynva, vg’f n onq vqrn.<br>Vs gur vzcyrzragngvba vf rnfl gb rkcynva, vg znl or n tbbq vqrn.<br>Anzrfcnprf ner bar ubaxvat terng vqrn — yrg’f qb zber bs gubfr!”””</pre><pre>d = {}<br>for c in (65, 97):<br>for i in range(26):<br>d[chr(i+c)] = chr((i+13) % 26 + c)</pre><pre>print “”.join([d.get(c, c) for c in s])</pre><p>The first approach to this code might be bewildering… but it’s not so hard to understand, in the end: basically, you have a huge string containing the whole crypted Zen and then you decode it into readable English characters and print it out loud. A few hints:</p><ul><li>65 is the ASCII for ‘A’</li><li>97 is the ASCII for ‘a’</li><li>there are 26 letters in the English alphabet</li><li>the “d” dictionary turns out to have uppercase/lowercase chars as keys and their corresponding translitterated chars as values. The “crypting magic” is given by: <em>i+13 % 26 + c</em></li><li>You have that “A”= decrypt[crypt[“A”]] = crypt[crypt[“A”]]Oddity: the Zen does not follow many of its aphorisms! In fact, its code is far from being <strong>explicit</strong>, and if it’s true that <strong>readability counts</strong>, well, the Zen doesn’t shine at it. Ok, <strong>practicality beats purity</strong> but this is <strong>complex</strong> (not <strong>complicated</strong>) to read out; in fact <strong>the implementation could be simpler to explain</strong>, which conveys that this could be done in a better way.</li></ul><h3>A metaphor</h3><p>My intention is not to disapprove Tim Peters’s work (never be it! I am just a silly rookie!!!) but to show what I think about the Zen: I think that it is a metaphor. It basically poses a problem to its readers, who need to “decipher” it in order to understand how it really works: this is a strong metaphor of life — if you dig deep on problems/difficulties you come up to be sage about them. And so goes for Python design guidelines.</p><p>… and considering that “now is better than never”…</p><p>… while writing this post, I scribbeld (it was funny!) <a href="https://github.com/csparpa/betterzen">a revised version of the Zen of Python</a>. It shows a few additional features (get random aphorisms, seek for specified keywords) that can help developers to better read and lookup the original Zen of Python. Features that — hopefully — comply with what the Zen itself says</p><figure><img alt="Occhiolino" src="https://cdn-images-1.medium.com/max/19/0*XJbPUEMShPgj1gbh.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=81d1b9c65f8a" width="1" height="1" alt=""><hr><p><a href="https://medium.com/time-is-a-gentleman/meditation-on-the-zen-of-python-81d1b9c65f8a">Meditation on the Zen of Python</a> was originally published in <a href="https://medium.com/time-is-a-gentleman">Time is a gentleman</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[The most dangerous software errors]]></title>
            <link>https://medium.com/time-is-a-gentleman/the-most-dangerous-software-errors-9b0dfe8d1df5?source=rss----5c14e1c1a96d---4</link>
            <guid isPermaLink="false">https://medium.com/p/9b0dfe8d1df5</guid>
            <category><![CDATA[software-security]]></category>
            <category><![CDATA[weakness]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[security]]></category>
            <dc:creator><![CDATA[Claudio Sparpaglione]]></dc:creator>
            <pubDate>Thu, 16 Jan 2014 15:56:29 GMT</pubDate>
            <atom:updated>2018-05-09T18:47:20.445Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_Xc-PpsKPcsPgMTHq6FB9Q.jpeg" /></figure><p>Have a look at the Common Weakness Enumeration, a communtiy-driven dictionary of the most dangerous — and yet frequent — SW levities:</p><blockquote><a href="http://cwe.mitre.org/top25/index.html">http://cwe.mitre.org/top25/index.html</a></blockquote><p>Take care of SW security!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9b0dfe8d1df5" width="1" height="1" alt=""><hr><p><a href="https://medium.com/time-is-a-gentleman/the-most-dangerous-software-errors-9b0dfe8d1df5">The most dangerous software errors</a> was originally published in <a href="https://medium.com/time-is-a-gentleman">Time is a gentleman</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>