View sidekiq.service
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# | |
# 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 |
View send_mail.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 | |
# |
View replace.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
git grep --name-only '< ApplicationJob' | xargs -I {} sed -i '' -e 's/< ApplicationJob/< BaseJobWithRetry/' {} |
View ruby_closures1.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def foo | |
puts 'hello from foo' | |
end | |
def bar(f) | |
f() | |
end | |
bar(foo) # => NoMethodError (undefined method `f' for main:Object) |
View ruby_closure.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
View ruby.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Base | |
end | |
class A < Base | |
def foo | |
puts 'foo' | |
end | |
end | |
class A < Base |
View magic.ru
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 =" |
View gist:551daaf4ea9256706393
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | |
View cache_pool.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class User | |
end | |
class UserChild < User | |
end | |
def cache | |
@cache ||= {} | |
end |
View cache.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@semaphore = Mutex.new | |
def cache | |
@cache ||= {} | |
end | |
def get_y | |
sleep 1 | |
Object.new | |
end |
NewerOlder