A couple of snippets for things I have to do a lot but forget how every once in a while
{ a: 'a', b: 'b' }.map { |k, str| [k, "%#{str}%"] }.to_h
# I have an array of hashesarray = [ {id: 1, name: "test"} ]# I want to turn it to a hash, where the key is `id`array.map { |h| [h[:id], h] }.to_h#=> { 1 => {:id => 1, :name => "test"} }