
If you live in a certain area with high temperatures and humidity, your house might be prone to attract a lot of fruit flies. They are harmless but sometimes you will need to control them using DIY methods such as this involving a water bottle, apple cider, and more simple household materials.
It seems our house has been overrun with fruit flies this fall with all the garden vegetables fruit in the house. So we built a DIY fruit fly trap to try and reduce the “herd”. My wife read about making a fruit fly trap from a water bottle so we gave it a try.
via homeconstructionimprovement
Brought to you by: Zedomax.com
DIY - How to Make a Fruit Fly Trap under a Buck!
A+Featured DIYs, apple cider, Consumer, Cool, DoItYourself!, DoItYourself!, Educational, Entertainment, fruit fly trap, Gadgets, herd, high temperatures, household materials, HOWTO, humidity, ProjectsMosquito misting system by MosquitoNix’s revolutionary mosquito control system. Take your yard back with our mosquito repellent system. Ask for a free quote on our mosquito trap today.
If your writing a shell script that writes files, its bad practice not to use trap. Useful scripts get used, copied, and shared. Users love to use Ctrl-C. If I had a nickel for every time I have heard “Ctrl-C out of it” being said by some user who did not understand the implications, I might have a few Euros. As such many, many scripts out there leave “krusties” all over the place.
Take this shell script for example:
$ cat krusties.sh
#!/bin/bash
tmpfile="/tmp/krusty"
cleanup()
{
rm -f $tmpfile
}
touch $tmpfile
sleep 5 # doing something useful here...
cleanup
It assumes that the cleanup function will always run. However, if I run the script and press Ctrl-C while its sleeping…
$ ls -l /tmp/k*
ls: /tmp/k*: No such file or directory
$ ./krusties.sh
^C
$ ls -l /tmp/k*
-rw-rw-r-- 1 brock brock 0 Oct 15 10:41 /tmp/krusty
$ rm -f /tmp/krusty
It leaves a krusty. In the best case scenario this is annoying. In the worst case it can cause serious problems. (E.g., lock files.) Now consider this modified script:
$ cat krusties.sh
#!/bin/bash
tmpfile="/tmp/krusty"
cleanup()
{
rm -f $tmpfile
exit
}
trap "cleanup" SIGINT SIGTERM
touch $tmpfile
sleep 5 # doing something useful here...
cleanup
I added the line trap “cleanup” SIGINT SIGTERM which causes the shell to execute the cleanup function on Ctrl-C and the terminate signal. If not killed, it runs cleanup on exit. This version does not leave the krusty:
$ ls -l /tmp/k*
ls: /tmp/k*: No such file or directory
$ ./krusties.sh
^C
$ ls -l /tmp/k*
ls: /tmp/k*: No such file or directory