Skip to content

Instantly share code, notes, and snippets.

View ka8725's full-sized avatar
๐Ÿš€
Building Web and Mobile apps

Andrei Kaleshka ka8725

๐Ÿš€
Building Web and Mobile apps
View GitHub Profile

๐Ÿ“Š Zapier vs. Self-made Solution for Event Processing

Factor Zapier Self-made Notes
Advanced level of customization โœ˜ โœ” Self-made solution provides 100% flexibility in logic, architecture, and integrations.
Debugging/fixing issues/customer support cost โœ˜ โœ” Zapier gives limited logs and debugging tools; self-made allows full control, observability, and in-house fixes.
Data consistency guarantee (exactly-once delivery) โœ˜ โœ”
#
# This file tells systemd how to run Sidekiq as a 24/7 long-running daemon.
#
# Customize this file based on your bundler location, app directory, etc.
#
# If you are going to run this as a user service (or you are going to use capistrano-sidekiq)
# Customize and copy this to ~/.config/systemd/user
# Then run:
# - systemctl --user enable sidekiq
# - systemctl --user {start,stop,restart} sidekiq
@ka8725
ka8725 / send_mail.rb
Last active October 24, 2022 18:41
Send mail matcher
# frozen_string_literal: true
# Source: https://gist.github.com/ka8725/6053d55be74f15b53cabfc3ac4dc99df
# Installation: put this file into spec/support/matchers/ folder.
# Simple matcher that allows checking of an email was sent during an example run.
#
# @example Positive expectation
# expect { action }.to send_email
#
@ka8725
ka8725 / replace.sh
Created March 4, 2021 12:39
Replace text in all found files
git grep --name-only '< ApplicationJob' | xargs -I {} sed -i '' -e 's/< ApplicationJob/< BaseJobWithRetry/' {}
@ka8725
ka8725 / states_matcher.rb
Created December 13, 2013 12:23
Custom matcher for Rspec to test state_machine status flow
# This custom matcher can be used to test state machine
#
# Examples
#
# it { should have_event(:status, :event_name, [:state1, :state2] => [:state3, :state4]) }
# it { should have_event(:status, :event_name, {
# :state1 => :state3,
# :state1 => :state4,
# :state3 => :state3,
# :state2 => :state4
class SMSGateway
# @param phone [String]
# @param message [String]
def self.send_message(phone, message)
puts "Hello #{phone}, #{message}"
end
end
User = Struct.new(:phone, :active)
def foo
puts 'hello from foo'
end
def bar(f)
f()
end
bar(foo) # => NoMethodError (undefined method `f' for main:Object)
module LiquidPresenters
class Plan < SimpleDelegator
def to_liquid
@to_liquid ||= HashWithIndifferentAccess.new({
id: self.id,
name: self.name,
description: self.description,
status: self.status,
class_id: self.plan_class_id
})
@ka8725
ka8725 / dbconfig.rake
Last active July 28, 2016 10:03
database.yml generator. Global Rake implementation
require 'yaml'
desc 'Generates database.yml, optional arguments: [adapter, user, password]'
task :dbconfig => 'database.yml'
file 'database.yml', [:adapter, :username, :password] do |t, args|
Dir.chdir('config')
args.with_defaults(:project_path => Dir.pwd)
DBConfigGenerator.new(t, args).generate
end
class Base
end
class A < Base
def foo
puts 'foo'
end
end
class A < Base