Skip to content

Instantly share code, notes, and snippets.

View Wojcirej's full-sized avatar

Wojciech Bal Wojcirej

  • Rzeszów, Poland
View GitHub Profile
@Wojcirej
Wojcirej / .eslintrc.js
Created October 24, 2019 18:13 — forked from nkbt/.eslintrc.js
Strict ESLint config for React, ES6 (based on Airbnb Code style)
{
"env": {
"browser": true,
"node": true,
"es6": true
},
"plugins": ["react"],
"ecmaFeatures": {
@Wojcirej
Wojcirej / capybara cheat sheet
Created November 6, 2018 20:26 — forked from zhengjia/capybara cheat sheet
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')
@Wojcirej
Wojcirej / gist:8c198dd7901bbefe0a1c95d21b27305d
Created June 4, 2018 14:26 — forked from jiggneshhgohel/gist:52bcd562e937ec4dad7b
Devise Security Extension Schema Migrations

Assuming you already have a Devise model named User and you want to add following Devise Security Extension to it

  • Password Expirable
  • Password Archivable
  • Session Limitable

then your User model should look like following:

User model

@Wojcirej
Wojcirej / ultimate-ut-cheat-sheet.md
Created April 18, 2018 14:22 — forked from yoavniran/ultimate-ut-cheat-sheet.md
The Ultimate Unit Testing Cheat-sheet For Mocha, Chai and Sinon

The Ultimate Unit Testing Cheat-sheet

For Mocha, Chai and Sinon

using mocha/chai/sinon for node.js unit-tests? check out my utility: mocha-stirrer to easily reuse test components and mock require dependencies


@Wojcirej
Wojcirej / cssSelectorPriority.md
Created February 27, 2018 14:34 — forked from mjj2000/cssSelectorPriority.md
css selector priority

css selector priority

priority selector example
1 inline style in html tag <div style="color:red">
2 tag#id div#myID { color:red; }
3 #id .myID { color:red; }
4 tag.class div.myClass { color:red; }
5 .class .myClass { color:red; }
6 tag div { color:red; }

Transactions

As your business logic gets complex you may need to implement transactions. The classic example is a bank funds transfer from account A to account B. If the withdrawal from account A fails then the deposit to account B should either never take place or be rolled back.

Basics

All the complexity is handled by ActiveRecord::Transactions. Any model class or instance has a method named .transaction. When called and passed a block, that block will be executed inside a database transaction. If there's an exception raised, the transaction will automatically be rolled back.

Example

@Wojcirej
Wojcirej / Capybara.md
Created November 23, 2017 15:24 — forked from tomas-stefano/Capybara.md
Capybara cheatsheet

Capybara Actions

# Anchor
click_link 'Save'

# Button
click_button 'awesome'

# Both above
@Wojcirej
Wojcirej / saveimages.rb
Created October 19, 2017 19:22 — forked from kfox/saveimages.rb
A quick Ruby script to download PNG, GIF, or JPEG images from a given URL
#!/usr/bin/env ruby
# usage: saveimages.rb <url>
# locally save all images from a web site
require 'nokogiri'
require 'open-uri'
exit if ARGV[0].nil?
@Wojcirej
Wojcirej / experience.rb
Created September 22, 2017 11:20 — forked from mamantoha/experience.rb
Rails API Filtering and Sorting
# app/models/experience.rb
#
# == Schema Information
#
# Table name: experiences
#
# id :integer not null, primary key
# title :string
# description :text
# created_at :datetime not null
@Wojcirej
Wojcirej / rspec_model_testing_template.rb
Created September 19, 2017 10:55 — forked from PWSdelta/rspec_model_testing_template.rb
Rails Rspec model testing skeleton & cheat sheet using rspec-rails, shoulda-matchers, shoulda-callbacks, and factory_girl_rails. Pretty much a brain dump of examples of what you can (should?) test in a model. Pick & choose what you like, and please let me know if there are any errors or new/changed features out there. Reddit comment thread: http…
# This is a skeleton for testing models including examples of validations, callbacks,
# scopes, instance & class methods, associations, and more.
# Pick and choose what you want, as all models don't NEED to be tested at this depth.
#
# I'm always eager to hear new tips & suggestions as I'm still new to testing,
# so if you have any, please share!
#
# @kyletcarlson
#
# This skeleton also assumes you're using the following gems: