Skip to content

Instantly share code, notes, and snippets.

@sknutsonsf
sknutsonsf / .screenrc
Last active November 26, 2022 05:08
Screenrc for emacs lovers
# Settings for Screen to allow better use of emacs
#
# Most important: rebind ctrl-A
## Control-^ (usually Control-Shift-6) is traditional and the only key not used by emacs
escape ^^^^
#
## do not trash BackSpace, usually DEL
bindkey -k kb
bindkey -d -k kb
#
@sknutsonsf
sknutsonsf / extract_table_names_with_company_id_column
Created June 20, 2015 18:28
Postgres: find all tables containing a specific column name
-- locate all table names (relname) with a company_id column:
-- extracted from http://www.postgresonline.com/journal/archives/215-Querying-table,-view,-column-and-function-descriptions.html
select n.nspname, t.spcname, c.relname
FROM pg_class As c
INNER JOIN pg_attribute As a ON c.oid = a.attrelid
LEFT JOIN pg_namespace n ON n.oid = c.relnamespace
LEFT JOIN pg_tablespace t ON t.oid = c.reltablespace
where a.attname = 'company_id'
and c.relkind='r'
order by c.relname;
@sknutsonsf
sknutsonsf / gist:e68310e7c6890c4bc669102af71dcdce
Created June 3, 2017 23:07
SUdoers example for cherrypy and celery
# This gist assumes you have a cherrypy server configured with name "powwow-webapp"
# and two celery queues -- all running on the same machine
# In production you'd want the webserver and celery should be on different machines
#Allow powwow user to restart apache and cherrypy (webapp)
Cmnd_Alias POWWOW_WEB=/bin/systemctl restart httpd, /bin/systemctl restart powwow-webapp, /bin/systemctl stop httpd, /bin/systemctl start httpd, /bin/systemctl stop powwow-webapp, /bin/systemctl start powwow-webapp
Cmnd_Alias POWWOW_CELERY=/bin/systemctl start celeryd, /bin/systemctl start long-job-celeryd, /bin/systemctl stop celeryd, /bin/systemctl stop long-job-celeryd,/bin/systemctl restart celeryd,/bin/systemctl restart long-job-celeryd
# we allow the powwow user to execute these as root without entering passwords, so they can be called from a fab script
powwow ALL=(root) NOPASSWD: POWWOW_WEB, POWWOW_CELERY