All posts by Juan Lebrijo

Boostrap AngularJS project with Yeoman

First take a look to this post making a basic NodeJS installation on Ubuntu. You will need npm and bower installed.

Installing Yeoman

Install all tools needed:

npm install -g grunt grunt-cli yo generator-karma generator-angular

Create Angular project

cd myapp
yo angular myapp
gem install compass
bower install grunt-svgmin grunt-contrib-jshint -S
grunt serve

WebStorm

Download it from Jetbrains-Webstorm site.

tar xvf WebStorm-9.0.3.tar.gz

How to Get Google to properly Index your Rails website

In order to be properly indexed by Google (and other search engines), we need to fix three basic values in the header: title, description and keywords. So in header layout we should include them as meta tags:

%title= content_for?(:title) ? yield(:title) : "Lebrijo.com - Internet applications Consultancy"
 %meta{content: content_for?(:description) ? yield(:description) : "We build high quality Internet application for our customers", name: "description"}
 %meta{content: content_for?(:keywords) ? yield(:keywords) : "ruby, ruby on rails, consultancy, webapps, developers", name: "keywords"}

Another useful thing is creating a /sitemap.xml file where Engine-bots see your app structure. We can use the sitemap_generator gem, just including it in our Gemfile.

I have created a rake task for auto generating it:

desc "Generates sitemap"
  namespace :sitemap do
  task :generate do
  SitemapGenerator::Sitemap.default_host = 'http://www.lebrijo.com'
  SitemapGenerator::Sitemap.create do
    add '/', changefreq: 'daily', priority: 0.9
    add '/', changefreq: 'daily', host: 'http://blog.lebrijo.com', priority: 0.8
    add '/', changefreq: 'weekly', host: 'http://jenkins.lebrijo.com'
    add '/about', changefreq: 'weekly'
    add '/contact', changefreq: 'weekly'
  end
  SitemapGenerator::Sitemap.ping_search_engines
  end
end

And a Capistrano task, auto-generating sitemap on all deployments:

namespace :sitemap do
  desc "Generate sitemap.xml"
  task :generate do
    on roles(:app) do
      within release_path do
        with rails_env: fetch(:stage) do
          execute :rake, 'sitemap:generate'
        end
      end
    end
  end
after "deploy:published", :generate
end

Finally be careful with your ‘robots.txt’ file configuration, because Google should be allowed to download and crawl your page.

Once everything is done and deployed in your application, just add it to Google WebMaster Tools. Don’t forget to add your sitemap.xml.gz URL.

Here you have a great link enumerating what other things you can do to improve your website SEO features.

How to create our web SSL Certificate

Self-signed SSL certificate

In my workday sometimes I had have to create a self-signed SSL certificate (.key and .crt files) to publish a website through Apache or Nginx. I will explain the process in three simple steps:

  • Generate private key without password
openssl genrsa 1024 > web.key
  • Generate a CSR (Certificate Signing Request), this contains all our data to be populated with our certificate:
openssl req -new -key web.key -out web.csr
  • Now we can generate our Self-Signed Certificate valid for 10,000 days:
openssl req -x509 -days 10000 -key web.key -in web.csr -out web.crt

StartSSL certificate

StartSSL.com gives free certificates for subdomains (not wilcard certificates). And is a well known “Certificate Authority” for all common browsers.

You have to sign up at StartSSL.com who will send you a .p12 certificate to authenticate you from your browser, when you log in.

To create a Private Key Certificate go to Certificates wizard > Web Server SSL/TLS certificate, and ask for it.

You will download your ‘server.key’ file for your domain with password. In order to remove server.key password (need that to publish on web):

sudo cp server.key server.key.org
sudo openssl rsa -in server.key.org -out server.key

Name it as “sudomain.myserver.key”

Hours later you can get .crt file at: Toolbox > Retrieve Certificate

In order to run in all browsers you have to add the Intermediate StartSSL Cert at the end of your .crt file. You can get this .pem at: Toolbox > StartCom CA Certificates > Class 1 Intermediate Server CA

Name it as “sudomain.myserver.crt”