Javascript: Convert image binary to base64 string

private convertImagetoURI(data): string {
let str = data.reduce(function (a, b) { return a + String.fromCharCode(b) }, ”);
return btoa(str).replace(/.{76}(?=.)/g, ‘$&\n’);

Considering that you get the image as binary data from an API call, use the above the function to pass the response and get back the string image.

Add it to you src in your image tag:

var imageSRC = ‘data:image/jpeg;base64,’ + this.convertImagetoURI(result.responseObject.Body)

<img src =imageSRC />

In angular2 you have to sanitize the string otherwise you  will get an xss error.

import DomSanitizer,

create a variable (e.g sanitizer :Domsanitizer)

use the bypassSecurity* functions


this.sanitizer.bypassSecurityTrustResourceUrl(‘data:image/jpeg;base64,’ + this.convertImagetoURI(result.responseObject.Body)) as string;


Oracle (plsql) scripts

Calculate first and last day of each month

Use the below script to select the last and first day for a number of months.

select trunc(add_months((sysdate),-level),'MM') date_from,
        trunc(add_months(last_day(sysdate),-level)) date_to
   from dual
connect by level < to_char(sysdate,'MM')+12 /*count since first month add +12 for 1 year back etc*/

Two more different approaches for calculation of last day of each month.

select last_day(to_date(t2.yy||'-'||t1.mon||'-01', 'YYYY-MM-DD')) foo
from (select level mon from dual connect by level < 13) t1,
     ( select distinct extract (year from date_period) yy from date_to) t2
order by 1 desc

  from dual m
order by 1 desc

Function to convert rows in separated-string

create or replace function append_field(sqlstr in varchar2, sep in varchar2 )
return varchar2 is
  ret varchar2(4000) := '';
  type cur_typ is ref cursor;
  rec cur_typ;
  field varchar2(4000);
     OPEN rec FOR sqlstr;
         FETCH rec INTO field;
         EXIT WHEN rec%NOTFOUND;
         ret := ret || field || sep;
     END LOOP;
     if length(ret) = 0 then
          RETURN '';
          RETURN substr(ret,1,length(ret)-length(sep));
     end if;

Function of oracle to convert rows in separated-string

select comp_emp.department , 
       listagg(user_login, ',') within group (order by department) as employees
  from comp_emp, employees, supplier_addresses
 where comp_emp.emp_code = employees.emp_code 
   and = supplier_addresses.recno 
   and in ( to_date('13-05-1926 15:02:34','DD-MM-YYYY HH24:MI:SS') )
  group by  comp_emp.department

BIRT :: Internet Explorer (IE) compatibility problem

In case Internet Explorer needs compatibility mode to show the report, try adding the following code on <head> section to the webapps/birt/webcontent/birt/pages/layout/FramesetFragment.jsp (line 46)

<!-- Mimics Internet Explorer 7, it just works on IE8. -->
<META HTTP-EQUIV="X-UA-Compatible" CONTENT="IE=EmulateIE7">

BIRT :: Cascaded Parameters

BIRT provides the capability to use dynamic parameters to present the end user with a list of choices that are populated from a dataset. This is very useful but can cause issues when the dataset returns many rows of data. To reduce the number of items in any parameter, the developer can use a cascaded parameter, which allows multiple levels and multiple datasets. When the user selects the first level parameter in a cascaded parameter group the second level in the group is automatically re-queried…….

Source : BIRT Cascaded Parameters

BIRT :: Date tips & tricks

Get the first day of month

Use the following expression to get it
BirtDateTime.addDay(, ( ))

Get the last day of previous month

Use the following expression to get it
BirtDateTime.addDay(, ( ))

Get the previous quarter day (since now)

Use the following expression to get it
BirtDateTime.addDay(BirtDateTime.addQuarter(,-2), ( )+1)

BIRT :: Rownum for sorted crosstab

  1. Put something like: var i = 0, in your initialize script.
  2. Then, instead of trying to use your rownum field as a dimension, just put a 2 column / 1 row grid in where your name field is.
  3. Put the name field in the right cell and a dynamic textbox in the left cell. For the dynamic textbox expression, put i++; i;.
  4. Now, for each row, the variable i will increment and then display in the textbox, giving you a row number.
In case you have a lot of crosstabs in the same report,  put more than one variables on the initialize script

var i = 0;
var j = 0;
var k = 0;
var l = 0;
var m = 0;
var n = 0;

and repeat the above steps.

Source: Rownum for sorted crosstab

%d bloggers like this: