2022年11月6日 星期日

2022年10月15日 星期六

[Linux] /dev

/dev是device的縮寫


● /dev/sda

SCSI device, SCSI(Small Computer System Interface)是電腦連接周邊裝置的介面 eq. 硬碟,光碟機,NVMe...


● /dev/ttyUSB0


● /dev/ttyS0

UART
stty -F /dev/ttyS0 -a 讀baud rate
echo "test UART" > /dev/ttyS0


Linux /dev目錄詳解和Linux系統各個目錄的作用

2022年10月5日 星期三

[其他] 淨水器DIY / NSF認證

紀錄一下最近研究淨水器的心得,先從3M淨水器講起.

●3us-max-s01h(台版) / 3us-max-s01(美版)

此型號是3M通過NSF認證的淨水器,其中型號中有s的是淨水系統,包含支架,水管...等.

若只要單獨濾心的型號是: 3us-max-f01h(台版) / 3us-max-f01(美版).

台版和美版一模一樣,唯一差別是台版型號多了一個h(有寫信問過美國3M原廠).

台版官方售價為台幣9280元(含安裝).
美版在亞馬遜官方賣場售價為美金47.35元,約台幣1500元(不含安裝),運費約美金20-30元.

2022年10月2日 星期日

[Git] 情境

Your branch is ahead of 'origin/master' by 3 commits

git reset --hard origin/master

branch diverged

git pull --rebase


git pull後overwritten
1. git stash (把修改過的檔案收起來)
2. git pull
3. git stash pop (再拿出來)

2022年8月11日 星期四

[應用程式] Source Insight

快捷鍵

  • F3: search上一個
  • F4: search下一個
  • F5: 跳指定行 = Ctrl+G
  • F10: 向右縮排

其他設定
  • 背景顏色: Options → preference → windows background → color
  • 用快捷鍵按highlight的方法:
    改成按F1
    1. Options → Key assignments
    2. 刪掉Help: Help...  的keystrokes: F1
    3. 在View: Highlight Word 的keystrokes加上F1



#SourceInsight#SourceInsight教學#SourceInsight快捷鍵#SourceInsight快速鍵

2022年8月9日 星期二

[C] Big-Endian vs. Little-Endian

Big-Endian:

資料放到記憶體中時會把最高位元組會放在最低的記憶體位址上.














Little-Endian:

則反,他會把最高位元組放在最高的記憶體位址上.















2022年7月19日 星期二

2022年7月11日 星期一

[應用程式] sublime

標記

標記指定行: Ctrl +F2
尋找標記處: F2

eq. 標記第五行後,前面會出現符號.

排除(exclude)特定檔案或資料夾方式


  • 檔案
    "file_exclude_patterns": ["*.d", "*.cmd"]
  • 資料夾
    "folder_exclude_patterns":[".git"]

跳到指定行數

ctrl + G



2022年7月9日 星期六

[Linux] iptables extension module -string

iptable比對string的Config和Function

●相對應的Kconfig

linux-4.xx/net/netfilter/Kconfig
config NETFILTER_XT_MATCH_STRING
	tristate '"string" match support'
	depends on NETFILTER_ADVANCED
	select TEXTSEARCH
	select TEXTSEARCH_KMP
	select TEXTSEARCH_BM
	select TEXTSEARCH_FSM
	help
	  This option adds a `string' match, which allows you to look for
	  pattern matchings in packets.

	  To compile it as a module, choose M here.  If unsure, say N.

●BM(Boyer-Moore)和 KMP(Knuth-Morris-Pratt)是字串匹配的演算法

相對應的程式位置:
TEXTSEARCH → linux-4.xx/lib/textsearch.c
TEXTSEARCH_KMP → linux-4.xx/lib/ts_kmp.c
TEXTSEARCH_BM → linux-4.xx/lib/ts_bm.c

●比對url的位置

xt_string.c → textsearch_prepare(…)


2022年7月6日 星期三

[Linux] Kconfig中的depends on和select

config A
   depends on B
   select C


CONFIG_A能否開啟,取決於CONFIG_B是否開啟,
若CONFIG_A被開啟後,CONFIG_C也會自動被開啟.


make menuconfig → 讀取Kconfig →最後存到.config

2022年7月4日 星期一

[Linux] printk顯示關閉時間

時間開啟或關閉




開機後控制:
Enable dmesg timestamp
echo Y > /sys/module/printk/parameters/time

Disable dmesg timestamp
echo N > /sys/module/printk/parameters/time


make menuconfig設定:
CONFIG_PRINTK_TIME=y

2022年5月27日 星期五

[Linux] Makefile Function

define funcName
@echo "pram1 = $(0)"
@echo "pram2 = $(1)"
@echo "pram3 = $(2)"
endef

all:
$(call funcName,hello 1,hello 2)


2022年5月2日 星期一

[C] JSON Library

安裝JSON函式庫(操作環境 ubuntu)
sudo apt install libjson-c-dev


範例1
int main()
{
	json_object *retObj_1 = NULL, *retObj_2 = NULL, *json_obj = NULL;
	int val_1, val_2;

	json_obj = json_object_new_object();

	/*Add object*/
	json_object_object_add(json_obj, "item1", json_object_new_int(123));
	json_object_object_add(json_obj, "item2", json_object_new_int(456));

	/*讀出json_obj內的所有key and value*/
	printf("%s\n", json_object_to_json_string(json_obj)); 
	//-> { "item1": 123, "item2": 456 }

	/*Get object, 下列兩種取到的object是一樣的*/
	retObj_1 = json_object_object_get(json_obj, "item1"); 	
	json_object_object_get_ex(json_obj, "item1", &retObj_2);
	//if retObj_1 = 0, item1 isn't existing

	val_1 = json_object_get_int (retObj_1);
	val_2 = json_object_get_int (retObj_2);
	printf(%d\n", json_object_get_int(val_1)); //-> 123
	printf("%d\n", json_object_get_int(val_2)); //-> 123
}

2022年4月28日 星期四

[Linux] iptables

filter table

  • INPUT
  • OUTPUT
  • FORWARD

nat table

  • PREROUTING
  • POSTROUTING
  • OUTPUT
  • mangle table
  • PREROUTING
  • OUTPUT
  • FORWARD
  • INPUT
  • POSTROUTING

raw table

  • PREROUTING
  • OUTPUT

2022年3月23日 星期三

[網頁] HTML, JavaSrcipt, CSS

<input type="text" v-model="message">

其中type的種類
button、checkbox、file、hidden、image、password、radio、reset、submit、text、color、date、datetime、datetime-local、email、month、number、range、search、tel、time、url、week



----------
JS函式

 

substring()

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/substring

2022年1月26日 星期三

[Linux] 取得時間及計時

Linux user space取得時間方式及計時方式


struct timeval結構內容
struct timeval 
{
   time_t tv_sec;/* seconds */   
   suseconds_t tv_usec;/* microseconds */   
}


2022年1月16日 星期日

[網路] 網路線線材介紹

如何區分各種網路線種類


U/UTP: UNSHIELDED TWISTED PAIRS
F/UTP: FOILED WITH UNSHIELDED TWISTED PAIRS.
S/UTP: SHIELDED WITH UNSHIELDED TWISTED PAIRS.
SF/UTP: SHIELDED AND FOILED WITH UNSHIELDED TWISTED PAIRS.
U/FTP: UNSHIELDED WITH FOILED TWISTED PAIRS

[Win10] 開啟Win10休眠

如何開啟win 10被隱藏的休眠功能

1. 以系統管理員身分執行cmd: powercfg /H on
2. 完成

2022年1月9日 星期日

[C#] List

List<T> my List = new List<T>();

0 Apple
1 Orange
2 Banana


Dictionary<Tkey, TValue> my Dic= new Dictionary<Tkey, TValue>();

0 Key0, Value0
1 Key1, Value1
2 Key2, Value2


2022年1月3日 星期一