Skip to content

Instantly share code, notes, and snippets.

Avatar
👁️
Big Brother is watching you

Sergei Popov Casual3498

👁️
Big Brother is watching you
View GitHub Profile
View movies.rb
#!/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
View movies.rb
#!/usr/bin/env ruby
filename = 'movies.txt'
name_template = 'Max'
name_index = 1
rating_index = 7
file = ""
filename = ARGV[0] || filename
View movies.rb
#!/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]}"
View movies.rb
#!/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 / del_redis_fill_transactions.rb
Created May 8, 2018
delete cache and fill transactions
View del_redis_fill_transactions.rb
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 / issue_patch.rb
Created Sep 16, 2019
Redmine issues optimization
View issue_patch.rb
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})))