Usage would typically work like this:

    Save this to a file, say 'reset.sql'
    Run the file and save its output in a way that doesn't include the usual headers, then run that output. Example: 

psql -Atq -f reset.sql -o temp
psql -f temp
rm temp

There are a few limitations to this snippet of code you need to be aware of:

    It might not work well with multiple schemas
    It only works on sequences that are owned by a table.