<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: karthik22061993</title>
    <description>The latest articles on DEV Community by karthik22061993 (@karthik22061993).</description>
    <link>https://dev.to/karthik22061993</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F338867%2F8a1ee624-25d1-471f-8a97-e03f3d82c48c.png</url>
      <title>DEV Community: karthik22061993</title>
      <link>https://dev.to/karthik22061993</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/karthik22061993"/>
    <language>en</language>
    <item>
      <title>Cannot read back correct JSON from excel workbook</title>
      <dc:creator>karthik22061993</dc:creator>
      <pubDate>Sun, 28 Jun 2020 20:55:51 +0000</pubDate>
      <link>https://dev.to/karthik22061993/cannot-read-back-correct-json-from-excel-workbook-59d3</link>
      <guid>https://dev.to/karthik22061993/cannot-read-back-correct-json-from-excel-workbook-59d3</guid>
      <description>&lt;p&gt;I am using npm module xlsx to write and read JSON data.&lt;/p&gt;

&lt;p&gt;I want to write this JSON to excel&lt;br&gt;
{ "name": "John", "class": 1, "address" : [ { "street": "12th Cross" , "city": "London" }, { "street": "22nd Cross" , "city": "Cade" } ] }&lt;/p&gt;

&lt;p&gt;Later when I read back I want to get same JSON from excel file&lt;/p&gt;

&lt;p&gt;If you already solved, any suggestion or help will be of great help :)&lt;/p&gt;

&lt;p&gt;Here is what I have tried&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;var XLSX = require("xlsx");
console.log("Node Version: " + process.versions.node);
console.log("XLSX Version: " + XLSX.version);

/* GENERATE TEST FILE */
(function() {
  // create workbook
  var wb = XLSX.utils.book_new();
  var ws = XLSX.utils.json_to_sheet([
    { "name": "John", "class": 1, "address" : [ { "street": "12th Cross" , "city": "London" }, { "street": "22nd Cross" , "city": "Cade" } ] }
    ], {header:["name","class","address","street","city"]});

XLSX.utils.book_append_sheet(wb, ws, "Sheet1");
XLSX.writeFile(wb, "testfile.xlsx");
let worksheet = wb.Sheets['Sheet1'];
let jsonArray= XLSX.utils.sheet_to_json(worksheet);
console.log(JSON.stringify(jsonArray));
})();
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;This returns&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Node Version: 8.12.0
XLSX Version: 0.16.2
[{"name":"John","class":1}]

But I was expecting 
 { "name": "John", "class": 1, "address" : [ { "street": "12th Cross" , "city": "London" }, { "street": "22nd Cross" , "city": "Cade" } ] }
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Any help or suggestion will be of great help :)&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>node</category>
      <category>npm</category>
      <category>excel</category>
    </item>
    <item>
      <title>How to create/ update large quantity records in azure cosmos database
</title>
      <dc:creator>karthik22061993</dc:creator>
      <pubDate>Sat, 13 Jun 2020 15:19:47 +0000</pubDate>
      <link>https://dev.to/karthik22061993/how-to-create-update-large-quantity-records-in-azure-cosmos-database-4mcm</link>
      <guid>https://dev.to/karthik22061993/how-to-create-update-large-quantity-records-in-azure-cosmos-database-4mcm</guid>
      <description>&lt;p&gt;I have 1500 records to be created in azure cosmos database, I just loop through using Javascript code. I have REST API connection to the database. I feed the data to be updated as JSON array. &lt;/p&gt;

&lt;p&gt;The problem is when I pass entire data, azure database timesout or send ECONNECTIONRESET. Many of you would create huge amount of records in the database and there is might be some efficient way to overcome this problem. I want your suggestion.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Since majority of records is not found, many times create new record part is hit and I have never pushed such huge amount of data before. Any suggestion or new idea will really help me.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Note : I run this javascript code using mocha unit test&lt;/p&gt;

&lt;p&gt;Below is code snippet&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Record.js&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const fetch = require('node-fetch');
let connectionAzureDataBase = "abc...";
let SubscriptionKey = "xyz";
let promises = [];
let j = -1;

module.exports = {
checkRecord
}
function checkRecord (req) {
 for (let i = 0; i &amp;lt; req.body.length; i++) {
    promises[j] = new Promise(async function(resolve, reject) {
      //check if record exist in azure
      var apiUrl = APICheckRecord( req.body[i].recordName);
            fetch(apiUrl , { headers:connectionAzureDataBase})
            .then(res =&amp;gt; res.json())
            .then(record =&amp;gt; {
              if(record) {
                console.log("Record Found");
              } else {
                console.log("Record not Found, calling API to create Record");
                var apiUrl = APICreateNewRecord( req.body[i].recordName);
                fetch(apiUrl , { headers:connectionAzureDataBase})
                .then(res =&amp;gt; res.json())
                .then(recordCreated =&amp;gt; {
                  if(recordCreated) {
                   console.log("record created successfully");
                   resolve("record created successfully");
                  } else {
                   console.log("Encountered some unexpected condition");
                   resolve("Encountered some unexpected condition");
                  }
                 }).catch(err =&amp;gt; {
                     console.log("record could not be created");
                      resolve("record could not be created");
                 }) 
              }
             }).catch(err =&amp;gt; {
                console.log("record not found");
                resolve("record not found");
             })
     })// close promise

 }// close for

 let replies = await Promise.all(promises); 
 let promise1 = new Promise (function(resolve,reject) {
   resolve(replies);
 }) 
}


&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Record.spec.js&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const Records = require("Record.js);

 it("should find/create records", async function() {
        this.timeout(6000000);
        try { 
         let req =[
          {
            "recordName": "Xyz",
            "recordDate": "12-06-2020"
          },
          {
            "recordName": "Abc",
            "recordDate": "13-06-2020"
           }
          ]
          let reply = await Records.checkRecord(req);
          console.log(JSON.stringify(reply));

        } catch(err) {
            console.log(err);
        }     
    })
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Error&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;  message: 'request to https://apim-dev.azure-api.net/api/portal/records/?recordName="Xyz" failed, reason: read ECONNRESET',
  type: 'system',
  errno: 'ECONNRESET',
  code: 'ECONNRESET' }

message: 'request to https://apim-dev.azure-api.net/api/portal/createRecords/ failed, reason: read ECONNRESET',
  type: 'system',
  errno: 'ECONNRESET',
  code: 'ECONNRESET' }
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;This is sample of data that is passed, I have 1500 such records&lt;br&gt;
&lt;strong&gt;SampleData&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;[
 {
   "recordName": "Xyz",
    "recordDate": "12-06-2020"
 },
{
   "recordName": "Abc",
    "recordDate": "13-06-2020"
 }
]
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



</description>
      <category>javascript</category>
      <category>database</category>
      <category>azure</category>
      <category>node</category>
    </item>
    <item>
      <title>How to format the file containing json objects to json array</title>
      <dc:creator>karthik22061993</dc:creator>
      <pubDate>Sat, 16 May 2020 07:14:24 +0000</pubDate>
      <link>https://dev.to/karthik22061993/how-to-format-the-file-containing-json-objects-to-json-array-4bhp</link>
      <guid>https://dev.to/karthik22061993/how-to-format-the-file-containing-json-objects-to-json-array-4bhp</guid>
      <description>&lt;p&gt;I am writing a javascript to format JSON objects to array of JSON objects.&lt;br&gt;
My input is,&lt;br&gt;
{&lt;br&gt;
  Name:"nom1",&lt;br&gt;
  Cities:['city1','city2']&lt;br&gt;
}&lt;br&gt;
{&lt;br&gt;
  Name:"nom2",&lt;br&gt;
  Cities:['city4','city5']&lt;br&gt;
}&lt;/p&gt;

&lt;p&gt;And I want the output as,&lt;/p&gt;

&lt;p&gt;var data = [ { Name:"nom1", Cities:['city1','city2'] }, { Name:"nom2", Cities:['city3','city4'] } ]}; &lt;/p&gt;

&lt;p&gt;How to write a script to achieve this?&lt;/p&gt;

</description>
      <category>javascript</category>
    </item>
    <item>
      <title>Electron app opening multiple windows or processes in spectron test</title>
      <dc:creator>karthik22061993</dc:creator>
      <pubDate>Thu, 16 Apr 2020 21:25:31 +0000</pubDate>
      <link>https://dev.to/karthik22061993/electron-app-opening-multiple-windows-or-processes-in-spectron-test-14f</link>
      <guid>https://dev.to/karthik22061993/electron-app-opening-multiple-windows-or-processes-in-spectron-test-14f</guid>
      <description>&lt;p&gt;My electron app works as expected but it keeps on opening new windows when I run spectron test that tests for number of windows opened.&lt;/p&gt;

&lt;p&gt;Versions Installed&lt;br&gt;
npm ls --depth=0 &lt;a href="mailto:demoelectronapp@1.0.0"&gt;demoelectronapp@1.0.0&lt;/a&gt; C:\demoCLS\demoElectronApp +-- &lt;a href="mailto:assert@2.0.0"&gt;assert@2.0.0&lt;/a&gt; +-- &lt;a href="mailto:electron@8.2.2"&gt;electron@8.2.2&lt;/a&gt; +-- &lt;a href="mailto:electron-packager@14.2.1"&gt;electron-packager@14.2.1&lt;/a&gt; +-- &lt;a href="mailto:mocha@7.1.1"&gt;mocha@7.1.1&lt;/a&gt; +-- &lt;a href="mailto:path@0.12.7"&gt;path@0.12.7&lt;/a&gt; `-- &lt;a href="mailto:spectron@10.0.1"&gt;spectron@10.0.1&lt;/a&gt; &lt;/p&gt;

&lt;p&gt;I am just running a small demo, below I will give code snippet&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Note: I am running the spectron test pointing to .exe file generated by electron-packager.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Does Anyone have an idea what is the issue if possible how to solve it?&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;main.js&lt;/strong&gt;&lt;br&gt;
&lt;code&gt;&lt;/code&gt;`&lt;br&gt;
const { app, BrowserWindow } = require('electron')&lt;/p&gt;

&lt;p&gt;function createWindow () {&lt;/p&gt;

&lt;p&gt;let win = new BrowserWindow({&lt;br&gt;
    width: 800,&lt;br&gt;
    height: 600,&lt;br&gt;
    webPreferences: {&lt;br&gt;
      nodeIntegration: true&lt;br&gt;
    }&lt;br&gt;
  })&lt;/p&gt;

&lt;p&gt;win.loadFile('index.html')&lt;br&gt;
}&lt;/p&gt;

&lt;p&gt;app.whenReady().then(createWindow)&lt;/p&gt;

&lt;p&gt;&lt;code&gt;`&lt;br&gt;
**index.js**&lt;br&gt;
`&lt;/code&gt;&lt;br&gt;
&amp;lt;!DOCTYPE html&amp;gt;&lt;br&gt;
&lt;br&gt;
  &lt;/p&gt;
&lt;br&gt;
    &lt;br&gt;
    Hello World!&lt;br&gt;
    &lt;br&gt;
  &lt;br&gt;
  &lt;br&gt;
    &lt;h1&gt;Hello World!&lt;/h1&gt;
&lt;br&gt;
  &lt;br&gt;
&lt;br&gt;
&lt;code&gt;`&lt;br&gt;
**test.js**&lt;br&gt;
`&lt;/code&gt;&lt;br&gt;
const assert = require('assert');&lt;br&gt;
const path = require('path');&lt;br&gt;
const Application = require('spectron').Application;&lt;br&gt;
const electronPath = require('electron');

&lt;p&gt;const app = new Application({&lt;br&gt;
    path: 'C:/demoElectronApp/winx64/demoelectronapp-win32-x64/demoelectronapp.exe',&lt;br&gt;
  });&lt;/p&gt;

&lt;p&gt;describe('client_settings_app', function () {&lt;br&gt;
    this.timeout(10000);&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;beforeEach(() =&amp;gt; {
  return app.start();
});

it('shows only one initial window', async () =&amp;gt; {
  const count = await app.client.getWindowCount();
  return assert.equal(count, 1);
});
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;})&lt;/p&gt;

&lt;p&gt;&lt;code&gt;`&lt;br&gt;
**package.json**&lt;br&gt;
`&lt;/code&gt;&lt;br&gt;
{&lt;br&gt;
  "name": "demoelectronapp",&lt;br&gt;
  "version": "1.0.0",&lt;br&gt;
  "description": "",&lt;br&gt;
  "main": "main.js",&lt;br&gt;
  "scripts": {&lt;br&gt;
    "test": "echo \"Error: no test specified\" &amp;amp;&amp;amp; exit 1",&lt;br&gt;
    "electronpackage": "electron-packager . --out winx64"&lt;br&gt;
  },&lt;br&gt;
  "author": "",&lt;br&gt;
  "license": "ISC",&lt;br&gt;
  "dependencies": {&lt;br&gt;
    "path": "^0.12.7"&lt;br&gt;
  },&lt;br&gt;
  "devDependencies": {&lt;br&gt;
   "electron": "^8.2.2",&lt;br&gt;
    "electron-packager": "^14.2.1",&lt;br&gt;
    "assert": "^2.0.0",&lt;br&gt;
    "mocha": "^7.1.1",&lt;br&gt;
    "spectron": "^10.0.1"&lt;br&gt;
  }&lt;br&gt;
}&lt;br&gt;
`&lt;code&gt;&lt;/code&gt;&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>html</category>
      <category>node</category>
      <category>electron</category>
    </item>
    <item>
      <title>Is setting position of elements relative or absolute elements to move left, right, top, bottom  correct</title>
      <dc:creator>karthik22061993</dc:creator>
      <pubDate>Thu, 20 Feb 2020 11:11:38 +0000</pubDate>
      <link>https://dev.to/karthik22061993/is-setting-position-of-elements-relative-or-absolute-elements-to-move-left-right-top-bottom-correct-1fn0</link>
      <guid>https://dev.to/karthik22061993/is-setting-position-of-elements-relative-or-absolute-elements-to-move-left-right-top-bottom-correct-1fn0</guid>
      <description>&lt;p&gt;To make elements move left, right, top, bottom I have to set position property to relative or absolute but when I resize the window, I see elements are rearranged incorrect way. I want to move elements left, right, top, bottom as well on window resize element to show in correct manner. How to achieve this?&lt;/p&gt;

</description>
      <category>css</category>
      <category>html</category>
      <category>javascript</category>
    </item>
    <item>
      <title>Button and input elements doesn't get applied css style : background</title>
      <dc:creator>karthik22061993</dc:creator>
      <pubDate>Thu, 20 Feb 2020 11:09:03 +0000</pubDate>
      <link>https://dev.to/karthik22061993/button-and-input-elements-doesn-t-get-applied-css-style-background-mhg</link>
      <guid>https://dev.to/karthik22061993/button-and-input-elements-doesn-t-get-applied-css-style-background-mhg</guid>
      <description>&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;
I want to bring output similar to one shown in the figure. I build the table in table2() and build buttons using ButtonDOM().

I want to get the layout shown in figure, so I make the button elements move to right by some pixels. I have a basic question in css,

To make elements move left, right, top, bottom I have to set position property to relative or absolute but when I resize the window, I see elements are rearranged incorrect way. I want to move elements left, right, top, bottom as well on window resize element to show in correct manner. How to achieve this?

I have applied background color to whole div but I see the buttons and date input element appear outside the div, though all these elements are within this div.

Note : I had to position the input date and button elements relative and absolute and the div #buttonsdiv relative just to position elements where I needed

To know more about this question https://stackoverflow.com/questions/60318158/button-and-input-elements-doesnt-get-applied-css-style-background?noredirect=1#comment106697427_60318158

&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;





&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;function maintest () {


   table2();
   ButtonDOM();
   addClasses();
  }



function table2 () {
    let h = $("&amp;lt;h3&amp;gt;").html("Borrowable Features:").prop("class","underline").appendTo("#BorrowableTable");
    let h1 = $("&amp;lt;h3&amp;gt;").html("Features:").prop("class","underline").appendTo("#BorrowableTable");
    let $table = $('&amp;lt;table&amp;gt;').attr({"id" : "borrowable"}).css({"width":"50%"});
    let $row1 = $('&amp;lt;tr&amp;gt;').appendTo($table);
    $('&amp;lt;td&amp;gt;').appendTo($row1);
    let header = $('&amp;lt;td&amp;gt;').text("Feature").appendTo($row1); 
    let $row2 = $('&amp;lt;tr&amp;gt;').prop("id","autocompleterow").appendTo($table);
    let $cell0 = $('&amp;lt;td&amp;gt;').appendTo($row2);



        let $cell1 = $('&amp;lt;td&amp;gt;').appendTo($row2);
        let $autocomplete1 = $("&amp;lt;input&amp;gt;").attr({"id" : "selector0","class":"creamcolorInput"}).appendTo($cell1);


        $("#BorrowableTable").append($table);
        autocomplete2 = $("#selector0").autocomplete( {"source": ['c++','java','javascript']}, {select: function(event, ui) { 
            selectedObj = ui.item.value; 


        } });

}



function addClasses () {
    let tableRows = $('tr').addClass('tableRows');
    let tableDefn = $('td').attr({"class":"tableDefn"});
    let tableHeader = $('th').attr({"class":"tableHeader"});
    let tbodyDOM = $('tbody').attr({"class" : "tbodyDOM"});
}


function ButtonDOM() {
  let buttonsdiv =  $("&amp;lt;div&amp;gt;&amp;lt;/div&amp;gt;").attr({"id":"buttonsdiv"}).css({"width":"50%"}).appendTo($("#BorrowableTable")); 
  let returnDate = $("&amp;lt;input&amp;gt;").attr({"id":"returnDate"}).appendTo($('#buttonsdiv'));
   $( "#returnDate" ).datepicker({ dateFormat: 'yy-mm-dd' }).attr({"class":"creamcolorInput"});

   $("&amp;lt;td&amp;gt;").html("Return Date").insertBefore(returnDate).css({"position":"relative","left":"350px","display":"inline"});
    $("&amp;lt;button&amp;gt;Borrow&amp;lt;/button&amp;gt;").attr({"value":"Save","id":"borrowButton"}).appendTo(buttonsdiv)

}
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;





&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;#buttonsdiv {
     height: unset !important;
     width:50%;
     position: relative;
     left :50px !important;
     bottom :0px !important;
     background-color: papayawhip !important;
  }

  #BorrowableTable {
    display: flex !important; 
    flex-direction: column;
    height:fit-content !important;

  }


  #borrowable {
      display: unset !important; 
      border-collapse: collapse;
      border-spacing :unset !important;
      margin-left:100px;
  }




  #BorrowableTable,.creamcolorInput,#buttonsdiv {
    background-color: papayawhip;

  }

  #borrowButton {
    position: absolute;
    left: 325px;
    top: 50px;
    height: 36px;
    width: 205px;
    cursor: pointer;
    border: solid 1px;
    background-color:whitesmoke;
    font-family: ffunit;
    font-size: 14px;
    margin-top: 35px;
    margin-left: 2px;
}

     #returnDate {
      position: absolute;
      left : 330px !important;
      top:25px;
      height:36px;
      width:200px; 
  }
   .tableRows, .tableDefn, .tableHeader { /*added from addClasses() */

      padding: 0; 
      margin: 0;
      font-family: ffunit;
      font-size: 14px;
      font-weight: bold;
      padding-right: 50px !important;
    }



   button {
      height:36px;
      width:205px;
      cursor: pointer;
      border: solid 1px;
      background-color:whitesmoke;
      font-family: ffunit;
      font-size: 14px;
      margin-top:35px;
      margin-left: 2px;
  }


  input {
    height: 30px;
    width: 250px;
    font-size: 20px;
    text-indent: 6px;
  }



 .tbodyDOM {
   float:  left !important;
  } 

   .images {
      position: relative !important;
      cursor: pointer !important;
      width:35px !important;
      height:35px !important;
      left: 35px !important;

  } 

   .underline {
     text-decoration: underline;
  }

&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;





&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/1.9.1/jquery.min.js"&amp;gt;&amp;lt;/script&amp;gt;
&amp;lt;script src="https://code.jquery.com/ui/1.12.1/jquery-ui.min.js"&amp;gt;&amp;lt;/script&amp;gt;
&amp;lt;body onload="maintest()"&amp;gt;

   &amp;lt;div id="BorrowableTable"&amp;gt;&amp;lt;/div&amp;gt;
&amp;lt;/body&amp;gt;

&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



</description>
      <category>css</category>
      <category>html</category>
      <category>javascript</category>
    </item>
  </channel>
</rss>
