5 minute read

Tags: , , , , , , , , , , , ,

網路!? 知識? :stuck_out_tongue_winking_eye:


DHCP 連線 issues

Gaining security and privacy by partitioning the cache

User-generated content

npm

  • check outdated package

    • npm outdated

Power BI

  • Get Data 資料匯入(Get Data: Database)

  • local
  • 雲端
  • Navigator
    • 拿 table
  • 編輯 data
    • 左邊的 sider bar
    • Applied steps
      • 編輯個步驟的細節
        • 可以移除 or 加入 想要特製的步驟
    • 出圖
      • 編輯畫面上方 (Data/Dril)
    • 設權限
      • 編輯畫面上方 (Modeling)
        • Manage roles
          • roles -> tables -> Table filter DAX expression
  • Power BI
    • Share
      • Embed report
  • 平台
    • APP
    • Desktop
    • 雲端
      • Row - Level Security
        • 從 role 中給 給相關人員信箱 只能看到的 資源

Cryptocurrency

OLTP

GLView

check folder usage




git


git 改了一堆 還沒 commit 然後想要放棄的時候

git clean -df
git checkout -- .
  • git clean removes all untracked files (warning: while it won’t delete ignored files mentioned directly in .gitignore, it may delete ignored files residing in folders) and

  • git checkout clears all unstaged changes.




CI/CD


在 gitlab 中加入 ci/cd vars

  • settings

    • variables [Add Variable]:
      • key: K8S_SECRET_ 開頭 會讓 gitlab 在 build 的時候吃你要指定的變數
      • 把 Flags [protect variable] 反勾
  • CI/CD Variable Description
    K8S_SECRET_* From GitLab 11.7, any variable prefixed with K8S_SECRET_ is made available by Auto DevOps as environment variables to the deployed application.

k8s Persistent Volumes




DB


Data Retetion

HA Database

Patroni Postgres

WAL(Write-Ahead Loggging)

Write-Ahead Logging (WAL) is a standard method for ensuring data integrity. A detailed description can be found in most (if not all) books about transaction processing. Briefly, WAL’s central concept is that changes to data files (where tables and indexes reside) must be written only after those changes have been logged, that is, after log records describing the changes have been flushed to permanent storage. If we follow this procedure, we do not need to flush data pages to disk on every transaction commit, because we know that in the event of a crash we will be able to recover the database using the log: any changes that have not been applied to the data pages can be redone from the log records. (This is roll-forward recovery, also known as REDO.)

postgres 監控

postgres 備份

pgBouncer

  • SetMaxIdleConns

    SetMaxIdleConns sets the maximum number of connections in the idle connection pool.

    If MaxOpenConns is greater than 0 but less than the new MaxIdleConns then the new MaxIdleConns will be reduced to match the MaxOpenConns limit

    If n <= 0, no idle connections are retained.

  • SetMaxOpenConns

    SetMaxOpenConns sets the maximum number of open connections to the database.

    If MaxIdleConns is greater than 0 and the new MaxOpenConns is less than MaxIdleConns, then MaxIdleConns will be reduced to match the new MaxOpenConns limit

    If n <= 0, then there is no limit on the number of open connections. The default is 0 (unlimited).

postgres procedures

  • PL/pgSQL can be used to define trigger procedures. A trigger procedure is created with the CREATE FUNCTION command, declaring it as a function with no arguments and a return type of trigger. Note that the function must be declared with no arguments even if it expects to receive arguments specified in CREATE TRIGGER — trigger arguments are passed via TG_ARGV, as described below.

  • When a PL/pgSQL function is called as a trigger, several special variables are created automatically in the top-level block. They are:

  • NEW

    • Data type RECORD; variable holding the new database row for INSERT/UPDATE operations in row-level triggers. This variable is NULL in statement-level triggers and for DELETE operations.
  • OLD

    • Data type RECORD; variable holding the old database row for UPDATE/DELETE operations in row-level triggers. This variable is NULL in statement-level triggers and for INSERT operations.
  • TG_NAME

    • Data type name; variable that contains the name of the trigger actually fired.
  • TG_WHEN Data type text; a string of BEFORE, AFTER, or INSTEAD OF, depending on the trigger’s definition.

  • TG_LEVEL

    • Data type text; a string of either ROW or STATEMENT depending on the trigger’s definition.
  • TG_OP

    • Data type text; a string of INSERT, UPDATE, DELETE, or TRUNCATE telling for which operation the trigger was fired.
  • TG_RELID

    • Data type oid; the object ID of the table that caused the trigger invocation.
  • TG_RELNAME

    • Data type name; the name of the table that caused the trigger invocation. This is now deprecated, and could disappear in a future release. Use TG_TABLE_NAME instead.
  • TG_TABLE_NAME

    • Data type name; the name of the table that caused the trigger invocation.
  • TG_TABLE_SCHEMA

    • Data type name; the name of the schema of the table that caused the trigger invocation.
  • TG_NARGS

    • Data type integer; the number of arguments given to the trigger procedure in the CREATE TRIGGER statement.
  • TG_ARGV[]

    • Data type array of text; the arguments from the CREATE TRIGGER statement. The index counts from 0. Invalid indexes (less than 0 or greater than or equal to tg_nargs) result in a null value.

postgres json func and operations

  • <>
    • Non-equality operator (same as !=)

SQL: subquery

select *
from member m
where m.name
in
(select
    distinct c.name
from
    club c
where c.sex = 'girl'
and c.age <= 30 ) ;




javascript


react lazy load

import React, { lazy, Suspense } from "react";
const Home = lazy(() => import("./Home"));
const EnglishOne = lazy(() => import("./EnglishOne"));
const EnglishTwo = lazy(() => import("./EnglishTwo"));
const MathOne = lazy(() => import("./MathOne"));
const MathTwo = lazy(() => import("./MathTwo"));
const App = () => {
  return (
    <div>
      ...
      <Suspense fallback={<div>LOADING</div>}>
        <Route exact path="/" component={<Home />} />
        <Route exact path="/english-1" component={<EnglishOne />} />
        <Route exact path="/english-2" component={<EnglishTwo />} />
        <Route exact path="/math-1" component={<MathOne />} />
        <Route exact path="/math-2" component={<MathTwo />} />
      </Suspense>
    </div>
  );
};
export default App;

node max old space size

{
  "scripts": {
    "start": "cross-env NODE_OPTIONS=--max_old_space_size=4096 craco start",
    "build": "GENERATE_SOURCEMAP=false craco build",
    "test": "craco test",
    "eject": "react-scripts eject"
  },




Go


time

  • func (Time) Sub
package main

import (
	"fmt"
	"time"
)

func main() {
	start := time.Date(2000, 1, 1, 0, 0, 0, 0, time.UTC)
	end := time.Date(2000, 1, 1, 12, 0, 0, 0, time.UTC)

	difference := end.Sub(start)
	fmt.Printf("difference = %v\n", difference)

}

cannot assign xxx field of a map

func main() {
    type T struct{x, y int}
    m := make(map[string]*T)
    m["foo"] = &T{1, 5} // Initialization is required, otherwise it contains “nil” pointer
    m["foo"].x = 4
    fmt.Println(m["foo"].x)
}
	for _ , ww := range wooh {
		y, m, _ := ww.EndTime.Date()
		year := strconv.Itoa(y)
		month := strconv.Itoa(int(m))
		k := year + "-" + month
		price := deviceMap[*ww.DeviceName][k]
        var min = ww.EndTime.Sub(ww.StartTime).Minutes() // nanosecond
        var rWooh = model.ReportWooh{
			ww,
			price * min,
		}
		fmt.Println("Price:", price)
        var workOrderId = ww.WorkOrderId // <--- init a var
		reportOutput[workOrderId].Wooh  = append(reportOutput[workOrderId].Wooh , rWooh)
        ...
	}