Skip to content

Instantly share code, notes, and snippets.

View eliotsykes's full-sized avatar

Eliot Sykes eliotsykes

View GitHub Profile
@eliotsykes
eliotsykes / Gemfile
Created December 22, 2014 10:29
Gemfile Ruby Version from .ruby-version file
source 'https://rubygems.org'
def ruby_version
version_file = ".ruby-version"
version_override = (File.exist?(version_file) && File.read(version_file).strip)
default_version = "2.1.5"
version_override || default_version
end
ruby ruby_version
@eliotsykes
eliotsykes / turbolinks-2.4.0.js
Created November 30, 2014 23:34
turbolinks.js compiled version 2.4.0
@eliotsykes
eliotsykes / capybara_finder_options_cheatsheet.md
Last active February 18, 2016 15:57
Capybara Finder Options Cheatsheet

Capybara Options Hash (options) for all, find:

  • text (String, Regexp) — Only find elements which contain this text or match this regexp
  • visible (Boolean, Symbol) — Only find elements with the specified visibility:
    • true - only finds visible elements.
    • false - finds invisible and visible elements.
    • :all - same as false; finds visible and invisible elements.
    • :hidden - only finds invisible elements.
    • :visible - same as true; only finds visible elements.
  • count (Integer) — Exact number of matches that are expected to be found
@eliotsykes
eliotsykes / rails-dev-box-postgresql-HOWTO.md
Last active August 29, 2015 14:07
How to setup rails-dev-box & PostgreSQL

SSH to the vagrant OS command line.

Terminal $> vagrant ssh

Login to postgres database as vagrant user with the psql client:

vagrant@rails-dev-box: psql -U vagrant postgres
require 'rails_helper'
RSpec.describe TodosController, :type => :controller do
describe "GET #index" do
#describe "POST #create" do
#describe "GET #show" do
#describe "PATCH #update" do (or PUT #update)
#describe "DELETE #destroy" do
#describe "GET #new" do
@eliotsykes
eliotsykes / code_example.md
Last active October 24, 2015 14:52
Markdown code block example using backticks

Triple backticks are used to open and close code blocks. The triple backticks need to be on their own line:

puts "hello world"

And here is another, separate code block. Triple backticks open and close it:

puts "line 1"
@eliotsykes
eliotsykes / Gemfile
Last active August 28, 2019 02:56
JavaScript testing in Rails 4.x with RSpec, Capybara, PhantomJS, Poltergeist
# Add poltergeist gem to Gemfile, in :test group,
# then run `bundle` to install
group :test do
...
gem 'poltergeist'
...
end
@eliotsykes
eliotsykes / windows_cheatsheet.md
Last active August 29, 2015 14:06
Where to run what on Windows?

Git Bash

Use Git Bash in Windows for:

  • subl commands (e.g. subl ., subl myfile.rb) to open files with Sublime Text
  • git commands (e.g. git add ., git commit -m "message" README.md, git push heroku master)
  • vagrant commands (cd ~/dev-rails-box first)
  • open commands

Vagrant VM

@eliotsykes
eliotsykes / asset_server_middleware.rb
Last active December 20, 2015 01:29
***** Checkout the rack-zippy gem, I recommend it over this gist, find it at https://github.com/eliotsykes/rack-zippy ***** An asset server for Rails 3.2.x that serves asset pipeline precompiled assets to clients, including those elusive gzipped (.gz) assets. Sadly Rails' own ActionDispatch::Static middleware does not take care of serving gzippe…
# 1. Add rack-rewrite to your Gemfile and run 'bundle install':
# gem 'rack-rewrite'
#
# 2. Create a file with the contents below in config/initializers/asset_server_middleware.rb
#
# 3. Rename 'YourApp' below
#
# 4. In config/environments/production.rb and config/environments/test.rb, set:
# config.serve_static_assets = true
# config.assets.compile = false
@eliotsykes
eliotsykes / gmaps4rails_example_1.html.erb
Last active December 19, 2015 12:38
Getting started with gmaps4rails - a simple map with a single point centred on London, UK
<%# Shows a map centred on London, using the default marker/pin image. %>
<%= gmaps4rails([{:lat => 51.51, :lng => -0.12}].to_json) %>
<%= yield :scripts %><%# Usually yield :scripts goes just before the closing body tag %>