Skip to content

Instantly share code, notes, and snippets.

@damjack
damjack / .bash_aliases
Last active June 28, 2018 15:52
Bash Profile and Aliases
# for colors
export CLICOLOR=1
export LSCOLORS=ExFxCxDxBxegedabagacad
# grep colors
# export GREP_OPTIONS="--color=auto"
# alias command
alias grep="ggrep"
alias g="git"
@damjack
damjack / Dockerfile
Created April 17, 2018 12:51
Docker for middleman
FROM ubuntu:latest
RUN apt-get update && apt-get install -y locales && rm -rf /var/lib/apt/lists/* \
&& localedef -i en_US -c -f UTF-8 -A /usr/share/locale/locale.alias en_US.UTF-8
ENV LANG en_US.utf8
EXPOSE 4567
ENV HOME /root
RUN apt-get -y update && \
@damjack
damjack / activestorage.md
Created April 24, 2018 06:49
Active Storage configuration

Rails Active Storage: Uploading files to Amazon S3

setup

add gem into Gemfile:

gem "rails", ">= 5.2.0.rc2"

install new gem with:

@damjack
damjack / psql-ssh-tunnel.md
Created May 25, 2018 21:51 — forked from noteed/psql-ssh-tunnel.md
SSH tunnel for PostgreSQL connection

SSH tunnel for PostgreSQL connection

Create a .pgpass file that will be used to provide the password for any libpq-based program for the matching hostname/port/database/user. That file should be chmod'd 0600.

> cat .pgpass
127.0.0.1:5433:database:user:password

Create a SSH tunnel: we open the local port 5433 and, out of the tunnel, go to localhost:5432. You probably really want localhost and not remote: your PostgreSQL database is probably accepting connections only from locahost.

> ssh -N -L 5433:localhost:5432 user@remote

@damjack
damjack / 1rails-rbenv.md
Last active June 28, 2018 21:54
Start with Rails on Mac OS

Install Ruby with rbenv on Mac OS

To make this better, we are going install a new, custom Ruby. This used to be a big, scary thing, but thanks to the awesome tools Homebrew and rbenv, it's a snap.*

A word of warning: you will have to use Terminal to install this stuff. If you are uncomfortable with text, words, and doing stuff with your computer beyond pointing and hoping, this may not work well for you. But if that's the case, I'm not sure why you were trying to use Ruby in the first place.

First, install Homebrew

Homebrew (or just brew, since that's the name of the command you'll use), is a package manager for Mac OS. It make installing all sorts of cool tools easy.

" We're running Vim, not Vi!
execute pathogen#infect()
" Enable syntax highlighting
syntax on
" Enable filetype detection
filetype on
" Enable filetype-specific indenting
filetype indent on
" Enable filetype-specific plugins
filetype plugin indent on
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>ANSIBlackColor</key>
<data>
YnBsaXN0MDDUAQIDBAUGKyxYJHZlcnNpb25YJG9iamVjdHNZJGFyY2hpdmVyVCR0b3AS
AAGGoKcHCBMZHSQoVSRudWxs1QkKCwwNDg8QERJcTlNDb21wb25lbnRzVU5TUkdCXE5T
Q29sb3JTcGFjZV8QEk5TQ3VzdG9tQ29sb3JTcGFjZVYkY2xhc3NPECgwLjE1Njg2OTg4
ODMgMC4xNzI0OTg3MzI4IDAuMjAzODUxNTgwNiAxTxAnMC4xMTc4NDk5NjA5IDAuMTI4

Pry Cheat Sheet

Command Line

  • pry -r ./config/app_init_file.rb - load your app into a pry session (look at the file loaded by config.ru)
  • pry -r ./config/environment.rb - load your rails into a pry session

Debugger

@damjack
damjack / gist:816a30c0ec46662690750d2733893ae4
Created August 28, 2018 10:38 — forked from hpjaj/gist:ef5ba70a938a963332d0
RSpec - List of available Expectation Matchers - from Lynda.com course 'RSpec Testing Framework with Ruby'
## From Lynda.com course 'RSpec Testing Framework with Ruby'
describe 'Expectation Matchers' do
describe 'equivalence matchers' do
it 'will match loose equality with #eq' do
a = "2 cats"
b = "2 cats"
expect(a).to eq(b)
@damjack
damjack / update-forcked-github.md
Last active January 18, 2019 12:00
Update a GitHub forked repository

Add the remote, call it "upstream":

git remote add upstream https://github.com/whoever/whatever.git

Fetch all the branches of that remote into remote-tracking branches, such as upstream/master:

git fetch upstream

Make sure that you're on your master branch: