Skip to content

Instantly share code, notes, and snippets.

@sabrinagannon
sabrinagannon / rails-jsonb-queries
Created May 25, 2022 13:46 — forked from mankind/rails-jsonb-queries
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")
@sabrinagannon
sabrinagannon / convert_with_pandoc.sh
Created September 28, 2020 23:56
Convert all markdown files in a directory to pdf
find . -name "*.md" -type f -exec sh -c '
pandoc -f markdown -t pdf -o "${1%.*}.pdf" "$1"
' find-sh {} \;
@sabrinagannon
sabrinagannon / pre-push
Created August 20, 2019 14:10
Git hook to prevent pushing directly to a given branch (master in this case)
protected_branch='master'
if [ $protected_branch = $current_branch ]
then
read -p "You're about to push the master branch, is that what you intended? [y|n] " -n 1 -r < /dev/tty
echo
if echo $REPLY | grep -E '^[Yy]$' > /dev/null
then
exit 0 # push will execute
fi
exit 1 # push will not execute
@sabrinagannon
sabrinagannon / submodules.md
Created May 12, 2019 17:16 — forked from manasthakur/submodules.md
Using git submodules to version-control Vim plugins

Using git-submodules to version-control Vim plugins

If you work across many computers (and even otherwise!), it's a good idea to keep a copy of your setup on the cloud, preferably in a git repository, and clone it on another machine when you need. Thus, you should keep the .vim directory along with your .vimrc version-controlled.

But when you have plugins installed inside .vim/bundle (if you use pathogen), or inside .vim/pack (if you use Vim 8's packages), keeping a copy where you want to be able to update the plugins (individual git repositories), as well as your vim-configuration as a whole, requires you to use git submodules.

Creating the repository

Initialize a git repository inside your .vim directory, add everything (including the vimrc), commit and push to a GitHub/BitBucket/GitLab repository:

cd ~/.vim