Thursday, December 2, 2021

NPM and docker installation and few commands

 NPM Installation

================

sudo apt install nodejs

sudo apt install npm


nodejs -v

(version)

npm -v

(Version)


sudo apt install build-essential

(install build essentials in case you want to compile code from source -- just to be make sure)

An alternative to installing Node.js with apt is to use a tool called nvm, which stands for “Node.js Version Manager”. Rather than working at the operating system level, nvm works at the level of an independent directory within your home directory. This means that you can install multiple self-contained versions of Node.js without affecting the entire system.



Docker installation

====================

sudo apt install docker.io


docker -v 

(version)

Just in case apt fails to install docker there is an alternative to intall snap and install docker from there... also to know about snap google it 


sudo apt install snap

sudo snap install docker


[some handy commands] ...google for more 

docker run hello-world

docker images

docker ps -a

docker ps

docker build ./

docker run -tid -p 8083:90 --name "work" a334445434

docker exec -it kantil bash

docker cp /root/var/www/html/test.php work:/var/www/html

docker exec 74f86665f0fd ls

chmod -R 755 /var/www/html

dockerfile basic example with apache and php php:7.4-apache

Create a docker file 

FROM php:7.4-apache

RUN echo "Building the Image"

COPY /var/www/html /var/www/html

RUN chmod -R 755 /var/www/html

EXPOSE 80


Rest of the commands

docker build ./

docker run -tid -p 8083:90 --name "work" a334445434

docker exec -it kantil bash

(exit to get out of bash)

This wont sync files dynamically into container after changes - but only onces

Wednesday, December 1, 2021

Run php page inside docker container using docker commands

 Run php page inside docker container using docker commands

===========================


docker run -tid -v /root/var/www/html:/var/www/html -p 8080:80 --name="phpserver" php:7.4-apache

(you have to upload a test.php file in /html location  and image is downloaded automatically if not available for php:7.4-apache)

docker ps

(above to get container id as container is created)

(gives file permisson -- but have to run everytime if you modify test.php or any other file in html folder) 

docker exec 20ea72577d44 chmod -R 755 /var/www/html


Run in url : http://[your local host address]/test.php

Friday, January 31, 2020

Autocomplete using jquery javascript snippet



//please correct the angular brackets
<  link rel="stylesheet" href="http://code.jquery.com/ui/1.10.3/themes/smoothness/jquery-ui.css" />
<  script src="http://code.jquery.com/ui/1.10.3/jquery-ui.js">
<  script src="http://code.jquery.com/jquery-1.9.1.js">

< script  >
  $(function() {
var contentvalues=[{"state":"AL","value":"Autauga","zipcode":"36003","county":"01001"},{"state":"AL","value":"Baldwin","zipcode":"36507","county":"01003"}]

var jsonObj = [];
$.each(contentvalues, function(index) {
        item = {}
        item ["state"] = contentvalues[index].state;
        item ["value"] = contentvalues[index].value + ' - ' + contentvalues[index].state;
        item ["zipcode"] = contentvalues[index].zipcode;
        item ["county"]= contentvalues[index].county;
        item ["countyname"]= contentvalues[index].value;
        jsonObj.push(item);

    });



    $( "#searchbox" ).autocomplete({
      minLength: 3,
      source: jsonObj,
      focus: function( event, ui ) {
        $( "#searchbox" ).val( ui.item.value  );
        return false;
      },

      select: function( event, ui ) {
var state=ui.item.state;
var county=ui.item.county;
var zipcode=ui.item.zipcode;
var countyname=ui.item.countyname;

       var url='https://www.yoursite.com/?state=' +  state + '&countyname=' + countyname + '&zipcode='+ zipcode + '&county=' + county;
   window.location.href = url;
        return false;

      }

  });
  });

</  script >

< form action="search" method="post" >
< input  name="searchbox" id="searchbox"   />
<   /form   >

Thursday, January 30, 2020

Wednesday, January 29, 2020

handy aws amazon rekognition snippets

These are handy amazon rekognision snippets. Make sure you have loaded the aws sdk from amazon for php

I have developed such applications and utilized these stuffs in php and python. Its pretty straight forward.

Snippets below!

Create collection

$result = $client->createCollection([
    'CollectionId' => 'mycollectionid',
]);

Results

[
    'CollectionArn' => 'aws:rekognition:us-west-

2:13234342323:collection/mycollectionid',
    'StatusCode' => 200,
]

Index faces
$result = $client->indexFaces([
    'CollectionId' => 'myphotos',
    'DetectionAttributes' => [
    ],
    'ExternalImageId' => 'myphotoid',
    'Image' => [
        'S3Object' => [
            'Bucket' => 'mybucket',
            'Name' => 'myphoto',
        ],
    ],
]);


$result = $rekognitionClient->searchFacesByImage([
                    'CollectionId' => ''.$collection_id.'', // REQUIRED
                    'FaceMatchThreshold' => 25.0,
                    'Image' => [ // REQUIRED
                            'S3Object' => [
                                'Bucket' => 'facetracking',
                                'Name' => 'test.jpg',
                                'Key' => 'test.jpg',
                                'Version' => 'latest',
                            ],
                    ], 'MaxFaces' => 2,
                ]);



Video

$result = $client->startFaceDetection([
    'ClientRequestToken' => '',
    'FaceAttributes' => 'DEFAULT|ALL',
    'JobTag' => '',
    'NotificationChannel' => [
        'RoleArn' => '', // REQUIRED
        'SNSTopicArn' => '', // REQUIRED
    ],
    'Video' => [ // REQUIRED
        'S3Object' => [
            'Bucket' => '',
            'Name' => '',
            'Version' => '',
        ],
    ],
]);



$result = $client->getFaceDetection([
    'JobId' => '', // REQUIRED
    'MaxResults' => ,
    'NextToken' => '',
]);
GetFaceDetection returns an array of detected faces (Faces) sorted by the

time the faces were detected.



$result = $client->getFaceSearch([
    'JobId' => '', // REQUIRED
    'MaxResults' => ,
    'NextToken' => '',
    'SortBy' => 'INDEX|TIMESTAMP',
]);



make you android phone a webcam or ipcamera

you can easily make your old/new android phone a webcamera

Step 1. Install DroidCam Wireless Webcam app on your Android smartphone
Step 2. Install the DroidCam Client app on your Windows PC
or  you can directly run the browser cam address on browser directly

Also if the webcam is on its also detected in other softwares as long as windows client is on! I have tested it using the windows client and also via web.


Search Google for droidcam wireless webcam apk and you will get the download link easily. It hardly takes 5 minutes to setup

Ref:
https://www.digitalcitizen.life/turn-android-smartphone-webcam-windows