Skip to content

Instantly share code, notes, and snippets.

View rupurt's full-sized avatar
🏠
Working from home

Alex Kwiatkowski rupurt

🏠
Working from home
View GitHub Profile
after(:each) do
errors = page.driver.browser.manage.logs.get(:browser)
if errors.present?
message = errors.map(&:message).join("\n")
puts message
end
end
@rupurt
rupurt / .tmux.conf
Created June 22, 2016 14:45
tmux configuration
# remap prefix to Control + a
set -g prefix C-a
set -g default-terminal "xterm-256color"
set -s escape-time 0
# bind 'C-a C-a' to type 'C-a'
bind C-a send-prefix
unbind C-b
# Lines of history
<header class="school-website-header uk-z-4">
<div class="uk-padding-horizontal uk-container uk-container-center">
<nav class="uk-navbar" data-behavior="dropdown">
<a href="{{current_school.logo_navigation_url}}" class="uk-brand">
{{ if current_school.logo_url }}
<img src="{{current_school.logo_url}}" alt="{{current_school.name}}">
{{ else }}
<span class="uk-text-large uk-text-bold">{{ current_school.name }}</span>
{{ end }}
</a>
@rupurt
rupurt / gist:182a474bb9889b54fa50ec5bc0445014
Last active May 19, 2016 12:46
includes AR weirdness
# Should be 8 records
ActiveRecord::Base.connection.execute(MembershipSummary.includes(:person).where(school_id: 2, group_id: 1).order("people.first_name asc NULLS LAST, person_id asc NULLS LAST").to_sql).count
# Should be 8 records but only returns 1
MembershipSummary.includes(:person).where(school_id: 2, group_id: 1).order("people.first_name asc NULLS LAST, person_id asc NULLS LAST").to_a.size
# 'joins' does what we want and returns 8 records. Maybe we can figure out how to get ransack to do a join instead of includes
MembershipSummary.joins(:person).where(school_id: 2, group_id: 1).order("people.first_name asc NULLS LAST, person_id asc NULLS LAST").to_a.size
heroku pg:backups -r production # list existing backups
curl -o a123.dump `heroku pg:backups public-url a123 -r production` # pull the backup down locally
pg_restore --verbose --clean --no-acl --no-owner -h localhost -d AppName_enviroment a123.dump
# Or even quicker
heroku pg:backups restore `heroku pg:backups public-url a123 -r sk-git-remote` DATABASE_URL -r sk-git-remote
curl -o a425.dump `heroku pg:backups public-url a425 -r remote-name`
@rupurt
rupurt / gist:09ec8f3f9ac9c4e6e180
Created February 24, 2016 17:03
Processing groups spike
module FileType
2 module ProcessingGroup
3 Box = [PDF, Word, Powerpoint]
4 Video = [Video]
5 end
@rupurt
rupurt / gist:7159363
Created October 25, 2013 18:19
CapybaraWebkit and Selenium with :debug tag
Capybara.default_driver = :webkit
RSpec.configure do |config|
config.before(debug: true) do
Capybara.current_driver = :selenium
end
config.after(debug: true) do
Capybara.use_default_driver
end
@rupurt
rupurt / gist:6800452
Created October 2, 2013 20:59
Kss custom routes
Kss::Engine.routes.draw do
get '/someurl' => 'controllername#actionname'
root :to => 'home#index'
end
@rupurt
rupurt / capybara.rb
Created July 29, 2013 21:52
Silence stderr from QtWebkit
Capybara.register_driver :webkit do |app|
connection = Capybara::Webkit::Connection.new(socket_class: TCPSocket, stderr: File.open('/dev/null', 'a'))
browser = Capybara::Webkit::Browser.new(connection)
Capybara::Webkit::Driver.new(app, browser: browser)
end