Search This Blog

Friday, June 18, 2021

React Native - Check Application is in Background or ForeGround with Time Diff - 10 seconds Move to Login Session Expired

 1. Install the below two mandatory npm plugins.

npm install --save react-native-async-storage

npm install --save moment


2. app.js


import React, { Component } from 'react';
import { StyleSheet, Text, View, AppState } from 'react-native';
//import Routing from "./src/routing/routing";
import AsyncStorage from '@react-native-async-storage/async-storage';
import moment from 'moment';
//import { Actions } from 'react-native-router-flux';

export default class App extends Component {
constructor() {
super();
this.state = {
appState: AppState.currentState
}
}
componentDidMount() {
AppState.addEventListener('change', this._handleAppStateChange);
}
componentWillUnmount() {
AppState.removeEventListener('change', this._handleAppStateChange);
}
_handleAppStateChange = async(nextAppState) => {
this.setState({ appState: nextAppState });
if (nextAppState === 'background') {
var previousTime = new Date();
await AsyncStorage.setItem( "previousTime", previousTime.toString() );
// Do something here on app background.
console.log( "App is in Background Mode @ ", previousTime );
}
if (nextAppState === 'active') {
// Do something here on app active foreground mode.
const start = moment( await AsyncStorage.getItem('previousTime') );
const end = moment();
//in original implementation, use minutes and check with N value.
//const range = end.diff(start,'minutes');
const range = end.diff(start,'seconds');
if ( range >= 10 ){
console.log ( "App is exit the Active Range, So moving to Login screen." );
/* Actions.login({"message":"Session Exit"} ); */
}
else{
console.log( "App is in Active Range, So continue your process ...");
}
}
if (nextAppState === 'inactive') {
// Do something here on app inactive mode.
console.log("App is in inactive Mode.")
}
};
render() {
return (
<View style={styles.MainContainer}>
{/* <Routing /> */}
<Text>Current state is: {this.state.appState}</Text>
</View>
);
}
}
const styles = StyleSheet.create({
MainContainer: {
flex: 1,
justifyContent: 'center',
alignItems: 'center',
backgroundColor: '#F5FCFF',
},
text: {
fontSize: 20,
color: '#000'
}
});

Friday, May 28, 2021

Eclipse - boto3 botocore.exceptions.ProfileNotFound: The config profile () could not be found

1.  If terminal is not opening, 

Go and update the eclipse from Help->MarketPlace.

2. See whether you installed boto3 and awscli from sudo or root and now you login as same user or different, 

   if different, then uninstall the above two plugin and install with the current user. 

    pip/pip3 install boto3

    pip/pip3 install awscli


3.type aws configure

            Enter Key, access scret, region

4. type vi ~/.aws/credentials

        [default]

            aws_access_key_id = xxx

            aws_secret_access_key = xx+xx

        [vijay]

            aws_access_key_id = x

            aws_secret_access_key = x+xx


5. your python program
   
          import csv
import datetime
import os
import smtplib, ssl
import boto3

botSession=boto3.session.Session(profile_name="vijay")
iam_mag_con=botSession.client(service_name="ec2",region_name='us-east-2')
resp = iam_mag_con.describe_regions()

....... 

Tuesday, May 11, 2021

Eclipse - PHP Fatal error: Call to undefined function json_decode()

Add PHP 

1. Window->Preferences->Installed PHPs-> Add

    /usr/bin/<search php> select /usr/bin/php7.4.x

2. Check "Window->Preferences->Installed PHPs" checkbox "Use system default php.ini configuration" must be enabled. And I had to setup "apt install php-json" on my Ubuntu.

3. Enable Debug

   Open Terminal -> sudo apt-get install php-xdebug

4. Check "Window->Preferences->Installed PHPs" ->Debuger -> XDebug [from dropdown]



Enjoy

Wednesday, April 7, 2021

Filezilla FTP zip file Uncompress / Extract

1. Copy the below code and paste it into a file and name it unzip.php

2. Copy this file to your current directory in ftp location where zip files are there. 

3. type your url/unzip.php  [ ex: infovijay.com/unzip.php ]

4. now you can see the screen like below. select the zip file and click unzip archieve. ENJOY.

tkx Andreas.



unzip.php


<?php

/**

 * The Unzipper extracts .zip or .rar archives and .gz files on webservers.

 * It's handy if you do not have shell access. E.g. if you want to upload a lot

 * of files (php framework or image collection) as an archive to save time.

 * As of version 0.1.0 it also supports creating archives.

 *

 * @author  Andreas Tasch, at[tec], attec.at

 * @license GNU GPL v3

 * @package attec.toolbox

 * @version 0.1.1

 */

define('VERSION', '0.1.1');


$timestart = microtime(TRUE);

$GLOBALS['status'] = array();


$unzipper = new Unzipper;

if (isset($_POST['dounzip'])) {

  // Check if an archive was selected for unzipping.

  $archive = isset($_POST['zipfile']) ? strip_tags($_POST['zipfile']) : '';

  $destination = isset($_POST['extpath']) ? strip_tags($_POST['extpath']) : '';

  $unzipper->prepareExtraction($archive, $destination);

}


if (isset($_POST['dozip'])) {

  $zippath = !empty($_POST['zippath']) ? strip_tags($_POST['zippath']) : '.';

  // Resulting zipfile e.g. zipper--2016-07-23--11-55.zip.

  $zipfile = 'zipper-' . date("Y-m-d--H-i") . '.zip';

  Zipper::zipDir($zippath, $zipfile);

}


$timeend = microtime(TRUE);

$time = round($timeend - $timestart, 4);


/**

 * Class Unzipper

 */

class Unzipper {

  public $localdir = '.';

  public $zipfiles = array();


  public function __construct() {

    // Read directory and pick .zip, .rar and .gz files.

    if ($dh = opendir($this->localdir)) {

      while (($file = readdir($dh)) !== FALSE) {

        if (pathinfo($file, PATHINFO_EXTENSION) === 'zip'

          || pathinfo($file, PATHINFO_EXTENSION) === 'gz'

          || pathinfo($file, PATHINFO_EXTENSION) === 'rar'

        ) {

          $this->zipfiles[] = $file;

        }

      }

      closedir($dh);


      if (!empty($this->zipfiles)) {

        $GLOBALS['status'] = array('info' => '.zip or .gz or .rar files found, ready for extraction');

      }

      else {

        $GLOBALS['status'] = array('info' => 'No .zip or .gz or rar files found. So only zipping functionality available.');

      }

    }

  }


  /**

   * Prepare and check zipfile for extraction.

   *

   * @param string $archive

   *   The archive name including file extension. E.g. my_archive.zip.

   * @param string $destination

   *   The relative destination path where to extract files.

   */

  public function prepareExtraction($archive, $destination = '') {

    // Determine paths.

    if (empty($destination)) {

      $extpath = $this->localdir;

    }

    else {

      $extpath = $this->localdir . '/' . $destination;

      // Todo: move this to extraction function.

      if (!is_dir($extpath)) {

        mkdir($extpath);

      }

    }

    // Only local existing archives are allowed to be extracted.

    if (in_array($archive, $this->zipfiles)) {

      self::extract($archive, $extpath);

    }

  }


  /**

   * Checks file extension and calls suitable extractor functions.

   *

   * @param string $archive

   *   The archive name including file extension. E.g. my_archive.zip.

   * @param string $destination

   *   The relative destination path where to extract files.

   */

  public static function extract($archive, $destination) {

    $ext = pathinfo($archive, PATHINFO_EXTENSION);

    switch ($ext) {

      case 'zip':

        self::extractZipArchive($archive, $destination);

        break;

      case 'gz':

        self::extractGzipFile($archive, $destination);

        break;

      case 'rar':

        self::extractRarArchive($archive, $destination);

        break;

    }


  }


  /**

   * Decompress/extract a zip archive using ZipArchive.

   *

   * @param $archive

   * @param $destination

   */

  public static function extractZipArchive($archive, $destination) {

    // Check if webserver supports unzipping.

    if (!class_exists('ZipArchive')) {

      $GLOBALS['status'] = array('error' => 'Error: Your PHP version does not support unzip functionality.');

      return;

    }


    $zip = new ZipArchive;


    // Check if archive is readable.

    if ($zip->open($archive) === TRUE) {

      // Check if destination is writable

      if (is_writeable($destination . '/')) {

        $zip->extractTo($destination);

        $zip->close();

        $GLOBALS['status'] = array('success' => 'Files unzipped successfully');

      }

      else {

        $GLOBALS['status'] = array('error' => 'Error: Directory not writeable by webserver.');

      }

    }

    else {

      $GLOBALS['status'] = array('error' => 'Error: Cannot read .zip archive.');

    }

  }


  /**

   * Decompress a .gz File.

   *

   * @param string $archive

   *   The archive name including file extension. E.g. my_archive.zip.

   * @param string $destination

   *   The relative destination path where to extract files.

   */

  public static function extractGzipFile($archive, $destination) {

    // Check if zlib is enabled

    if (!function_exists('gzopen')) {

      $GLOBALS['status'] = array('error' => 'Error: Your PHP has no zlib support enabled.');

      return;

    }


    $filename = pathinfo($archive, PATHINFO_FILENAME);

    $gzipped = gzopen($archive, "rb");

    $file = fopen($destination . '/' . $filename, "w");


    while ($string = gzread($gzipped, 4096)) {

      fwrite($file, $string, strlen($string));

    }

    gzclose($gzipped);

    fclose($file);


    // Check if file was extracted.

    if (file_exists($destination . '/' . $filename)) {

      $GLOBALS['status'] = array('success' => 'File unzipped successfully.');


      // If we had a tar.gz file, let's extract that tar file.

      if (pathinfo($destination . '/' . $filename, PATHINFO_EXTENSION) == 'tar') {

        $phar = new PharData($destination . '/' . $filename);

        if ($phar->extractTo($destination)) {

          $GLOBALS['status'] = array('success' => 'Extracted tar.gz archive successfully.');

          // Delete .tar.

          unlink($destination . '/' . $filename);

        }

      }

    }

    else {

      $GLOBALS['status'] = array('error' => 'Error unzipping file.');

    }


  }


  /**

   * Decompress/extract a Rar archive using RarArchive.

   *

   * @param string $archive

   *   The archive name including file extension. E.g. my_archive.zip.

   * @param string $destination

   *   The relative destination path where to extract files.

   */

  public static function extractRarArchive($archive, $destination) {

    // Check if webserver supports unzipping.

    if (!class_exists('RarArchive')) {

      $GLOBALS['status'] = array('error' => 'Error: Your PHP version does not support .rar archive functionality. <a class="info" href="http://php.net/manual/en/rar.installation.php" target="_blank">How to install RarArchive</a>');

      return;

    }

    // Check if archive is readable.

    if ($rar = RarArchive::open($archive)) {

      // Check if destination is writable

      if (is_writeable($destination . '/')) {

        $entries = $rar->getEntries();

        foreach ($entries as $entry) {

          $entry->extract($destination);

        }

        $rar->close();

        $GLOBALS['status'] = array('success' => 'Files extracted successfully.');

      }

      else {

        $GLOBALS['status'] = array('error' => 'Error: Directory not writeable by webserver.');

      }

    }

    else {

      $GLOBALS['status'] = array('error' => 'Error: Cannot read .rar archive.');

    }

  }


}


/**

 * Class Zipper

 *

 * Copied and slightly modified from http://at2.php.net/manual/en/class.ziparchive.php#110719

 * @author umbalaconmeogia

 */

class Zipper {

  /**

   * Add files and sub-directories in a folder to zip file.

   *

   * @param string $folder

   *   Path to folder that should be zipped.

   *

   * @param ZipArchive $zipFile

   *   Zipfile where files end up.

   *

   * @param int $exclusiveLength

   *   Number of text to be exclusived from the file path.

   */

  private static function folderToZip($folder, &$zipFile, $exclusiveLength) {

    $handle = opendir($folder);


    while (FALSE !== $f = readdir($handle)) {

      // Check for local/parent path or zipping file itself and skip.

      if ($f != '.' && $f != '..' && $f != basename(__FILE__)) {

        $filePath = "$folder/$f";

        // Remove prefix from file path before add to zip.

        $localPath = substr($filePath, $exclusiveLength);


        if (is_file($filePath)) {

          $zipFile->addFile($filePath, $localPath);

        }

        elseif (is_dir($filePath)) {

          // Add sub-directory.

          $zipFile->addEmptyDir($localPath);

          self::folderToZip($filePath, $zipFile, $exclusiveLength);

        }

      }

    }

    closedir($handle);

  }


  /**

   * Zip a folder (including itself).

   *

   * Usage:

   *   Zipper::zipDir('path/to/sourceDir', 'path/to/out.zip');

   *

   * @param string $sourcePath

   *   Relative path of directory to be zipped.

   *

   * @param string $outZipPath

   *   Relative path of the resulting output zip file.

   */

  public static function zipDir($sourcePath, $outZipPath) {

    $pathInfo = pathinfo($sourcePath);

    $parentPath = $pathInfo['dirname'];

    $dirName = $pathInfo['basename'];


    $z = new ZipArchive();

    $z->open($outZipPath, ZipArchive::CREATE);

    $z->addEmptyDir($dirName);

    if ($sourcePath == $dirName) {

      self::folderToZip($sourcePath, $z, 0);

    }

    else {

      self::folderToZip($sourcePath, $z, strlen("$parentPath/"));

    }

    $z->close();


    $GLOBALS['status'] = array('success' => 'Successfully created archive ' . $outZipPath);

  }

}

?>


<!DOCTYPE html>

<html>

<head>

  <title>File Unzipper + Zipper</title>

  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">

  <style type="text/css">

    <!--

    body {

      font-family: Arial, sans-serif;

      line-height: 150%;

    }


    label {

      display: block;

      margin-top: 20px;

    }


    fieldset {

      border: 0;

      background-color: #EEE;

      margin: 10px 0 10px 0;

    }


    .select {

      padding: 5px;

      font-size: 110%;

    }


    .status {

      margin: 0;

      margin-bottom: 20px;

      padding: 10px;

      font-size: 80%;

      background: #EEE;

      border: 1px dotted #DDD;

    }


    .status--ERROR {

      background-color: red;

      color: white;

      font-size: 120%;

    }


    .status--SUCCESS {

      background-color: green;

      font-weight: bold;

      color: white;

      font-size: 120%

    }


    .small {

      font-size: 0.7rem;

      font-weight: normal;

    }


    .version {

      font-size: 80%;

    }


    .form-field {

      border: 1px solid #AAA;

      padding: 8px;

      width: 280px;

    }


    .info {

      margin-top: 0;

      font-size: 80%;

      color: #777;

    }


    .submit {

      background-color: #378de5;

      border: 0;

      color: #ffffff;

      font-size: 15px;

      padding: 10px 24px;

      margin: 20px 0 20px 0;

      text-decoration: none;

    }


    .submit:hover {

      background-color: #2c6db2;

      cursor: pointer;

    }

    -->

  </style>

</head>

<body>

<p class="status status--<?php echo strtoupper(key($GLOBALS['status'])); ?>">

  Status: <?php echo reset($GLOBALS['status']); ?><br/>

  <span class="small">Processing Time: <?php echo $time; ?> seconds</span>

</p>

<form action="" method="POST">

  <fieldset>

    <h1>Archive Unzipper</h1>

    <label for="zipfile">Select .zip or .rar archive or .gz file you want to extract:</label>

    <select name="zipfile" size="1" class="select">

      <?php foreach ($unzipper->zipfiles as $zip) {

        echo "<option>$zip</option>";

      }

      ?>

    </select>

    <label for="extpath">Extraction path (optional):</label>

    <input type="text" name="extpath" class="form-field" />

    <p class="info">Enter extraction path without leading or trailing slashes (e.g. "mypath"). If left empty current directory will be used.</p>

    <input type="submit" name="dounzip" class="submit" value="Unzip Archive"/>

  </fieldset>


  <fieldset>

    <h1>Archive Zipper</h1>

    <label for="zippath">Path that should be zipped (optional):</label>

    <input type="text" name="zippath" class="form-field" />

    <p class="info">Enter path to be zipped without leading or trailing slashes (e.g. "zippath"). If left empty current directory will be used.</p>

    <input type="submit" name="dozip" class="submit" value="Zip Archive"/>

  </fieldset>

</form>

<p class="version">Unzipper version: <?php echo VERSION; ?></p>

</body>

</html>


Monday, November 9, 2020

Forticlient SSL VPN - Ubuntu 16.x 18.x 20.x

 sudo apt update

 64 bit

wget https://hadler.me/files/forticlient-sslvpn_4.4.2333-1_amd64.deb


32 bit

wget https://hadler.me/files/forticlient-sslvpn_4.4.2333-1_amd32.deb

sudo dpkg -i forticlient-sslvpn_4.4.2333-1_amd64.deb 


After Installation

Just windows key or desktop search = type forticlient


Tuesday, October 13, 2020

Product Idea : Universal Hub for Patient Medical Records – UHPMR

 Idealist: D.R. Vijaykumar
Draft: Version 0.1

Why?
So far, Healthcare industry has been slow to adapt to a technology. Thus, the current healthcare ecosystem comprises in information systems that lack data security, interoperability, standardisation, sharing, collaborating and trust.

Who will do?
    This should avoid if a Single system handles the Patient Medical Records universally to storing all his Records electronically into a CENTRALIZED ARSENAL “CR” like Youtube for videos, which are imperative for seamless health information exchange to any System himself has a talking/collaborating facility and completely handle by Patient only only only.

To Whom?
Let’s begin with a Story!
A boy named Kumar from a South Indian middle class family, he lived with his parents. His father used to collect all his Son used items, photos, videos, dresses and all activities at each and every stage including his son’s school bills rather than medical records as a part of memories, When I asked his father, Why are you keeping school bills?, He replied with caution, School bills may useful if the school says, you didn’t pay your son tuition fees and he pointed out with smile, Not only to me!, most of the families are doing the same. Days went and I started watching his family activities, noted one thing and realize they didn’t keep the medical records as a part of activities.
Every time he took his son Mr. Kumar to the hospital whether Minor/Major problems. They will go like the first time visitor, because he doesn’t keep the medical records in their hand. He gave less important to his son medical records until his son diagnosed with unknown disease. A good doctor named Vijay, stepped into his son problem to analyse when it starts, initially he don’t have clue and faced many problems, Such as
•    When he faced similar kind of problems.
•    Which Physician or Hospital he visits.
•    What Doctors prescribed.
•    What course he went.
•    After what other medical issues faced in-between.
•    Is this a genetically inherited.  
•    Even well educated person will ignore the prescriptions prescribed by doctors on minor problems like cold, cough, headache, rashes, but they don’t aware even a headache is the symptoms for brain cancer and it can route to death.
At last a Good Doctor finds the reason that it is a “genetically inherited” which he got it from his own Mother where she passed away when he was kid. Unfortunately his son died, I was deeply saddened and want to know what happened to him, so I can build Software to overcome these situations between patient and doctor. So I personally contact the Good Doctor and discussed, here are the points he furnished with emotions.
As I am a Doctor, My duty is to cure all patients whoever visiting to our hospital. So we created a healthy ecosystem to give natural immune power to patients. Also we build Software where we can store all the Patient information’s and his visiting histories. But WE LAGGING AND LACKING to get all information’s about Patients. Even though Healthcare industry has grown far, still I am facing a problem, such as.
•    Only I can access the patient information which is stored in my Hospital Database.
#. But that is not sufficient to start prescribing a medicines to patient, because we cannot assure the patient is always visiting our hospital only.

•    Now Hospital Software systems are improved and its starts collaborating between Hospitals to share the Patient Medical Information based on the Patient request and consent approval.
#. But anytime the hospital himself can withdraw the sharing features, because it is not legalize yet.
#. They cannot serve, due to technical failure and it will impact when patient is in urgent.
#. Any changes from either a side will impact the smooth transition of PMR “Patient Medical Record”.
•    Even though Technology has helped the healthcare ecosystem to optimise these complex workflows by connecting the various stakeholders and providing real-time information that helps in delivering enhanced patient care.
#. But still all above problem exists.



What I “CR” do?    

    CENTRALIZED ARSENAL is the only solution where a Patient can keep his/her Medical Records electronically at one place.
•    Patients can upload his PMR at any time anywhere at any point and order it into right folder.
•    Patient can re-order the records at his/her convenient.
•    Global Internal SEO will make sure the patient can filter or search the records at any point.
•    Hospital can push the record via multiple channels to this centralized arsenal after patient consent.
•    No expiry for the records stored inside centralized arsenal.
•    Patient can directly share his MR “Medical Record” to doctor/hospital who installed the same UHPMR app or via web browsers.
•    It will be secure and not allowing Doctor to download.
•    Patient only can download or delete the PMR on his/her records.
•    Patient itself can set the expiry DT while sharing to doctor app.
•    Patient can revert at any time and no need to wait until the expiry DT set previously.


More Points will add @Draft V0.2

Monday, October 5, 2020

Ubuntu - Maven - SSL Error while doing mvn clean install

sudo dpkg --purge --force-depends ca-certificates-java sudo apt-get install ca-certificates-java sudo update-ca-certificates -f

Friday, September 25, 2020

Java Contains Byte String - Back to Original Content String from Byte Array String

Code


String str = "hello";
byte [] x = str.getBytes ();
System.out.println ( new String (x) );
String byStr = "104, 101, 108, 108, 111";
String a [] = byStr.split ( "," );
byte xx [] = new byte[a.length];
int count = 0;
for ( String s :  a)
{
xx[count++] = Byte.parseByte ( s.trim () );
}
System.out.println ( new String (xx) );


Output

hello

hello




Friday, August 7, 2020

Python AutoBot - ChatterBot Plugin

 >install python 3.8

> create your app folder

> pip or pip3 install  chatterbot
> pip or pip3 install   chatterbot-corpus

>Program mychat.py

from chatterbot import ChatBot
from chatterbot.trainers import ListTrainer

# Create a new chat bot named ArsenaliT
chatbot = ChatBot('ArsenaliT')

trainer = ListTrainer(chatbot)

trainer.train([
    "Hi",
    "Hi, can I help you?",
    "Sure, I'd like to book a flight to Iceland.",
    "Your flight has been booked."
])

user = "hi";
print("User : ", user)
response = chatbot.get_response(user)
print("Bot : ", response)

user = "I'd like to book a flight ";
print("User : ", user)
response = chatbot.get_response(user)
print("Bot : ", response)


> OUTPUT

User :  hi
Bot :  Hope you are safe and good
User :  I'd like to book a flight
Bot :  Your flight has been booked.



ENJOY

Wednesday, July 15, 2020

Hit Counter


View My Stats