Skip to content

Instantly share code, notes, and snippets.

View bellatrix988's full-sized avatar

Marina bellatrix988

View GitHub Profile
@bellatrix988
bellatrix988 / README.md
Last active January 12, 2023 22:26
Rails 7 & Hotwire & Turbo & Devise workaround

Rails 7 & Hotwire & Turbo & Devise workaround

This gist is relevant while this Devise issue#5446 is not closed or a better solution is not suggested.

Problem:

Not getting flashes errors using turbo.

Solutions:

1. Override FailureApp and devise parent controller.

@bellatrix988
bellatrix988 / .railsrc
Last active June 11, 2022 14:59
Rails initialisation templates
--database=postgresql
--skip-action-cable
--skip-action-mailer
--skip-bundle
--skip-javascript
--skip-keeps
--skip-test
javascript:taskName = document.getElementsByClassName('AutogrowTextarea-input')[0].value;taskLink = window.location.href;taskNameShort = taskName.replace(/\W/g, '').replace(/[A-Z]/g, letter => ` ${letter.toLowerCase()}`).trim().replace(/\s/g, '_').substring(0,30);result = `${taskLink.match(/.*([0-9]{16})/).pop()}-${taskNameShort}`; el = document.createElement('textarea'); el.value = result;  document.body.appendChild(el);   el.select();document.execCommand("copy"); document.body.removeChild(el);

DA-upgrade tips

Common Rails 3, 4 deprications

  1. replace after_filter and before_filter with after_action and before_action callbacks. after_filter and before_filter are both deprecated in rails 5

  2. Rails 5 stops some raw SQL and prevents SQL injections. For raw SQL there will be warning (error in rails 6) so we should change raw SQL string literals to Arel objects Arel.sql('')

  3. :condition no longer an acceptable key (replace with where) :order is no longer an option has_many :order (block)

#!/bin/sh
# W
# R RW W.
# RW::::RW DR::R
# :RRRRRWWWWRt:::::::RRR::::::E jR
# R.::::::::::::::::::::::::::Ri jiR:::R
# R:::::::.RERRRRWWRERR,::::::Efi:::::::R GjRRR Rj
# R::::::.R R:::::::::::::;G RRj WWR RjRRRRj
# Rt::::WR RRWR R::::::::::::::::fWR::R; WRW RW R
# WWWWRR:::EWR E::W WRRW:::EWRRR::::::::: RRED WR RRW RR
@bellatrix988
bellatrix988 / pow.sh
Last active March 15, 2021 08:10 — forked from jpsilvashy/pow.sh
pow
#!/bin/sh
# W
# R RW W.
# RW::::RW DR::R
# :RRRRRWWWWRt:::::::RRR::::::E jR
# R.::::::::::::::::::::::::::Ri jiR:::R
# R:::::::.RERRRRWWRERR,::::::Efi:::::::R GjRRR Rj
# R::::::.R R:::::::::::::;G RRj WWR RjRRRRj
# Rt::::WR RRWR R::::::::::::::::fWR::R; WRW RW R
# WWWWRR:::EWR E::W WRRW:::EWRRR::::::::: RRED WR RRW RR
@bellatrix988
bellatrix988 / .zshrc
Last active July 12, 2022 12:49
Development triks
function rubucop_current_changes() {
current_branch=$(git branch --show-current)
git diff $branch_name develop --name-status | grep '\.rb$' | xargs rubocop
}
alias zshreload="source ~/.zshrc"
[2] pry(#<QuoteFinancial>)> '%s' % 'test'
=> "test"
pry(#<QuoteFinancial>)> '%{name} %{email}' % {name: 'alex', email: '1@1.eu'}
=> "alex 1@1.eu"
@bellatrix988
bellatrix988 / gist:4e57cc875be45d3e5f15b4e1f4833640
Last active December 5, 2017 09:53
Description of "Worker's reports"

Description of "Worker's reports"

Реализовать веб-приложение для отчетов работников о проделанной и планируемой работе.

Описание интерфейса Кнопка добалвения, форма добавления, список записей.

  • Кнопка 'Show more' показывает записи следующего промежутка.

Функционал

  • Просмотр всех отчетов