Heroku for Dummies

There are a lot of documentation to explain technical considerations about Heroku, in this post I would like to offer a big picture about Heroku.

In last years, through PaaS (Platform for Cloud Service) third party companies could easily manage infrastructure for others. One of the PaaS that we can find is Heroku.

What is Heroku 

Heroku is a cloud platform as a service (PaaS) supporting several programming languages like Ruby, Java, Node.js, Scala, Clojure, Python and PHP.

Heroku is free for low consumption applications for example a proof of concept, and then if all goes well could be easily scalable.

According with his page: Heroku makes the processes of deploying, configuring, scaling, tuning, and managing apps as simple and straightforward as possible, so developers can focus on what’s most important: building great apps that delight and engage customers.

What kind of project could be hosted by Heroku?

According with his page: An application is a collection of source code written in one of these languages, perhaps a framework, and some dependency description that instructs a build system as to which additional dependencies are needed in order to build and run the application.
Any project that you want and written in one of the language supported for Heroku (Ruby, Java, Node.js, Scala, Clojure, Python and PHP).

How difficult could be? (Getting started in Heroku)

There are a lot of guides according to the language: Ruby, PHP, node.js, Python, Java, Clojure and Scala. I deeply recommend to start for there. In broad strokes, the steps could summarize in:

  1. To create a account in Heroku.com
  2. Rails and GIT have already installed
  3. To install Heroku Gem
  4. To create SSH keys and adding to Heroku
  5. To create the app in Heroku.

Data Base

Via Heroku Postgres is possible to access a SQL database-as-a-service that (again) lets the developer be concentrate in building the application instead of working on database management. Also it provides continuous protection and encryption at rest to keep data safe and secure.


  • Free for low consumption applications
  • Low cost for small application, with more requirements for resources:
  • Free up to 5MB of DB
  • Almost instantaneous updates using GIT


  • No SSH access
  • Read-Only Filesystem
  • The answer to the first request may be delayed.



How to create a Text Analyzer in Ruby?

These are my notes about Chapter 4 from the book Beginning Ruby: From Novice to Professional.A book highly recommended for dummies. I found it via A Path to Learn Rails 4 properly.


This code will read in text supplied in a separate file, analyze it for various patterns and statistics, and print out the results for the user.

Required Basic Features

  • Character count
  • Character count (excluding spaces)
  • Line count
  • Word count
  • Sentence count
  • Paragraph count
  • Average number of words per sentence
  • Average number of sentences per paragraph

Building the Basic Application

Let’s outline the basic steps as follows:

  1. Obtain some dummy text
  2. Load in a file containing the text or document you want to analyze.
  3. As you load the file line by line, keep a count of how many lines there were.
  4. Put the text into a string and measure its length to get your character count.
  5. Temporarily remove all whitespace and measure the length of the resulting string to get the character count excluding spaces.
  6. Split out all the whitespace to find out how many words there are.
  7. Split on full stops to find out how many sentences there are.
  8. Split on double newlines to find out how many paragraphs there are.
  9. Perform calculations to work out the averages. Create a new, blank Ruby source file and save it as analyzer.rb in your Ruby folder. As you work through the next few sections, you’ll be able to fill it out.

1. Obtain some dummy text

The dummy file must be within the same folder where you will save example1.rb, and call it text.txt

2. Load in a file containing the text

The parameters are taken from ARGV[0] or ARGV.first (which both mean exactly the same thing the first element of the ARGV array).

lines = File.readlines(ARGV[0])

To process text.txt now, you will run it:

ruby analyzer.rb text.txt

3. count how many lines are within the file.

line_count = lines.size

4. Put the text into a string and measure its length.

The join method can be used to join the Array back into a single String

text = lines.join
character_count = text.length

 5. Temporarily remove all whitespace and measure the length

The gsub method String.gsub(RegExpression,substring), replaces into “String” the parts of it that meet the regular expression  and replaces it with “substring”.

character_count_nospaces = text.gsub(/\s+/, '').length

 6. Find out how many words there are.

The split method to split a string based on a single character or static sequence of characters

word_count = text.split.length

7. Split on full stops to find out how many sentences there are.

sentence_count = text.split(/\.|\?|!/).length

8. Split on double newlines to find out how many paragraphs there are

paragraph_count = text.split(/\n\n/).length

 9. Perform calculations to work out the averages.

all_words = text.scan(/\w+/)
good_words = all_words.select{ |word| !stopwords.include?(word) }
good_percentage = ((good_words.length.to_f / all_words.length.to_f) * 100).to_i


# analyzer.rb -- Text Analyzer

stopwords = %w{the a by on for of are with just but and to the my I has some in}
lines = File.readlines(ARGV[0])
line_count = lines.size
text = lines.join

# Count the characters
character_count = text.length
character_count_nospaces = text.gsub(/\s+/, '').length

# Count the words, sentences, and paragraphs
word_count = text.split.length
sentence_count = text.split(/\.|\?|!/).length
paragraph_count = text.split(/\n\n/).length

# Make a list of words in the text that aren't stop words,
# count them, and work out the percentage of non-stop words
# against all words
all_words = text.scan(/\w+/)
good_words = all_words.select{ |word| !stopwords.include?(word) }
good_percentage = ((good_words.length.to_f / all_words.length.to_f) * 100).to_i

# Summarize the text by cherry picking some choice sentences
sentences = text.gsub(/\s+/, ' ').strip.split(/\.|\?|!/)
sentences_sorted = sentences.sort_by { |sentence| sentence.length }
one_third = sentences_sorted.length / 3
ideal_sentences = sentences_sorted.slice(one_third, one_third + 1)
ideal_sentences = ideal_sentences.select { |sentence| sentence =~ /is|are/ }

# Give the analysis back to the user
puts "#{line_count} lines"
puts "#{character_count} characters"
puts "#{character_count_nospaces} characters (excluding spaces)"
puts "#{word_count} words"
puts "#{sentence_count} sentences"
puts "#{paragraph_count} paragraphs"
puts "#{sentence_count / paragraph_count} sentences per paragraph (average)"
puts "#{word_count / sentence_count} words per sentence (average)"
puts "#{good_percentage}% of words are non-fluff words"
puts "Summary:\n\n" + ideal_sentences.join(". ")
puts "-- End of analysis"

XML, JSON & YAML for Dummies

What happens when we need to transmit data between two machines?

When we want to transmit data between two machines, store configuration data or save for later use, we must decide what type of file format we will use for that.  For this purpose there are predefined formats; some of the most popular formats are XML, JSON and YALM. These formats often provide libraries for creation and / or use of the files.



  • It is an extensible (eXtensible Markup Language) format. But it’s more than a format: it is a language.
  • It has a well defined structure could be checked by DTD or Schema.
  • It has a lot associated tools (CSS, DTD, XPath, Schema, …).
  • Processed by the management of the entire tree (DOM) or as lee (SAX). DOM allows more power at the expense of resources and SAX provides higher speed and lower power consumption.
  • Used in complex communication systems such as SOAP or Web Services.


  • Acronym for JavaScript Object Notation. JSON is a subset of the object literal notation JavaScript that does not require the use of XML.
  • It is a lightweight format for data exchange. Allows serialize almost any object.
  • It is a string representation of a combination of hashes, vectors and key-value pair format.
  • It has been standardized as a method of communication between methods of the same application, as part between Java and JSP from a servlet.
  • It is very suitable and simple for small structures but will tend to complicate quickly. For a small set of data is very intuitive, however the simplicity tends to diminish  when data will increase.
  • Gossip! There are a lot of information about that Twitter has removed support for XML within his API and Foursquare’s API v2 only supports JSON.


  • It can be considered the most lightweight markup language: it has a simple, easy syntax by developing human with a plain text editor
  • It is especially useful to create configuration files.
  • It’s not as language agnostic as XML.




Ipv4 vs Ipv6 for Dummies


Q: What is IP protocol?
A: The Internet Protocol (IP) is the principal communications protocol in the Internet protocol suite for relaying datagrams across network boundaries. Its routing function enables internetworking, and essentially establishes the Internet.

Q: What is main function of IP protocol?
IP, as the primary protocol in the Internet layer of the Internet protocol suite, has the task of delivering packets from the source host to the destination host solely based on the IP addresses in the packet headers. An Ip adress is assigned for each device within Internet such as

Q: What is IPv6?
A: IPv6 is the sixth revision to the Internet Protocol and the successor to IPv4. It utilizes 128-bit addresses. I’ll explain why this is important in a moment.

Q: Why are we running out of IPv4 addresses?
A: IPv4 uses 32 bits for its Internet addresses. That means it can support 2^32 IP addresses in total — around 4.29 billion.

Q: How does IPv6 solve this problem?
A: As previously stated, IPv6 utilizes 128-bit Internet addresses. Therefore, it can support 2^128 Internet addresses — 340,282,366,920,938,000,000,000,000,000,000,000,000 of them to be exact.

Q: When will be the switch completed from IPv4 to IPv6?
A: The depletion of IPv4 addresses was predicted years ago, so the switch has been in progress for the last decade. However, IPv4 stacks will probably never be switched off completely.


What is YAML? For Dummies

What is YAML?
It is a format for the exchange of information that facilitates the mapping of more complex data structures in an easy readable plain text document.

What is the meaning of YAML?
It is a recursive acronym for “YAML Ain’t Markup Language”.
What is yaml used for?
To define configuration files or other documents.

Simple structure.
Easily readable documents.

Even when you can serialized(*) objects with YALM, is slower so other formats; so JSON is used for this.

How look a YAML file?
The file structure is key-value type.
Indentation is also important to define the structure of parent-child tree.

Description: box
Color: black
Price: 14.99

(*) Serialized objects: write the structure of a string object so it can be retrieved later