Skip to content

Instantly share code, notes, and snippets.

View htlin222's full-sized avatar
🦎

Hsieh-Ting Lin (林協霆) htlin222

🦎
View GitHub Profile
@htlin222
htlin222 / click_gui.py
Created April 5, 2024 00:57
自動點擊的魔法
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# title: auto click on my screen
# author: Hsieh-Ting Lin, the Lizard 🦎
# description: 自動點擊的魔法
# date: "2024-04-05"
# --END-- #
import time
@htlin222
htlin222 / pomodoro.sh
Last active March 28, 2024 05:25
an simple pomodoro CLI on macOS
#!/bin/bash
# Author: Hsieh-Ting Lin
# Title: "pomodoro"
# Date: "2024-03-12"
# Version: 1.0.0
# description: "pomodoro, need pipx install termdown"
# 默認參數設置
focus_min=${1:-25}
break_min=${2:-5}
long_break_min=${3:-15}
@htlin222
htlin222 / patient_oop.py
Created February 29, 2024 09:02
A short script to demonstrate object-oriented programming (OOP) in clinical practice
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# title: patient_oop
# description: A short script to demonstrate object-oriented programming (OOP) in clinical practice
# date: "2024-02-29"
# author: Hsieh-Ting Lin, the Lizard 🦎
class Patient:
def __init__(self, age, sex, comorbidities, history, treatments, current_admission):
@htlin222
htlin222 / batch_add_event_from_gsheet_to_gcalendar.gs
Last active March 28, 2024 05:31
batch_add_event_from_gsheet_to_gcalendar
// 當檔案打開時執行
function onOpen() {
var ui = SpreadsheetApp.getUi(); // 獲取當前的用戶界面實例
var menu = ui.createMenu('處理'); // 創建一個新菜單
var calendarDict = getValuesAsDict(); // 從工作表獲取日曆ID和名稱對應關係
var counter = 2; // 計數器,用於生成函式名稱
// 遍歷所有日曆名稱和ID
for (var name in calendarDict) {
@htlin222
htlin222 / rename.sh
Last active March 28, 2024 05:25
rename pdf by pdftotext, and ChatGPT, this script will return something like: 2024-02-06-[journal]-Name_Created_by_ChatGPT
#!/bin/bash
# Author: Hsieh-Ting Lin
# Title: "rename"
# Date: "2024-02-06"
# Version: 1.0.0
# desc: rename by ChatGP
#
# 同目錄下新增一個 .env 檔將 OPENAI_API_KEY=sk-xxxx 放在裡面
# 將.env檔案中的變量加載到當前shell環境中
# set -a # 自動導出變量
@htlin222
htlin222 / chatgpt.R
Created January 30, 2024 11:56
send chatGPT request in R
# desc: send chatGPT request in R
# date: "2024-01-30"
# install.packages("dotenv")
# install.packages("httr")
# install.packages("jsonlite")
send_chatgpt_request <- function(system_message, user_message) {
library(httr)
library(jsonlite)
@htlin222
htlin222 / create_subtitle_for_long_text_by_whisper_api.py
Created January 30, 2024 08:31
Split a long video into small mp3 files, generate .srt files for each mp3, and then merge all content into a single srt file
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# title: generate_subtitle
# date: "2024-01-30"
# description: "Split a long video into small mp3 files, generate .srt files for each mp3, and then merge all content into a single srt file"
# author: Hsieh-Ting Lin, the Lizard 🦎
import argparse
import os
import tempfile
@htlin222
htlin222 / generate_subtitle_zh-TW.py
Last active October 29, 2024 01:14
將一個長影片分割成小的mp3檔後,針對每一個mp3檔產生.srt檔,最後再合併所有內容成一個srt
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# title: generate_subtitle
# date: "2024-01-30"
# description: "將一個長影片分割成小的mp3檔後,針對每一個mp3檔產生.srt檔,最後再合併所有內容成一個srt"
# author: Hsieh-Ting Lin, the Lizard 🦎
import argparse
import os
import tempfile
@htlin222
htlin222 / trim.py
Last active March 28, 2024 05:26
此 Python 指令碼可從視訊檔案中根據指定的時間段列表提取多個片段。它接受命令列參數以指定時間段檔案、視訊源和輸出目錄。若輸出目錄不存在,則自動建立。指令碼使用 moviepy 庫處理視訊,並生成以開始時間命名的片段檔案。
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# title: trim
# date: "2024-01-29"
# description: 此 Python 指令碼可從視訊檔案中根據指定的時間段列表提取多個片段。它接受命令列參數以指定時間段檔案、視訊源和輸出目錄。若輸出目錄不存在,則自動建立。指令碼使用 moviepy 庫處理視訊,並生成以開始時間命名的片段檔案。
# `python trim.py -i clips.csv -v input.mp4`
import argparse
import os
@htlin222
htlin222 / align_inline_comments.lua
Last active January 13, 2024 13:25
Align Comments in Neovim, ignoring lines that are Markdown hyperlink references
-- description: Align Comments in Neovim, ignoring lines that are Markdown hyperlink references
--
local vim = vim
local augroup = vim.api.nvim_create_augroup -- Create/get autocommand group
local autocmd = vim.api.nvim_create_autocmd -- Create autocommand
local function align_comments()
local lines = vim.api.nvim_buf_get_lines(0, 0, -1, false)
local max_comment_start = 0
local comment_block = {}
local new_lines = {}