Skip to content

Instantly share code, notes, and snippets.

View yfwu's full-sized avatar

Yu-Fu Wu yfwu

View GitHub Profile
@yfwu
yfwu / organize.py
Last active November 5, 2023 20:57
Organize the nested folders to move all video files from subfolders into the base folder.
#!/bin/env python3
# %%
import os
from pathlib import Path
import sys
# %%
# get all the folders and nested folders and files into a list
def get_all_files(path):
"""Get all files in a folder and subfolders"""
@yfwu
yfwu / wordle.md
Created February 4, 2022 16:09 — forked from huytd/wordle.md
Wordle in less than 50 lines of Bash

image

How to use:

./wordle.sh

Or try the unlimit mode:

@yfwu
yfwu / extract.py
Created November 22, 2021 10:37
Extract word from texts
import re
import difflib
word="acromegaly"
textarea = "acromegaly, pneumonia, prolactinoma"
pattern = r'\w+'
l = re.findall(pattern, textarea)
matcher = difflib.SequenceMatcher(b=word)
for test_word in l:
@yfwu
yfwu / concat.ipynb
Last active April 26, 2021 16:50
Concat and merge
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
import os
import sys
from bs4 import BeautifulSoup
def get_metadata(f):
with open(f, 'rb') as h:
html_doc = h.read()
soup = BeautifulSoup(html_doc, 'html.parser')
title = str(soup.find("title")).replace("<title>", "").replace("</title>", "")
date = soup.find("meta", property="created")
@yfwu
yfwu / read_data_m.py
Last active September 4, 2019 14:50
modified read_data for generating word array
def read_data_modified(fname):
data = []
with open(fname) as f:
for line in f.readlines():
line = re.sub('[!@#%^&:;,`\.\']', '', line)
data.extend(line.replace('\n', '').strip().lower().split(' '))
return data
@yfwu
yfwu / prog3-1.m
Created February 1, 2019 19:35
prog3-1 <programming in obj-c 6/e>
**@interface** Fraction: NSObject
-(**void**) print;
-(**void**) setNumerator: (**int**) n;
-(**void**) setDenominator: (**int**) d;
**@end**
*// ————*
@yfwu
yfwu / plot_lm.R
Last active June 11, 2018 05:54
Linear regression plotting
labor<- c(115.63, 134.13, 140.31, 125.14, 76.96, 78.3, 67.71, 72.36, 96.14, 111.82, 113.46, 73.67, 125.6, 143.78, 136.28, 131.65)
marriage<- c(46.96, 21.47, 24.75, 31.36, 50.37, 49.41, 37.36, 32.11, 0, 23.88, 35.43, 11.73, 53.58, 51.9, 99.74, 0)
plot(labor, marriage)
mod <- lm(marriage ~ labor)
abline(mod, col=2, lwd=3)
@yfwu
yfwu / intmed.py
Created April 14, 2018 15:53
內科學誌下載
import requests
import time
prefix = "http://www.tsim.org.tw/journal/jour"
for i in range(19, 30):
for j in range(1, 7):
for k in range(1, 8):
url = prefix + str(i) + "-" + str(j) + "/0" + str(k) + ".PDF"
print(url)
conda create -n orange python=3.4 numpy scipy scikit-learn docutils beautifulsoup4 nose Sphinx xlrd pyqt psycopg2
source activate orange
pip install bottlechest
pip install chardet
pip install recommonmark
pip install pyqtgraph
pip install qt-graph-helpers
git clone https://github.com/biolab/orange3.git