New Hugo site and deployment workflow

Fri, Mar 27, 2015
I’ve longed for long to have a statically generated website. I’ve always found wordpress not to be inline with my vision of as thin code as possible. This is where Hugo came into play. I find it particularly attractive because: it is blazing fast (you can rebuild your site in milliseconds) it is written in go language which I find extremely interesting for its simplicity it is written by Steve Francia of Docker, MongoDB, vim-spf13 and other project’s fame I love docker and vim and now also Hugo!

Polymorphic attachments for Rails 4 and ActiveAdmin

Sat, Jan 4, 2014
Following my 2012 post!!! I finally managed to write down a small Rails 4 engine that allows anyone to add multiple files to any model in his rails app. The gem has the highly innovative name of: AttachIt. As the original post also took into account ActiveAdmin I managed to add the same functionalities to ActiveAdmin also. The gem is thought for use in the show action for your model. I have a lot of websites with this requirement of handling multiple files for multiple models so I think this must be a fairly common pattern.

Migrate Joomla from Windows 2003 to Docker

Sat, Jan 4, 2014
Migrate Apache2/PHP website to docker Before continuing my series on rails deployment with docker in a PAASY environment I needed to migrate and existing Joomla 1.5 from a Windows 2003 machine to an Azure Ubuntu Linux 12.04. Nothing fancy but there is also a Rails application pointing to the same MySql db which also needs to run on the same Linux VM. As the Joomla app is the main company website I don’t want any problem in the Rails app to affect the main website.

Deploy Rails with Docker, Part 2

Sat, Jan 4, 2014
Series takeaways: Configure a Rails app to be deployed on a cloud architecture (Part 1) Create a vagrant test machine with docker installed (Part 1) Interactive image building vs. Dockerfiles (Part 2) Data Persistence (Part 2) Good Practices (Part 2) Create 7 docker containers that will host the reconfigured rails app (Part 3): Container 1: Redis Server (for session storing) Container 2: Fluentd (log collection) Container 3: ElasticSearch (log storage) Container 4: Kibana (log analysis) Container 5: PostgreSQL + PostGIS Container 6: Chruby Ruby Rails Puma Container 7: Nginx Link the 7 containers through Docker Links (Part 3) —> intra host communication Real Docker Playground with two hosts (Part 4) Deploy PostgreSQL on this second host (Part 4) Make the app work with the second host postgres container (Part 4) —> inter host communication SCALE (Part 5) Automatic Service Discovery with Skydns and Skydock * Session data and Logs HA Database HA Interactive image building vs Dockerfiles It is possible to create docker images either interactively or through a Dockerfile.

2014 thinning list

Sat, Jan 4, 2014
To be faithful to my motto Thin code is king code I’m willing to slim down my development/deployment stack. This year I will: Switch from rvm to chruby Migrate this blog from WordPress to either LocomotiveCMS or Jeckyll Thin down all development and deployment by using Docker Learn Go (this is just because to thin down code you need to use the thinnest tool available for each task) Happy coding year.

Deployment Rails with Docker Part 1

Wed, Dec 11, 2013
After my first approach to easying up the many pains of Rails deployment I happened to bump into Docker for a broader PAAS project. So my thought was: why automate only code deployment if I can automate the whole machine deployment especially with a tool like Docker that makes this task trivial and quick. In this way it will be extremely easy to replicate a development/production environment and instead of updating code I could simply redeploy a machine.

Easy Peasy Deploy

Thu, Nov 14, 2013
I’m a bit tired of reinventing the wheel every time I need to deploy a rails app. Capistrano has made the good decision to use rake instead of his own DSL so I’ll follow that path. I need a deploy.rake file with some tasks inside. I want to be able to perform ssh commands but I’d also like a good DSL for this so I ended up using the same tool Capistrano uses: sshkit.

Multithreaded Rails App 4 REAL

Tue, Oct 29, 2013
Rubinius 2.0 (actually 2.1.1) is out and with it rails apps can finally be fully multithreaded taking advantage of multicore processors and substantially reducing memory consumption (benchmark of latest ruby implementations). Im currently porting a Rails 2 app to Rails 4. It is a patients management app with also image management. Some doctors have up to 4000 patients. My aim is to publish an alpha version of the revamped app on my local home server to let the users actually try the changes and be able to change the final output.

Tailing problems in Windows

Sun, Feb 17, 2013
I built this beautiful dashboard collecting data from different sensors on a high efficiency vehicle. I opted for an html page with server-events. Now I need to tail two files every 0.2 seconds and those files are uptaded every 0.2 seconds. These in Windows 7 brings up random errors when tail.exe tries to read a file that’s being updated in the same exact instant. This means that tail.exe uses file reading with an exclusive lock ….

Who's calling? (I mean ruby method)

Wed, Oct 3, 2012
I needed to know which method was calling another method in a ruby app. I’m writing a legacy protocol parser and need to control that received packets from the serial port stream are matching with commands replies. So I have a set of methods performing some commands and constants which represent correct replies: I wanted to be able to have the following interface to parse reply packets so that I can adapt the correct answer on the basis of the sent command: So I had to find a way to dynamically call the reply packet constant.

Start vSphere machine from OSX

Tue, Sep 11, 2012
So I have a vSphere 5.1 free Hypervisor installed on a HP Microserver. Very nice hardware, very nice piece of software, so far so good. Unfortunately I don’t have a Windows machine in my house except for a Win 7 which is virtualized on the vSphere machine. I don’t want to install a Windows virtual machine on my MacBook just to start my Win 7 machine on the vSphere center. The virtualized Win 7 machine is equipped with vSphere Client.

EventMachine & SerialPort

Thu, Sep 6, 2012
I need to communicate with an inertial platform to track GPS data in a dashboard. As the dashboard is working with EventMachine I decided to use ruby-serialport with EventMachine. UPDATE em-serialport is not working on Windows furthermore, having a good chat on the irc eventmachine channel, the use of eventmachine pure ruby library is not at all efficient. First of all you can now install eventmachine version 1.0.0 on Windows. Then I decided to follow the approach used in serialport-server to listen to my serialport.

Rails 3 is_documentable with activeadmin

Wed, Jul 11, 2012
I need to add the chance to add as many documents as needed for several models of a Rails 3 app. Each model is something that can have associated drawings, administrative acts and so forth. To avoid duplication as far as possible I opted for an acts_as like feature for documents. It will be called acts as documentable. The acts as coding pattern rely on the polymorphic association with which a model can belong to more than one other model, on a single association.

RealTime dashboard: ruby, eventmachine and d3.js

Sat, Jun 30, 2012
We need to build a dashboard for a field veichle through which we collect different street data. We have two lasers used to monitor the status of pavimentation and three accelerometers to monitor that data acquisition be consistent and without spikes. We have a GPS to georeference all the collected data and a video camera to actually see the road and be able to log the presence of different kind of elements on the road graph.

My Website stack: WNWS

Fri, Jun 8, 2012
After much thinking and wondering around through many solutions I opted for the following stack: Webbynode Nginx Wordpress Svbtle I already had a Webbynode account and this was an easy choice. My Webby is actually configured with nginx which is also my default webserver for rails deployments: another easy choice. I fell in love with svbtle layout and administrative interface because I find it very clean and relaxing like the IA Writer I use in my iPad.

Thinking Code

Wed, Jun 6, 2012
I thought that, almost in my forties, I was big enough to have my own website. The name thinking code is obviously linked to my job as a developer which is mainly thinking about code. But this won’t be only a blog about ruby and rails code, I’d like to talk about different codes. There are several codes you can find in society: economical political ethical anthropological theological I like to write about all this different topics trying to unveil patterns, errors and possible refactoring.


If you think I can help you somehow don't hesitate to email me or twit me.
Tommaso Patrizi