There is no excuse for poor driving, but the only safe way of dealing with such idiots is to leave a bigger gap/distance between you and them in order to create a greater safety cacoon around you. Generally that means dropping back or even coming off and rejoining if on a motorway. Don't ever compromise your own safety.