Skip to main content

Posts

Showing posts from 2018

JSON in JavaSscript - Accessing fields and manipulations. ADD REMOVE, EDIT JSON ELEMENTS

ADD, REMOVE, EDIT JSON ELEMENTS  Reference from https://techtothepoint.blogspot.com/ Demo Link: https://jsfiddle.net/axkdwku6/51/ // Sample json object var json ={ "id": "", "entityname": "eset", "entitydescription": "", "entityTags": [], "esetname": "APAIBOT", "entityacl": [ "public" ], "fields": { "esetname": { "name": "esetname", "type": "string", "default": "", "id": "esetname", "field_order": 0, "entityreference": "", "acl": { "required": true } }, "description": { "name": "description", ...

ReactJS REST CALL Example : Populate a list Search box enter key press.

This demo shows, 1. Updating a list within the react component 2. Updating a list in child react component by passing 'state' as 'props' 3. Updating simple 'props' 4. All the updates are on 'Enter Key' press on an input field. //demo.js import React from "react"; import PropTypes from "prop-types"; import { withStyles } from "@material-ui/core/styles"; import List from "@material-ui/core/List"; import ListItem from "@material-ui/core/ListItem"; import ListItemText from "@material-ui/core/ListItemText"; import ListSubheader from "@material-ui/core/ListSubheader"; import TextField from "@material-ui/core/TextField"; const styles = theme => ({ root: { width: "100%", maxWidth: 360, backgroundColor: theme.palette.background.paper, position: "relative", overflow: "auto", maxHeight: 300 }, listSection: { ...

Javascript 3 dimentional matrix html board onclick empty current box

javascript 3 dimentional matrix html board onclick empty current box  Algorithm! Rules: 1. Only immediate Box can be swapped. Should not jump another box 2. Only directions allowed: Left, Right, Up, Down. 3. Should not swap diagonally.   See the Pen 3d matrix map numbers. by PV ( @moorthi07 ) on CodePen .   function hasClass(elem, className) {   return elem.className.split(" ").indexOf(className) > -1; } function addClick() {   var btn = '<button class="btn1">kkkkk</button>';   document.getElementById("container").innerHTML += btn; } // function boxbodyClick(obj) { //   /* console.log(';;;',obj.className) */ //   /* alert(obj) */ // } var arr = [3]; for (var i = 0; i < 3; i++) {   arr[i] = new Array(3); } var emti = 0; var emtj = 0; function btnClick(obj, i, j) {   if (arr[i][j] !== "-") {            if (j + 1 == emtj || j == emtj || j - 1 == emtj)...

Find Longest last name in the array.

This example shows finding longest lastname / string in an array or in a JSON object. Using: - Plain javascript conditional statments - Array.Sort function https://jsfiddle.net/marsmoorthi/umgpf3cz/5/ var namesobj = [ { 'fname' : 'senthil' , 'lname' : 'velanderson' }, { 'fname' : 'mark' , 'lname' : 'andersonvelanderson' }, { 'fname' : 'Bill' , 'lname' : 'gatesvelanderson' } ] /* firstname,lastname */ var namesarr=[ [ 'senthi' , 'velanderson' ], [ 'mark' , 'anderson' ], [ 'bill' , 'gatesvelanderson' ] ]; /* using array.sort */ function fromArraySort ( namesarr ) { var sortedArr = namesarr.sort(sortfn); function sortfn ( a,b ) { if (a[ 1 ] === b[ 1 ]) { return 0 ; } else { //Sorty by desending order return (a[ 1 ].length > b[ 1 ].length) ? -1...

NodeJS vs Java Performance for microservices

NodeJS vs Java Performance for microservices. In a nutshell: NodeJS tops with - High IO Speed, faster app restart , great memory use. (For non CPU intense apps - that blocks the eventloop in NodeJS). Full Presentation: Node.js Performance and Highly Scalable Micro-Services - Chris Bailey, IBM 

Deployd Contributors Code Jam for 1 hr. Google Hangout.

Deployd Contributors Code Jam for 1 hr. Google Hangout. http://deployd101.blogspot.com/2018/02/deployd-contributors-online-code-jam.html This effort will repeat weekly or as regular as possible. What we do: Fix issues and add new features quickly by collaborating . All contributors are welcome to join a google hangout . (We like to keep it invite only . So if you are interested send me your gmail id via gitter  https://gitter.im/deployd/deployd - private message : @moorthi07. Thanks. -PV

Calling Observable by subscribe .Return data in a subscribe call.

 Calling Observable method using  subscribe  and return data in a subscribe 'd call. Calling method: onClick(fileName){ this ._service. getFiles (fileName). subscribe (filestring  =>  { console.log('filestring',filestring.fileContent); }, (err) =>  { console.log( 'Error to get file' ,err); }); } Called method:  getFiles ( fileName ): Observable <any> { return this ._http .get( this .baseUrl + '/' + fileName , this .options()) . map ((res: Response) => res.json() ) }