Skip to content

Instantly share code, notes, and snippets.

View tgaff's full-sized avatar

tgaff tgaff

View GitHub Profile

site prism

Page Object Model gem for ruby Page Objects are like react-components for integration spec code. They let you componentize pages or parts of pages so you don't use css-selectors every where.

If you have page.find('button', text: 'update section') in a lot of tests, when the PM says it should be 'Change Section' you have a lot of changes to make. By sticking this in the page-object it limits the needed scope of change to just that POM and possible the one test that regression checked this.

pages

Let you define elements on your page

@tgaff
tgaff / mfa authentication.md
Last active November 27, 2023 16:40
mfa authentication in aws

multi-factor authentication for aws cli and eb cli commands

tldr

  1. get YOUR_MFA_SERIAL from IAM web console.
  2. get YOUR_MFA_CODE from your MFA device/app.
  3. aws sts get-session-token --serial-number YOUR_MFA_SERIAL --token-code YOUR_MFA_CODE --duration 129600
  4. Edit `~/.aws/credentials adding or editing an [mfa] section
    [mfa]
    
@tgaff
tgaff / safeRead.js
Created April 27, 2018 21:24
Reading deeply nested key in ES6 object
/* safely read deeply nested keys
*
* obj - the object to read from
* s - a string representation of the keys like 'my.deeply.nested.key'
* arguments - individual keys
*
* Usage:
* 1) safeRead(someObj, 'my', 'deeply', 'nested', 'key')
* 2) safeRead(someObj, 'my.deeply.nested.key')
*

Moving from jQuery

Events

// jQuery
$(document).ready(function() {
  // code
})
@tgaff
tgaff / Gemfile
Last active September 19, 2016 23:27
flatten array
source "https://rubygems.org"
gem "rspec"
@tgaff
tgaff / .eslintrc.json
Last active September 11, 2019 07:01
.eslintrc.json for working with ignite
{
"parser": "babel-eslint",
"env": {
"es6": true,
"node": true
},
"extends": "eslint:recommended",
"parserOptions": {
"ecmaFeatures": {
"experimentalObjectRestSpread": true,

#Building a Rails API

Objectives

After this lesson, students will be able to:

  • Create RESTful JSON endpoints for API requests using Rails
  • Add namespaced controllers for serving a JSON API
  • Add namespaced routes for a JSON API

Preparation

@tgaff
tgaff / authentication_with_bcrypt_in_rails_4.md
Last active March 11, 2023 02:21 — forked from eerwitt/authentication_with_bcrypt_in_rails_4.md
Simple Authentication in Rail 4 Using Bcrypt

#Simple Authentication with Bcrypt

This tutorial is for adding authentication to a vanilla Ruby on Rails app using Bcrypt and has_secure_password.

The steps below are based on Ryan Bates's approach from Railscast #250 Authentication from Scratch (revised).

You can see the final source code here: repo. I began with a stock rails app using rails new gif_vault

##Steps

@tgaff
tgaff / using_ruby.rb
Last active April 21, 2016 21:11
sample questions
# create a function first that returns the first item in an array
# Name: first
# Input: [-2, 3, 74, 'math', 'popcorn', 17]
# Output: -2
def first(arr)
arr.first
end
# Create a function final that returns the final element in an array
var burgers = [
"50/50 burger",
"Angus burger",
"Australasian hamburgers",
"Banquet burger",
"Barbecue burger",
"Bøfsandwich",
"Butter burger",
"Buffalo burger",
"California burger",