Skip to content

Instantly share code, notes, and snippets.

View dmakhmutov's full-sized avatar

Damir M dmakhmutov

View GitHub Profile
1. Create command line tool for rumybine https://www.jetbrains.com/help/ruby/working-with-the-ide-features-from-command-line.html#arguments
2. Open iterm -> Profiles -> Advanced -> Semantic History -> Run command and past
[ -z "\2" ] && /usr/local/bin/mine \1 || /usr/local/bin/mine --line \2 \1
@dmakhmutov
dmakhmutov / rails-jsonb-queries
Created June 6, 2019 14:47 — forked from mankind/rails-jsonb-queries
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")
module Enumerable
def cluster
cluster = []
each do |element|
cluster.last && cluster.last.last == element ? cluster.last << element : cluster << [element]
end
cluster
end
end
@dmakhmutov
dmakhmutov / test
Last active August 29, 2015 13:57
module Enumerable
def cluster
cluster = []
each do |element|
if cluster.last && cluster.last.last == element
cluster.last << element
else
cluster << [element]
end
end