Skip to content

Instantly share code, notes, and snippets.

View roadhouse's full-sized avatar

Jean Uchôa roadhouse

View GitHub Profile
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 }}
@roadhouse
roadhouse / code.ruby
Created June 28, 2023 14:53 — forked from cleicar/code.ruby
Get the largest branch in a Binary Tree in Ruby
class BinaryTree
def initialize
@root = nil
@left_nodes = []
@right_nodes = []
end
def insert(value)
@root.nil? ? @root = TreeNode.new(value) : @root.insert(value)
end
def xor_encrypt(string, key)
string.bytes.map.with_index { |byte, index| (byte ^ key.bytes[index % key.length]).chr }.join
end