Brachos 9:3-4
Brachos 9:3
If a person builds a new house or acquires new utensils, he recites the blessing of shehechiyanu. One recites “the true Judge” on bad news even if has a positive side, and one recites “Who is good and causes good” on good news even if it has a negative side. If one prays to change something that has already happened, he prays in vain. For example, if he prays for a boy when his wife is already pregnant (because the sex is already determined) or if he hears a cry and prays “please let that not be from my house” (because it either was or it wasn’t).
Brachos 9:4
One who enters a city recites two prayers - one upon entering (that he should do so in peace) and one upon exiting (that he should do so in peace). Ben Azzai says that he recites four prayers two upon entering (one that he should do so in peace, followed by thanks for same) and two upon exiting (one that he should do so in peace, followed by thanks for same).