Skip to content

Instantly share code, notes, and snippets.

View thnery's full-sized avatar
🎸
Playing The Blues

Tácio Nery thnery

🎸
Playing The Blues
View GitHub Profile
@mankind
mankind / rails-jsonb-queries
Last active January 29, 2024 05:38
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")
@henriquemenezes
henriquemenezes / android-generate-keystores.md
Last active March 16, 2024 01:43
Android: Generate Release/Debug Keystores

Android: Generate Release/Debug Keystores

Generate Keystores

Debug Keystore

$ keytool -genkey -v -keystore debug.keystore -storepass android -alias androiddebugkey -keypass android -keyalg RSA -keysize 2048 -validity 10000 -dname "C=US, O=Android, CN=Android Debug"
@henriquemenezes
henriquemenezes / vim.md
Last active February 18, 2020 04:22
Vim

Vimtutor:

Tips & Tricks

	:source $MYVIMRC	Reload .vimrc without restart vim, after reload run :e
	:e 			Reload buffer and trigger FileType event

Modes:

@Kartones
Kartones / postgres-cheatsheet.md
Last active March 19, 2024 06:01
PostgreSQL command line cheatsheet

PSQL

Magic words:

psql -U postgres

Some interesting flags (to see all, use -h or --help depending on your psql version):

  • -E: will describe the underlaying queries of the \ commands (cool for learning!)
  • -l: psql will list all databases and then exit (useful if the user you connect with doesn't has a default database, like at AWS RDS)
@sj26
sj26 / array-pluck.rb
Created December 9, 2011 03:05
Gather values from an array of hashes
class Array
def pluck key
map { |hash| hash[key] }
end
end
[{:number => "1"}, {:number => "2"}, {:number => "3"}].pluck(:number)
# => ["1", "2", "3"]