Skip to content

Instantly share code, notes, and snippets.

@itsterry
itsterry / mysql-57-ppa.sh
Created August 22, 2019 15:29
Installs latest MySQL Server 5.7 version from MySQL PPA.
#!/bin/bash
####
# 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
#
#!/bin/bash
data_dir="/usr/data"
function prepare-data-dir(){
echo "* Preparring data directory"
sudo mkdir $data_dir
sudo chown mysql:mysql $data_dir
}
@itsterry
itsterry / gist:e8e7e3c950ff9b7da479016cd64918a8
Created October 13, 2016 12:27
Vim command to turn RSpec controller actions into new 'process' format
# 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
itsterry / gist:6508969
Created September 10, 2013 12:53
How we like to put image upload on the page at the moment
=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
=nice_asset(event.asset,:thumb95x95)
=f.input :asset_attachment_title,:label=>"Image Description", :input_html => {:value=>(event.asset ? event.asset.title : "")}
#turn an email address into a javascript-built email link, to frustrate email harvest bots
def protected_email_link(e=nil)
if e.present?
name,domain=e.split('@')
content_tag(:script,type:"text/javascript") do
raw("emailE=('#{name}'+'@'+'#{domain}');"+
"document.write('<a href=\"mailto:' + emailE + '\">'+ emailE + '</a>');")
end
end
end
@itsterry
itsterry / pre-commit.rb
Created October 1, 2015 22:59 — 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
#!/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
itsterry / active_admin_page_title_patch.rb
Created December 16, 2011 22:27
Customize page title on active admin index pages
module ActiveAdmin
module Views
module Pages
class Index < Base
def title
if config[:page_title].blank?
active_admin_config.plural_resource_name
else
config[:page_title]
end
@itsterry
itsterry / gist:8938168
Created February 11, 2014 16:21
Terrys_rspec_helpers.rb
module Terrys_rspec_helpers
def boolean_default_false(method)
exists(method)
it "should default to false" do
new_thing=@instance.class.new
expect(new_thing.send(method)).to be_false
end
end
@itsterry
itsterry / gist:8938002
Created February 11, 2014 16:13
Default spec_helper.rb
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
itsterry / gist:8935468
Created February 11, 2014 14:08
Default Gemfile as of Feb 11, 2014
source 'https://rubygems.org'
# 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]