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

Saturday, January 18, 2020

simple csv reader in python

import csv
datafile = open('touristspot-final.csv', 'r')
myreader = csv.reader(datafile)

for row in myreader:
    print(row[0], row[1], row[2])

Please make sure to install csv package in python.

install nvm in udumbu


apt-get update
apt-get install build-essential libssl-dev

curl https://raw.githubusercontent.com/creationix/nvm/v0.25.0/install.sh | bash

Ref:
https://github.com/creationix/nvm/releases (see version latesT)
Ref: https://www.liquidweb.com/kb/how-to-install-nvm-node-version-manager-for-node-js-on-ubuntu-12-04-lts/
Ref:
https://www.sitepoint.com/quick-tip-multiple-versions-node-nvm/

Install Jquery module in your IONIC 3 app

Install Jquery module in your IONIC-3 app,

npm install jquery --save
npm install @types/jquery
Import JQuery in HomePage.ts

import * as $ from "jquery";

Use $ to call jquery methods.


ngAfterViewInit(){
    $(document).ready(function(){
        alert('JQuery is working!!');
    });
}

Python selenium installation

Make sure you have pip installed. Generally it comes with the package already.

Now install selenium
C:\Python34\Scripts\pip.exe install -U selenium
Later you have to download the browser driver (either for firefox or chrome etc) - just google it to get the location. The downloaded stuffs path needs to be used in python code.

Rest of the other related stuffs are as below -- used for data scraping
pip install beautifulsoup4

pip install requests

ionic installation

* ionic start myApp tabs --type ionic1  // for ionic 1   
ionic start myApp tabs --type ionic-angular // for ionic 2/3   
ionic start myApp tabs --type angular  // for ionic 4+

* npm install -g ionic
*https://ionicframework.com/getting-started/
ionic start myApp tabs
cd myApp
ionic serve

android cordova installation and set path command

* install node from website
* npm install -g cordova
* npm install -g ionic
* install jdk oracle site jdk
* android studio or command line version
* sdkmanager "platform-tools" "platforms;android-23"
* sdkmanager "platform-tools" "platforms;android-24"
* cordova create hello com.example.hello HelloWorld
* set command for android path
*
set ANDROID_HOME=C:\Users\admin-new\Downloads\sdk-tools-windows-4333796\
set PATH=%PATH%;%ANDROID_HOME%\tools;%ANDROID_HOME%\platform-tools

(plz check paths)
set JAVA_HOME=D:\Program Files\Java\jdk1.8.0_221\
set PATH=%PATH%;

(working)
set PATH=%PATH%;D:\Program Files\Java\jdk1.8.0_221\bin
set PATH=%PATH%;C:\gradle\gradle-5.6.2\bin

* cordova platform update android@6.1.2

install nvm in mac


install nvm using brew (mac)
brew install nvm
nvm ls-remote    # find the version you want
nvm install v7.10.0
nvm alias default v7.10.0    # set default node version on a shell

New ionic 3 project startup



New ionic 3 project
https://ionicframework.com/docs/cli/commands/start


ionic start
ionic start --list
ionic start myApp
ionic start myApp blank
ionic start myApp tabs --cordova
ionic start myApp tabs --capacitor
ionic start myApp super --type=ionic-angular
ionic start myApp blank --type=ionic1
ionic start cordovaApp tabs --cordova
ionic start "My App" blank
ionic start "Conference App" https://github.com/ionic-team/ionic-conference-app
Inputs

32 bit node.js installation


nvm install 8.12.0 32 (32 bits)

multiple version of node installation


* https://www.sitepoint.com/quick-tip-multiple-versions-node-nvm/
nvm ls-remote
nvm ls available (windows)

* see list of available node version in pc
nvm list

* install old version of node
nvm install 8.12.0

* Fortunately, when installing a new Node.js version, you can reinstall the npm global packages from a specific version. For example:

nvm install v9.0.0 --reinstall-packages-from=8.9

1)  nvm to manage node versions
2) npm for packages



nvm use latest
npm install -g ionic

nvm use 8.12.0
npm uninstall -g ionic
npm install -g ionic@3.9.2


For library adding
npm install --save

--save adds to package

nvm install 8.12.0 32 (32 bits)

Gulp Meaning


* gulp meaning

Gulp is a task runner that uses Node. js as a platform. It purely uses the JavaScript code and helps to run front-end tasks and large-scale web applications. Gulp builds system automated tasks like CSS and HTML minification, concatenating library files, and compiling the SASS files.

https://en.wikipedia.org/wiki/Gulp.js
https://www.tutorialspoint.com/gulp/index.htm

install nvm for windows

download nvm for windows from
https://github.com/coreybutler/nvm-windows

After installation use some commands

nvm use 4.4.0
npm install gulp-cli -g
nvm use 0.10.33
npm install gulp-cli -g

Install Curl, apache, vesta control panel In Debian Linux

Install Apache

sudo apt-get install apache2

Uninstall

sudo apt-get --purge remove apache2
sudo apt-get remove apache2-common



Install curl in debian linux

$sudo apt install curl

OR
$sudo apt-get install curl



How to install Vesta Control panel
1. Connect to your server as root via SSH
ssh root@your.server-name


2. Download installation script
curl -O http://vestacp.com/pub/vst-install.sh


3. Run it
bash vst-install.sh