Tuesday, November 15, 2016

Git: use external diff command

git difftool --extcmd=diff sql/mbqt_prov_api.sql

Monday, November 7, 2016

PostgreSQL: remove all Bucardo triggers from a schema

do
$$
declare
    _row record;
    _query text;
begin
    for _row in SELECT tgname, tgrelid::regclass as table_name FROM pg_trigger where tgname ~ 'bucardo' and tgrelid::regclass::text ~ 'shared_db' loop
        _query := format('drop trigger %s on %s', _row.tgname, _row.table_name);
        raise notice '%', _query;
        execute _query;
    end loop;
end
$$;

Sunday, November 6, 2016

Google Drive web hosting is shutting down

An alternative is to use Google Firebase.

Create new project on Firebase console :
Select Storage :
Import your files :
Edit your template in Blogger :
Copy the Firebase URL of the file you want to use in Blogger :
Replace your Google Drive URL :
Save your template and you will get an error about token :
To workaround the token issue, go to the Google URL shortener, and paste the Firebase URL :
Copy the short URL :
Replace the Firebase URL with the shortened one in Blogger :
[2021-09-05 Edit]
syntaxhighlighter has stopped working for some time now. The Web Dev Tools console in FF shows the following error:
The resource from “https://goo.gl/kQztrh” was blocked due to MIME type (“text/html”) mismatch (X-Content-Type-Options: nosniff).
So, it seems as if something changed either in the Google shortener behavior, or maybe in FF itself.
Let's try to re-use the original URLs instead of the shortened ones. As the Blogspot UI changed, you now need to go to "Themes", and click the "Customize" button.
Then select the "Edit HTML" menu item.
But using, e.g. "https://firebasestorage.googleapis.com/v0/b/syntaxhighlighter-2b128.appspot.com/o/scripts%2FshBrushPhp.js?alt=media&token=1533c104-e33b-43fa-b299-c2dd8c8f81ab" instead of "https://goo.gl/kQztrh" brings back the old error:
which is actually caused by the use of "&token=" instead of "&token=".
Once all the URLs have been substituted and the "&token=" occurences replaced, we're back in tracks :)

Thursday, November 3, 2016

PostgreSQL: Find a table columns type

From http://dba.stackexchange.com/questions/75015/query-to-return-output-column-names-and-data-types-of-a-query-table-or-view:
SELECT attname, format_type(atttypid, atttypmod) AS type
FROM   pg_attribute
WHERE  attrelid = 'foo'::regclass
AND    attnum > 0
AND    NOT attisdropped
ORDER  BY attnum;