Skip to content

Instantly share code, notes, and snippets.

View johnmeehan's full-sized avatar
:octocat:

John Meehan johnmeehan

:octocat:
  • Meetyl
  • Ireland
View GitHub Profile
@johnmeehan
johnmeehan / ubunutu_setup.sh
Last active March 16, 2016 13:04
Setup a clean ubuntu install
#!/bin/sh
# John Meehan 9/3/2016
# Setup a clean ubuntu install
# run with . <filename>.sh
# Get password to be used with sudo commands
# Script still requires password entry during rvm and heroku installs
echo -n "Enter password to be used for sudo commands:"
read -s password
@johnmeehan
johnmeehan / git_source_tree.sh
Created March 11, 2016 13:28
Git source tree
git log --graph --oneline --decorate
@johnmeehan
johnmeehan / atom-setup.rb
Last active March 14, 2016 21:08
Atom packages setup
# Atom packages set up.
# John Meehan 2016
# ruby atom-setup.rb
[ "emmet",
"editor-stats",
"language-haml",
"linter",
"linter-ruby",
"linter-rubocop",
"linter-scss-lint",
@johnmeehan
johnmeehan / ansi-terminal-colours.rb
Created March 14, 2016 21:01
ANSI Colours for coloured terminal output.
# ANSI Colours for coloured terminal output.
# John Meehan 2016
# foreground color
"\033[30m" #BLACK_TEXT
"\033[31m" #RED_TEXT
"\033[32m" #GREEN_TEXT
"\033[33m" #BROWN_TEXT
"\033[34m" #BLUE_TEXT
"\033[35m" #MAGENTA_TEXT
@johnmeehan
johnmeehan / reform_prepopulators.rb
Created August 29, 2016 15:40
Reform prepopulator and allow for deletion
collection :side_panels, form: SidePanelForm,
prepopulator: ->(options) {
if side_panels.count == 0
self.side_panels << SidePanel.new(sales_order_id: sales_order_id, collection: sales_order.collection)
end
},
populator: ->(fragment:, index:, **) {
if fragment['panel_id'] == "" #'0' # or 'None' => nil then wouldn't need to make a None on the DB then.
deserialized_panel = side_panels.find { |p| p.id.to_s == fragment["id"] }
if deserialized_panel
@johnmeehan
johnmeehan / bootstrap_tabs.haml
Created October 5, 2016 11:27
example to bootstrap tabs switching out the tab and its contents
#tabs
%ul.nav.nav-tabs.nav-justified
%li.active
= link_to 'Quotes', '#quotes', data: { toggle: "tab" }
%li
= link_to 'Draft', '#drafts', data: { toggle: "tab" }
%li
= link_to 'Submitted', '#submitted', data: { toggle: "tab" }
%li
= link_to 'Accepted', '#accepted', data: { toggle: "tab" }
@johnmeehan
johnmeehan / _modal.html.haml
Last active February 14, 2023 19:20
Rails + Reform + Bootstrap + Ajax Modal Form
# simple_form Reform Form for creating a basic postal address
# errors will be shown on the violating fields
= simple_form_for(@form, remote: true) do |f|
.modal-dialog
.modal-content
.modal-header
%button.close{"aria-hidden" => "true", "data-dismiss" => "modal", :type => "button"} ×
%h3.modal-title
New Address for
= @customer.name
@johnmeehan
johnmeehan / grouped_select.coffee
Created November 1, 2016 11:26
Grouped Select Example
# :coffeescript
jQuery ->
designs = $('.design').html()
$('.style').change ->
style = $('.style option:selected').text()
options = $(designs).filter("optgroup[label='" + style + "']").html()
$('.design').html(options)
@johnmeehan
johnmeehan / wait_for_ajax.rb
Created March 8, 2017 15:39
RSpec, Capyabara, Poltergiest, Angular, jQuery wait_for_ajax
# spec/support/wait_for_ajax.rb
# # Angular, Rails, Capybara, wait for ajax
# Useage:
# click_link("Send an ajax request")
# wait_for_ajax
# expect(page).to have_content("expected ajax response message")
module WaitForAjax
def wait_for_ajax(max_wait_time = 30)
Timeout.timeout(max_wait_time) do
while pending_ajax_requests?
@johnmeehan
johnmeehan / browserstack.md
Last active March 1, 2020 22:10
Browserstack + Rails5 + RSpec + Capybara

Browserstack

My setup for configuring a Rails app with RSpec Feature tests that uses Capabara to test on a browserstack remote browser.

The browserstack docs only show either an RSpec or a Capabara setup.

What I wanted:

  1. In development run my tests quickly with poltergiest.
  2. Run nightly builds on CI to test against different web browsers using browserstack.
  3. Have the option to visually run my tests with selenium with Chrome, Firefox etc.