Skip to content

Instantly share code, notes, and snippets.

View lenart's full-sized avatar
🎯

Lenart Rudel lenart

🎯
  • Ljubljana, Slovenia
View GitHub Profile
@nddeluca
nddeluca / gist:44e07faac0b922c94a20
Created April 8, 2015 14:47
Hash Key Conversions
class Hash
def to_underscore
convert_keys(self, :underscore)
end
def to_camel_case
convert_keys(self, :camelize, :lower)
end
def to_underscore!
@miharekar
miharekar / README.md
Last active December 9, 2020 08:36
Don't Screw Up When You SSH To Production
@mankind
mankind / rails-jsonb-queries
Last active May 3, 2025 05:37
Ruby on Rails-5 postgresql-9.6 jsonb queries
http://stackoverflow.com/questions/22667401/postgres-json-data-type-rails-query
http://stackoverflow.com/questions/40702813/query-on-postgres-json-array-field-in-rails
#payload: [{"kind"=>"person"}]
Segment.where("payload @> ?", [{kind: "person"}].to_json)
#data: {"interest"=>["music", "movies", "programming"]}
Segment.where("data @> ?", {"interest": ["music", "movies", "programming"]}.to_json)
Segment.where("data #>> '{interest, 1}' = 'movies' ")
Segment.where("jsonb_array_length(data->'interest') > 1")