Skip to content

Instantly share code, notes, and snippets.


Terry S itsterry

View GitHub Profile
itsterry /
Created Aug 22, 2019
Installs latest MySQL Server 5.7 version from MySQL PPA.
# Description: Installs latest MySQL Server 5.7 version from MySQL PPA.
# Runs on: All platforms
# Usage:
# Add the following command to the setup of a build in the Project Settings
function prepare-data-dir(){
echo "* Preparring data directory"
sudo mkdir $data_dir
sudo chown mysql:mysql $data_dir
itsterry / gist:e8e7e3c950ff9b7da479016cd64918a8
Created Oct 13, 2016
Vim command to turn RSpec controller actions into new 'process' format
View gist:e8e7e3c950ff9b7da479016cd64918a8
# Only works with leading spaces (not tabs) and with existing params
# So get :edit, id: 1 # will work
# But get :edit # won't
%s/\(^ *\)\(get\|post\|patch\|delete\) \(:[^,]*\), \(.*$\)/\1process \3, via: :\2, params: { \4 }/ge
itsterry / pre-commit.rb
Created Oct 1, 2015 — forked from vindia/pre-commit.rb
Git pre-commit hook to block committing Spec files with :focus => true on test blocks and .orig files from merge conflicts
View pre-commit.rb
#!/usr/bin/env ruby
orig_hits = []
spec_hits = []
# In Mountion Lion Apple uses BSD grep with REG_ENHANCED enabled,
# so all regular regex special chars like ?, | and + need to be
# escaped...
def grep_focus
if `grep --v`.match /BSD/
itsterry / gist:8938168
Created Feb 11, 2014
View gist:8938168
module Terrys_rspec_helpers
def boolean_default_false(method)
it "should default to false" do
expect(new_thing.send(method)).to be_false
itsterry / gist:8938002
Created Feb 11, 2014
Default spec_helper.rb
View gist:8938002
require "spork"
Spork.prefork do
ENV["RAILS_ENV"] ||= 'test'
require File.expand_path("../../config/environment", __FILE__)
require 'rspec/rails'
require 'email_spec'
require 'rspec/autorun'
require 'factory_girl'
itsterry / gist:8935468
Created Feb 11, 2014
Default Gemfile as of Feb 11, 2014
View gist:8935468
source ''
# ALPHABETICAL ORDER, please, to avoid duplication.
# gem 'gemname', [require: false, ], [group: [:if_necessary]]
# comment out anything not being used yet. Even if it'll be used later
gem 'airbrake'
gem 'ancestry' #rails g migration add_ancestry_to_things ancestry:string
gem 'autotest-rails', group: [:development,:test]
itsterry / gist:8935308
Created Feb 11, 2014
Stuff we add to the bottom of .gitignore to cope with the team's differing IDEs etc
View gist:8935308
#ignore vim temp files
# mac-specific
itsterry / gist:6508969
Created Sep 10, 2013
How we like to put image upload on the page at the moment
View gist:6508969
=simple_form_for event do |f|
=f.input :asset_attachment, :as=>:file,:label=>"Image"
=f.input :asset_attachment_remove, :as=>:boolean, :label=>'Remove' if event.asset
=f.input :asset_attachment_title,:label=>"Image Description", :input_html => {:value=>(event.asset ? event.asset.title : "")}
View Protected
#turn an email address into a javascript-built email link, to frustrate email harvest bots
def protected_email_link(e=nil)
if e.present?
content_tag(:script,type:"text/javascript") do
"document.write('<a href=\"mailto:' + emailE + '\">'+ emailE + '</a>');")
You can’t perform that action at this time.