Skip to content

Instantly share code, notes, and snippets.

View yshmarov's full-sized avatar
🇺🇦

Yaro Shm yshmarov

🇺🇦
View GitHub Profile
@yshmarov
yshmarov / hotwire-native-oauth.md
Last active March 1, 2026 05:02
hotwire-native-oauth.md

OAuth in Hotwire Native iOS apps

Google and Apple block OAuth from embedded web views (WKWebView) with disallowed_useragent. This guide shows how to make OAuth work in a Hotwire Native iOS app using ASWebAuthenticationSession — Apple's purpose-built API for OAuth — with a path configuration rule and token handoff.

The approach uses zero bridge components. It works with any OmniAuth provider (Google, Apple, Facebook, etc.) and extends to social account linking (YouTube, TikTok, etc.) where the user is already signed in.

How it works

┌─────────────┐     ┌──────────────────────────┐     ┌─────────┐     ┌──────────┐
@yshmarov
yshmarov / no-tailwind-yes-importmaps.txt
Last active August 22, 2025 08:48
new rails app with minimal dependencies for screencasts
rails new myapp --skip-docker --skip-keeps --skip-action-mailer --skip-action-mailbox --skip-action-text --skip-thruster --skip-brakeman --skip-rubocop --skip-ci --skip-kamal
BEGIN:VCALENDAR
CALSCALE:GREGORIAN
PRODID:-//Apple Inc.//macOS 15.2//EN
VERSION:2.0
BEGIN:VTIMEZONE
TZID:Europe/Paris
BEGIN:DAYLIGHT
DTSTART:19810329T020000
RRULE:FREQ=YEARLY;BYMONTH=3;BYDAY=-1SU
TZNAME:CEST
@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 %>