Blogs

View as a Table

Ubuntu 16.04 Nginx Rails Phusion Server with RVM


Create Swap File

sudo fallocate -l 3G /swapfile
sudo chmod 600 /swapfile
sudo mkswap /swapfile
sudo swapon /swapfile
sudo swapon --show
free -h
sudo cp /etc/fstab /etc/fstab.bak;
echo '/swapfile none swap sw 0 0' | sudo tee -a /etc/fstab
sudo apt-get update

Install RVM

sudo apt-get install libgdbm-dev libncurses5-dev automake libtool bison libffi-dev
gpg --keyserver hkp://keys.gnupg.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3 7D2B...

Read Blog Post


Compressing Documents To Zip


If you have a ton of uploaded files you need to have a visitor download, you will want to compress said information to decrease size and combine many files into one single zip. We will do this using the rubyzip gem. Keep in mind that if the files are audio or video, compressing them may not have any effect on the size.

Installation

We will first add the gem to our project.

# Gemfile
gem "rubyzip"

View

= link_to 'Download Zip', route_path(format: ...

Read Blog Post


Delayed Jobs


Sometimes when you have a project, you'll want to run really long scripts and have them daemonized and running in the background. This allows your server to scale and not hang a http request and cause long latency requests on your box.

First Step

Let's install a few gems that will help us do exactly this. I chose to use delay jobs gem over sidekiq, because I felt it would be better for my usage of it. Keep in mind that active job was added in Rails 4.2, so if you are running a versi...


Read Blog Post


Learning To Use Git


Setting Up Aliases

A great place to start concatenating git commands is in your shell's rc file. I currently use Oh-My-Zsh, in which case I'd vim into it and add aliases like so.

vim ~/.zshrc

You can add in extra aliases to fit your needs, but below is just a list of the main git commands one would use most of the time.

# Insert these main aliases
alias gaa = "git add ."
alias gstat = "git status"
alias gdiff = "git diff"
alias gcm = "git commit -m"...

Read Blog Post


Install Crystal & Amber


Mac OSX


Installing Crystal

Let's install Crystal first so we have the language on our machine. Keep in mind that you can also omit --with-llvm on the installation if you do not plan to do any contributing to the Crystal Lang.

brew update
brew install crystal-lang --with-llvm

If you run in to any errors, it could be because you don't have xcode installed and using its command line tools.

xcode-select --install
xcode-select --switch /Librar...

Read Blog Post


SSH Authorized Keys


Creating The Authorized Keys

If you need to create a private and public ssh key, run the following command.

ssh-keygen -t rsa -b 4096 -C "email@example.com"

By default, AWS will give you a .pem key when you create your server. The key is automatically added into the authorized keys upon creation. If you like this way, you can keep it, but you can specify it even more if you were going to give your team access too, and wanted an easy way to remove them afterwards ...


Read Blog Post


Enable AAC and aptX Bluetooth Codecs on Mac


#1 Download Bluetooth Tools

To start, you'll need to have a developer account, click the link to download the appropriate tool to manage your codec libraries Mac Developer Tools. Search for “Additional Tools for Xcode”, the latest version is 9.0.

Extract the dmg and search for “Bluetooth Explorer.app”. Move it into your Application Folder within your Mac.

Bluetooth Explorer

Run the Bluetooth Explorer and then go to Tools -> Aud...


Read Blog Post


Facebook Omniauth Rails


Setup a Facebook Developer Account


Integrate Omniauth


Add Omniauth To Your Gemfile

# Gemfile
gem 'omniauth-facebook'

Update The User Table With New Columns

rails g migration AddOmniauthToUsers provide...

Read Blog Post


CSS Tricks


Just a list of things I've done with CSS that I'd like to keep note of for future styling. Most of these will be in SASS format.

Vertical Centering

Been running into this a lot, helped me center images in middle of the screen even when resizing it. Percentages may need to be adjusted by case scenario along with media queries.

transform: translateY(-50%)
position: absolute
top: 50%

/* OR */

display: flex
flex-direction: column
align-self: center

Dynam...


Read Blog Post


Using Docker macOS / Ubuntu 14.04 LTS


#Option 1: Installing on macOS

Let's start off by installing Docker on our Mac. Visit the docker site to download the Mac application.

Creating an Image

Then we will need to create a directory in which to start building our image.

cd ~ && mkdir first-docker-image

After creating your directory, let's create an image in which we can create our own container. We will first start off by cre...


Read Blog Post