Categories
certbot letsencrypt OS

Generating a PFX cert with certbot and openssl

That was a long title. Now, down to business. I ran these commands on macOS so they may vary a bit if you’re on another OS. After installing certbot, go ahead and generate a new cert using: certbot certonly –manual –preferred-challenges dns –email administrator@domain.com –domains domain.com This will give you a DNS challenge which basically […]

Categories
API Gateway AWS CloudFormation CodeBuild CodePipeline Lambda S3

CI/CD for static assets and Lambda function

This Gist is based on Building a continuous delivery pipeline for a Lambda application with AWS CodePipeline. What happened? Needed to build a NodeJS project, upload the static assets to an S3 bucket and also deploy a small Lambda function that lived in a subfolder. Prerequisites The AWS Guide above will get you familiarized with […]

Categories
AWS CloudFront Databases EC2 PostgreSQL RDS

Lower your AWS bill

First step: hire me. Done. Joking aside (or maybe not), there are some obvious things to do like: purchasing reserved instances, using scheduled instances or even spot instances. And some that are not so obvious like right-sizing your instances (EC2 and RDS) or asking for discounted pricing when it comes to CloudFront. RDS First step […]

Categories
certbot Heroku letsencrypt

Generate SSL cert for Heroku app on your local machine

So, the problem was that we needed to add multiple domains (and their corresponding SSL cert) to a single Heroku app, they provide a guide at the bottom: https://help.heroku.com/8P5TVA4T/how-can-i-configure-multiple-ssl-certificates-for-a-single-app But won’t provide you with the steps to generate it. You first need to install certbot on your local machine, I’m on macOS so Homebrew is highly […]

Categories
AWS Databases EC2 MySQL Wordpress

From Hostgator shared hosting to AWS EC2 using Bitnami’s WordPress AMI

I needed to move two WordPress sites from a Hostgator shared hosting account to AWS EC2 for two simple reasons: website performance and SSL certificates. There are several WP plugins to ease the transfer but the main problem is that the entire website + database is almost 1GB in size so I have to do […]

Categories
Databases PostgreSQL Rails Ruby

Change column type from boolean to integer

Background I had an ActiveRecord Class Message with a read column of type boolean. This column was used, you guessed it, to know if the message had been read by the recipient. Initially this column was of type boolean because it was a simple true/false case but as I continued working on the project and extending the functionality […]

Categories
Databases MySQL

Remove leading and trailing spaces from a string in MySQL

It might be frustrating when trying to query for a record that, without knowing, has a leading or trailing space on a string column. Lets say that you have a User record with ‘ email@example.com ‘ as email attribute, one easy way to find this record is using the TRIM string function in MySQL: SELECT * FROM […]

Categories
Rails Ruby

Tableless model with associations in Rails 3.2

While upgrading a Rails 2.3.4 app to version 3.2 I came across a tableless model that had associations, in version 2.3.4 this works: See the gist on github. But in Rails 3.2 it doesn’t work anymore because it complains about the missing table, after trying several changes I was able to get it working with just one […]

Categories
OS

View file changes on each commit on Git

Recently I needed to view the changes made to a specific file on git, this pretty awesome command will list the changes made on each commit since the beginning of time…even if the file was renamed (I think so): git log –follow -p filename

Categories
OS

How to install Homebrew – Mac OS X

Before installing Homebrew you need a compiler, for this, first check this post: How to install Xcode 4.3.2 with Command Line Tools – Mac OS X And then simply run this in terminal: /usr/bin/ruby -e “$(/usr/bin/curl -fksSL https://raw.github.com/mxcl/homebrew/master/Library/Contributions/install_homebrew.rb)”