Skip to content

Instantly share code, notes, and snippets.

View rosskevin's full-sized avatar

Kevin Ross rosskevin

View GitHub Profile
@rosskevin
rosskevin / features-support-javascript.rb
Last active May 9, 2019 08:20
Continuous Integration, parallel_tests, cucumber, headless, capybara-webkit, chrome. For mac and linux.Conditionally @show chrome browser (:selenium) in development if @show tag is used, otherwise run headless and *always* run headless in a CI environment regardless of the tag's presence. Check javascript errors automatically when using webkit.
# verified against log_in.feature for blake
# https://github.com/jnicklas/capybara/issues/1443
# turn on webkit driver debug
$use_webkit = true
$use_chrome_instead_of_firefox = false
$webkit_debug = false
$wait_time = 5
def webkit_driver
if $webkit_debug
@rosskevin
rosskevin / step_definitions-fill_in_blank
Last active December 19, 2015 14:48
Cucumber Capybara fill_in '' triggering client_side_validations. I fill in happy path values in the Background, and use Scenario Outline examples to create invalid submissions. This will properly trigger validations for both :selenium (firefox and chrome) and :webkit (capybara-webkit) drivers. Note that this is recently changed in capybara >= 2.…
When /^I fill in "([^"]*)" with "([^"]*)"$/ do |field, value|
# special - if ! ignore filling in
if value.eql? '!'
return
else
f = find_field(field)
current_value = f.value
# fill in unless it is already the same, then just leave it as-is
@rosskevin
rosskevin / db.rake
Last active March 6, 2018 05:02
My db.rake with multi-environment db:rebuild and db:truncate. Some strange behavior in ActiveRecord `database_tasks.rb` adds to the confusion. See this StackOverflow post in the comment.
namespace :db do
# Rake::Task['db:load_config'].enhance [:environment]
desc 'Truncate all tables'
task :truncate => :environment do
puts 'Truncating: '
ActiveRecord::Base.connection.tables.each do |table|
unless %w(schema_migrations rails_admin_histories).include? table
@rosskevin
rosskevin / Rakefile
Last active October 28, 2015 10:41
Rakefile - less to sass a.k.a. less2sass or less2scss
# less to scss based on http://stackoverflow.com/a/19167099/2363935
namespace :convert do
task :less_to_scss do
source_glob = "assets/less/*.less"
dest_dir = "converted"
rm_r dest_dir rescue nil
mkdir_p(dest_dir)
@rosskevin
rosskevin / AnchorDisabler
Created October 16, 2014 20:49
AnchorDisabler.coffee - disable links once and for all with a.disabled or the disabled attribute
class AnchorDisabler
###
This provides for multiple levels of defense so that Anchors marked as disable actually behave as such.
Using this approach, you get an anchor that you cannot:
- click
- tab to and hit return
- tabbing to it will move focus to the next focusable element
- it is aware if the anchor is subsequently enabled
@rosskevin
rosskevin / ElasticSearch.sh
Last active August 29, 2015 14:16 — forked from ricardo-rossi/ElasticSearch.sh
CLI version - java8
### ElasticSearch version
if [ -z "$1" ]; then
echo ""
echo " Please specify the Elasticsearch version you want to install!"
echo ""
echo " $ $0 1.4.0"
echo ""
exit 1
fi
@rosskevin
rosskevin / Enable overlay fs in docker on Ubuntu 15.04
Last active March 31, 2017 20:30
Enable the overlay fs for Docker on Ubuntu 15.04
systemctl stop docker
# kill all old images etc
rm -rf /var/lib/docker
# change the startup options for docker service
mkdir /etc/systemd/system/docker.service.d
cd /etc/systemd/system/docker.service.d
vi storage.conf
sysbench --test=fileio --file-total-size=2G prepare
sysbench --test=fileio --file-total-size=2G --file-test-mode=rndrw --init-rng=on --max-time=300 --max-requests=0 run
sysbench --test=fileio --file-total-size=2G cleanup
@rosskevin
rosskevin / bundle_engines.rb
Last active October 1, 2015 19:59
Bundle Gemfile hack for working with rails engines both locally and otherwise - symlinks directory when in local developer mode.
#----------------------------------------------------------------------
#
# Load all engines
#
# Sample hash - Add to your Gemfile:
# # Load all engines
# @engines = {
# acme: {git: 'git@bitbucket.org:alienfast/acme.git'}
# }
# eval_gemfile File.expand_path 'bundle_engines.rb', File.dirname(__FILE__)
sudo mount /dev/nvme0n1p3 /mnt
sudo mount /dev/nvme0n1p1 /mnt/boot/efi
for i in /dev /dev/pts /proc /sys /run; do sudo mount -B $i /mnt$i; done
#sudo cp --remove-destination /etc/resolv.conf /mnt/etc/resolv.conf
sudo chroot /mnt
grub-install --efi-directory=/boot/efi --target=x86_64-efi --uefi-secure-boot /dev/nvme0n1
exit