Skip to content

Instantly share code, notes, and snippets.

View htlin222's full-sized avatar
🦎

Hsieh-Ting Lin (林協霆) htlin222

🦎
View GitHub Profile
import pyimgur
import pyperclip
from PIL import Image, ImageGrab
import os
import time
# define the t to make the image name
t = time.localtime()
t =time.strftime("%y-%m-%d_%H_%M_%S", t)
CLIENT_ID = "YOURCLIENTID" # get if from https://imgur.com/account/settings/apps
#!/usr/bin/env python
import re
import pyperclip
import bitlyshortener
# Bitly token
api_token = 'db874d7954f55ad86d7a6bb769af1bff34153aa1'
# get myurl from clipboard
myurl = pyperclip.paste()
# Create and regex for check if a valid URL or not
regex = re.compile(
@htlin222
htlin222 / hellow.md
Last active July 26, 2023 07:00
update
  1. Longo DL, Armitage JO. A Better Treatment for Advanced-Stage Hodgkin’s Lymphoma? New England Journal of Medicine. 2022;387(4):370-372. doi:10.1056/NEJMe2207639
  2. Choi Y, Diefenbach C. Advances in Therapy for Relapsed or Refractory Hodgkin Lymphoma. Current Oncology Reports. 2020;22(1):6-6. doi:10.1007/s11912-020-0866-3
  3. Connors JM, Jurczak W, Straus DJ, et al. Brentuximab Vedotin with Chemotherapy for Stage III or IV Hodgkin’s Lymphoma. New England Journal of Medicine. 2018;378(4):331-344. doi:10.1056/NEJMoa1708984
  4. Kersten MJ, Driessen J, Zijlstra JM, et al. Combining brentuximab vedotin with dexamethasone, high-dose cytarabine and cisplatin as salvage treatment in relapsed or refractory Hodgkin lymphoma: the phase II HOVON/LLPC Transplant BRaVE study. Haematologica. 2021;106(4):1129-1137. doi:10.3324/haematol.2019.243238
  5. Epperla N, Hamadani M. Double-refractory Hodgkin lymphoma: tackling relapse after brentuximab vedotin and checkpoint inhibitors. Hematology. 2021;2021(1):247-253. doi:10.118
import os
import re
import pyperclip as pc
# pip install pyperclip if not installed
text = pc.paste()
# replace:
# 「blablabla... 」
#
# 摘錄自:Author. 「」。Apple Books.
@htlin222
htlin222 / scrape_review_from_apple_and_google_play_store.py
Last active January 26, 2023 15:48
以 python 用 google_play_scraper 和 app_store_scraper 兩個套件來爬app的評論,存成兩份excel檔
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# title: google and apple app review
# date: "2023-01-26"
from google_play_scraper import Sort, reviews_all
from app_store_scraper import AppStore
import pandas as pd
from urllib.parse import quote
import numpy as np
@htlin222
htlin222 / split_markdown_by_heading.py
Last active March 28, 2024 05:28
$python split_markdown_by_heading --level=2 --file="YOUR_FILE_NAME"
# -*- coding: utf-8 -*-
#!/usr/bin/env python3
# title: split_by_heading
# date created: "2023-01-23"
import os
import sys
import argparse
from datetime import datetime
@htlin222
htlin222 / add_to_anki.py
Created February 11, 2023 19:53
python add_to_anki --deck="DECK_NAME" --front="Question here" --back="answer..."
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# title: add_to_anki
# date: "2023-02-12"
import requests
import argparse
## python add_to_anki --deck="DECK_NAME" --front="Question here" --back="answer..."
def main(deck_name, front, back):
@htlin222
htlin222 / openai.vim.md
Created February 18, 2023 12:39
call a open function

function! ChatGPTTitle() let text = substitute(@", '\n', ' ', 'g') " Replace newlines with spaces let response = system('curl -X POST -H "Content-Type: application/json" -d '{"text": "' . text . '", "model": "text-babbage-001"}' https://api.openai.com/v1/engines/davinci-codex/completions') let json = json_decode(response) let title = json['choices'][0]['text'] put = "### " . title endfunction

# Import necessary libraries
import pandas as pd #用於資料處理的模組
import openai #OpenAI API模組
# Read the Excel file with two columns
df = pd.read_excel('data.xlsx', usecols=['id', 'content']) #從Excel檔案讀取資料到dataframe中,只取'id'和'content'欄位的資料
# Set the OpenAI API key from an environment variable
openai.api_key = "OPENAI_API_KEY" #設置OpenAI API的金鑰
@htlin222
htlin222 / Save_images_to_anki.py
Created April 15, 2023 17:34
python script to watch all images in current directory and use AnkiConnect API to create new card to a Anki Deck
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# date: "2023-04-12"
import os
import requests
import base64
folder_path = "."