Skip to content

Instantly share code, notes, and snippets.

@mycargus
mycargus / example_project_files.md
Last active January 20, 2017 23:14
Testing Rake Tasks with RSpec and FakeFS
# Rakefile

require_relative 'lib/task_helpers'

namespace :reset do
  desc 'Clean logs'
  task :logs do
    FileUtils.rm_rf 'log/'
  end
// XPath CheatSheet
// To test XPath in your Chrome Debugger: $x('/html/body')
// http://www.jittuu.com/2012/2/14/Testing-XPath-In-Chrome/
// 0. XPath Examples.
// More: http://xpath.alephzarro.com/content/cheatsheet.html
'//hr[@class="edge" and position()=1]' // every first hr of 'edge' class
@mycargus
mycargus / .bash_profile_docker
Last active December 6, 2016 19:00
These bash functions make for quick docker work.
######################
####### DOCKER #######
######################
# Purpose: Delete all containers and images related to the provided tag name
# Example: `docker-nuke selenium` will delete all containers and images related to "selenium"
function docker-nuke {
args=("$@")
docker ps -a | grep ${args[0]} | cut -d ' ' -f 1 | while read ID; do docker rm $ID; done;
docker images | grep ${args[0]} | tr -s " " | cut -d ' ' -f 3 | while read ID; do docker rmi $ID; done
@mycargus
mycargus / prompt.sh
Created September 28, 2016 14:50
My custom BASH prompt. Add this to your .bashrc file or wherever you like to keep these things. :)
function prompt { # from http://dobsondev.com/customizing-your-terminal/
local BLACK="\[\033[0;30m\]"
local BLACKBOLD="\[\033[1;30m\]"
local RED="\[\033[0;31m\]"
local REDBOLD="\[\033[1;31m\]"
local GREEN="\[\033[0;32m\]"
local GREENBOLD="\[\033[1;32m\]"
local YELLOW="\[\033[0;33m\]"
local YELLOWBOLD="\[\033[1;33m\]"
local BLUE="\[\033[0;34m\]"
@mycargus
mycargus / add_users.rb
Created September 26, 2016 18:57
A ruby script that creates a course and 6 users, enrolls one user as a teacher in the course, and enrolls the remaining 5 users as students in the course
require 'spec/factories/course_factory'
require 'spec/factories/user_factory'
# Create, register, and enroll teacher
course_with_teacher(
active_course: 1,
active_enrollment: 1,
course_name: 'E2E Course',
name: 'Teacher 1'
)
@mycargus
mycargus / migrate_casks.sh
Created June 28, 2016 15:11
Migrating Homebrew casks to new default location. Source: https://github.com/caskroom/homebrew-cask/issues/21913
mv /opt/homebrew-cask/Caskroom /usr/local
brew cask install --force $(brew cask list)
@mycargus
mycargus / features-support-javascript.rb
Created May 23, 2016 18:45 — forked from rosskevin/features-support-javascript.rb
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
@mycargus
mycargus / docker_cleanup.sh
Created April 13, 2016 20:04
Use this to cleanup your docker-machine host before or when it runs out of space :)
# Purpose: Remove all non-running images and containers
# Use `docker-cleanup --dry-run` to see what would be deleted.
function docker-cleanup {
EXITED=$(docker ps -q -f status=exited)
DANGLING=$(docker images -q -f "dangling=true")
if [ "$1" == "--dry-run" ]; then
echo "==> Would stop containers:"
echo $EXITED
echo "==> And images:"
@mycargus
mycargus / courses
Created March 16, 2016 16:50
term-course-section hierarchy scenarios
COURSES
* indicates full coverage
** indicates partial coverage
Course 1**
- active
-- past start date
-- no end date
- unrestricted
@mycargus
mycargus / Dockerfile_rspec_example
Last active March 14, 2016 18:07
docker-compose: confirm a dependent container is launched and accepting TCP connections
FROM ruby:latest
USER root
ENV APP_HOME /usr/src/app
RUN mkdir -p $APP_HOME
WORKDIR $APP_HOME
RUN apt-get update && apt-get install -y \
netcat-openbsd