Skip to content

Instantly share code, notes, and snippets.

View iqiancheng's full-sized avatar
🌴
On vacation

千橙 iqiancheng

🌴
On vacation
View GitHub Profile
@iqiancheng
iqiancheng / download-youtube-subtitles.user.js
Last active January 15, 2024 07:43 — forked from kugland/download-youtube-subtitles.js
Download YouTube subtitles (GreaseMonkey/TamperMonkey script)
// ==UserScript==
// @name Download YouTube subtitles
// @namespace http://tampermonkey.net/
// @version 0.1
// @description Now you can download YouTube subtitles
// @author André Kugland
// @match http*://*.youtube.com/*
// @grant none
// @require https://cdn.jsdelivr.net/npm/file-saver@2.0.2/dist/FileSaver.min.js#sha256=bbf27552b76b9379c260579fa68793320239be2535ba3083bb67d75e84898e18
// ==/UserScript==
@iqiancheng
iqiancheng / README.md
Last active November 8, 2023 02:28
HEIC 照片转png/jpg
@iqiancheng
iqiancheng / arxiv_social_media.user.js
Created November 2, 2023 03:35 — forked from Xeophon/arxiv_social_media.js
Arxiv Discussions Tampermonkey Script
// ==UserScript==
// @name Arxiv Twitter Search
// @namespace http://tampermonkey.net/
// @version 0.1
// @description Add discussions links to Arxiv
// @author Xeophon + ChatGPT
// @match https://arxiv.org/abs/*
// @grant GM_xmlhttpRequest
// ==/UserScript==
@iqiancheng
iqiancheng / FlexibleJSONLoader.md
Last active September 5, 2023 03:03
既可以加载严格json格式的json,又可以加载Python 代码中的单引号格式的json,且最后一行k-v之后有"," 也不会报错的Python工具类

下面是一个可以满足你需求的Python工具类代码示例。该工具类使用了json库来处理JSON格式,可以加载严格的JSON和Python代码中的单引号格式的JSON。在处理最后一行的逗号问题上,它会自动处理,不会引发错误。

import json

class FlexibleJSONLoader:
    @staticmethod
    def load(file_path):
        with open(file_path, 'r') as file:
            content = file.read()
@iqiancheng
iqiancheng / config_tool.py
Created August 22, 2023 07:21
用Python发送模版邮件
import os
class ConfigTool:
def __init__(self):
# Load configurations from environment variables into the global dictionary.
self._config_dict = {key: os.environ[key] for key in os.environ}
def get(self, key, default=None):
"""Retrieve value by key from the configuration dictionary."""
return self._config_dict.get(key, default)
@iqiancheng
iqiancheng / mute_twitter.user.js
Last active August 20, 2023 15:01
黄推屏蔽油猴脚本 Userscript Mute twitter user with one click 按住 alt 键点击推文一键 mute 用户, 共享黑名单:https://greasyfork.org/zh-CN/scripts/470359-twitter-block-porn
// ==UserScript==
// @name One click to mute the twitter user - twitter.com
// @namespace Violentmonkey Scripts
// @match https://twitter.com/*
// @grant none
// @version 1.0
// @author weijarz
// @description 6/28/2023, 12:46:22 PM
// ==/UserScript==
@iqiancheng
iqiancheng / apple_notes_exporter.py
Last active August 20, 2023 11:46
Apple Notes Exporter 苹果电脑上便签导出脚本
import subprocess, os
class NotesExporter:
@staticmethod
def export_notes_to_md(output_directory):
applescript = """
on clean_filename(filename)
set cleaned_filename to ""
repeat with c in filename
set targetUnicodeArray to {47, 92, 124, 63, 58, 42, 34, 60, 62}
@iqiancheng
iqiancheng / pip_list_to_requirements.md
Created August 12, 2023 07:47
Python 工程导出 requirements.txt

你可以使用 sedawk 来从 pip list 的结果中提取包名和版本号,然后将其转换为 requirements.txt 格式。以下是一个示例命令:

pip list | grep -E 'keyword1|keyword2|keyword3' | awk '{print $1"=="$2}' > requirements.txt

这个命令将 pip list 结果中的包名和版本号提取出来,使用 == 连接,然后将结果输出到 requirements.txt 文件中。你可以将 keyword1|keyword2|keyword3 替换为实际的关键词。

在执行这个命令之前,确保你已经在命令行中切换到你想要保存 requirements.txt 文件的目录。执行命令后,你会在当前目录下生成一个包含你筛选出的包名和版本号的 requirements.txt 文件。

@iqiancheng
iqiancheng / mi-note-export.js
Created July 31, 2023 13:18 — forked from tvytlx/mi-note-export.js
小米便签导出, artoo.js 浏览器脚本
// 便签元素在 frame 里,不能直接用 artoo 处理,得先得到内部的 dom 元素,然后传给 artoo。
const iframe = 'iframe#js_note_mod_ctn.js_sandbox.business-mod-ctn.note-mod-ctn';
let get_container = (str)=>{return $(iframe)[0].contentDocument.body.querySelector(str)};
let notes_container = get_container('.home-bd .briefs-ctn.js_home_briefs_ctn');
// 开始抓取
let is_in_box = (this_)=>{
return (this_.attr('class')=='js_folder_brief folder-brief js_normal_folder js_lock') ||
(this_.attr('class')=='js_folder_brief folder-brief js_normal_folder')
};
@iqiancheng
iqiancheng / mi-notes.py
Created July 31, 2023 13:18 — forked from tvytlx/mi-notes.py
把mi-note-export.js导出的data.json文件转换成能导入到mac便签的文件夹
#!/usr/bin/python
#-*- coding: utf-8 -*-
from __future__ import print_function, unicode_literals
import sys
import json
import os
import shutil
import re
import subprocess
import platform