Skip to content

Instantly share code, notes, and snippets.

@zxdvd
zxdvd / .bash_profile
Created October 15, 2016 06:02
osx .bashrc
# Setting PATH for Python 3.5
# The orginal version is saved in .bash_profile.pysave
PATH="/Library/Frameworks/Python.framework/Versions/3.5/bin:${PATH}"
export PATH
##
# Your previous /Users/zxd/.bash_profile file was backed up as /Users/zxd/.bash_profile.macports-saved_2015-12-25_at_23:41:43
##
# MacPorts Installer addition on 2015-12-25_at_23:41:43: adding an appropriate PATH variable for use with MacPorts.
@zxdvd
zxdvd / postgresql_functions.sql
Last active August 20, 2018 11:02
postgresql
-- function to get user privileges of all tables in schemas
create or replace function get_user_table_privs(schemas text[], username text) returns table (username text, schema text, relname regclass, privs text[]) AS $$
select $2, n1.nspname::text, c1.oid::regclass,
array_remove(ARRAY[
(case when has_table_privilege($2, c1.oid, 'SELECT') then 'SELECT' else NULL END),
(case when has_table_privilege($2, c1.oid, 'INSERT') then 'INSERT' else NULL END),
(case when has_table_privilege($2, c1.oid, 'UPDATE') then 'UPDATE' else NULL END),
(case when has_table_privilege($2, c1.oid, 'DELETE') then 'DELETE' else NULL END),
(case when has_table_privilege($2, c1.oid, 'TRUNCATE') then 'TRUNCATE' else NULL END),
(case when has_table_privilege($2, c1.oid, 'REFERENCES') then 'REFERENCES' else NULL END),