Skip to content

Instantly share code, notes, and snippets.

View Casual3498's full-sized avatar
👁️
Big Brother is watching you

Sergei Popov Casual3498

👁️
Big Brother is watching you
View GitHub Profile
@Casual3498
Casual3498 / issue_patch.rb
Created September 16, 2019 20:20
Redmine issues optimization
require_dependency 'issue'
module MosregJoinEnabledModules
module Patches
module IssuePatch
def self.included(base)
base.class_eval do
scope :visible, lambda {|*args|
joins(project: :enabled_modules).
where(Issue.visible_condition(args.shift || User.current, *(args << {join_enabled_modules: true})))
@Casual3498
Casual3498 / del_redis_fill_transactions.rb
Created May 8, 2018 13:05
delete cache and fill transactions
del_keys = $redis.keys.select { |el| /\ACryptocompareClient:(BTC|ETH):USD:(\d{10})\z/.match(el).present?&&/\ACryptocompareClient:(BTC|ETH):USD:(\d{10})\z/.match(el)[2].to_i >= DateTime.parse('18-04-2018 00:00').to_i }
del_keys.each { |key| $redis.del(key) }
EthTransaction.all.each { |tr| tr.set_usd_amount }
BtcTransaction.all.each { |tr| tr.set_usd_amount }
@Casual3498
Casual3498 / movies.rb
Last active December 16, 2017 19:00
4lesson
#!/usr/bin/env ruby
require 'csv'
require 'ostruct'
#require 'date'
filename = 'movies.txt'
keys_array = %i[href name year country date genres duration rank director actors]
films_array =[]
@Casual3498
Casual3498 / movies.rb
Last active December 14, 2017 17:07
3lesson
#!/usr/bin/env ruby
filename = 'movies.txt'
keys_array = %i[href name year country date genres duration rank director actors]
films_array =[]
def output_films (arr)
arr.each do |film|
puts "#{film[:name]} :(#{film[:date]} ; #{film[:genres]}) - #{film[:duration]}"
@Casual3498
Casual3498 / movies.rb
Last active December 13, 2017 19:46
2lesson
#!/usr/bin/env ruby
filename = 'movies.txt'
name_template = 'Max'
name_index = 1
rating_index = 7
file = ""
filename = ARGV[0] || filename
@Casual3498
Casual3498 / movies.rb
Last active December 13, 2017 16:17
1lesson
#!/usr/bin/env ruby
bad_films = ['Titanic', 'Alien 18']
good_films = ['Matrix', 'Interstate 60']
puts case
when good_films.map(&:downcase).include?(ARGV[0].downcase) then "#{ARGV[0]} is a good movie."
when bad_films.map(&:downcase).include?(ARGV[0].downcase) then "#{ARGV[0]} is a bad movie."
else "Haven't seen #{ARGV[0]} yet"
end