When one of you intend to wear footwear such as shoes or socks, he should first ensure nothing is inside the footwear such as insects or sharp objects. Turning the shoes upside down and shaking it will usually remove anything inside.
This was the practice of the Prophet of Allah 
which he ordered after a snake crawled into his sock without him knowing. Allah sent a large bird to remove the snake before it caused any harm to the prophet.
- The Prophet of Allah  was once wearing socks in a jungle. He wore the first sock and was intending to put on the second sock when a crow dived in and carried off the sock. The crow flew at a great height and dropped the sock on the ground. The shock of landing threw out a snake from the sock which fell at some distance. On seeing this, the Prophet of Allah  offered thanks to Allah and said 'It is the duty of every Muslim that on intending to wear socks, he should shake them first (making sure they are safe to wear)'