Author Archives: ronaldpringadi

Colorize Linux Shell Menu

Do you ever feel like you’re going blind because the prompt text color and the result text color are the same? Here’s how to colorize your shell prompt. Open your favorite text editor (vim or nano), edit your ~/.bashrc, and … Continue reading

Posted in Linux, Operating System, Ubuntu | Comments Off on Colorize Linux Shell Menu

Edit default Gnome-Terminal

Every time I open a shell terminal in my Ubuntu, I always think that the window size is too small. I always ended up resizing the shell window manually using the mouse. If you’re having this problem here is how … Continue reading

Posted in Linux, Ubuntu | Comments Off on Edit default Gnome-Terminal

Add an Existing User to an Existing Group on Linux

1usermod -a -G GROUPNAME USERNAME

Posted in Linux | Comments Off on Add an Existing User to an Existing Group on Linux

Backup and Restore Postgres Using pg_dump and psql

This is how you backup your Postgres Database To Backup 1pg_dump –host=localhost –port=5432 –username=postgres –file=YOUR_FILENAME.sql YOUR_DB_NAME There are other options such as if you’re interested only on the structure then you can add: 1pg_dump –host=localhost –port=5432 –username=postgres –schema-only –format=p –create … Continue reading

Posted in Database, PostgreSQL | Comments Off on Backup and Restore Postgres Using pg_dump and psql

Setting Session Authorization and Search Path

SET SESSION AUTHORIZATION jane; SET search_path = schema1,schema2, schema3; SELECT * FROM any_table_in_schema_1_2_or_3;

Posted in Database, PostgreSQL | Comments Off on Setting Session Authorization and Search Path

Implicit Casting in PostgreSQL

12CREATE CAST(integer AS character varying) WITH INOUT AS IMPLICIT; CREATE CAST (character varying AS integer) WITH INOUT AS IMPLICIT;

Posted in Database, PostgreSQL | Comments Off on Implicit Casting in PostgreSQL

Integer Array Casting in PostgreSQL

123456– Rule: "_DELETE" ON sometable — DROP RULE "_DELETE" ON sometable; CREATE OR REPLACE RULE "_DELETE" AS     ON DELETE TO sometable DO INSTEAD  DELETE FROM _sometable  WHERE _sometable.account_id = old.account_id AND (old.domain_id = ANY ((( SELECT get_visible_domains(‘DELETE’::text) AS … Continue reading

Posted in Database, PostgreSQL | Comments Off on Integer Array Casting in PostgreSQL

Tracing PostgreSQL Error Log

1/pgsql/dev-db/tail -f postgresql.log

Posted in Database, Linux, PostgreSQL | Comments Off on Tracing PostgreSQL Error Log

Reset Sequence using PostgreSQL

1SELECT setval(‘YOUR_SEQUENCE_NAME’, (SELECT MAX(id) FROM YOUR_TABLE_NAME));

Posted in Database, PostgreSQL | Comments Off on Reset Sequence using PostgreSQL