2015-02-27

postgresql unpivot

Given a monthly currency conversion table like:
iso4127_codeJanFebMarAprMayJunJulAugSepOctNovDec
JPY0.0096130.0097920.0097780.0097570.0098270.0097900.0098290.0097170.0093460.0092620.0086060.008375

I need to unpivot so that I get a table that is:
iso4127_codemonthrate
JPY10.009613
JPY20.009792
...
select iso4127_code, 
unnest(array[1,2,3,4,5,6,7,8,9,10,11,12]) as month,
unnest(array[jan, feb, mar, apr, may, jun, jul, aug, sep, oct, nov, dec]) as rate
from table

Strip HTML tags using regex

While for proper Markup Language parsing one should actually use an XML parser, sometimes you just want to strip all the markup using regex:
s/<\/?[^>]+>//

Query AD using ldapsearch

(Useful for troubleshooting AD logons if you have cygwin:

http://jurjenbokma.com/ApprenticesNotes/ldapsearch_ad_query.html)

Now at: http://jurjenbokma.com/ApprenticesNotes/ldapsearch_ad_query.xhtml
to force TLS_REQCERT never:

LDAPTLS_REQCERT=never ldapsearch ...