I am not sure if Iam allowed to use it in a commerial application without limits
Most open source licenses are redistribution licenses, which means use isn't generally affected (or asserted to be affected) while (re)distribution is only permitted if certain requirements are met.
For example, the MIT license requires that its copyright be preserved. Most open source licenses have a similar requirement (including the BSD licenses). This means that wherever your program displays its copyright, it needs to additionally display the copyrights of any code you've lifted. If you do not do this, you do not have the right to redistribute your code (with the embedded MIT-licensed code).
The GPL is notable in that it additionally requires that your software be redistributable under the terms of the GPL. This means using GPL-licensed code, and redistributing your program, essentially makes your program GPL. The high-quality of some GPL programs has been successfully used to "free" previously non-free software.
There are some subtleties I'm glazing over here, but the answer you need is probably: ask the author of the code snippet. If this is impossible or impractical, ask a lawyer who is well-versed in copyright law, and especially familiar with software.