linux – How to present multiple greps as if they were in different columns?

I have 2 greps for example:

  • grep -i computer /etc/hosts
  • grep -i ips /etc/hosts

They give me answers like

Well I would like to get a file with headers and the information organized as this:

Name Ip
oser1313 19.168.100.1

I’m quite lost I have no idea how could I format this I usually copy-paste it on Excel but I don’t want to do it anymore.

javascript – Why Google Sheets Crud/ search form is not working if has more than 5 columns?

I am working on a simple app that will display search window and the results based on the range in google sheets.
However I have a problem that I cannot understand at all.

The code is working perfect till I have 5 columns to display (search.html). If it is more than 5 it is not displaying anything….

I have no idea why. If anyone could help me with that I would be grateful.

CRUD.gs

function loadMainForm(){

   const htmlServ = HtmlService.createTemplateFromFile("main");
   const html = htmlServ.evaluate();
   html.setWidth(950).setHeight(600)
   
   const ui = SpreadsheetApp.getUi();
         ui.showModalDialog(html, "データ検索");   
}

function createMenu(){
   const ui = SpreadsheetApp.getUi();
   const menu = ui.createMenu("データ検索");
  
  menu.addItem("検索フォームを開く", "loadMainForm");
  menu.addToUi();
}

function onOpen(){
  createMenu();
}

main.html

<!doctype html>
<html lang="en">
  <head>
    <!-- Required meta tags -->
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">

    <!-- Bootstrap CSS -->
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@4.5.3/dist/css/bootstrap.min.css" integrity="sha384-TX8t27EcRE3e/ihU7zmQxVncDAy5uIKz4rEkgIXeMed4M0jlfIDPvg6uqKI2xXr2" crossorigin="anonymous">
   
   <style>
   .nav-link {
   cursor: pointer;
   }
   </style>

  </head>
  <body>
    
    <div class="container">
    
    <ul class="nav nav-tabs">
  <li class="nav-item">
    <div class="nav-link active" id="home-link">Home</div>
  </li>
  <li class="nav-item">
    <div class="nav-link"id="search-link">検索</div>
  </li>

</ul>

     <div id="app"></div>    
  <!-- Content here -->
</div>

    <!-- Option 1: jQuery and Bootstrap Bundle (includes Popper) -->
    <script src="https://code.jquery.com/jquery-3.5.1.slim.min.js" integrity="sha384-DfXdz2htPH0lsSSs5nCTpuj/zy4C+OGpamoFVy38MVBnE+IbbVYUew+OrCXaRkfj" crossorigin="anonymous"></script>
    <script src="https://cdn.jsdelivr.net/npm/bootstrap@4.5.3/dist/js/bootstrap.bundle.min.js" integrity="sha384-ho+j7jyWK8fNQe+A12Hb8AhRq26LrZ/JpcUGGOn+Y7RsweNrtN/tE3MoK7ZeZDyx" crossorigin="anonymous"></script>

    
  <script>
  
  var data;
  
  function loadView(options){
var id = typeof options.id === "undefined" ? "app" : options.id;
var cb = typeof options.callback === "undefined" ? function(){} : options.callback;

google.script.run.withSuccessHandler(function(html){
document.getElementById("app").innerHTML = html;
typeof options.params === "undefined" ? cb() : cb(options.params);
})(options.func)();
}

function setDataForSearch(){
google.script.run.withSuccessHandler(function(dataReturned){
data = dataReturned.slice();
}).getDataForSearch();
}

function search(){

var searchinput = document.getElementById("searchinput").value;
var resultsArray = data.filter(function(r){
//return r(1).indexOf(searchinput) !== -1;
return r(0).toString().toLowerCase().indexOf(searchinput.toString().toLowerCase()) !== -1;
});
var searchResultsBox = document.getElementById("searchResults");
var templateBox = document.getElementById("rowTemplate");
var template = templateBox.content;
searchResultsBox.innerHTML = "";
resultsArray.forEach(function(r){

var tr = template.cloneNode(true);
var hinmokuColumn = tr.querySelector(".hinmoku");
var buhinCodeuColumn = tr.querySelector(".buhinCode");
var buhinNameColumn = tr.querySelector(".buhinName");
var hitsuyoColumn = tr.querySelector(".hitsuyo");
var genkaColumn = tr.querySelector(".genka");
var kobaiColumn = tr.querySelector(".kobai");
var sagakuColumn = tr.querySelector(".sagaku");
var kenshoColumn = tr.querySelector(".kensho");

hinmokuColumn.textContent = r(0);
buhinCodeuColumn.textContent = r(1);
buhinNameColumn.textContent = r(2);
hitsuyoColumn.textContent = r(3);
genkaColumn.textContent = r(4);
kobaiColumn.textContent = r(5);
sagakuColumn.textContent = r(6);
kenshoColumn.textContent = r(7);

searchResultsBox.appendChild(tr);

});
}

function loadSearchView(){
loadView({func:"loadSearchView", callback: setDataForSearch});
}


document.getElementById("search-link").addEventListener("click",loadSearchView);


function inputEventHandler(e){
if (e.target.matches("#searchinput")){
  search();
}
}
document.getElementById("app").addEventListener("input",inputEventHandler);
    
    </script>
    
  </body>
</html>

search.html

<h1>検索</h1>

<div class="form-group">  
    <input type="text" class="form-control" id="searchinput" placeholder="検索">
 </div>

<table class="table table-hover">
  <thead>
    <tr>
      
      <th scope="col">品目</th>
      <th scope="col">部品コード</th>
      <th scope="col">部品名</th>
      <th scope="col">必要数</th>
      <th scope="col">原価</th>
      <th scope="col">購買原価</th>
      <th scope="col">差額1ヶ</th>
      <th scope="col">検証状況</th>

    </tr>
  </thead>
  <tbody id="searchResults">
  
  </tbody>
</table>


<template id="rowTemplate">
 <tr>
      
      <td class="hinmoku"></td>
      <td class="buhinCode"></td>
      <td class="buhinName""></td>
      <td class="hitsuyo"></td>
      <td class="genka"></td>
      <td class="kobai"></td>
      <td class="sagaku"></td>
      <td class="kensho"></td>

  </tr>
</template>

loadPartial.gs

function loadPartialHTML_(partial) {
  const htmlServ = HtmlService.createTemplateFromFile(partial);
  return htmlServ.evaluate().getContent();
  
}

function loadSearchView(){
 
   return loadPartialHTML_("search");
}

serverSideFuncs.gs

function getDataForSearch(){
    
  const ss = SpreadsheetApp.getActiveSpreadsheet();
  const ws = ss.getSheetByName("Array");
  
  return ws.getRange(2, 1, ws.getLastRow(),8).getValues();

}

Arithmetic overflow error converting numeric to data type numeric (SQL Server). But the columns are big enough to contain data

We are getting the following error when inserting our data into SQL Server table:
Arithmetic overflow error converting numeric to data type numeric

The data we are inserting looks like this:
INSERTED.ID VALUES(0, ‘Blah Blah’, 6202, 2, -697937977842128, -179239499006078, 529122280867677, -682697977842128, -163999499006078, 529445721858303, -690317977842128, -171619499006078, 52928400136299, 1000)

But the column definitions for the big numbers are all Decimal(18,9) so I am not sure why we are getting this error.

plotting – How to make columns different colors in an ArrayPlot?

Consider an ArrayPlot of some arbitrary matrix with values between zero and one.

matrix = {
          {0.1, 0.1, 0.1}
        , {0.3, 0.3, 0.3}
        , {0.5, 0.5, 0.5}
      };

I want to plot this matrix as an ArrayPlot but with each Column as a different color.

Using ColorFunction and Lighter I can make all the Columns the same color.

matrix = {{0.1, 0.1, 0.1}, {0.3, 0.3, 0.3}, {0.5, 0.5, 0.5}};
ArrayPlot(matrix, ColorFunction -> (Lighter(Red, #) &))

How do I make each Column of the ArrayPlot shades of a different color?

For instance, I would like to make the cells of the first column shades of blue.

sharepoint online – Power Automate – Changing a column’s properties removes it from the schema

Before I go tear apart an entire workflow and app to fix this, I wanted to see if there was a simpler solution.

I have a flow in SPO that needs to set a People column with an “Update Item” action. Originally that column was set to allow multiple people, and that was fine. Then I ran into an issue where I had to switch it to single selections instead. That broke the workflow, naturally. At first it was giving me an error saying the field didn’t exist anymore and should be removed from the schema of the update. I just deleted and re-added the “Update Item” action, but now the People column isn’t even showing up.

My only idea is to completely rip out and recreate the column, but that would bust various parts of the workflow and its associated app. Any thoughts?

google sheets – How to use counta function with two columns (or)

Try this:

=COUNTA(FILTER(A:A,A:A&B:B<>""))

Really the first B:B could be A:A or D:D or ROW(A:A). It’s just there to have something for COUNTA to count.

By concatenating each row-cell of A:A with the corresponding row-cell of B:B, we form one string, which we can evaluate as one string and thus count as one string.

how to handle divide zero in generate columns in MySQL

Now I am using generate columns in MySQL 5.7:

ALTER TABLE report_user 
MODIFY avg_trans_out_amount bigint 
GENERATED ALWAYS AS (round(trans_out_amount/(trans_out_count))) STORED;

but sometimes the trans_out_count could be 0, then the generate columns will encount divide zero. so I do it like this:

ALTER TABLE report_user 
MODIFY avg_trans_out_amount bigint 
GENERATED ALWAYS AS (round(trans_out_amount/(trans_out_count+0.00001))) STORED;

but the data could be a little problem like 100000/1.00001, the right value is 100000, but the actual value it not correct 9,999.90. what should I do to handle this problem? this is the table DML:

CREATE TABLE `report_user` (
  `trans_into_count` int(11) NOT NULL DEFAULT '0' COMMENT '转入次数',
  `trans_out_count` int(11) NOT NULL DEFAULT '0' COMMENT '转出次数',
  `trans_into_amount` bigint(11) NOT NULL DEFAULT '0' COMMENT '转入金额',
  `trans_out_amount` bigint(11) NOT NULL DEFAULT '0' COMMENT '转出金额',
  `avg_trans_into_amount` bigint(20) GENERATED ALWAYS AS (round((`trans_into_amount` / (`trans_into_count` + 0.00001)),0)) STORED,
  `avg_trans_out_amount` bigint(20) GENERATED ALWAYS AS (round((`trans_out_amount` / (`trans_out_count` + 0.00001)),0)) STORED,
  `user_name` varchar(256) COLLATE utf8mb4_bin NOT NULL DEFAULT '' COMMENT '用户名',
  `user_id` bigint(20) NOT NULL COMMENT '用户ID'
) ENGINE=InnoDB AUTO_INCREMENT=36149 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin COMMENT='提转统计';

How to create new columns based on over(partition by) another column?

I have a query that gives me this table:

| contract | sent_date |
| -------- | --------- |
|    a     |2020-01-02 |
|    a     |2020-01-02 |
|    b     |2020-01-02 |
|    a     |2020-01-03 |
|    c     |2020-01-03 |
|    b     |2020-01-04 |
|    a     |2020-01-05 |
|    a     |2020-01-05 |

I want to aggregate the count of each contract for each sent date. So the return table looks like:

| contract | 2020-01-02 | 2020-01-03 | 2020-01-04 | 2020-01-05 |
| -------- | ---------- | ---------- | ---------- | ---------- |
|    a     |     2      |     1      |     0      |     2      |
|    b     |     1      |     0      |     1      |     0      |
|    c     |     0      |     1      |     0      |     0      |

Could anyone kindly give me some guidance how to form such query? Thank you.

Excel returns TRUE on comparison of two columns. However one cell contains value 0 and other cell is empty

How can I compare excel sheet data. If 1st sheet contains ‘0’ and 2nd sheet is empty. Currently, excel return TRUE, which is wrong. I do comparisons like below. Is there any way to return false when value doesn’t match or anyone cell is empty.

='Sheet1'!A34='Sheet2'!A34

enter image description here

Data tables: Combining 2 columns into 1

I am a budding UX designer currently working on a booking management system that allows both booking by the HR and employees. HR can make bookings on behalf of the employees via the management system whereas the employees make their bookings on a mobile app.

HR cannot overwrite data input by employees (e.g name, email, mobile) but can do so if it’s data input by HR themselves.

Problem:
Presently, the system only shows 1 name column which is the one imported by the HR. As such, we have instances where the HR wants to change the name but couldn’t because it has been updated by the employees on the mobile app.

On the backend however, there are 2 names data, HR imported name and employee updated name.

Proposed solution:
I proposed to concatenate the 2 name columns and create a new column ‘latest name’ so the HR will not need to refer to 2 columns for the ‘same’ information. This column will always show employee updated name when available, otherwise HR imported name. All employee updated name will be indicated with an asterisk and upon hover, a tooltip will appear to tell the HR that it has been updated by employee.
Proposed design

We will still keep the 2 original name data, but tucked in a filter column button where user can choose to show.


However, my engineer mentioned that many rows are already overloaded and prefers a more generic solution.

Does anyone here have any ideas how else I can do it?