Friday, January 13, 2017

sort string elements in an array object

$scope.source.specializations.sort(function(a, b) {
    var textA = a.specialization.toUpperCase();
    var textB = b.specialization.toUpperCase();
    return (textA < textB) ? -1 : (textA > textB) ? 1 : 0;
});

robomongo insert a doc

db.specialization.insert({specialization:'', programArea:'', visibility:true})

Friday, January 6, 2017

posgresql select case

Just to help if anyone stumble on this question like me, if you want to use if in PostgreSQL, you use "CASE"
select 
    case
        when stage = 1 then 'running'
        when stage = 2 then 'done'
        when stage = 3 then 'stopped'
    else 
        'not running'
    end as run_status from processes

Tuesday, January 3, 2017

regex tool

http://www.regexr.com/v1/desktop/

download desktop version

replace 1 with 2016

I have a database with year value 1=>2016, 2=> 2017, 3=>2015

use Pentaho data integration transformation

^.{0,1}[1]$ is used to match 1 with length 1
^.{0,1}[2]$ is used to match 2 with length 1
....