Ruby on Rails / How to change controller name

Things to take care of when changing controller name
  • Controller name and optionally directory name
  • Controller class name in class XxxController < ApplicationController
  • Associated routes in routes.rb
  • *_path and *_url URL helper instances

SSL / How to generate a CSR, in simple steps

What is CSR, in short


A certificate signing request or CSR is a piece of text that must be generated on your web server as a prerequisite for ordering the SSL certificate. A CSR consists of the public key of a key pair and some additional information. Both of these components are used by certificate authority when it is being signed by them.


Preparation


OpenSSL
OpenSSL is an open-source tool that provides an extensive set of cryptographic functions. In order to check if it is already installed, run the following command:

❯ openssl version
OpenSSL 0.9.8zh 14 Jan 2016

This software has to be installed in order to continue.


Let's get started


1. Create a private key (and store it in a cool, dry and secure place)
Use the following genrsa command to generate a private key:

❯ openssl genrsa -out private_key.pem 2048

2. Create a CSR using the following command

❯ openssl req -sha256 -new -key private_key.pem -out new_csr.pem

The command will ask you for some information (used by CA later):

Country Name
The two-letter ISO code for your country. All coutry codes are available in Online Browsing Platform (OBP) from ISO: https://www.iso.org/obp/ui/#search

State or Province Name
The full name of the state or province where your organization is located. Do not use an abbreviation.

Locality Name
The name of the city where your organization is located.

Organization Name
The full legal name of your organization.

Common Name
The fully-qualified domain name for your CNAME. This name must be an exact match. For example, www.mycompany.com or mycompany.com.

Email Address
The server administrator's email address.

3. Apply for an SSL certificate to one of the various CA using the just generated CSR 
(REISUB does not recommend any specific CA).

4. Register your website with a SSL reminder service in order to be in time for certificate renewal
Forgetting about or missing the date your certificate expires may lead to particularly unpleasant consequences for a website and the business behind it. 
SSLreminder.pro has a simple interface and is on time reminding to extend the certificate.



It is also possible to generate a self-signed certificate. It should only be used for testing purposes as it will not be trusted by modern web browsers:

Ruby on Rails / Test pride

In order to make your test output a little bit more interesting, use the --pride option within TESTOPTS:

TESTOPTS='--pride'

and here's what it does:









Rails testing / How to use assert_equal on arrays

The answer is simple: don't.
Instead use assert_same_elements from gem shoulda. Details below.

Imagine you have a test like this:

and a fixture file that looks like the following:

AWS / A Flask-based serverless Python Framework

Serverless computing is one of the most talked-about subjects among AWS customers. The AWS serverless offerings, AWS Lambda and Amazon API Gateway, make it possible for developers to create and run API applications with built-in, virtually unlimited scalability without managing any servers. Today the AWS Developer Tools team is excited to announce the preview of the Python Serverless Microframework for AWS.
This three-minute video shows how quickly you can start building serverless APIs using the framework and its command-line tool, chalice.


In just 45 seconds, I created a new Hello World project, inspected its code file (app.py), deployed it to a public API endpoint, and using curl, made a successful HTTP GET request to the endpoint. Because our goal is to minimize the time it takes to get started, we hope you’ll enjoy the simple and fast experience offered by the new microframework.
In the next minute of the video, I added a new API feature to the app.py file, redeployed the API, and then verified that it works as expected.
If you’ve noticed the programming model feels familiar, that’s because it’s based on the one used by Flask, a popular Python microframework praised by the Python community for its simplicity and ease of use. We believe adopting a similarly succinct and intuitive style will help Python developers build serverless APIs as quickly as possible.