What is a NullReferenceException, and how do I fix it?

What is the cause? Bottom Line You are trying to use something that is null (or Nothing in VB.NET). This means you either set it to null, or you never set it to anything at all. Like anything else, null gets passed around. If it is null in method “A”, it could be that method “B” passed a null to method “A”. null can have different meanings: Object variables … Read more

How to change CSS using jQuery?

Ignore the people that are suggesting that the property name is the issue. The jQuery API documentation explicitly states that either notation is acceptable: http://api.jquery.com/css/ The actual problem is that you are missing a closing curly brace on this line: Change it to this: Here’s a working demo: http://jsfiddle.net/YPYz8/

Sleep for milliseconds

Note that there is no standard C API for milliseconds, so (on Unix) you will have to settle for usleep, which accepts microseconds:

Curve curvature in numpy

EDIT: I put together this answer off and on over a couple of hours, so I missed your latest edits indicating that you only needed curvature. Hopefully, this answer will be helpful regardless. Other than doing some curve-fitting, our method of approximating derivatives is via finite differences. Thankfully, numpy has a gradient method that does these difference calculations for us, … Read more

How do I list all files of a directory?

os.listdir() will get you everything that’s in a directory – files and directories. If you want just files, you could either filter this down using os.path: or you could use os.walk() which will yield two lists for each directory it visits – splitting into files and dirs for you. If you only want the top directory you can break the first time it yields or, shorter: