Airmanship -> Safetymanship -> Airmanship
由2012 到 2022+1, 11年了, 我發覺無論當初想做機師到家下做一個安全人員, 我初心不變, 希望自己每次睇自己既BLOG 都要提自己, 點解要入行… 呢樣野由Day 1 到我退休都不應該變~
Python: Check if String Contains Substring
Ref: https://stackabuse.com/python-check-if-string-contains-substring/ fullstring = “StackAbuse” substring = “tack” if substring in fullstring: print(“Found!”) else: print(“Not found!”)
Python : Split by Character and Get front part
Ref: https://bobbyhadz.com/blog/python-split-string-and-get-last-element my_str = ‘bobby_hadz_com’ first = my_str.split(‘_’, 1)[0] print(first) # 👉️ ‘bobby’
Python : Data to Text (.txt)
Ref: https://www.w3schools.com/python/python_file_write.asp To write to an existing file, you must add a parameter to the open() function: “a” – Append – will append to the end of the file “w” – Write – will overwrite any existing content f = open(“demofile2.txt”, “a“) f.write(“Now the file has more content!”) f.close() f = open(“demofile3.txt”, “w“) f.write(“Woops! I have deleted the content!”) f.close()
Python : Unicode to 中文
Ref: https://ithelp.ithome.com.tw/articles/10187778 import sys print(sys.getdefaultencoding()) # 打印出目前系統字符編碼 s = ‘你好’ s_to_unicode = s.decode(encoding=‘utf-8’) # 要告訴decode原本的編碼是哪種 print(s_to_unicode)
Python 爬蟲 : Capture HTML CODE 取得網頁HTML Code
Ref: https://www.guru99.com/accessing-internet-data-with-python.html Python Internet Access using Urllib.Request and urlopen() Python 3 Example # # read the data from the URL and print it # import urllib.request # open a connection to a URL using urllib webUrl = urllib.request.urlopen(‘https://www.youtube.com/user/guru99com’) #get the result code and print it print (“result code: ” + str(webUrl.getcode())) # read the data

有關平安卡 (綠卡)
都好一陣子沒有打blog(多數用左IG/FB),難得呢幾日特登放假去CIC上A12S同見緊工,就試下2023又開始記錄生活點滴。 Tutor : 大家有無唸過點解地盤要平安卡同A12S而工廠又吾洗? 如果您只係一般工友您可能會覺呢句無咩特別,但您做安全的就會覺呢句老是好似有點問題,那不如我們先重溫下職安健例… 參考第59章 《工廠及工業經營條例》 – Cap. 59 Factories and Industrial Undertakings Ordinance (elegislation.gov.hk) 又或者我過去既post What’s Industrial Undertaking (工業經營), Factory (工廠), Notifiable Workplace (應呈報工場) ? – Tommy’s Diaries (tommykwan.com) 在本條例中,除文意另有所指外 —— 工業經營 (industrial undertaking)包括 —— (a) 任何工廠; (b) 任何礦場或石礦場; (由1969年第4號第2條修訂) (c) 任何進行物品的製造、更改、清洗、修理、裝飾、精加工、出售前改裝、搗碎或拆除,或進行物料改變的工業,包括造船業; (d) 電力或任何種類動力的生產、變壓及輸送; (e) 任何建築工程; (由1973年第52號第2條代替) (f) 在任何船塢、埠頭、貨運碼頭、倉庫或機場裝卸或搬運貨品或貨物; (由1973年第52號第2條代替。由1977年第73號第2條修訂) (fa)
line bot 發佈文字訊息(push text message) 流程
可參考 https://learn.markteaching.com/%E3%80%90chatbot-%E6%95%99%E5%AD%B8%E3%80%91-line%E6%A9%9F%E5%99%A8%E4%BA%BA-%E7%99%BC%E4%BD%88%E6%96%87%E5%AD%97%E8%A8%8A%E6%81%AFpush-text-message/ 首先需要在Line 控制台取得 User id 接著再程式碼內新增一個方法(method) 最後就是發佈文字訊息就能搞定啦! 下面示範的是當user 對line BOT 說 “GetUID”, line BOT 就會回傳其UID, 再主動發一個MESSAGE 給該USER~ if event.message.text == “GetUID”: uid = event.source.user_id login_status = “not-member” line_bot_api.reply_message(event.reply_token, TextSendMessage(text=uid)) line_bot_api.push_message(uid, TextSendMessage(text=login_status))
‘staticfiles’ is not a registered tag library. Must be one of
可參考 https://stackoverflow.com/questions/55929472/django-templatesyntaxerror-staticfiles-is-not-a-registered-tag-library
ImportError: cannot import name ‘url’ from ‘django.conf.urls’ (在Django 4 用舊版本指令的後果)
可參考 https://www.youtube.com/watch?v=cRrShdhqyuM 開啟 urls.py : from django.urls import path, include, re_path from django.urls import re_path as url
“’django-admin’ is not recognized as an internal or external command,” 解決方法
python -m venv venv venv\Scripts\activate pip install django django-admin startproject mysite
List
List 入面的東西可以不同Type List 入面亦可以有另一個 List List 入面不同的 List 可以有不同的 dimension L=[1,”1″,2.5,True] L[0] L[1] L[2] L[3] L[4] #以下有是指 L1 有3個 List (List 中 List) ,但count L1 的length 只會有3個 items L1=[[1,”1″,2.5,True,2,3],[4.1,”ABC”,4],[7,8,9,10]] # 取得 L1 的 length len(L1) # 取得 L1 內第0個元素的 length len(L1[0]) # 取得 L1 內第1個元素的 length len(L1[1]) # 取得 L1 內第2個元素的 length len(L1[2]) 以下會示範取得
Filtering by postion : first one (第一個), 第x個 (某一個), last one (最後一個), 單數/雙數
在開始之前,先學會COUNT 一個字串的長度 function: len() s=”1234567″ len(s) expected result: 7 接下來,要著意python 第一個值是 0 ; 最後一個值是 -1 s=”1234567″ # Python initial position is 0 s[0] 所以first one : s[0] # Python last position is -1 s[-1] 所以last one : s[-1] 再來就是抽某一個範圍的數值 s=”1234567″ s[x:n] —– 其中x, n為數字; 代表第x個位置開始抽,抽到第 N-1 個位置 ; 例子: # 由第x個位置開始抽,抽到第 N-1 個位置
1st Python : Print
# print() is a function in python print(“hello”) 值得留意的是,如果將 “hello” 設定為variable, 則不用print 的情況下,在Jupyter 都可以直接Run,例子: c=”Python is cool” c Expected result: Python is cool
僱員/工友顧己及人的相關條文
都快要入行1年多,今晚就拿起書本看看,又上DOJ的elegislation.gov.hk溫故知新。 首先,僱員跟工友是很類近的CONCEPT, 但又不完全相同 – 這是主要香港現時 (2022) 有關職安健的相關法規有兩大條例,N條子例 (N是很多的意思了)。 https://www.elegislation.gov.hk/hk/cap509!en-zh-Hant-HK?INDEX_CS=N 第509章 《職業安全及健康條例》 Cap. 509 Occupational Safety and Health Ordinance Section 2 條例的目的 本條例的目的是 —— (a) 確保在工作中的僱員的安全及健康; (b) 訂明會有助於使僱員的工作地點變得對該等僱員更加安全和健康的措施; (c) 改善適用於在工作地點使用或存放的若干危險工序、作業裝置及物質的安全及健康標準; (d) 一般地對僱員的工作環境的安全和健康方面作出改善。 基本上,”僱員” 是Cap. 282 [第282章 《僱員補償條例》] 之外,另一條有相關 “字眼” 的條例。 而Cap 509 適用的範圍是 “工作地點” : 這一點很重要! 要知 “工作地點”的定義就要好好看原文了。 第59章 《工廠及工業經營條例》 Cap. 59 Factories and Industrial Undertakings Ordinance
“Guidance for the Management of Household Hazardous Waste at Civic Amenity Sites” 摘要
大耐無打BLOG , 今日就一邊看書一邊做摘要, 今日看的文件 (書) 叫 “Guidance for the Management of Household Hazardous Waste at Civic Amenity Sites” 這是一本由EPA (U.S. Environmental Protection Agency) 聯同Health and Safety Authority (HSA) 及 civic amenity (CA) 所編寫的guidance。 This guidance is recommended to CA site designers and operators as good practice, but it is not compulsory. 在Intro 果part, 作者們就用了一句去講重要性: The
Book list about Environmental Learning
Waste: A Handbook for Management 2nd Edition (2019 ; ISBN: 978-0-12-815060-3) Handbook of Environmental Engineering (2018 ; ISBN: 9781118712948 ) Wastewater and Biosolids Management (2017 ; ISBN: 9781780408231) Hazardous Waste Management (2017 ; ISBN: 9781945612893) Hazardous Waste Management, Volume Two : Characterization and Treatment Processes (2018 ; ISBN: 9781945612916)