Mencari Sesuatu ?

Jumat, 09 Desember 2022

Vanilla JS like jquery document.ready

 Default can use this :



document.addEventListener('DOMContentLoaded', function () {

  // do something here ...

}, false);



on fully load use this :



window.addEventListener('load', function () {

  // do something here ...

}, false);







credit to source : 

https://www.codeinwp.com/snippets/jquery-document-ready-in-vanilla-javascript/

Rabu, 07 Desember 2022

Linux Screenshot melalui remote SSH terminal

ssh root@ "runuser -l  -c 'DISPLAY=:0 import -window root /tmp/screenshot.png'" 


nama_user that running or use the display / x server
for information on running user can use this command :

$> loginctl list-sessions

Selasa, 06 Desember 2022

PHP FUNCTION Send document Telegram bot channel

 



function send_file_telegram($file,$message,$channelid,$token){  
    $curl = curl_init();
    $fh=new CURLFile(realpath($file));
    curl_setopt_array($curl, [
      CURLOPT_URL => "https://api.telegram.org/bot".urlencode($token)."/sendDocument",  
      CURLOPT_RETURNTRANSFER => true,
      CURLOPT_ENCODING => "",
      CURLOPT_MAXREDIRS => 10,
      CURLOPT_TIMEOUT => 30,
      CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
      CURLOPT_CUSTOMREQUEST => "POST",
      CURLOPT_POSTFIELDS => array(
        "document"=>$fh,
        "caption"=>$message,
        "disable_notification"=>true,
        "chat_id"=>$channelid,
      ),
      CURLOPT_HTTPHEADER => [
        "User-Agent: Telegram Bot SDK",
        "Content-Type: multipart/form-data;charset=utf-8"
      ],
    ]);
   
    $response = curl_exec($curl);
    $err = curl_error($curl);
   
    curl_close($curl);
   
    if ($err) {
      echo "cURL Error #:" . $err;
    } else {
      echo $response;
    }
   
}


Senin, 05 Desember 2022

perintah hanya untuk directory zip_log dengan umur diatas 60 hari

 #perintah hanya untuk directory zip_log dengan umur diatas 60 hari

find /var/www/html/ -type d -regex ".*zip_log.*" -mtime +60 -print -exec rm -rf "{}" \;