Skip to content

Instantly share code, notes, and snippets.

View ka8725's full-sized avatar
🚀
Ruby on Rails expert with business development mindset | WideFix Founder

Andrei Kaleshka ka8725

🚀
Ruby on Rails expert with business development mindset | WideFix Founder
View GitHub Profile
#
# 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/' {}
def foo
puts 'hello from foo'
end
def bar(f)
f()
end
bar(foo) # => NoMethodError (undefined method `f' for main:Object)
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)
class Base
end
class A < Base
def foo
puts 'foo'
end
end
class A < Base
params = {a: 1, b: "2", n: {c: 3}}
struct = Magic.new(params)
struct.a # => 1
struct.b # => "2"
struct.c # => undefined method "c"
struct[] # => undefined method "[]"
struct.a = 2 # => undefined method "a ="
Running 30s test @ http://127.0.0.1:3000/users
1 threads and 16 connections
Thread Stats Avg Stdev Max +/- Stdev
Latency 321.24ms 37.67ms 794.62ms 93.10%
Req/Sec 49.87 6.95 60.00 67.80%
1491 requests in 30.08s, 13.32MB read
Requests/sec: 49.56
Transfer/sec: 453.51KB
class User
end
class UserChild < User
end
def cache
@cache ||= {}
end
@ka8725
ka8725 / cache.rb
Last active January 9, 2016 08:25
@semaphore = Mutex.new
def cache
@cache ||= {}
end
def get_y
sleep 1
Object.new
end