Skip to content

Instantly share code, notes, and snippets.

View JimLiu's full-sized avatar
🐶
Yesterday is history, tomorrow is a mystery, and today is a gift

Jim Liu 宝玉 JimLiu

🐶
Yesterday is history, tomorrow is a mystery, and today is a gift
View GitHub Profile
@JimLiu
JimLiu / PDF2Images.py
Created March 23, 2023 07:37
Convert PDF pages to 2x2 images
import os
from pdf2image import convert_from_path
from PIL import Image
def merge_images(images):
images = [Image.open(x) for x in images]
widths, heights = zip(*(i.size for i in images))
total_width = max(widths) if len(widths) < 3 else max(widths) * 2
max_height = max(heights) * 2 if len(heights) > 1 else max(heights)
You are an expert subtitle translator in all languages. Translate the English subtitle to Chinese subtitle, and keep the original English sentence as new Chinese and English subtitle. Keep the original srt format, make sure the output is valid srt format. Do not miss any empty lines.
The basic structure of an SRT file is as follows:
- A sequence number indicating the order of the subtitle, let's use {NUMBER} to present it
- The start and end timecodes of the subtitle, let's use {TIMECODES} to present it
- The subtitle text itself, which may be displayed in multiple lines separated by blank lines
Here's an example of what an SRT file might look like:
@JimLiu
JimLiu / Subtitle.srt
Last active July 23, 2023 03:01
The Amazing AI Super Tutor for Students and Teachers | Sal Khan | TED
1
00:00:04,543 --> 00:00:08,421
所以任何在过去几个月一直关注的人
So anyone who's been paying attention for the last few months
2
00:00:08,462 --> 00:00:10,547
都会看到这样的标题,
has been seeing headlines like this,
@JimLiu
JimLiu / gist:d4456ac2408a242025fbe0a4e448e79a
Created July 2, 2023 06:07
Boost Your English Skills With This Morning Study Routine
Hey, one of the biggest challenges that
English learners face is not knowing how
to study English, not having a proper
routine that will take them from the
intermediate level to the advanced level,
not knowing how to actually study English
consistently and enjoy the process.
Have you ever experienced this challenge?
Are you experiencing
this challenge right now?
@JimLiu
JimLiu / block-by-comment-likes.js
Last active December 31, 2024 01:15
微博一键拉黑点赞
// 使用方法:
// 1. Chrome打开weibo.com
// 2. 打开Chrome Dev Tool(使用 Ctrl/Cmd + Shift + I)
// 3. 在Console中复制粘贴以下代码,修改评论id为你要一键拉黑的评论ID
// 4. 回车运行
// 获取评论id方法:
// 1. 在评论下点击投诉,在新窗口中可以得到评论id,例如 https://service.account.weibo.com/reportspam?rid=XXXXXXXXXX
const cId = 123456 // 修改为真实评论ID
@JimLiu
JimLiu / How AI Could Empower Any Business | Andrew Ng | TED.ass
Created September 11, 2023 06:53
How AI Could Empower Any Business | Andrew Ng | TED
[Script Info]
Title: How AI Could Empower Any Business | Andrew Ng | TED
ScriptType: v4.00+
WrapStyle: 0
Collisions: Reverse
PlayResX: 384
PlayResY: 288
Timer: 100.0000
ScaledBorderAndShadow: no
@JimLiu
JimLiu / chatgpt-continue.js
Created September 18, 2023 02:05
ChatGPT自动继续脚本
(function () {
const wait = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
async function continueInput() {
await wait(3000);
console.log("Type continue after 1 second");
const textarea = document.querySelector("#prompt-textarea");
textarea.value = "继续"
textarea.click();
console.log("Press Enter after 1 second");
@JimLiu
JimLiu / chatgpt-auto-click-continue.js
Created September 18, 2023 02:12
ChatGPT自动点击"Continue generating"按钮
(function () {
const observer = new MutationObserver(() => {
// Find the button of 'Continue generating'
[...document.querySelectorAll("button.btn")].forEach((btn) => {
if (btn.innerText.includes("Continue generating")) {
console.log("Found the button of 'Continue generating'");
setTimeout(() => {
console.log("Clicked it to continue generating after 1 second");
btn.click();
}, 1000);
@JimLiu
JimLiu / ChatGPT-Translate-Long-Text.js
Last active April 8, 2024 07:26
使用ChatGPT自动分页翻译长文
// WARNING:此脚本仅做学习和演示用途,在不了解其用途前不建议使用
// 本脚本的用途是将输入内容分页,每次提取一页内容,编辑第二条消息,发送,然后收集结果
// 使用前,需要有两条消息,参考模板 https://chat.openai.com/share/17195108-30c2-4c62-8d59-980ca645f111
// 演示视频: https://www.bilibili.com/video/BV1tp4y1c7ME/?vd_source=e71f65cbc40a72fce570b20ffcb28b22
//
(function (fullText) {
const wait = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
const groupSentences = (fullText, maxCharecters = 2800) => {
const sentences = fullText.split("\n").filter((line) => line.trim().length > 0);
@JimLiu
JimLiu / getMessagesWithReactDevTools.js
Created October 30, 2023 02:38
Get React state of ChatGPT from React Dev Tools
(function() {
const getMessagesWithReactDevTools = () => {
const messages = [];
function traverseComponentTree(fiberNode) {
let parts = fiberNode.memoizedProps?.parts;
if (Array.isArray(parts)) {
// console.log(fiberNode, parts);