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 xor_encrypt(string, key) | |
string.bytes.map.with_index { |byte, index| (byte ^ key.bytes[index % key.length]).chr }.join | |
end |
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 BinaryTree | |
def initialize | |
@root = nil | |
@left_nodes = [] | |
@right_nodes = [] | |
end | |
def insert(value) | |
@root.nil? ? @root = TreeNode.new(value) : @root.insert(value) | |
end |
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
real=Sidekiq::Queue.new('realtime') | |
jobs= real.group_by {|i| i.args} | |
jobs.delete_if {|k,v| v.size == 1} | |
jobs.map {|k,v| v[0..(v.size-2)].map {|i| i.delete }} |