JavaScript – Check if a variable is an integer

function isInt(value) { return !isNaN(value) && parseInt(Number(value)) == value && !isNaN(parseInt(value, 10)); } Tests: isInt(7) // true isInt(“7”) // true isInt(7e5) // true isInt(“7e7″) // true isInt(” 7 “) // true isInt(“”) // false isInt(“…

Prevent sql injection with php

Here is a simple function to prevent Sql Injection with PHP. Just recall it and check both GET and POST parameters <?php function checkInjection() { $badchars = array("DROP", "SELECT", "UPDATE", "DELETE", "INSERT", "TRUNCATE", "UNION ALL",…

JS Minify 1.3.2 Released

To make JS Minify more and more complete, we started implementing some options. Version 1.3.2 provides: remove unreachable code drop unreferenced functions and variables join consecutive var statements preserve comments discard calls to console.* functions…

Python – Run two threads and stop them

In this post i extend an example found on stackoverflow.com, here’s how to launch two simultaneous threads and stop them after 5 seconds. import threading import time def doit(arg): t = threading.currentThread() while getattr(t, “do_run”,…