Python - Cachetools LRUCache KeyError

If your application is threaded and you’re getting a “KeyError” while using the non-decorator version of cachetool’s LRUCache, then you need to put whatever is manipulating the cache object inside of a lock. Also, since LRUCache is modified when values are gotten from it, you will also need to make sure you’re locking when you get values from cache too. If you can use the decorator version of LRUCache, that’s preferred since it has built-in locking.

Here’s an example of the error:

And an example of the fix: https://bitbucket.org/zzzeek/dogpile.cache/pull-requests/32/add-a-cachetools-lru-lfu-in-memory-backend/diff#comment-22242704

Javascript's Round vs PHP's Round

Today I learned that by default PHP rounds differently than javascript.

PHP (using the default PHP_ROUND_HALF_UP)

php > echo round(-1.5);
-2

“Round val up to precision decimal places away from zero, when it is half way there. Making 1.5 into 2 and -1.5 into -2.”

https://secure.php.net/manual/en/function.round.php

Javascript

Math.round(-1.5);
-1

“For negative numbers, if the decimal portion is exactly -0.5, the return value is the smallest integer that is greater than the number.”

https://msdn.microsoft.com/en-us/library/5cza0web(v=vs.94).aspx

Datatables - Uncaught TypeError: Cannot read property 'style' of undefined

If you see this error in datatables: “Uncaught TypeError: Cannot read property ‘style’ of undefined”

It’s likely that you’re missing a header column in your table. Make sure you have the same number of <th> elements as items in the “columns” section of your datatables initialization.

Javascript Data Tables

Updated 2026-09-08: mindmup/editable-table and daniel-nagy/md-data-table are now archived on GitHub. Swapped the SlickGrid link for 6pac/SlickGrid, the actively maintained fork of the original.