Skip to content

Instantly share code, notes, and snippets.

View mdecourse's full-sized avatar

KMOLab mdecourse

  • KMOL
  • Taiwan
View GitHub Profile
@mdecourse
mdecourse / cp2021_hw1_stat.py
Last active October 23, 2021 09:07
cp2021 HW1 discussion data and parsing
# Spur Gear in Cango and gearUtils-09.js
from browser import document as doc
from browser import html
from browser import window
# 將 document 中 id 為 "brython_div" 的標註
# 設為與 brython_div 變數對應
brython_div = doc["brython_div"]
# 將 canvas 標註放入 brython_div 所在位置
dataurl = "https://gist.githubusercontent.com/mdecourse/0c1bd6c67c7da225cc802354919b6932/raw/1362980d45f75c210f073485d555a566c1780009/cp2021hw1_discussion.txt"
@mdecourse
mdecourse / cp2021_1a_list.py
Last active January 19, 2022 04:07
random pick user
from browser import html
from browser import document
import random
brython_div = document["brython_div"]
url = "https://mde.tw/studlist/2021fall/1a.txt"
data = open(url).readlines()
# 檢查資料筆數, 第一筆為 title
#print(data)
@mdecourse
mdecourse / meArm_ik_symbolic.py
Created October 16, 2021 09:25
cad2021 meArm IK
import sympy as sp
# Define symbols
theta1, theta2, theta3, theta4, l1, l3, l4, l6, xb,zb = sp.symbols("theta1 theta2 theta3 theta4 l1 l3 l4 l6 xb zb")
# Define equations, rearranged so expressions equal 0
eq1 = l1 * sp.cos(theta1) + l3 * sp.cos(theta2) - xb
eq2 = l1 * sp.sin(theta1) - l3 * sp.sin(theta2) - zb
eq3 = l4 * sp.cos(theta3) + l6*sp.cos(theta4) - xb
eq4 = l4 * sp.sin(theta3) - l6*sp.sin(theta4) - zb
@mdecourse
mdecourse / check_dictionary_save_into_sqlite.py
Last active October 16, 2021 03:47
From pdf get text and check vocabulary
import urllib.request
from bs4 import BeautifulSoup
import sys, codecs
from pybean import Store, SQLiteWriter
# 將系統輸出語系編碼設為 utf8
sys.stdout = codecs.getwriter("utf8")(sys.stdout.detach())
# 表示要讀入的文章檔名為 wed.txt
filename = "wed"
@mdecourse
mdecourse / 2a_w1_stud_list.txt
Last active November 28, 2021 13:48
cad2021 scripts
cad2021 2a w5 Github 帳號
40823143
40923101 a40923101
40923102 40923102
40923103 40923103
40923104 409231044
40923105 40923105
40923106 40923106
40923107 40923107
40923108 40923108
@mdecourse
mdecourse / cad2a_seat_list.py
Last active October 6, 2021 06:16
2021 Fall w2 programs
# 根據各班的電腦輔助設計實習課號, 以 Heroku 主機為跳板, 取出修課學員名單
cad2aurl = "https://nfulist.herokuapp.com/?semester=1101&courseno=0805&column=True"
# readlines() 可以將所讀的資料放入數列
data = open(cad2aurl).readlines()
# 確認所讀出的資料內容為學員學號數列
# print(data)
# 設計一個篩選學員學號的函式, 用來安排座號, 但以本班學員順序為主
def setSeat(firstNum):
# 利用 len() 計算學員總數
totalNum = len(data)
@mdecourse
mdecourse / about_global.py
Last active September 20, 2021 15:15
Python 範例收集
# global 可以讓函式中所設定的 x 有效範圍擴及函式外圍
# 請試著關閉或開啟 myfun() 中的 global x 設定, 就可以了解如何使用 global 關鍵字
def myfun():
global x
x = 2
print(x)
def myfun2():
print(x)
@mdecourse
mdecourse / distrubute_cad_combination.py
Last active September 17, 2021 03:08
cad2021 相關程式
# 導入排列組合相關模組
from itertools import combinations
import random
# 2021 Fall 各班修課人員名單
cp_a = "https://nfulist.herokuapp.com/?semester=1101&courseno=0766&column=True"
cp_b = "https://nfulist.herokuapp.com/?semester=1101&courseno=0780&column=True"
cad_a = "https://nfulist.herokuapp.com/?semester=1101&courseno=0805&column=True"
cad_b = "https://nfulist.herokuapp.com/?semester=1101&courseno=0818&column=True"
@mdecourse
mdecourse / cango_gear1.py
Last active September 15, 2021 03:09
Spur gear graphics in Cango gearUtils-0.9.js
# Spur Gear in Cango and gearUtils-09.js
from browser import document as doc
from browser import html
from browser import window
import browser.timer
import math
# 利用 html 建立一個 CANVAS 標註物件, 與變數 canvas 對應
canvas = html.CANVAS(width = 600, height = 400)
# 將 canvas 標註的 id 設為 "cango_gear"
canvas.id = "cango_gear"
@mdecourse
mdecourse / spur_set_num.py
Created September 8, 2021 14:13
Brython canvas spur gear and form to set gear number
# Draw single Spur Gear
from browser import document as doc
from browser import html
import math
# 利用 Brython 建立 canvas 標註元件
canvas = html.CANVAS(width = 600, height = 400)
# 將此 canvas 的 id 設為 "spur"
canvas.id = "spur"
# 將 brython_div 變數設為 id 為 "brython_div 的 doc 物件
brython_div = doc["brython_div"]