1 minute read

Tags: , , ,

CI/CD


Gitlab ci/cd

  • https://docs.gitlab.com/ee/ci/pipelines/

  • A typical pipeline might consist of four stages, executed in the following order:

    • A build stage, with a job called compile.
    • A test stage, with two jobs called test1 and test2.
    • A staging stage, with a job called deploy-to-stage.
    • A production stage, with a job called deploy-to-prod.

Gitlab SSH or 要加 personal access token

  • [https://teamdynamix.umich.edu/TDClient/47/LSAPortal/KB/ArticleDet?ID=1517]{:target=”_back”}
git remote set-url <https://token name you picked:the personal access token@gitlab.umich.edu/user or project/repo name.>




JavaScript


js round .25

var number = 5.12345;
number = (Math.round(number * 4) / 4).toFixed(2);

在 url 中 + # 等 都會 GG

// encodes characters such as ?,=,/,&,:
console.log(`?x=${encodeURIComponent("test?")}`);
// expected output: "?x=test%3F"

console.log(`?x=${encodeURIComponent("шеллы")}`);
// expected output: "?x=%D1%88%D0%B5%D0%BB%D0%BB%D1%8B"

印東西

function PrintElem(elem) {
  var mywindow = window.open("", "PRINT", "height=400,width=600");

  mywindow.document.write("<html><head><title>" + document.title + "</title>");
  mywindow.document.write("</head><body >");
  mywindow.document.write("<h1>" + document.title + "</h1>");
  mywindow.document.write(document.getElementById(elem).innerHTML);
  mywindow.document.write("</body></html>");

  mywindow.document.close(); // necessary for IE >= 10
  mywindow.focus(); // necessary for IE >= 10*/

  mywindow.print();
  mywindow.close();

  return true;
}

下載 canvas

const canvas = document.getElementById(id);
const pngUrl = canvas
  .toDataURL("image/png")
  .replace("image/png", "image/octet-stream");
let downloadLink = document.createElement("a");
downloadLink.href = pngUrl;
downloadLink.download = `${name}.png`;
document.body.appendChild(downloadLink);
downloadLink.click();
document.body.removeChild(downloadLink);




Git


git set-url

git remote set-url <remote_name> <remote_url>

git 拿 某個 commit 下面的 某之檔案

  1. 用 gitk or sourceTree 找到 那個 commit 的 ``

  2. git checkout <commit-id> --fileName

本次狀況: 我的 package-lock 有毒 只能用華華的 XDD

git chkcout xxxx --packag-lock.json




開發


VSC 自動排版

  • settings:

    • File > Preferences > Settings
      • Editor: Format On Save
  • 阿如果還沒有!

    • Editor: Default Frmatter
      • 自己去找: 自己喜歡的(我是用: prettier-Code formatter)