Skip to content

Instantly share code, notes, and snippets.

View yshmarov's full-sized avatar
🇺🇦

Yaro Shm yshmarov

🇺🇦
View GitHub Profile
@yshmarov
yshmarov / gist:1330c88bb6976313003151b53653de5c
Created July 25, 2024 08:53
Jumpstart: what's good and what's bad
SVGs are not abstracted
Connected_accounts & accounts - misleading naming; accounts should be organizations
No exmaple of a resource that requires paid account to access
Inconsistent CSS (btn btn or inline classes)
UI could be better (do not mix User-level features and Acconut level features (Billing, members))
Reuse shared <head>
Flash above app content. WTF?!
Bloatware
- action text mentions
def authenticate_and_get_companies
host = "https://api.procore.com"
client_id = "foo"
client_secret = "bar"
procore_account = ProcoreAccount.create!(access_token: nil, refresh_token: nil, expires_at: nil)
token = Procore::Auth::ClientCredentials.new(
client_id: client_id,
client_secret: client_secret,
@yshmarov
yshmarov / ferrum.rb
Created February 20, 2024 20:32 — forked from bopm/ferrum.rb
format.pdf do
html = ApplicationController.new.render_to_string(
template: 'pdfs/test',
formats: [:pdf],
layout: 'layouts/pdf',
assigns: { user: @user },
encoding: 'UTF-8'
)
Ferrum::Browser.new(timeout: 7).tap do |browser|
browser.content = html

Для интеграции ChatGPT в приложение Rails вам потребуются следующие шаги:

  1. Получите API-ключ GPT, откройте сайт https://openai.com/ и зарегистрируйте аккаунт, елкгда будут инструкции по получению ключа.

  2. Добавьте библиотеку 'httparty' в файл Gemfile вашего приложения и запустите

bundle install
  1. Создайте класс в папке 'lib' вашего приложения для обращения к сервису GPT:
@yshmarov
yshmarov / config.yml
Created May 17, 2022 12:10
notes about deploying on render
### 1. Database setup
Create a new Postgresql database on Render [link](https://dashboard.render.com/new/database)
Copy "Internal Connection String"
Locally, add "Internal Connection String" to credentials `bin/rails credentials:edit`:
```ruby
# config/credentials.yml
@yshmarov
yshmarov / mailer.html.erb
Created June 29, 2021 09:24
email layout styling example
<% # frozen_string_literal: true %>
<html>
<head>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type"/>
<scss>
body {
font-family: Helvetica, Arial, sans-serif;
.message {
width:600px;
border-top: 2px dashed;
@yshmarov
yshmarov / _form.html.erb
Created May 30, 2021 17:28
show or hide div based on a form value (d-none is a bootstrap5 class for hiding)
<%= form_with(model: post) do |form| %>
<%= content_tag :div, nil, data: { controller: "showhide", showhide_show_if_value: "lorem", showhide_hide_class: "d-none" } do %>
<%= form.select :content, [nil, "lorem", "150"], {}, {data: { showhide_target: "field", action: "change->showhide#change" }} %>
<div data-showhide-target="output">
you can see this text if selected value = lorem
</div>
<% end %>
<% end %>
@yshmarov
yshmarov / _form.html.haml
Created May 30, 2021 17:26
conditional dropdowns with stimulus and jquery (bad approach)
= simple_form_for @valuation, html: { data: { controller: 'valuation' } } do |f|
= f.input :tenure_id, collection: Tenure.all, input_html: { id: 'tenure_dropdown', data: { action: 'change->valuation#toggleTenure' } }
#tenure
= f.input :is_remaining_term_less_than_85_years, as: :select, input_html: { id: 'timeleft_dropdown', data: { action: 'change->valuation#toggleTimeleft' } }
#timeleft
= f.input :remaining_term_details
@yshmarov
yshmarov / blob active_Storage
Created May 14, 2021 10:15
blob active_Storage
app/views/active_storage/blobs/_blob.html.haml
<%= render "active_storage/blobs/blob", blob: @post.avatar %>
<figure class="attachment attachment--<%= blob.representable? ? "preview" : "file" %> attachment--<%= blob.filename.extension %>">
<% if blob.representable? %>
<%= image_tag blob.representation(resize_to_limit: local_assigns[:in_gallery] ? [ 800, 600 ] : [ 1024, 768 ]) %>
<% elsif blob.image? %>
<%= image_tag blob, width: "200px" %>
<% elsif blob.audio? %>
@yshmarov
yshmarov / bootstrap_card.html
Created January 21, 2021 13:47
bootstrap card syling
<div class="card shadow">
<div class="card-header">
<h2>
</h2>
</div>
<div class="card-body">
</div>
<div class="card-footer">
</div>
</div>