Skip to content

Instantly share code, notes, and snippets.


Darren Terhune darrenterhune

View GitHub Profile
darrenterhune / search-widget.html
Last active Aug 29, 2015
ASAP Search Widget (NEW)
View search-widget.html
<!-- START widget -->
<style type="text/css" media="screen">
#asap.asap-widget{margin:20px 0;}#asap.asap-widget .title{background:#ddd;color:#666;text-shadow:1px 1px 0 #eee;top:-1px;border:1px solid #C2C2C2;padding:10px;margin:0;}#asap.asap-widget .link{padding:5px;background:#333;color:#eee;}#asap.asap-widget table{display:block;border:1px solid #D8D8D8;border-bottom:none;}#asap.asap-widget table tr{padding:5px;}#asap.asap-widget table th{text-align:left;padding:5px;color:#333;}#asap.asap-widget table td{padding:10px;}#asap.asap-widget table td.title{width:200px;font-weight:bold;color:#777;}#asap.asap-widget table form input.submit{margin-left:4px;}</style>
<div id="asap" class="asap-widget"><div class="recent-widget"><h3 class="title"><span>Find Aircraft Parts</span></h3><div class="items"><table><tr><td><form action="" method="get" target="_blank"><input id="search" name="search" type="text" /><input type="hidden" name="submit" value="
darrenterhune /
Last active Aug 29, 2015
Redis install
# redis install
sudo apt-get install tcl8.5
tar xvzf redis-stable.tar.gz
cd redis-stable/
make test
sudo make install
sudo mkdir /etc/redis
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 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 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(
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);
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 / active_admin_export_worker.rb
Last active Jul 20, 2020
Simple activeadmin export full table csv using a sidekiq background worker
View active_admin_export_worker.rb
# app/workers/active_admin_export_worker.rb
class ActiveAdminExportWorker
include Sidekiq::Worker
sidekiq_options queue: 'high'
def perform(options = {})
model = options[:model_name].classify.constantize
path = "#{Rails.root.to_s}/tmp/#{filename(options[:name])}"
columns = model.send(:column_names)
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
You can’t perform that action at this time.