R. Samuel bar Nahmani said: "He makes even his enemies to be at peace with him" (Proverbs 16:7) — this refers to the serpent, of whom it is written, "And I will put enmity, etc." (Genesis 3:15). And when the Holy One, blessed be He, is pleased with the ways of a person, He makes it at peace with him. There was an incident concerning a certain serpent who came darting from the field. It entered the house of a man on the eve of the Sabbath as it was growing dark, and it saw a bowl of crushed garlic placed upon the table. It put its mouth over it to eat the garlic, and when it had eaten, it vomited into the bowl, and it covered the bowl just as it had been at first. Another serpent of the house saw it. What did it do? It went and uncovered the bowl. And they found it uncovered, and they poured it out. Who caused this householder not to die? That serpent which uncovered it. Thus: "When the LORD is pleased with the ways of a man, etc." (Proverbs 16:7).
The Serpent Who Spared a Householder on Sabbath Eve
Midrash Tanchuma Buber, Beshalach 3:3
ר' שמואל בר נחמני אמר גם אויביו ישלים זה הנחש, שכתיב בו ואיבה אשית וגו' (בראשית ג טו), וכשהקב"ה רוצה בדרכיו של אדם הוא משלים אותו לו. מעשה בנחש אחד שהיה ב ומרתיע מן השדה, נכנס לתוך ביתו של אדם ערב שבת עם חשיכה, וראה קערה של שום שחוק נתונה על השולחן, נתן פיה עליה לאכול את השום, וכשאכלו הקיאו לתוכה, וכיסה את הקערה, כשם שהיתה מתחילה, ראה אותו נחש אחר של בית, מה עשה, הלך וגילה את הקערה, ומצאו אותה מגולה ושפכוה, מי גרם לבעל הבית הזה שלא מת, אותו נחש שגילה אותה, הוי ברצות ה' דרכי איש וגו'.