Search results for [ %s ] - 79 hit

[Python]對於 Decorator 裝飾器的理解

Decorator 裝飾器

程式設計中的「函式」是為了解決程式碼的重複利用、模組化,同時也增加可讀性。而 Python 的「裝飾器」可以在不改變原本函式的功能之下,又再進一步強化 (簡化) 不同函式之間程式碼的共用。

Python 的「函式」是所謂的「一級函式」,支援「高階函式」的用法,可被當成參數來傳遞。「裝飾器」就是一個「兩層」的函式,先接收一個函式進行包裝 (處理),包裝完再回傳新的函式。就是「吃進去又吐出來」的意思!

Read more

[Python]Miniconda 的使用說明

Anaconda、Miniconda

一般用過 Anaconda 的人應該都是直接安裝 Anaconda 的「全家桶」來開發 Python 程式。維基百科記載: Anaconda 是一個開源的 Python 和 R 語言的發行版本,用於計算科學 (資料科學、機器學習、大數據處理和預測分析),擁有超過 1400 個套件...。

2023/10 最新的 Anaconda 版本為 v2023.09-0,安裝好約 4.6GB

但如果你像我一樣,根本用不到那麼多套件,只想使用 Anaconda 中的虛擬環境、套件管理、Spyder IDE,那麼你應該選擇精簡版的 Miniconda,再另外安裝最新版的 Spyder,或其它 Python 的 IDE 來使用。
Read more

[Python]Spyder IDE 5.5 繁體中文語言套件,以及一些 Spyder 的操作說明

Spyder 中文套件

Spyder 是一個功能強大的 Python 程式語言整合開發環境 (IDE),程式內建的多國語言有支援「簡體中文」,但沒有「繁體中文」。

本來我只是打算把「簡體中文」轉成「繁體中文」就拿來使用,但卻發現他的中文翻譯有很多不通順跟錯誤的地方!

於是我鼓起勇氣,硬著頭皮,一行一行對照著英文把它給翻譯完畢! Spyder 整合了很多套件,文字量比我想像的龐大,也有很多專業用語,費了一翻功夫才翻譯到我覺得還算滿意的成果,才敢丟出來給大家使用。

雖然說我不認為這種 IDE 需要特別翻譯成中文,但對於一些剛入門 Python 的新手,希望仍有幫助。
Read more

[Python]如何安裝 pip 套件管理程式,以及 pip 常用指令

pipPython 的套件管理程式,如果你從官網下載並安裝 Python,裡面就有 pip 可直接使用。但如果你是獨立安裝的 Spyder IDE,那麼 Spyder IDE v5.4.* 所附帶的 Python 並沒有包含 pip! 在 Spyder 的 IPython 主控台執行 pip 會出現錯誤:

In []: pip list
Note: you may need to restart the kernel to use updated packages.
 C:\Program Files\Spyder\Python\python.exe: No module named pip

PS. Spyder IDE v6.0.0 已經有包含 pip。
Read more

Visual Studio Code 的安裝說明,以及推薦的延伸模組 (Windows/Linux)

微軟開發的 Visual Studio Code (簡稱 VS Code) 是一套非常熱門的「編輯器」! VS Code 跨平台,且開放原始碼。它雖然僅是一個輕量版的編輯器,卻可經由安裝延伸模組來支援程式碼語法突顯、偵錯、自動補全、重構、Markdown...等琳瑯滿目功能,打造你夢想中的 IDE (整合開發環境)。

VS Code 預設僅支援 JavaScript、TypeScript、CSS、HTML,同樣能透過下載延伸模組來支援 Python、C/C++、Java、Perl、Go... 等其他程式語言。

Read more

[Perl]如何在 Visual Studio Code 建立 Perl 的程式開發環境 (Windows/Linux)

據說 Perl 可能是近幾年會消失的 5 種程式語言之一,另外 4 個語言分別是 RubyHaskellObject-CR! 現在在 Visual Studio Code (簡稱 VS Code) 建立 Perl 的程式開發環境也算是幫 Perl 續一下命,大慈大悲、功德無量。

要建立好整個 Perl 的開發環境主要分為三個步驟:

  1. 安裝 Perl 的執行環境
  2. 安裝 VS Code Editor
  3. 在 VS Code 安裝 Perl 的延伸模組 (Extension)

Read more

如何製作簡繁轉換的中文字型

我在四年前製作了給電子書用的偽直排字型,後來也有加入了「簡體中文轉繁體中文」的功能。以下說明如何使用 FontForge 來製作簡入繁出的字型檔。

指令檔

下載 Simp2Trad-v1.zip,這是本文的重點。

Simp2Trad-v1.zip 解壓縮後會有三個檔案:

  1. simp2trad.txt: 簡繁轉換的指令碼
  2. simp2trad-Reference.txt: 簡繁轉換的指令碼
  3. result.html: 全部轉換的文字

(我有加入幾個引號的轉換)

Read more

如何找回 Skype 的分割檢視模式,如何讓 skype 停止自動更新

大家都知道 Microsoft Windows 是一個圖形介面、支援多視窗、多工環境的作業系統,那麼在 Windows 上使用聊天軟體,開啟多個視窗跟不同人聊天也是合理的,沒錯吧?!

工作上我會用到 Skype 與同事對話,雖然 Skype for Desktop 預設是單一視窗介面,一次只能看到與一個對象的聊天內容,但 Skype (v8.96 及之前的版本),只要於選項中「啟用分割檢視模式 (Split View)」,就能讓你每次點選不同的聊天對象就開啟一個新視窗,方便同時跟不同人聊天、對話:


因為可以開啟多個視窗,我時常會用來:

  • 開多個對話視窗來比對或複製資料
  • 保留未結束的對話視窗
  • 保留重要的對話視窗

對我而言,Skype 能同時開啟多個視窗是很重要且必要的功能。
Read more

如何解決 SSH Server 使用了不安全的加密演算法: ARCFOUR、CBC、HMAC-MD5、HMAC-RIPEMD160

弱點掃瞄

弱點 1: SSH Supports Weak Cipher

The SSH server is configured to support either Arcfour or Cipher Block Chaining (CBC) mode cipher algorithms. SSH can be configured to use Counter (CTR) mode encryption instead of CBC. The use of Arcfour algorithms should be disabled.

  • Severity: Medium
  • Risk: A weak cipher has been detected.
  • Recommendation: Configure the SSH server to disable Arcfour and CBC ciphers.

弱點 2: SSH Supports Weak MAC

The SSH server is configured to support MD5 algorithm. The cryptographic strength depends upon the size of the key and algorithm that is used. A Modern MAC algorithms such as SHA1 or SHA2 should be used instead.

  • Severity: Medium
  • Risk: A weak Message Authentication Code (MAC) algorithm has been detected.
  • Recommendation: Configure the SSH server to disable the use of MD5.

Read more

如何自動將網站的 http:// 網址轉址為 https://

弱點掃瞄

弱點: Site does not enforce HTTPS

The site responds to HTTP requests without ultimately redirecting the browser to a secure version of the page. Since the site allows plaintext traffic, a man-in-the-middle attacker is able to read and modify any information passed between the site and the user. There are a variety of situations in which an attacker can intercept plaintext traffic in a man-in-the-middle position, including but not limited to:

  1. Open Wi-Fi Hotspots
  2. WPA/WPA2 encrypted hot-spots where the attacker connected before the victim
  3. Malicious Wi-Fi access points
  4. Compromised switches and routers
  5. ARP poisoning on the same wired network

It's important to remember that in many of the above situations, an attacker can not only read traffic, but also actively modify the traffic. Even if a site that does not contain sensitive information, an attacker can still inject malicious content to a user’s browser.

  • Severity: High
  • Risk: Site does not enforce the use of HTTPS encryption, leaving the user vulnerable to man-in-the-middle attackers (who can falsify data and inject malicious code).
  • Recommendation: Any site served to a user (possibly at the end of a redirect chain) should be served over HTTPS.

Read more

return top