Skip to content

Instantly share code, notes, and snippets.

View motoroller95's full-sized avatar

Искандар Гохар motoroller95

View GitHub Profile
class MailParser
delegate :within_window, :within_frame, :find, :all, :window_opened_by, :page, :click_link, :first, to: :@capybara
def initialize(window, capybara)
@window = window
@capybara = capybara
@users_count = 0
@current_idx = 0
end
@motoroller95
motoroller95 / transaction.rb
Last active October 2, 2020 11:46 — forked from briu/transaction.rb
transaction
ApplicationRecord.transaction do
user = User.create!
CalculatePayoutJob.perform_later(user)
// куча действий тут
end
@motoroller95
motoroller95 / users.rb
Last active November 13, 2020 11:18 — forked from briu/users.rb
create two classes with same interfaces
# User attributes name surname
class User < ApplicationRecord
# attributes :id, integer
# attributes :name, string
# attributes :email, string
def log!
Log.create!(...)
end
ActiveRercord::Base.transaction do
user = User.create!(params)
user_profile = User::Profile.create!(user: user)
UserHandler.perform_async(user.id)
# 10 строк кода
end
#include <sys/types.h>
#include <sys/socket.h>
#include <stdio.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <unistd.h>
#include <string.h>
#include <stdlib.h>
#include <fcntl.h>
#include <sys/shm.h>
create table gifts_partitioned (
id integer not null default nextval('gifts_id_seq'::regclass),
; ...
finished boolean not null default false,
; ...
PRIMARY KEY(id, finished)
)
partition by list(finished);
@motoroller95
motoroller95 / production.rb
Created October 21, 2023 12:15 — forked from mudge/production.rb
How to configure Rails and Rack::Attack to use the real client IP when running behind Cloudflare
Rails.application.configure do
# Add Cloudflare's IPs to the trusted proxy list so they are ignored when
# determining the true client IP.
#
# See https://www.cloudflare.com/ips-v4/ and https://www.cloudflare.com/ips-v6/
config.action_dispatch.trusted_proxies = ActionDispatch::RemoteIp::TRUSTED_PROXIES + %w[
173.245.48.0/20
103.21.244.0/22
103.22.200.0/22
103.31.4.0/22