Skip to content

Instantly share code, notes, and snippets.

rianrainey / external_file.js
Last active Dec 22, 2015
Open external links in a new window.
View external_file.js
$("a").each(function() {
var a;
a = new RegExp("/" + + "/");
if (!a.test(this.href)) {
return $(this).click(function(event) {
return, "_blank");
rianrainey / unix.t
Created Aug 5, 2013
Replace all PHP files will new text
View unix.t
find . -name '*.php' -exec sed -i "" 's/Old_Text/New_Text/g' "{}" \;
rianrainey / create-wordpress-admin.sql
Last active Dec 19, 2015
Add an admin user to your Wordpress installation via MYSQL statements.
View create-wordpress-admin.sql
-- Create a new user into the db
INSERT INTO `wp_users` (`ID`, `user_login`, `user_pass`, `user_nicename`, `user_email`, `user_registered`, `user_activation_key`, `user_status`, `display_name`)
VALUES ('99', 'admin', MD5('admin'), 'Rian Rainey', '', '2013-07-07 00:00:00', '', '0', 'Rian Rainey')
-- Give the new user administrator capabilities
INSERT INTO `wp_usermeta` (`umeta_id`, `user_id`, `meta_key`, `meta_value`)
VALUES (NULL, '99', 'wp_capabilities', 'a:1:{s:13:"administrator";s:1:"1";}')
-- Give the new user the highest level in the system
INSERT INTO `wp_usermeta` (`umeta_id`, `user_id`, `meta_key`, `meta_value`)
rianrainey / admin_page_shared_examples.rb
Created Jun 12, 2013
Rspec Shared Examples with Rails URL Helper
View admin_page_shared_examples.rb
shared_examples_for "an admin index page" do
it "has an admin navigation bar" do
page.has_selector?("nav.navbar").should be_true
it "has a User Management link in the navigation bar" do
page.has_content?("User Management").should be_true
it "has an h1 title tag" do
page.has_selector?("h1").should be_true
rianrainey / link_to.html.erb
Created Jun 5, 2013
Rails link_to helper block
View link_to.html.erb
View Lampo-Rspec-Expect-Change.rb
context "when a valid form is submitted" do
before do
3.times do |s|
FactoryGirl.create(:specialty, urn: "urn-num-#{s}")
it "adds specialties to an organization" do
visit edit_organization_path(organization)
specialty_first = Specialty.first
rianrainey / gist:5602337
Last active Dec 17, 2015
Corewellness FactoryGirl setup.
View gist:5602337
# Read about factories at
FactoryGirl.define do
factory :user do
factory :facilitator, class: Facilitator do
sequence(:email) { |n| "facilitator#{n}" }
password "leezlepon"
password_confirmation "leezlepon"
contact_uri "asdfjkl;"
View gist:5601663
# Read about factories at
FactoryGirl.define do
factory :user do
email: ""
factory :facilitator, :class => Facilitator do
sequence(:email) { |n| "facilitator#{n}" }
after(:build) { |pm| = }
before(:create) { |pm| = FactoryGirl.create(:property_management_company) }
rianrainey / .wprouter.php
Created May 9, 2013
Run Wordpress using PHP 5.4's built-in server. This is an attempt to get routing working with Wordpress using PHP 5.4. It works for the non-admin pages. I'm still working on getting it working for Admin pages. It just doesn't reference the CSS properly.
View .wprouter.php
$path = '/'.ltrim(parse_url($_SERVER['REQUEST_URI'])['path'],'/');
if(is_dir($root.$path) && substr($path,strlen($path) - 1, 1) !== '/')
$path = rtrim($path,'/').'/index.php';
rianrainey / Heroku Master Command
Created Mar 28, 2013
How to push a different branch to Heroku as Master because Heroku prefers branches that are master.
View Heroku Master Command
git push heroku yourbranch:master