Skip to content

Instantly share code, notes, and snippets.

View htlin222's full-sized avatar
🦎

Hsieh-Ting Lin (林協霆) htlin222

🦎
View GitHub Profile
@htlin222
htlin222 / unify_the_date_as_yyyymmdd_string.js
Last active April 22, 2025 02:46
將 Google Sheets 中所有看似日期的值轉換成 YYYYMMDD 格式。
/**
* 將 Google Sheets 中所有看似日期的值轉換成 YYYYMMDD 格式。
* 支援真實日期物件與常見格式字串(如 "2024-4-5", "2024/04/05", "2024.4.5")。
* 用法:在 Google Sheets 的 App Script 中貼上此函式,執行 convertAnyDateToYYYYMMDD_RobustCheck()。
*/
function convertAnyDateToYYYYMMDD_RobustCheck() {
const sheet = SpreadsheetApp.getActiveSheet();
const range = sheet.getDataRange();
@htlin222
htlin222 / pub_ready_KM-plot.R
Created April 18, 2025 05:26
Publication-ready KM plot in R
# 安裝並載入所需的套件,使用pacman套件管理器
# 如果pacman未安裝,則先安裝pacman
if (!require("pacman")) install.packages("pacman")
# 使用pacman一次性載入多個套件:ggsurvfit(繪製生存曲線)、survival(生存分析)、ggplot2(繪圖系統)
pacman::p_load(ggsurvfit, survival, ggplot2, showtext)
# Find first TTF font in current directory and load it as "default"
ttf_files <- list.files(pattern = "\\.ttf$", ignore.case = TRUE)
if (length(ttf_files) > 0) {
font_add("default", ttf_files[1])
cat("Loaded font:", ttf_files[1], "\n")
title marp author paginate headingDivider theme footer
56-year-old man with chronic anemia for one year
true
Hsieh-Ting Lin
true
3
main
[■](#table-of-contents)
@htlin222
htlin222 / 排班小精靈.py
Created March 9, 2025 11:03
排班小精靈 (Scheduling Wizard) - Python Version
import sys
"""
排班小精靈 (Scheduling Wizard) - Python Version
输入格式 (Input Format):
---------------------
1. 第一行: 日数,起始星期,参与排班人数
First line: number_of_days,starting_weekday,number_of_staff
@htlin222
htlin222 / image_colorizer.ipynb
Last active February 5, 2025 13:45
image_colorizer.ipynb
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
import React, { useState, useRef, useEffect } from 'react';
const snippets = {
'if': 'if (condition) {\n \n}',
'fo': 'for (let i = 0; i < array.length; i++) {\n \n}',
'co': 'console.log();',
};
const TextEditor = () => {
const [text, setText] = useState('');
import React, {
useState,
useRef,
useEffect,
useCallback,
useMemo,
} from "react";
import {
Search,
Save,
@htlin222
htlin222 / pdf_explain.py
Created July 12, 2024 18:18
This script splits a PDF file into individual pages and saves each page as a Markdown file with an auto-generated title and explanation in Traditional Chinese. It uses the OpenAI API to generate titles and explanations.
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# title: pdf_explain
# author: Hsieh-Ting Lin, the Lizard 🦎
# description: This script splits a PDF file into individual pages and saves each page as a Markdown file with an auto-generated title and explanation in Traditional Chinese. It uses the OpenAI API to generate titles and explanations.
# date: "2024-07-13"
import os
import openai
@htlin222
htlin222 / extract_text_from_PDF_and_convert_to_JSON_by_ChatGPT.py
Last active July 3, 2024 01:44
This script is to extract the text from a PDF file and convert it to JSON format. Used for foundation_one NGS report, for biomarker_findings
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# title: main
# author: Hsieh-Ting Lin, the Lizard 🦎
# description: This script is to extract the text from a PDF file and convert it to JSON format. Used for foundation_one NGS report, for biomarker_findings
# date: "2024-07-01"
# --END-- #
import json
{
"translatorID": "d90fd4af-9eeb-4232-9feb-8fd05bcf6f8b",
"translatorType": 2,
"label": "Markdown Item URI with Citekey",
"creator": "Silent",
"target": "markdown",
"minVersion": "2.0",
"maxVersion": "",
"priority": 200,
"inRepository": false,