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;


How to receive email alerts on Selinux denials on RHEL and CentOS

Firts of all install a few packages to get started:

yum install setroubleshoot{-server,-plugins,-doc}

Assuming that the system has been configured to use an smpt relay do:

echo “<your-email-address>       filter_type=never” > /var/lib/setroubleshoot/email_alert_recipients
service auditd restart ; service messagebus restart

The option filter_type can be customized as needed. A valid list of options are:

  1. after_first. This option will allow the system to sent you the first denial notification and then silence them.
  2. never. This option will never filter out notifications
  3. alway. This option will always silence notifications.

If you need to set an different email server, open /etc/setroubleshoot/setroubleshoot.conf in your favorite text editor and adjust the [email] section to fit your server:

recipients_filepath = /var/lib/setroubleshoot/email_alert_recipients
smtp_port = 25
smtp_host = localhost
from_address =
subject = [MyServer] SELinux AVC Alert

Hope this saves you from some trouble searching.

How To setup remote syslog on Vmware ESXi 5.x

To enable remote syslog for wmare esxi 5.x you need to do it from the cli using an ssh terminal

First open an ssh connection to esxi server and see your current configuration

~ # esxcli system syslog config get
Default Network Retry Timeout: 180
Local Log Output: /scratch/log
Local Logging Default Rotation Size: 1024
Local Logging Default Rotations: 8
Log To Unique Subdirectory: false
Remote Host: <none>

As you can see Remote Host setting is not set yet. So we need to specify it

 ~ # esxcli system syslog config set –loghost=’tcp://<your-syslog-server-ip-here>:514′


 ~ # esxcli system syslog config set –loghost=’udp://<your-syslog-server-ip-here>:514′

Now let see again the settings

# esxcli system syslog config get
Default Network Retry Timeout: 180
Local Log Output: /scratch/log
Local Logging Default Rotation Size: 1024
Local Logging Default Rotations: 8
Log To Unique Subdirectory: false
Remote Host: udp://<your-syslog-server-ip-here>

Then reload syslog configuration for changes to take effect

esxcli system syslog reload

Happy sysloging 😉


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: