Skip to content

Instantly share code, notes, and snippets.

View darrenterhune's full-sized avatar

Darren Terhune darrenterhune

  • Canada
View GitHub Profile
@darrenterhune
darrenterhune / wordpress_wp_config.php
Last active January 27, 2018 00:53
Wordpress wp-config.php settings
$table_prefix = 'wp_RANDOMUUID-HERE';
define('WP_AUTO_UPDATE_CORE', true);
define('WP_POST_REVISIONS', false);
define('FORCE_SSL_ADMIN', true);
# 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'
end
end
class MicrositeConstraint
def self.matches?(request)
taken = %w(
@darrenterhune
darrenterhune / capybara_cheetsheet.rb
Last active July 10, 2017 18:21
Capybara cheetsheet
# SCOPING
within(*find_args) # within('div#delivery-address') do
within(a_node) # fill_in('Street', with: '12 Main Street')
# end
# MATCHERS
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)
@darrenterhune
darrenterhune / rails_status_codes.rb
Created January 24, 2017 01:40
List of rails status codes
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
@darrenterhune
darrenterhune / redis.sh
Last active August 29, 2015 14:16
Redis install
# redis install
sudo apt-get install tcl8.5
wget http://download.redis.io/redis-stable.tar.gz
tar xvzf redis-stable.tar.gz
cd redis-stable/
make
make test
sudo make install
sudo mkdir /etc/redis
@darrenterhune
darrenterhune / search-widget.html
Last active August 29, 2015 14:05
ASAP Search Widget (NEW)
<!-- START aircraftsalesandparts.com 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="https://aircraftsalesandparts.com/parts/search" method="get" target="_blank"><input id="search" name="search" type="text" /><input type="hidden" name="submit" value="
@darrenterhune
darrenterhune / heartbleed.sh
Created April 9, 2014 19:24
openssl heartbleed update
# Update the system and packages
sudo apt-get update
sudo apt-get dist-upgrade
# Restart server
sudo shutdown -r now
# Check openssl is upgraded against versions below
dpkg -l | grep "openssl"
@darrenterhune
darrenterhune / finder.rb
Last active August 29, 2015 13:57
Find all users unless has_many matches a specific date
User
has_many :bookings
| id | name |
---------------
| 1 | amy |
| 2 | jack |
@darrenterhune
darrenterhune / nokogiri.sh
Last active August 29, 2015 13:55
Nokogiri Mac OS X Mavericks
gem install nokogiri -- --with-xml2-include=/usr/local/Cellar/libxml2/2.9.1/include/libxml2 --with-xml2-lib=/usr/local/Cellar/libxml2/2.9.1/lib --with-xslt-dir=/usr/local/Cellar/libxslt/1.1.28
@darrenterhune
darrenterhune / digitalocean.md
Last active April 14, 2016 00:43
Digital Ocean [Virtual Hosts, MySQL] Setup

Setup Virtual Hosts

Execute the following commands after ssh into vps:

sudo mkdir -p /var/www/example.com
sudo chown -R $USER:$USER /var/www/example.com
cd /var/www/
sudo chown www-data:www-data * -R 
sudo usermod -a -G www-data username-logged-in-as
cd