Sunday, May 19, 2013

How to find id of enclosing tr

var myId = $(this).closest('tr').attr('id');

How to post without redirecting / reloading the page

$.post(action, $('#MY_FORM').serialize());

How to deal with dots in HTML id

/* "." and ":" are problematic within the context of a jQuery selector
 * because they indicate a pseudo-class and class, respectively */
myId = myId.replace(/(:|\.)/g, "\\$1");

Thursday, May 2, 2013

PL/SQL: sum per month

SELECT TO_CHAR(CDR_DATE, 'mm/yyyy') MONTH, SUM(CHARGED_VOL) CHARGED_VOL FROM...GROUP BY TO_CHAR(CDR_DATE, 'mm/yyyy')

PL/SQL: date to epoch

SELECT (TO_DATE('26/10/2012 12:34:14', 'dd/mm/yyyy hh24:mi:ss') - TO_DATE('01/01/1970', 'dd/mm/yyyy')) * 86400 FROM DUAL;

Diff 2 XML files

Let's say we have XML files stripped on 1 line and we want to compare them.
We just need to re-format them, then use whatever tool to compare them (e.g. diff or p4merge)
xmllint --format /tmp/GET_SUB_INFO.log > /tmp/13.xml

Perl: Date to epoch

perl -MDate::Parse -e 'print str2time("01/25/2013 19:23:22 UTC"), "\n"'