Skip to content

Instantly share code, notes, and snippets.

@mycargus
mycargus / selenium_hover.rb
Created October 30, 2015 20:15
From sauce labs tips
run do
@driver.get 'http://the-internet.herokuapp.com/hovers'
an_avatar = @driver.find_element(class: 'figure')
@driver.action.move_to(an_avatar).perform
expect(@driver.find_element(class: 'figcaption').displayed?).to eql true
end
@mycargus
mycargus / slack-dark-theme.css
Created November 25, 2015 18:22
A dark Stylish theme for Slack
body {
background: #222;
color: #e6e6e6; }
a {
color: #949494; }
a:link, a:visited {
color: #949494; }
a:hover, a:active, a:focus {
color: #c7c7c7; }
Failures:
1) Viewing a selective release quiz as the teacher on the assignments index page shows all the quizzes
Failure/Error: expect(list_of_assignments).to include_text SelectiveRelease::Homework.quizzes.quiz_for_everyone.title
NoMethodError:
undefined method `[]' for nil:NilClass
# ./spec/selenium/quizzes/quizzes_selective_release_spec.rb:19:in `block (4 levels) in <top (required)>'
# ./spec/selenium/common.rb:82:in `block (2 levels) in <top (required)>'
# ./spec/spec_helper.rb:34:in `block (3 levels) in <top (required)>'
# ./spec/spec_helper.rb:32:in `block (2 levels) in <top (required)>'
@mycargus
mycargus / spec_and_failure
Created January 8, 2016 22:49
Modified spec and its failure message
code:
```
it 'should print an object reference' do
puts SelectiveRelease::Homework.quizzes.quiz_for_everyone
end
```
Failures:
1) Viewing a selective release quiz as the teacher on the assignments index page shows all the quizzes
class String
def trim sep=/\s/
sep_source = sep.is_a?(Regexp) ? sep.source : Regexp.escape(sep)
pattern = Regexp.new("\\A(#{sep_source})*(.*?)(#{sep_source})*\\z")
self[pattern, 2]
end
end
@mycargus
mycargus / example_specs.rb
Created January 18, 2016 20:53
Selective Release (AKA Differentiated Assignments) example specs
require_relative '../../helpers/selective_release/selective_release_common'
describe 'Viewing selective release assignments' do
include_context 'selective release'
let(:assignments) { SelectiveRelease::Homework::Assignments }
let(:discussions) { SelectiveRelease::Homework::Discussions }
let(:quizzes) { SelectiveRelease::Homework::Quizzes }
context 'as the teacher' do
@mycargus
mycargus / remove-docker-containers.md
Created February 23, 2016 21:49 — forked from ngpestelos/remove-docker-containers.md
How to remove unused Docker containers and images
  1. Delete all containers

     $ docker ps -q -a | xargs docker rm
    

-q prints only the container IDs -a prints all containers

Notice that it uses xargs to issue a remove container command for each container ID

  1. Delete all untagged images
@mycargus
mycargus / error.sh
Created March 6, 2016 07:13
error message
Failures:
1) This is an example and it works
Failure/Error: visit '/'
Errno::ECONNREFUSED:
Failed to open TCP connection to 127.0.0.1:4444 (Connection refused - connect(2) for "127.0.0.1" port 4444)
# /home/docker/.gem/ruby/2.3.0/gems/selenium-webdriver-2.52.0/lib/selenium/webdriver/remote/http/default.rb:107:in `response_for'
# /home/docker/.gem/ruby/2.3.0/gems/selenium-webdriver-2.52.0/lib/selenium/webdriver/remote/http/default.rb:58:in `request'
# /home/docker/.gem/ruby/2.3.0/gems/selenium-webdriver-2.52.0/lib/selenium/webdriver/remote/http/common.rb:59:in `call'
# To untrack a single file that has already been added/initialized to your
# repository, i.e., stop tracking the file but not delete it from your system use:
git rm --cached filename
# To untrack every file that is now in your .gitignore:
# First commit any outstanding code changes, and then, run this command:
git rm -r --cached .
@mycargus
mycargus / docker_inspect_network_settings.sh
Last active February 3, 2018 23:21
docker inspect network settings for a running named container
docker inspect -f '{{ json .NetworkSettings }}' $(docker inspect --format="{{.Id}}" $container_name) | python -mjson.tool