Capturing ctrl+z key combination in javascript

Use onkeydown (or onkeyup), not onkeypress Use keyCode 90, not 122 function KeyPress(e) { var evtobj = window.event? event : e if (evtobj.keyCode == 90 && evtobj.ctrlKey) alert(“Ctrl+z”); } document.onkeydown = KeyPress; Online demo: http://jsfiddle.net/29sVC/ To clarify, keycodes are not the same as character codes. Character codes are for text (they differ depending on the … Read more

Finding all possible combinations of numbers to reach a given sum

This problem can be solved with a recursive combinations of all possible sums filtering out those that reach the target. Here is the algorithm in Python: def subset_sum(numbers, target, partial=[]): s = sum(partial) # check if the partial sum is equals to target if s == target: print “sum(%s)=%s” % (partial, target) if s >= … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)