Skip to content

Instantly share code, notes, and snippets.

View Yorickov's full-sized avatar
👽
Still going strong

Dzmitry Monich Yorickov

👽
Still going strong
  • Jet Rockets
  • Poland
  • 01:42 (UTC +02:00)
View GitHub Profile
@Yorickov
Yorickov / !README.MD
Created June 15, 2023 13:09 — forked from davideluque/!README.MD
Sign in with Apple in Ruby on Rails using apple_id gem.

Implementation of the Sign in with Apple service in Ruby on Rails. This implementation is convenient for Ruby on Rails APIs as it does not use views.

This implementation does:

  • Verify the user's identity token with apple servers to confirm that the token is not expired and ensure it has not been tampered with or replayed to the app.
  • Log in the user, register the user or connect the user's apple account to the user's existing account.

Parameters

  • code: Apple's authorizationCode after sign in. Example: c49a75458b1e74b9f8e866f5a93b1689a.0.nrtuy. ...
@Yorickov
Yorickov / db.rake
Created June 10, 2023 12:47 — forked from hopsoft/db.rake
Rails rake tasks for dump & restore of PostgreSQL databases
# lib/tasks/db.rake
namespace :db do
desc "Dumps the database to db/APP_NAME.dump"
task :dump => :environment do
cmd = nil
with_config do |app, host, db, user|
cmd = "pg_dump --host #{host} --username #{user} --verbose --clean --no-owner --no-acl --format=c #{db} > #{Rails.root}/db/#{app}.dump"
end
puts cmd
@Yorickov
Yorickov / example_activejob.rb
Created June 5, 2023 12:44 — forked from ChuckJHardy/example_activejob.rb
Example ActiveJob with RSpec Tests
class MyJob < ActiveJob::Base
queue_as :urgent
rescue_from(NoResultsError) do
retry_job wait: 5.minutes, queue: :default
end
def perform(*args)
MyService.call(*args)
end
@Yorickov
Yorickov / git.migrate
Created May 28, 2021 11:40 — forked from niksumeiko/git.migrate
Moving git repository and all its branches, tags to a new remote repository keeping commits history
#!/bin/bash
# Sometimes you need to move your existing git repository
# to a new remote repository (/new remote origin).
# Here are a simple and quick steps that does exactly this.
#
# Let's assume we call "old repo" the repository you wish
# to move, and "new repo" the one you wish to move to.
#
### Step 1. Make sure you have a local copy of all "old repo"
### branches and tags.
@Yorickov
Yorickov / monit.rc
Created April 6, 2020 16:02
Monit config
### Nginx ###
check process nginx
with pidfile /run/nginx.pid
start program = "/usr/sbin/service nginx start"
stop program = "/usr/sbin/service nginx stop"
if cpu > 60% for 2 cycles then alert
if cpu > 80% for 5 cycles then restart
if memory usage > 80% for 5 cycles then restart
if failed host 188.166.44.84 port 80 protocol http
then restart
CREATE DATABASE test_guru;
CREATE TABLE categories (
title text PRIMARY KEY
);
CREATE TABLE tests (
title text PRIMARY KEY,
level integer,
category_title text REFERENCES categories(title)
@Yorickov
Yorickov / gist:4ab74b3c81e7cc0cab6ec245d69d6ffa
Last active November 14, 2019 22:31
ncat-testing-GET-query
ncat -C httpbin.org 80
GET /anything?id=5&name=freddy HTTP/2.0
Host: httpbin.org
HTTP/1.1 200 OK
Access-Control-Allow-Credentials: true
Access-Control-Allow-Origin: *
Content-Type: application/json
Date: Thu, 14 Nov 2019 22:30:55 GMT
Referrer-Policy: no-referrer-when-downgrade
@Yorickov
Yorickov / gist:c43b8da4b61478c64f496e9a9c94b121
Last active November 14, 2019 22:26
ncat-testing-POST
ncat -C httpbin.org 80
POST /anything?pass=5 HTTP/2.0
Host: httpbin.org
Content-Length: 5
Content-Type: application/x-www-form-urlencoded
id=11
HTTP/1.1 200 OK
Access-Control-Allow-Credentials: true
Access-Control-Allow-Origin: *
ncat -C httpbin.org 80
GET /anything HTTP/2.0
Host: httpbin.org
HTTP/1.1 200 OK
Access-Control-Allow-Credentials: true
Access-Control-Allow-Origin: *
Content-Type: application/json
Date: Thu, 14 Nov 2019 22:27:56 GMT
Referrer-Policy: no-referrer-when-downgrade