A student who took a "cocktail" of drugs before being found naked outside a shopping centre in the early afternoon has avoided a conviction.
Sean O'Brien (21) was upset after videos of him were posted on social media.
He was also in a state of shock after a friend suffered "a bad turn" and he had to give him cpr.
O'Brien had also taken LSD for the first time and this, combined with alcohol and cocaine, caused him to behave in a way he would not normally do.
Judge David McHugh struck out the charges after O'Brien completed the restorative justice services programme and made a donation to charity.
The defendant, of Castleknock Way, Castleknock, admitted public drunkenness and threatening and abusive behaviour when he appeared before Blanchardstown District Court.
He also admitted criminal damage to a patrol car and possession of cocaine.
The incident took place at around 2.30pm last May 5.
Sgt Geraldine McManigan previously said gardai received calls about a naked man at Laurel Lodge, Castleknock.
O'Brien had no clothes on and was holding his trousers in his hand.
The defendant was very intoxicated and tried to run from the scene.
He was extremely agitated and aggressive towards gardai, the sergeant said.
His clothes were searched and gardai found cocaine worth €150.
O'Brien was taken to Blanch- ardstown Garda Station, and he urinated and defecated in the patrol car on the way to the station.
The court heard he had never been in trouble before.
Defence solicitor Mark O'Sullivan said O'Brien, a business management student, had been at a party and had taken a "cocktail" of alcohol, cocaine and LSD, which he had used for the first time.
Mr O'Sullivan said a friend had had a "bad turn" and O'Brien gave him cpr. The friend has since recovered.
However, the shock of his friend's state combined with the LSD caused the defendant to behave in such a way.