Skip to content

Instantly share code, notes, and snippets.

Darren Terhune darrenterhune

Block or report user

Report or block darrenterhune

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
darrenterhune /
Last active Apr 14, 2016
Digital Ocean [Virtual Hosts, MySQL] Setup

Setup Virtual Hosts

Execute the following commands after ssh into vps:

sudo mkdir -p /var/www/
sudo chown -R $USER:$USER /var/www/
cd /var/www/
sudo chown www-data:www-data * -R 
sudo usermod -a -G www-data username-logged-in-as
darrenterhune / rails_status_codes.rb
Created Jan 24, 2017
List of rails status codes
View rails_status_codes.rb
100 = :continue
101 = :switching_protocols
102 = :processing
200 = :ok
201 = :created
202 = :accepted
203 = :non_authoritative_information
204 = :no_content
205 = :reset_content
206 = :partial_content
View datica_rails_app.rb
# routes.rb (checks if subdomains is present in the request object then sends it off to the correct location)
Rails.application.routes.draw do
constraints MicrositeConstraint do
root to: 'microsites#index', as: 'microsite_root'
class MicrositeConstraint
def self.matches?(request)
taken = %w(
View capybara_cheetsheet.rb
within(*find_args) # within('div#delivery-address') do
within(a_node) # fill_in('Street', with: '12 Main Street')
# end
have_select(locator, options = {}) # expect(page).to have_select('id', options: ['Yes', 'No'])
# expect(page).to have_select('id', options: [1,2,3], selected: 2)
have_field(locator, options = {}) # expect(page).to have_field('id', placeholder: 'What city do you live in?')
# expect(page).to have_field('id', with: 'Some value', visible: false)
View reset mysql root user password
# Found from
# Stop MySQL
sudo service mysql stop
# Make MySQL service directory.
sudo mkdir /var/run/mysqld
# Give MySQL user permission to write to the service directory.
sudo chown mysql: /var/run/mysqld
# Start MySQL manually, without permission checks or networking.
sudo mysqld_safe --skip-grant-tables --skip-networking &
View failure.rb
# frozen_string_literal: true
require 'rails_helper'
feature 'Updating Admin Clinics feature' do
let(:admin) { create(:admin) }
let!(:clinic) { create(:clinic) }
before do
login_as(admin, scope: :user)
darrenterhune / passwordless_ssh.zsh
Last active Jan 17, 2018
Dreamhost passwordless login
View passwordless_ssh.zsh
scp ~/.ssh/
mkdir .ssh
cat >> .ssh/authorized_keys
chmod go-w ~
chmod 700 ~/.ssh
chmod 600 ~/.ssh/authorized_keys
darrenterhune / wordpress_wp_config.php
Last active Jan 27, 2018
Wordpress wp-config.php settings
View wordpress_wp_config.php
$table_prefix = 'wp_RANDOMUUID-HERE';
define('WP_AUTO_UPDATE_CORE', true);
define('WP_POST_REVISIONS', false);
define('FORCE_SSL_ADMIN', true);
darrenterhune /
Last active Jul 11, 2018
Installing rails without the initial gem install rails

Installing Rails w/o gem install

mkdir -p ~/Sites/myapp
cd ~/Sites/myapp
echo 2.4.2 > .ruby-version
rbenv install 2.4.2
bundler init
echo "source ''" > Gemfile
echo "ruby '2.4.2'" >> Gemfile
darrenterhune / quote_csv.rb
Created Oct 11, 2018
Add quotes to a csv file directly in the terminal
View quote_csv.rb
# Run this in terminal, then paste in csv into terminal window
ruby -rcsv -ne 'puts CSV.generate_line(CSV.parse_line($_), :force_quotes=>true)'
You can’t perform that action at this time.