There are a few links on Stack Overflow about this topic but the solutions seem old (link, link).  I figured out how to do this correctly in the latest version of AngularJS (v1.4.0 as of writing this).

Then add the interceptor to the pipeline like this in your function.

As a side note, I left my session injection code in there.  I use this to insert a sessionid header into every request.  You can remove that part and rename this interceptor from sessionInjector to unauthorizedToLoginInterceptor if you wish.

TL;DR – Use SELECT * FROM functionName(); vs SELECT functionName();

Given the following custom data type in PG:

I created a simple function that selects the correct counts to fill this data type correctly and then returns the data type as a result.

So there are a few ways to use this function.  The first IMHO is useless:

Which results in the following result:

Screen Shot 2015-04-18 at 6.26.16 PM

However querying the following way results in a more useful response:

Which give a useful response:

Screen Shot 2015-04-18 at 6.27.59 PM

First connect to the PG server using psql and as your DB owner account or the superuser account.

$> psql

Create the user and set a password.  Here I am creating user rouser with a password of R34D0NLY.


Next, switch to your database context (here my database is named mydatabase, and my superuser is named postgres)

postgres=# \connect mydatabase;

The prompt will switch to:


No execute the following (be sure to swap out your username with my rouser username):

Now your user has readonly access to the schema public.  If you are creating tables and other database objects in another schema you will need to do the same thing but replace public with your other schema name.

Allow a user to use a sequence:


I have been using JetBrains new 0XDBE to do some database development on PostgreSQL.  I installed PostgreSQL myself on my linux VPS and immediately got frustrated with the following error:

java.sql.SQLException: SSL error: PKIK path building failed: unable to find valid certification path to requested target.


Data Sources and Drivers


The error is confusing but luckily the fix is simple.

In the Data Source settings add: org.postgresql.ssl.NonValidatingFactory to the sslfactory setting in the Advanced tab.



After adding that setting click apply and then test the connection again and you should be good to go.



Working on an Android application at the moment and needed a quick way to make calls to a REST api.  I found Luke’s post very helpful.

There were some quote corruptions and a missing enum so I fixed those and provided a zip file for the class.  This is NOT MY WORK, please thank Luke for his work 5 years ago.

UPDATE: I added the ability to do basic auth with this class and the ability to attach a JSON object to the request.  In my opinion it makes this class a lot more useful.