Skip to content

Instantly share code, notes, and snippets.

View cgat's full-sized avatar

Chris Gat cgat

  • Metalab Design
  • The World
View GitHub Profile
@zhengjia
zhengjia / capybara cheat sheet
Created June 7, 2010 01:35
capybara cheat sheet
=Navigating=
visit('/projects')
visit(post_comments_path(post))
=Clicking links and buttons=
click_link('id-of-link')
click_link('Link Text')
click_button('Save')
click('Link Text') # Click either a link or a button
click('Button Value')
@nathanl
nathanl / pry_and_debugger_cheat_sheet.md
Created November 15, 2012 14:59
Pry and debugger cheat sheet

Ruby Debugging

Pry

ruby -rpry some_script.rb - the r means require. If there's a binding.pry there, you'll be on it.

Pry gives you a graphical look at your program in progress, lets you cd among objects, ls to see available variables, etc. You can't step, though; just explore a snapshot at that moment.

Debugger

Must install debugger gem for your version of Ruby (1.9 is 'gem install debugger'). Doesn't play well with Spork.

# Wouldn't it be great if you could have STI like functionality
# without needing to encode strings of class names in the database?
# Well today is your lucky day! Discriminable Model is here to help.
#
# Simply specify your models desired type column, and provide a block to
# do the discrimination. If you want the whole STI-esque shebang of properly
# typed finder methods you can supply an array of 'discriminate_types' that will
# be used to apply an appropriate type.
#
# class MyModel < ActiveRecord::Base
@hubgit
hubgit / SelectField.tsx
Last active July 16, 2024 07:40
Use react-select with Formik
import { FieldProps } from 'formik'
import React from 'react'
import Select, { Option, ReactSelectProps } from 'react-select'
export const SelectField: React.SFC<ReactSelectProps & FieldProps> = ({
options,
field,
form,
}) => (
<Select