Fix Microsoft Mouse in Linux Ubuntu

nano /etc/X11/xorg.conf

Section "InputDevice"
Identifier "Configured Mouse"
Driver "mouse"
Option "CorePointer"
# Option "Device" "/dev/input/mice"
Option "Protocol" "ExplorerPS/2"
Option "Emulate3Buttons" "false"
Option "ZAxisMapping" "4 5"
Option "ButtonMapping" "1 2 3 6 7"
EndSection

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?
We here is how to colorize your shell menu

Open your favorite text editor vim or nano, and add this at the end

$ nano ~/.bashrc
PS1='\[\e[1;32m\][\u@\h \t \w]\$\[\e[0m\] '

0;30 black
0;31 light red
0;32 light green
0;33 light yellow
0;34 light blue
0;35 light purple
0;36 light cyan

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. I you’re having this problem here is how to fix it permanently.
gnome-terminal --geometry=80x25 -x /home/janne/.adom/adom

Backup and Restore Postgres Using pg_dump and psql

This is how you backup your Postgres Database

To Backup

pg_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:

pg_dump --host=localhost --port=5432 --username=postgres --schema-only --format=p --create --inserts --file=YOUR_FILENAME.sql YOUR_DB_NAME

To Restore

psql -Upostgres -hlocalhost YOUR_DB_NAME < YOUR_FILENAME.sql

Integer Array Casting in PostgreSQL


-- 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 get_visible_domains)::integer[])));