Skip to content

Instantly share code, notes, and snippets.

@TeaMoe
TeaMoe / capybara.rb
Created September 22, 2017 08:20
unknown error: Chrome failed to start: exited abnormally
require 'capybara/rails'
Capybara.register_driver(:headless_chrome) do |app|
args = %W[disable-gpu no-sandbox window-size=1680,1050]
args << 'headless' if ENV.fetch("HEADLESS", "1") == "1"
# args << "proxy-server=localhost:3128"
capabilities = Selenium::WebDriver::Remote::Capabilities.chrome(
chrome_options: { args: args }
)
@TeaMoe
TeaMoe / .(spac)emacs
Last active September 11, 2017 14:21
Flycheck Syntax Checker for Haml 5
;; Syntax checker for haml
(flycheck-define-checker haml5
"A Haml syntax checker using the Haml compiler.
See URL `http://haml.info'."
:command ("haml" "-c" source)
:error-patterns
((error line-start "Syntax error on line " line ": " (message) line-end)
(error line-start (file-name) ":" line ": syntax error, " (message) line-end))
:modes haml-mode)
# -*- coding: utf-8 -*-
#
# Purpose:
# Extend the date parsing capabilities of Ruby to work with dates with international month names.
#
# Usage:
#
# Date.parse_international(date_string)
# DateTime.parse_international(date_string)
# date_string.to_international_date
" convert shoulda to rspec
function! Shoulda2Rspec()
exec ':%s/setup/before/gce'
exec ':%s/teardown/after/gce'
exec ":%s/should \\(\"\\|'\\)/it \\1should /gce"
exec ":%s/^\\(\\s\\+\\)should\\(_not\\)\\? \\([^\"'].*$\\)/\\1it { should\\2 \\3 }/gce"
exec ':%s/:\(\w\+\)\s\?=>\s\?/\1: /gce'
exec ':%s/assert_\([[:alpha:]]\+\)(\(.*\))/assert_\1 \2/gce'
exec ':%s/assert_contains \([^,]\+\), \?\(.*\)$/expect(\1).to include(\2)/gce'
exec ':%s/assert_does_not_contain \([^,]\+\), \?\(.*\)$/expect(\1).to_not include(\2)/gce'