The Mekhilta [a midrash on the book of Shemot/Exodus] to the verse: “Ye shall not make with Me gods of silver and gods of gold” (Ex. 20: 23) comments: “Do not behave towards Me as heathens behave to their gods. When happiness comes to them, they sing praises to their gods, but when retribution comes upon them, they curse their gods. If I bring happiness upon you, give thanks, and when I bring sufferings give thanks also.” 
It’s reflected in the following letter, written by the parents of Leiby Kletzky, an 8 year-old Brooklyn boy who was kidnapped on July 11, 2011 and whose body was found two days later, on July 13. 
Tammuz 19, 5771 / July 21, 2011
The traditional seven intense days of mourning (“shiva”) for our beloved Leiby are complete, but the ache in our hearts will remain forever.
We thank G-d for the nearly nine beautiful years that He entrusted us with Leiby’s pure soul. We are certain that Leiby is now looking down from heaven and blessing us all.
We would like to once again thank all our friends and neighbors; all the selfless volunteers from near and far; local, city, state, and federal agencies; and all our fellow New Yorkers and beyond who assisted us physically, emotionally, and spiritually—as well as all of God’s children around the world who held our dear Leiby in their thoughts and prayers.
We pray that none of you should ever have to live through what we did. But if any tragedy is to ever befall any of you, God forbid, you should be blessed with a community and public as supportive as ours. We feel that through Leiby we’ve become family with you all.
Many of you have asked us what you can do now in Leiby’s memory, and how you can help us find comfort. Looking back at Leiby’s all-too-short years among us, here are a few ideas:
Acts of unity and loving kindness. Let us perpetuate the feeling of collective responsibility and love expressed during the search for Leiby. An additional act of kindness toward your neighbor, or to those less fortunate than you, can go a long, long way toward perfecting our world. Putting a couple of coins into a charity box daily is one way of tangibly expressing that loving kindness.
Gratitude. Leiby deeply cherished his siddur, his prayerbook, and praying to God meant the world to him. He was known by his teachers for his concentration in prayer, always being the last to finish. In Leiby’s memory, when you wake up each morning take a few moments to pray and reflect and thank God for giving us life (“Modeh Ani” in the prayerbook).
Light. Every Friday evening our family sits down together for Shabbat dinner to the light of the Shabbat candles. A candle shines for each of our children—and Leiby’s candle will always be included. On Friday evening, please give a few coins to charity and light the candles before sunset with our beloved Leiby in mind.
Memorial fund. Together with Rabbi Binyamin Eisenberger, we have established a www.leibykletzkymemorialfund.com> memorial fund to help people in dire need, to channel the lovingkindness shown to us and our dear Leiby toward many, many others in need. We welcome your participation.
From the deepest place in our hearts, we thank you all for your help, your support and your prayers. May Leiby’s soul live on as a blessing inside each and every one of you.
Nachman and Itta Kletzky
 The Talmud also says “One should bless G-d for the bad [that happens in our lives] in the same way as for the good, as it says, “…you shall love the L-rd your G-d with all your heart, with all your soul and with all your might…’with all your might’ means [regardless of] whatever treatment is meted out to you.” (Berachot 54a; mishnah 9:5). See also:
 from http://moriyasplace.blogspot.com/2011_07_01_archive.html and elsewhere