Skip to content

Instantly share code, notes, and snippets.

View WooodHead's full-sized avatar

WooodHead

  • Hangzhou
View GitHub Profile
@import 'https://fonts.googleapis.com/css?family=Open+Sans';
* {
-webkit-box-sizing: border-box;
box-sizing: border-box;
}
body {
font-family: 'Open Sans', sans-serif;
line-height: 1.75em;
@WooodHead
WooodHead / ChatGPT-Translate-Long-Text.js
Created October 1, 2023 06:33 — forked from JimLiu/ChatGPT-Translate-Long-Text.js
使用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);
@WooodHead
WooodHead / generate_directory_index_caddystyle.py
Created March 19, 2023 03:24 — forked from glowinthedark/generate_directory_index_caddystyle.py
Generate directory index (recurse subfolders with `-r` or `--recursive`). Use `-h` or `--help` for all options
#!/usr/bin/env python3
# ---
# Copyright 2020 glowinthedark
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
#
# You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
javascript:(function(){ function walkDOMTree( root, whatToShow = NodeFilter.SHOW_ALL, { inspect, collect, callback } = {} ) { const walker = document.createTreeWalker(root, whatToShow, { acceptNode(node) { if (inspect && !inspect(node)) { return NodeFilter.FILTER_REJECT; } if (collect && !collect(node)) { return NodeFilter.FILTER_SKIP; } return NodeFilter.FILTER_ACCEPT; }, }); const nodes = []; let n; while ((n = walker.nextNode())) { callback?.(n); nodes.push(n); } return nodes; } const PARENT_TAGS_TO_EXCLUDE = ["STYLE", "SCRIPT", "TITLE"]; function getAllTextNodes(el) { return walkDOMTree(el, NodeFilter.SHOW_TEXT, { inspect: (textNode) => !PARENT_TAGS_TO_EXCLUDE.includes(textNode.parentElement?.nodeName), }); } function generateRandomString(length) { var result = ""; var characters = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"; var char
@WooodHead
WooodHead / serverless_regions.md
Created January 24, 2023 16:23 — forked from nicolasdao/serverless_regions.md
Serverless Regions

AMAZON API GATEWAY REGIONS

US East (Ohio) us-east-2 apigateway.us-east-2.amazonaws.com HTTPS ZOJJZC49E0EPZ

US East (N. Virginia) us-east-1 apigateway.us-east-1.amazonaws.com HTTPS Z1UJRXOUMOOFQ8

US West (N. California) us-west-1 apigateway.us-west-1.amazonaws.com HTTPS Z2MUQ32089INYE

US West (Oregon) us-west-2 apigateway.us-west-2.amazonaws.com HTTPS Z2OJLYMUO9EFXC

Postgres - Simple Master-Slave Replication

This is insecure, fast-to-setup setup of simple master-slave replication with dockerized PostgreSQL installation. Note, that below works with version postgres version 12.2: postgres (PostgreSQL) 12.2 (Debian 12.2-1.pgdg100+1).

Preparation:

# This is where your primary database files will be stored
@WooodHead
WooodHead / a_mongodb_to_s3_backup.sh
Created April 19, 2022 05:06 — forked from lazarofl/a_mongodb_to_s3_backup.sh
MongoDB Automatic Backup to Amazon S3 with Crontab and s3cmd. Red Hat Linux on Amazon EC2
#!/bin/bash
#Force file syncronization and lock writes
mongo admin --eval "printjson(db.fsyncLock())"
MONGODUMP_PATH="/usr/bin/mongodump"
MONGO_HOST="prod.example.com"
MONGO_PORT="27017"
MONGO_DATABASE="dbname"
@WooodHead
WooodHead / starship.toml
Created March 31, 2022 08:06 — forked from ruralocity/starship.toml
My current Starship.rs configuration file
# Don't print a new line at the start of the prompt
add_newline = false
# Disables the line_break module, making the prompt a single line.
[line_break]
disabled = true
# Replace the "❯" symbol in the prompt
[character]
symbol = "$"
@WooodHead
WooodHead / update_metabase_docker.sh
Created February 19, 2022 17:43 — forked from ohld/update_metabase_docker.sh
How to safely update Metabase if you use docker deployments WITHOUT ANY DATA LOSS
# check the name of metabase container
docker ps
# make a backup
docker cp metabase:/metabase.db /root/
# get updated version
docker pull metabase/metabase
# remove old running container