短叹

文章 评论 浏览 27

短叹 2025-02-20 19:32:43

handleselectall 中,您需要设置 checkeditems 是您的所有数组项目。您不需要 iScheckall 状态,您可以通过验证 checkedItems 的长度查看所有状态,

const flattenCartData = (cartData) => {
  const arr = [];
  cartData.Result.forEach((shop) => {
    shop.ShopCartList.forEach((cart) => {
      cart.productCartList.forEach((items) => {
        arr.push(items);
      });
    });
  });
  return arr;
};

export default function App() {
  const [checkedItems, setCheckedItems] = useState(
    JSON.parse(localStorage.getItem("checkedItems") || "[]")
  );
  const ITEMS = flattenCartData(cartData);
  const isCheckAll = checkedItems.length === ITEMS.length;
  useEffect(() => {
    localStorage.setItem("checkedItems", JSON.stringify(checkedItems));
  }, [checkedItems]);
  const addChecked = (itemId, variationId, qty) => {
    setCheckedItems([
      ...checkedItems,
      { ProductID: itemId, VariationID: variationId, Count: qty }
    ]);
  };

  const removeChecked = (itemId, variationId) => {
    const toBeRemove = checkedItems.find(
      (item) => item.ProductID === itemId && item.VariationID === variationId
    );

    if (toBeRemove) {
      checkedItems.splice(checkedItems.indexOf(toBeRemove), 1);
      setCheckedItems([...checkedItems]);
    }
  };

  const getCheckedStatus = (itemId, variationId) => {
    const found = checkedItems.find(
      (item) => item.ProductID === itemId && item.VariationID === variationId
    );

    return found !== undefined;
  };

  const handleSelectAll = (e) => {
    if (isCheckAll) {
      setCheckedItems([]);
    } else setCheckedItems([...ITEMS]);
  };

  return (
    <div className="App">
      {cartData.Result.map((shop) =>
        shop.ShopCartList.map((cart) => (
          <div key={cart.ShopID} md="12" lg="12">
            {cart.productCartList.map((items) => {
              return (
                <div key={items.VariationID} md="12" lg="12">
                  <div id="additem" className="pt-5">
                    {items.Stock === 0 ? (
                      <h6 className="bg-light text-danger font-weight-bold ">
                        SOLD OUT
                      </h6>
                    ) : (
                      <div>
                        <input
                          type="checkbox"
                          checked={getCheckedStatus(
                            items.ProductID,
                            items.VariationID
                          )}
                          onChange={(e) => {
                            if (e.target.checked) {
                              addChecked(
                                items.ProductID,
                                items.VariationID,
                                items.Count
                              );
                            } else {
                              removeChecked(
                                items.ProductID,
                                items.VariationID,
                                items.Count
                              );
                            }
                          }}
                        />
                        <span>{items.ProductName}</span>
                      </div>
                    )}
                  </div>
                </div>
              );
            })}
          </div>
        ))
      )}
      <div>
        <input
          type="checkbox"
          name="selectAll"
          id="selectAll"
          onChange={handleSelectAll}
          checked={isCheckAll}
        />
        Select All
      </div>
    </div>
  );
}

我创建了 codesandbox 。您可以检查,希望它有帮助!

In handleSelectAll you need to set checkedItems is all your array items. You dont need isCheckAll state, you can see check all status by verify length of your checkedItems

const flattenCartData = (cartData) => {
  const arr = [];
  cartData.Result.forEach((shop) => {
    shop.ShopCartList.forEach((cart) => {
      cart.productCartList.forEach((items) => {
        arr.push(items);
      });
    });
  });
  return arr;
};

export default function App() {
  const [checkedItems, setCheckedItems] = useState(
    JSON.parse(localStorage.getItem("checkedItems") || "[]")
  );
  const ITEMS = flattenCartData(cartData);
  const isCheckAll = checkedItems.length === ITEMS.length;
  useEffect(() => {
    localStorage.setItem("checkedItems", JSON.stringify(checkedItems));
  }, [checkedItems]);
  const addChecked = (itemId, variationId, qty) => {
    setCheckedItems([
      ...checkedItems,
      { ProductID: itemId, VariationID: variationId, Count: qty }
    ]);
  };

  const removeChecked = (itemId, variationId) => {
    const toBeRemove = checkedItems.find(
      (item) => item.ProductID === itemId && item.VariationID === variationId
    );

    if (toBeRemove) {
      checkedItems.splice(checkedItems.indexOf(toBeRemove), 1);
      setCheckedItems([...checkedItems]);
    }
  };

  const getCheckedStatus = (itemId, variationId) => {
    const found = checkedItems.find(
      (item) => item.ProductID === itemId && item.VariationID === variationId
    );

    return found !== undefined;
  };

  const handleSelectAll = (e) => {
    if (isCheckAll) {
      setCheckedItems([]);
    } else setCheckedItems([...ITEMS]);
  };

  return (
    <div className="App">
      {cartData.Result.map((shop) =>
        shop.ShopCartList.map((cart) => (
          <div key={cart.ShopID} md="12" lg="12">
            {cart.productCartList.map((items) => {
              return (
                <div key={items.VariationID} md="12" lg="12">
                  <div id="additem" className="pt-5">
                    {items.Stock === 0 ? (
                      <h6 className="bg-light text-danger font-weight-bold ">
                        SOLD OUT
                      </h6>
                    ) : (
                      <div>
                        <input
                          type="checkbox"
                          checked={getCheckedStatus(
                            items.ProductID,
                            items.VariationID
                          )}
                          onChange={(e) => {
                            if (e.target.checked) {
                              addChecked(
                                items.ProductID,
                                items.VariationID,
                                items.Count
                              );
                            } else {
                              removeChecked(
                                items.ProductID,
                                items.VariationID,
                                items.Count
                              );
                            }
                          }}
                        />
                        <span>{items.ProductName}</span>
                      </div>
                    )}
                  </div>
                </div>
              );
            })}
          </div>
        ))
      )}
      <div>
        <input
          type="checkbox"
          name="selectAll"
          id="selectAll"
          onChange={handleSelectAll}
          checked={isCheckAll}
        />
        Select All
      </div>
    </div>
  );
}

I have created a codesandbox. You can check, hope it help!

选择ALL REECT JS中的所有复选框

短叹 2025-02-20 09:32:43

在您的功能的此部门中:

if (taxWage > minWage) {
    // calculates tax recursively calling two other functions difference() and taxStep() 
    tax = tax + difference(taxWage) * taxStep(taxWage);
    var newSalary = taxWage - difference(taxWage);
    taxes(tax, newSalary); 
}

您没有从功能或设置 return tax 中返回值。当您不返回任何内容时,返回值为 undefined

也许,您想要这个:

if (taxWage > minWage) {
    // calculates tax recursively calling two other functions difference() and taxStep() 
    tax = tax + difference(taxWage) * taxStep(taxWage);
    var newSalary = taxWage - difference(taxWage);
    return taxes(tax, newSalary); 
}

In this arm of your function:

if (taxWage > minWage) {
    // calculates tax recursively calling two other functions difference() and taxStep() 
    tax = tax + difference(taxWage) * taxStep(taxWage);
    var newSalary = taxWage - difference(taxWage);
    taxes(tax, newSalary); 
}

you are not returning a value from the function or setting returnTax. When you don't return anything, the return value is undefined.

Perhaps, you want this:

if (taxWage > minWage) {
    // calculates tax recursively calling two other functions difference() and taxStep() 
    tax = tax + difference(taxWage) * taxStep(taxWage);
    var newSalary = taxWage - difference(taxWage);
    return taxes(tax, newSalary); 
}

递归功能返回未定义

短叹 2025-02-20 04:52:42

也许在其中放置条件,如果课程是背景检查,那么第二级顶级课程并具有一定的阈值。因此,说出背景是否检测到第二最佳信心是什么,然后使用该课程。

Maybe put a condition in there and if class is background check the 2nd top class and have some threshold. So say if it detects background see what 2nd best confidence was and use that class instead.

图像分类如何制作程序&#x27;几秒钟

短叹 2025-02-20 04:20:35

只需为您的作者实体添加渴望即可。
这样:

import {
  Entity,
  Column,
  PrimaryGeneratedColumn,
  ManyToMany,
  JoinTable,
} from 'typeorm';

import { Book } from '../entities/book.entity';

@Entity()
export class Author {
  @PrimaryGeneratedColumn()
  id: number;

  @Column()
  FirstName: string;

  @Column()
  LastName: string;
//right here!
  @ManyToMany(() => Book,{eager:true})
  @JoinTable()
  Books: Book[];
  //In order to create an object using the book entity I need to define constructors.
  constructor(FirstName: string, LastName: string, Books: Book[]);
  constructor(FirstName: string, LastName: string, Books: Book[], id?: number) {
    this.FirstName = FirstName || '';
    this.LastName = LastName || '';
    this.Books = Books || null;
    this.id = id || null;
  }
}

如果没有急切的态度,当您调用find()方法时,它将无法自动加入。

just add eager to you author entity.
Like this :

import {
  Entity,
  Column,
  PrimaryGeneratedColumn,
  ManyToMany,
  JoinTable,
} from 'typeorm';

import { Book } from '../entities/book.entity';

@Entity()
export class Author {
  @PrimaryGeneratedColumn()
  id: number;

  @Column()
  FirstName: string;

  @Column()
  LastName: string;
//right here!
  @ManyToMany(() => Book,{eager:true})
  @JoinTable()
  Books: Book[];
  //In order to create an object using the book entity I need to define constructors.
  constructor(FirstName: string, LastName: string, Books: Book[]);
  constructor(FirstName: string, LastName: string, Books: Book[], id?: number) {
    this.FirstName = FirstName || '';
    this.LastName = LastName || '';
    this.Books = Books || null;
    this.id = id || null;
  }
}

without the eager, it won't be able to join automatically when you call the find() method.

即使在调用查找或查找功能时,即使它们之间存在关系,实体即使它们之间有关系

短叹 2025-02-19 22:12:56

在第一步,我们需要一个符号来解决数组中的项目,我喜欢点表示法,

$array = [
    'item_1' => [
        'item_2' => 1,
        'item_3' => [
            'item_4',
            'item_5'
        ]
    ]
];

例如'item_1.item_3.0'而不是$ array ['item_1'] ['item_3'] [0]

现在我们需要在我们的地址密钥上迭代并找到目标元素,

function  replaceArrayItem($searchKey, $replacement, $array) {
    $itemAddressBlocks = explode('.', $searchKey); // convert to array so we can iterate on address
    
    $replacedArray = $array;
    $temp = &$replacedArray; // pass by reference

    foreach($itemAddressBlocks as $depth => $index) {
        if( $depth < sizeof($itemAddressBlocks) - 1 ) {  // rolling in the deep :)
            $temp = &$temp[$index];  
            continue;
        }
        
        $temp[$index] = $replacement;  // last step and replacement
    }
    
    return $replacedArray;
}

现在让我们测试我们的新功能,


/**
Array
(
    [item_1] => ***replacedItem***
)
**/
print_r( replaceArrayItem('item_1', 'replacedItem', $array) );

/**
Array
(
    [item_1] => Array
        (
            [item_2] => ***replacedItem***
            [item_3] => Array
                (
                    [0] => item_4
                    [1] => item_5
                )

        )

)
**/
print_r( replaceArrayItem('item_1.item_2', 'replacedItem', $array) );


/**
Array
(
    [item_1] => Array
        (
            [item_2] => 1
            [item_3] => Array
                (
                    [0] => item_4
                    [1] => ***replacedItem***
                )

        )

)


**/
print_r( replaceArrayItem('item_1.item_3.1', 'replacedItem', $array) );



现在可以进行前进

$itemAddress = 'content.0';
for($i =0; $i < 4; $i++) {
    $itemAddress .= '.elements.0';
}
$itemAddress .= '.settings._attributes';

replaceArrayItem($itemAddress, $yourValue, $array);

At the very first step we need a notation to address an item in an array, i like the dot notation

$array = [
    'item_1' => [
        'item_2' => 1,
        'item_3' => [
            'item_4',
            'item_5'
        ]
    ]
];

For example 'item_1.item_3.0' instead of $array['item_1']['item_3'][0]

Now we need to iterate on our address key and find destination element

function  replaceArrayItem($searchKey, $replacement, $array) {
    $itemAddressBlocks = explode('.', $searchKey); // convert to array so we can iterate on address
    
    $replacedArray = $array;
    $temp = &$replacedArray; // pass by reference

    foreach($itemAddressBlocks as $depth => $index) {
        if( $depth < sizeof($itemAddressBlocks) - 1 ) {  // rolling in the deep :)
            $temp = &$temp[$index];  
            continue;
        }
        
        $temp[$index] = $replacement;  // last step and replacement
    }
    
    return $replacedArray;
}

Now lets test our new function


/**
Array
(
    [item_1] => ***replacedItem***
)
**/
print_r( replaceArrayItem('item_1', 'replacedItem', $array) );

/**
Array
(
    [item_1] => Array
        (
            [item_2] => ***replacedItem***
            [item_3] => Array
                (
                    [0] => item_4
                    [1] => item_5
                )

        )

)
**/
print_r( replaceArrayItem('item_1.item_2', 'replacedItem', $array) );


/**
Array
(
    [item_1] => Array
        (
            [item_2] => 1
            [item_3] => Array
                (
                    [0] => item_4
                    [1] => ***replacedItem***
                )

        )

)


**/
print_r( replaceArrayItem('item_1.item_3.1', 'replacedItem', $array) );



Now You can progamatically

$itemAddress = 'content.0';
for($i =0; $i < 4; $i++) {
    $itemAddress .= '.elements.0';
}
$itemAddress .= '.settings._attributes';

replaceArrayItem($itemAddress, $yourValue, $array);

在嵌套数组-PHP中替换值

短叹 2025-02-19 19:36:42

,只有一个请求将同时处理特定线程?

同时 - 是的,同一线程内的执行是顺序的,因此它不会同时处理多个请求。但是,由于请求处理线程被汇总和重复使用,因此将重复使用以后的不同用户请求。请求处理后,您似乎不会清理线程的上下文,因此这是问题所在。

清理工作的好地方是调用 filterchain.dofilter()

and only one request will be processed at the same time in particular thread?

At the same time — yes, the execution inside the same thread is sequential, so it won't process multiple requests at the same time. However, it will be reused for future requests of different users, since request processing threads are pooled and reused. You don't seem to clean up the context from the thread after request processing, so this would be the problem.

A good place to do the cleanup would be after calling filterChain.doFilter().

使用嵌入式tomcat在弹簧靴中使用ThreadLocal安全地持有数据

短叹 2025-02-19 17:44:05

Description

这是一个示例脚本的示例脚本,即如何用后缀号码重命名表格,以避免重命名已经存在的名称。

code.gs

function insertSheet() {
  try {
    let ss = SpreadsheetApp.getActiveSpreadsheet();
    let tz = ss.getSpreadsheetTimeZone();
    let name = Utilities.formatDate(new Date(), tz, 'MM-dd-yyyy');
    let sheets = ss.getSheets();
    // get sheets that include today's date at the start of the name
    sheets = sheets.filter( sheet => sheet.getName().indexOf(name) === 0 );
    if( sheets.length > 0 ) {
      let min = 0;
      // get the lowest number suffix (i.e. -3, -2, -1)
      sheets.forEach( sheet => {
          let i = parseInt(sheet.getName().slice(name.length));
          min = i < min ? i : min;
        }
      );
      // now rename starting from lowest number (i.e. -3)
      while( min < 1 ) {
        let rename = min === 0 ? name : name+min;
        let sheet = ss.getSheetByName(rename);
        if( sheet ) {
          sheet.setName(name+(min-1));
        }
        min++;
      }
    }
    let sheet = ss.insertSheet(1);
    sheet.setName(name);
  }
  catch(err) {
    console.log(err);
  }
}

参考

  • string.indexof(
  • ) jsref/jsref_foreach.asp“ rel =” nofollow noreferrer“> array.foreach()
  • noreflow一个href =“ https://www.w3schools.com/jsref/jsref_parseint.asp” rel =“ nofollow noreferrer”> parseint()

Description

Here is an example script of how to rename sheets with a suffix number that avoids renaming a sheet with a name that already exists.

Code.gs

function insertSheet() {
  try {
    let ss = SpreadsheetApp.getActiveSpreadsheet();
    let tz = ss.getSpreadsheetTimeZone();
    let name = Utilities.formatDate(new Date(), tz, 'MM-dd-yyyy');
    let sheets = ss.getSheets();
    // get sheets that include today's date at the start of the name
    sheets = sheets.filter( sheet => sheet.getName().indexOf(name) === 0 );
    if( sheets.length > 0 ) {
      let min = 0;
      // get the lowest number suffix (i.e. -3, -2, -1)
      sheets.forEach( sheet => {
          let i = parseInt(sheet.getName().slice(name.length));
          min = i < min ? i : min;
        }
      );
      // now rename starting from lowest number (i.e. -3)
      while( min < 1 ) {
        let rename = min === 0 ? name : name+min;
        let sheet = ss.getSheetByName(rename);
        if( sheet ) {
          sheet.setName(name+(min-1));
        }
        min++;
      }
    }
    let sheet = ss.insertSheet(1);
    sheet.setName(name);
  }
  catch(err) {
    console.log(err);
  }
}

References

用今天的日期重命名一个标签,并“ mm/dd/yyyy”然后是“ mm/dd/yyyy-1”的另一个

短叹 2025-02-19 10:39:48

您需要转换为数组,然后应用排序方法,然后再次加入字符串,尝试以下操作:

strs = ["one", "two"];
let sorted_str = strs.map((s) => [s.split('').sort().join(''), s])

console.log(sorted_str);

You need to convert to array, then apply the sort method, and then join to a string again, try this:

strs = ["one", "two"];
let sorted_str = strs.map((s) => [s.split('').sort().join(''), s])

console.log(sorted_str);

在JavaScript中使用MAP()时,在元素上使用字符串函数?

短叹 2025-02-19 06:21:58

我一直在查看一些答案,此代码给出了正确的答案,但是我感到困惑的是,当您使用左桌上的子句时,您的查询会变成/行为,但为什么不这样做,但是为什么不是上面的代码表现得像内心一样,有人可以解释吗?

一般而言,关于“查询变为/行为的行为”的短语通常是不正确的。仅当直接在位置中使用右表的列时,这是正确的,并且连接条件定义的右表行的可能性不得存在,因此根据列值可以不考虑列值。您的查询使用Cocece,因此考虑到列值可能是由于连接的行吸收而无效的,并且您的查询会产生所需的输出。

ie在这种情况下 on e.empid = b.empid and cocece(b.benus,0)&lt; = 1000 应该正确工作吗?

不,它将产生与您需要的输出不同的输出。此类查询变体还将返回'Thomas'的行,并在奖励列中返回与所需输出不同的奖金列。


如果您将条件从哪里移至输出列表,您可能会了解这一点。比较输出:

SELECT E.NAME, B.BONUS
       , COALESCE(B.BONUS,0)<=1000 AS criteria_for_where
FROM EMPLOYEE AS E 
LEFT JOIN BONUS AS B ON E.EMPID = B.EMPID 
-- WHERE COALESCE(B.BONUS,0)<=1000

并且

SELECT E.NAME, B.BONUS
FROM EMPLOYEE AS E 
LEFT JOIN BONUS AS B ON E.EMPID = B.EMPID and COALESCE(B.BONUS,0)<=1000

还考虑到 - 附加条件和Cocce(B.Bonus,0)&lt; = 1000 仅应用于现有的奖励表,因此CoceSce用法在案例,并将第三查询添加到比较中,该查询将执行与第二查询一样:

SELECT E.NAME, B.BONUS
FROM EMPLOYEE AS E 
LEFT JOIN BONUS AS B ON E.EMPID = B.EMPID and B.BONUS<=1000

PS。您的任务条件告诉:“奖金少于1000”,而不是“少或相等” /“不高于”。因此,您必须不使用&lt; = ,而是&lt;

pps。 “但是我感到困惑的是,当您使用左表的左表上的子句时,您会错误地定义左/右表。您必须查看查询文本中的表格 - 因此员工为左表,奖金是右表。当使用左联接时,这意味着“从左表拿起所有行”,右联接表示“从右表中拿起所有行”。

I have been looking at some answers and this code gives right answer, but I am confused its said that when you use where clause on left table with left Join, you query becomes/behaves like Inner join, but why isn't the code above behaving like Inner Join, can someone explain?

The phrase about "query becomes/behaves like Inner join" is not correct in general. It is correct only when the column from right table is used directly in WHERE, and the possibility that the right table row defined by joining condition must not present and hence the according column value can be NULL is not taken into account. Your query uses COALESCE, so it takes into account that the column value may be NULL due to joined row absense, and your query produces needed output.

i.e. in this case ON E.EMPID = B.EMPID AND COALESCE(B.BONUS,0)<=1000, should work right?

No, it will produce the output which differs from one you need. Such query variant will also return the row for 'Thomas' with NULL in BONUS column which differs from the desired output.


You may understand this everything if you'd move the condition from WHERE to the output list. Compare the outputs:

SELECT E.NAME, B.BONUS
       , COALESCE(B.BONUS,0)<=1000 AS criteria_for_where
FROM EMPLOYEE AS E 
LEFT JOIN BONUS AS B ON E.EMPID = B.EMPID 
-- WHERE COALESCE(B.BONUS,0)<=1000

and

SELECT E.NAME, B.BONUS
FROM EMPLOYEE AS E 
LEFT JOIN BONUS AS B ON E.EMPID = B.EMPID and COALESCE(B.BONUS,0)<=1000

Also take into account - additional condition and COALESCE(B.BONUS,0)<=1000 is applied to existing rows of BONUS table only, so COALESCE usage makes no sense in the case, and add 3rd query to the comparing which will do the same like 2nd query:

SELECT E.NAME, B.BONUS
FROM EMPLOYEE AS E 
LEFT JOIN BONUS AS B ON E.EMPID = B.EMPID and B.BONUS<=1000

PS. Your task condition tells: "with a bonus less than 1000", not "less or equal" / "not above". So you must use not <= but <.

PPS. "but I am confused its said that when you use where clause on left table with left Join" - you define left/right tables incorrectly. You must look at the table posession in the query text - so EMPLOYEE is left table and BONUS is right table. When LEFT JOIN is used than this means "take all rows from left table", and RIGHT JOIN means "take all rows from right table" accordingly.

为什么代码不像内部连接一样行事?在哪里vs和左加入?

短叹 2025-02-19 05:26:46

请尝试一下,与删除所有其他删除的源文件的良好远程同步,一个用于压缩的好镜子添加 -z flag, - delete-delay 等待等待直到复制文件...

简单的快速答案,忽略现有文件,快速,清理旧文件,等待完成,递归等。

rsync -rtvu --delete-delay source_folder/ destination_folder/

干燥/测试:

我意识到您没有要求,但是为了帮助您的情况,我建议您进行干式运行[A-存档,n-Dryrun,v-verobse], -a 使复制递归并保留像修改时间之类的原始道具,同时还要复制其符合Symlinks的符号链接,保留权限,保留所有者和组信息,并保留设备和特殊文件...

//[A-archive,n-DryRun,V-Verobse]
rsync -anv someDir1/ someDestdir2

// now compare those two
rsync -anv someDir1 someDestdir2   

在处理远程服务器时

1 ssh

*In some cases, if you are `rsync`ing between two servers, wordpress hosting etc, rsync doesn't manage/have the connection between the two servers, you can ssh into them and run this*

// rsync between two remote servers, if you have ssh, this i
ssh -R 50000:host2:22 host1 'rsync -e "ssh -p 50000" -vuar /host1/someDir1 localhost:/host2/someDestdir2'

杂项。用于IP的远程服务器

2 使用域,IP地址和SSH配置文件中定义的服务器的本地文件夹

rsync -rtvz source_folder/ user@domain:/path/to/destination_folder/
rsync -rtvz source_folder/ [email protected]:/path/to/destination_folder/
rsync -rtvz source_folder/ server_name:/path/to/destination_folder/

3 使用域,IP地址和SSH配置文件中定义的服务器的远程文件夹

rsync -rtvz user@domain:/path/to/source_folder/ destination_folder/
rsync -rtvz [email protected]:/path/to/source_folder/ destination_folder/
rsync -rtvz server_name:/path/to/source_folder/ destination_folder/

please try this, a good remote sync with delete any additional removed source files, a good mirror for compression add -z flag, --delete-delay wait till files are copied...

Simple quick answer, ignores existing files, fast, cleans up old files, waits for completion, recursive etc.

rsync -rtvu --delete-delay source_folder/ destination_folder/

Dry Runs/Testing:

I realize you didn't ask, but to help your case, may I recommend a dry run [A-archive,n-DryRun,V-Verobse], -a makes the copy recursive and keeps original props like modification times, while also copying the symlinks that it encounters as symlinks, preserve the permissions, preserve the owner and group information, and preserve device and special files...

//[A-archive,n-DryRun,V-Verobse]
rsync -anv someDir1/ someDestdir2

// now compare those two
rsync -anv someDir1 someDestdir2   

When dealing with Remote Servers

1 With SSH

*In some cases, if you are `rsync`ing between two servers, wordpress hosting etc, rsync doesn't manage/have the connection between the two servers, you can ssh into them and run this*

// rsync between two remote servers, if you have ssh, this i
ssh -R 50000:host2:22 host1 'rsync -e "ssh -p 50000" -vuar /host1/someDir1 localhost:/host2/someDestdir2'

Additional Misc. for Remote servers with IP

2 Local folder to remote folder, using a domain, an IP address and a server defined in the SSH configuration file:

rsync -rtvz source_folder/ user@domain:/path/to/destination_folder/
rsync -rtvz source_folder/ [email protected]:/path/to/destination_folder/
rsync -rtvz source_folder/ server_name:/path/to/destination_folder/

3 Remote folder to local folder, using a domain, an IP address and a server defined in the SSH configuration file:

rsync -rtvz user@domain:/path/to/source_folder/ destination_folder/
rsync -rtvz [email protected]:/path/to/source_folder/ destination_folder/
rsync -rtvz server_name:/path/to/source_folder/ destination_folder/

带有GitHub文件夹的Rsync Auto本地文件夹

短叹 2025-02-19 02:57:27

从现有存储库中,您可以从 [myRepo] .git 中获取所需的分支 v1.1.2 。 1.2 ):

git fetch origin v1.1.2:v1.1.2

或者如果回购不称为 Origin ,则为

git fetch [myrepo].git v1.1.2:v1.1.2

的左:是要获取的分支/commit
的权利:是新的本地分支名称,

如果您省略:v1.1.2 part,则获取的提交将以 fetch_head 临时可用。
您可以将其用于运行 git分支V1.1.2 fetch_head git Checkout -B v1.1.2 fetch_head 手动。

笔记:
如果您希望单支存储库在将来自动获取 v1.1.2 ,则可能需要调整 .git/config 之后。

From within the existing repository, you can fetch the desired branch v1.1.2 from [myrepo].git into a new local branch with the same name (v1.1.2):

git fetch origin v1.1.2:v1.1.2

or if the repo isn't known as origin, then

git fetch [myrepo].git v1.1.2:v1.1.2

Left of : is the branch/commit to be fetched
Right of : is the new local branch name

If you omit the :v1.1.2 part, then the fetched commit will be temporarily available as FETCH_HEAD.
You could use that to e.g. run git branch v1.1.2 FETCH_HEAD or git checkout -b v1.1.2 FETCH_HEAD manually.

Note:
You probably want to adjust your .git/config after, if you want the single-branch repository to automatically fetch v1.1.2 in future.

将远程分支获取到仅包含一个分支的现有存储库中

短叹 2025-02-19 00:54:48

而不是 qmake -version qmake -project 使用 qmake 的完整路径。

/Users/username/Qt5.12.0/5.12.0/clang_64/bin/qmake -version
/Users/username/Qt5.12.0/5.12.0/clang_64/bin/qmake -project

但是,这不是最佳解决方案。因此,我尝试在〜/.zshrc 中添加 Alias

vi ~/.zshrc 

然后添加别名。我认为,只要您不将其放在其他代码字段中,代码在顶部还是底部都没有关系。

alias qmake="/Users/username/Qt5.12.0/5.12.0/clang_64/bin/qmake"

请记住 source〜/.zshrc 重新加载配置文件并激活更改。

source ~/.zshrc

enter image description here

Instead of qmake -version and qmake -project use the full path of qmake.

/Users/username/Qt5.12.0/5.12.0/clang_64/bin/qmake -version
/Users/username/Qt5.12.0/5.12.0/clang_64/bin/qmake -project

However, it's not the optimal solution. So I try to add alias in ~/.zshrc

vi ~/.zshrc 

Then add the alias. I think whether the code is on the top or the bottom doesn't matter, as long as you don't put it in other code fields.

alias qmake="/Users/username/Qt5.12.0/5.12.0/clang_64/bin/qmake"

Remember to source ~/.zshrc to reload the configuration file and activate the changes.

source ~/.zshrc

ZSH:找不到命令:qmake但是,我安装了QT5.12.0,我可以午餐QT创建者

短叹 2025-02-18 23:02:06

您需要为这种情况定义正确的返回类型。

这样的想法应该有效:

@PostMapping("/query")
public List<Item> getData() {
    List<Item> response = new ArrayList<>();
    Item item = new Item();
    item.type = "table";
    Column col1 = new Columne("Time", "time");
    item.columns.add(col1);
    // add other columns
    item.rows.add(new Object[] {1234567, "SE", 123})
    // add other rows
    response.add(item);
    return response;
}

class Item {
  public String type;
  public List<Column> columns = new ArrayList<>();
  public List<Object[]> rows = new ArrayList<>();
}

class Column {
  public String text;
  public String type;
  public Column(String text, String type) {
    this.text = text;
    this.type = type;
  }
}

You need to define the correct return type for this case.

Somethink like this should work:

@PostMapping("/query")
public List<Item> getData() {
    List<Item> response = new ArrayList<>();
    Item item = new Item();
    item.type = "table";
    Column col1 = new Columne("Time", "time");
    item.columns.add(col1);
    // add other columns
    item.rows.add(new Object[] {1234567, "SE", 123})
    // add other rows
    response.add(item);
    return response;
}

class Item {
  public String type;
  public List<Column> columns = new ArrayList<>();
  public List<Object[]> rows = new ArrayList<>();
}

class Column {
  public String text;
  public String type;
  public Column(String text, String type) {
    this.text = text;
    this.type = type;
  }
}

Java Spring Boot JSON回应

短叹 2025-02-18 22:16:38

您可以从 Matcher 类中使用结果方法,该类将返回 MatchResult s的流首先获得所有匹配项,使用使用结果 matchResult.group ,立即使用方法 string.replaceall 使用模式AS REGEX和您的 fractactionFormatter 作为替换,并最终使用新行加入了所有行:

String fileContent = "aaabbcac aabb\n" +
                     "bcbcbbccc babba";

Pattern pattern = Pattern.compile("bb.*(.)(abb)");
String extractionFormatter = "$1: $0, \\$2";

String output = pattern.matcher(fileContent)
                        .results()
                        .map(MatchResult::group)
                        .map(s -> s.replaceAll(pattern.pattern(), extractionFormatter))
                        .collect(Collectors.joining(System.lineSeparator()));

System.out.println(output);

You can use the results method from the Matcher class which returns a stream of MatchResults to first get all matches, get the results as string using MatchResult.group, replace now using the method String.replaceAll using the pattern as regex and your extractionFormatter as replacement and finally join all using new line:

String fileContent = "aaabbcac aabb\n" +
                     "bcbcbbccc babba";

Pattern pattern = Pattern.compile("bb.*(.)(abb)");
String extractionFormatter = "$1: $0, \\$2";

String output = pattern.matcher(fileContent)
                        .results()
                        .map(MatchResult::group)
                        .map(s -> s.replaceAll(pattern.pattern(), extractionFormatter))
                        .collect(Collectors.joining(System.lineSeparator()));

System.out.println(output);

用Java Regex提取文本并提供参考支持

短叹 2025-02-18 03:56:44
val value: Seq[String] = Await.result(res, 3600000 seconds)

value 将是 string>字符串的 的 dbutils.notebook.run 呼叫的结果。

val value: Seq[String] = Await.result(res, 3600000 seconds)

value will be a List of the String results from the dbutils.notebook.run calls.

如何将Scala未来输出进入单独的变量

更多

推荐作者

櫻之舞

文章 0 评论 0

弥枳

文章 0 评论 0

m2429

文章 0 评论 0

野却迷人

文章 0 评论 0

我怀念的。

文章 0 评论 0

更多

友情链接

    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文