Monthly Archives: January 2013
Git undo, reset or revert?
Also useful:
1 |
git rm -r --cached * |
That will recursively remove every file from the index (files staged for commit).
Temporarily Disable PostgreSQL Triggers
To temporarily disable all triggers in a PostgreSQL session, use this:
1 |
SET session_replication_role = replica; |
That disables all triggers for the current database session only. Useful for bulk operations, but remember to be careful to keep your database consistent.
To re-enable:
1 |
SET session_replication_role = DEFAULT; |
Disable a Single Trigger
To disable just a single trigger, use ALTER TABLE:
1 |
ALTER TABLE mytable DISABLE TRIGGER mytrigger; |
The difference to the previous method is that ALTER TABLE will globally disable the trigger, affecting all database sessions, not just the current one.
To disable all triggers for one table:
1 |
ALTER TABLE mytable DISABLE TRIGGER ALL; |
To re-enable:
1 |
ALTER TABLE mytable ENABLE TRIGGER ALL; |
Ubuntu 12.04 Active Directory Authentication
Update 2015-06-16: Ubuntu 14.04 Active Directory Authentication
Authenticating Linux users against Active Directory has traditionally been hard. There’s a multitude of HOWTOs on how to do it, and every one of them seems to do it a bit differently. This is because environments and goals vary, and there are many ways to achieve a particular goal. I will add my version to the mix. This one fetches users and groups from Active Directory LDAP using a machine account added using the Samba tools, and authenticates users to the Active Directory Key Distribution Center using Kerberos. Continue reading Ubuntu 12.04 Active Directory Authentication
Checking PostgreSQL Disk Usage
This query sums total disk space used by the table including indexes and toasted data for the 20 largest tables:
1 2 3 4 5 6 7 8 9 |
SELECT nspname || '.' || relname AS "relation", pg_size_pretty(pg_total_relation_size(C.oid)) AS "total_size" FROM pg_class C LEFT JOIN pg_namespace N ON (N.oid = C.relnamespace) WHERE nspname NOT IN ('pg_catalog', 'information_schema') AND C.relkind <> 'i' AND nspname !~ '^pg_toast' ORDER BY pg_total_relation_size(C.oid) DESC LIMIT 20; |