Skip to content

Instantly share code, notes, and snippets.

View htlin222's full-sized avatar
🦎

Hsieh-Ting Lin (林協霆) htlin222

🦎
View GitHub Profile
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,
/* @theme my-theme */
@charset "UTF-8";
/*!
*
* @auto-scaling true
* @size 4:3 960px 720px
* @size 16:9 1280px 720px
*/
@import url("https://unpkg.com/markdown-it-admon/styles/admonition.css");

<% for (const annotation of it) { %> <%~ include("annotation", annotation) %>

<% } %>

<%= it.map(lit => [[${lit.citekey}|(${lit.authors.first()}, ${lit.date})]]).join("; ") %>

<%= it.title %>

  • Authors: <%= it.authors .map(author => [[${author}]]) .join(', ') %>
  • Date: <%= it.date ?? it.year %>

[!note] Page <%= it.pageLabel %>

<%= it.imgEmbed %><%= it.text %> <% if (it.comment) { %>

💬

<%= it.comment %> <% } %>

@htlin222
htlin222 / rearrange_pdf.py
Last active April 17, 2024 13:02
把簡報印成小冊子,時常拿出來蕊,不是一件很快樂的事嗎?
#!/Users/htlin/.pyenv/versions/automator/bin/python
# -*- coding: utf-8 -*-
# title: rearrange_pdf
# author: Hsieh-Ting Lin, the Lizard 🦎
# description: 把簡報印成小冊子,時常拿出來蕊,不是一件很快樂的事嗎?
# date: "2024-04-17"
# --END-- #
"""
把簡報印成小冊子,時常拿出來蕊,不是一件很快樂的事嗎?