Brooklyn judge gives troubled gun-wielder second chance to prove himself