This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def clear(i): | |
if isinstance(i, basestring): | |
return '' | |
elif isinstance(i, int): | |
return 0 | |
elif isinstance(i, float): | |
return 0.0 | |
elif i is None: | |
return None | |
elif isinstance(i, dict): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Based on https://gist.github.com/petere/6023944 | |
set -eux | |
sudo apt-get update | |
packages="python-setuptools postgresql-$PGVERSION postgresql-server-dev-$PGVERSION postgresql-common" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* Assumes that applications connect as 'my_project__blah' and that you've done GRANT my_project__app to my_project__blah. | |
* Also assumes that select_roles is a list of groups, like "my_project__dev", "my_project__read_only", etc. | |
*/ | |
CREATE FUNCTION ddl_tools.schema__defaults( | |
schema_name name | |
, select_roles text | |
) RETURNS void LANGUAGE plpgsql AS $body$ | |
DECLARE | |
select_template CONSTANT text := $template$ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CREATE OR REPLACE FUNCTION lambda( | |
code text | |
, VARIADIC inputs anyarray | |
) RETURNS anyelement LANGUAGE plpgsql AS $body$ | |
DECLARE | |
c_prefix CONSTANT text := 'lambda_function_'; | |
c_pattern CONSTANT text := '^' || c_prefix || '([0-9]+)$'; | |
fname text; | |
foid regprocedure; | |
fargs regtype[]; |