Batch clean up of local git branches

Standard

I usually add  an alias in my .zshrc file so that I can run a single command to clean up feature branches that are merged into master or develop.

But if you run:

This will remove all branches that are merged into master or develop.

How to speed up bundle install on a Mac

Standard

Most new laptops/computers come with multiple cores standard.

So assuming you do have a system with multiple cores why not use them.

* This might work on any *nix system just find the appropriate commands.

Setup Jenkins and BitBucket without plugins

Standard

This was pretty straight forward since BitBucket has hooks ready for Jenkins.

I usually create 2 Jenkins projects, 1 to build and 1 to deploy.

Jenkins Server

Make sure you have a Jenkins user that can Read Overall and Read Job. I use “Project-based Matrix Authorization Strategy” you can find that under “Configure Global Security”

So I have a user called automated-user and it has Read Overall and Read Job checked. It also has an API Token you will need that you will find here: Jenkins >> Manage Jenkins >> Manage Users >> Select your user, in my case ‘automated-user’ >> Configure >> “Show API Token”. I get eadefe23232121232sdasdfadf as an example.

Build Project

Give the project a name: project-name-build
Source Code Management: Select “Git Repositories” >> Repository URL = https://username@bitbucket.org/username/git-repo.git >> Add credentials & Select it.
Build Triggers: Check, “Trigger builds remotely (e.g., from scripts)” >> Authenticated Token, enter a token SecureRandom.urlsafe_base64 works well for this. Lets say we got this: wtOhS3d4TV1MRX_bVn_lAA

Deploy Project

Source Code Management: Select “Git Repositories” >> Repository URL = https://username@bitbucket.org/username/git-repo.git >> Add credentials & Select it.
Build Triggers: Check, “Build after other projects are built”

BitBucket

Go to: Your Repo >> Settings >> Hooks >> Select Jenkins

Enter: 
Endpoint: http://automated-user:eadefe23232121232sdasdfadf@ci-server-address.com
Project Name: project-name-build
Token: wtOhS3d4TV1MRX_bVn_lAA

Save.

You should be good to go minus some settings you’ll need to configure based on your needs.

Creating a new rails app

Standard

How to create a new project without test unit and with postgresql database

 

My grep commands

Standard

When I search for things in my codebase I find that using the terminal and grep is usually the best option. Here is what I usually run:

 

Learn how to use top command in linux

Standard

I find myself using this often while debugging errors or trying to figure why a server is slow or unresponsive.

 

Vagrant Boxes / VMWare Fusion / CentOS 7

Standard

Use one found here: http://www.vagrantbox.es you can use one of those to build upon or you can create one.

These steps are if you want to to create a fresh box.
Grab the latest CentOS image here:
http://www.centos.org/download/

I use the minimal image http://ftp.usf.edu/pub/centos/7.0.1406/isos/x86_64/CentOS-7.0-1406-x86_64-Minimal.iso

First you need to create a VM using Fusion.

  1. Select “Install from disc or image” >> Continue
  2. “Use another disc or disc image” >> Find your iso >> Continue
  3. Uncheck “Use Easy Install” make sure “Make your home folder accessible to the virtual machine is unchecked. >> Continue
  4. Click “Customize Settings” >> Rename your vm and place it somewhere safe.

Continue reading

Nginx / Comodo PositiveSSL / CentOS 7

Standard

1. Before you purchase your SSL

Before any purchase of an SSL you’ll need a key file and a csr (Certificate Signing Request).

The certificate registrar is going to ask for the contents of your csr file, just cut and paste whats inside the file into the webform. Make sure you register with the domain name you plan on using. Purchase your SSL, they’ll send your administrator an email validate that. Then wait for an email from Comodo with a zip file.

Within this zip file you’ll receive 4 files:

  • AddTrustExternalCARoot.crt – Root Cert
  • COMODORSAAddTrustCA.crt – Intermediate Cert
  • COMODORSADomainValidationSecureServerCA.crt – Intermediate Cert
  • server_name.crt – Your Positive Cert

2. Prep for installing SSL Cert

3. Installing the SSL Certificate

Now to configure Nginx.

4. Restart Nginx

To test your ssl: https://www.ssllabs.com/ssltest/