Skip to content

Instantly share code, notes, and snippets.

View amane-katagiri's full-sized avatar

Amane Katagiri amane-katagiri

View GitHub Profile
@amane-katagiri
amane-katagiri / emoji_atokdict_generator.py
Last active November 15, 2023 07:20
Emoji dictionary generator for ATOK.
#!/usr/bin/env python3
r"""
Generate emoji dict file for ATOK.
You can convert emoji_strategy.json on emoji-toolkit (https://github.com/joypixels/emoji-toolkit) into:
```
Grinning 😀 名詞*
...
@amane-katagiri
amane-katagiri / export_chatgpt.py
Last active July 31, 2023 06:57
List all conversation lines from exported data of ChatGPT.
#!/usr/bin/env python3
# Usage: ./export_chatgpt.py conversations.json ./path/to/export/dir
from dataclasses import dataclass
import itertools
import json
import logging
from logging import getLogger, StreamHandler
import sys
@amane-katagiri
amane-katagiri / correct.sh
Last active July 22, 2023 18:01
A tiny script to print proofreading suggestions for your sentences with OpenAI API.
#!/bin/bash -eu
# https://blog.jxck.io/entries/2023-03-24/proofreading-via-openai.html
PROMPT='バッククォートで囲まれた以下の文章の誤字、脱字、スペルミスを、原文をできるだけ尊重しつつ修正してください。返答は修正後の文章のみを簡潔に返すこと。'
QUOTE='```'
CONF="$HOME/.correct"
CACHE="$HOME/.correct_cache"
FORCE=''
@amane-katagiri
amane-katagiri / sample.atom.xml
Last active June 4, 2023 01:26
Atomフィードのサンプル
<?xml version="1.0" encoding="UTF-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
<title>【サイトタイトル】</title>
<!-- サイトのURL -->
<link rel="alternate" href="https://your-site.example.com/"></link>
<!-- フィードのURL -->
<link rel="self" href="https://your-site2.example.com/path/to/feed.atom.xml"></link>
<!-- フィードのID「tag:【サイトドメイン】,【公開年(月日)】:【URL】」 -->
<id>tag:your-site.example.com,2023:/</id>
<!-- フィードの最終更新日時 -->
@amane-katagiri
amane-katagiri / expose-wsl-server.ps1
Last active June 3, 2023 20:36
Expose server connection on WSL to LAN.
#!/usr/bin/pwsh
if ($args.count -eq 0){
$connectport = [Microsoft.VisualBasic.Interaction]::InputBox("Input connectport (expose port on wsl)", $MyInvocation.MyCommand.Name, "8000")
if ($connectport.length -eq 0) {
Write-Error "Set connectport" -ErrorAction Stop
}
$listenport = [Microsoft.VisualBasic.Interaction]::InputBox("Input listenport (expose port on host)", $MyInvocation.MyCommand.Name, $connectport)
if ($listenport.length -eq 0) {
Write-Error "Set listenport" -ErrorAction Stop
@amane-katagiri
amane-katagiri / feedgen.py
Last active June 2, 2023 14:07
CSVっぽいテキストからAtomフィードを生成する
#!/usr/bin/env python3
# ##### つかいかた #####
#
# 実行前に `pip install feedgenerator` でライブラリをインストールしてください
#
# 例1: ./feedgen.py
# => サンプル入力からフィードを生成して標準出力に表示します
# 例2: ./feedgen.py input.txt
# => input.txtの内容からフィードを生成して標準出力に表示します
@amane-katagiri
amane-katagiri / email-protection.py
Created March 13, 2017 06:53
Implementation of "https?://some.domain.under.cdn.cloudflare.example.com/cdn-cgi/l/email-protection#{encoded_email_address}".
def protect_email(key: int, data: bytes) -> bytes:
return bytes([x ^ (key % 256) for x in b"\x00" + data])
def deprotect_email(data: bytes) -> bytes:
return bytes([x ^ data[0] for x in data[1:]])
def main():
import argparse
@amane-katagiri
amane-katagiri / message.txt
Created July 19, 2022 01:15
Last weekend’s Revue outage
Between 1:30pm ET on Friday, June 8, and around 6:15pm ET on Saturday, June 9, the Revue website was inaccessible.
We are sorry for the inconvenience this caused, and would like to explain what happened.
First off, some things to know:
Scheduled newsletter issues that were sent during the outage will have impacted delivery, but this incident will not affect future delivery
Analytics and aggregated data regarding your newsletters continued normally
The problem was caused by a Domain Name System (“DNS”) issue, which affected Revue between the hours stated above. The team worked hard to resolve the issue as swiftly as possible.
Once the issue was resolved, Revue came back online for a lot of people — but DNS changes can take up to 24 hours to propagate globally, which led to some people experiencing the outage for longer than others.
We sincerely apologize and we have taken the feedback you have shared into account. Our @TwitterWrite team will ensure that transparent, clear communication continues t
@amane-katagiri
amane-katagiri / dns-01-auth-netlify.sh
Last active July 19, 2022 00:52
/etc/letsencrypt/scripts/dns-01-auth-netlify.sh
#!/bin/sh
API_TOKEN='YOUR_NETLIFY_API_TOKEN'
if [ "$CERTBOT_VALIDATION" != "" ] && [ "$CERTBOT_DOMAIN" != "" ]; then
DNS_ZONE_ID=$(curl -Ss \
-H 'Authorization: Bearer '"$API_TOKEN" \
'https://api.netlify.com/api/v1/dns_zones' \
| jq -r '(.[] | select(.name == "'"$CERTBOT_DOMAIN"'")).id')
curl -Ss -X POST \
-H 'Content-Type: application/json' \
@amane-katagiri
amane-katagiri / emoji_search.json
Created July 9, 2022 09:08
JSON file mapped from emoji alias to twemoji image (72x72 png).
{
":grinning:": "https://raw.githubusercontent.com/twitter/twemoji/master/assets/72x72/1f600.png",
":smiley:": "https://raw.githubusercontent.com/twitter/twemoji/master/assets/72x72/1f603.png",
":smile:": "https://raw.githubusercontent.com/twitter/twemoji/master/assets/72x72/1f604.png",
":grin:": "https://raw.githubusercontent.com/twitter/twemoji/master/assets/72x72/1f601.png",
":laughing:": "https://raw.githubusercontent.com/twitter/twemoji/master/assets/72x72/1f606.png",
":satisfied:": "https://raw.githubusercontent.com/twitter/twemoji/master/assets/72x72/1f606.png",
":sweat_smile:": "https://raw.githubusercontent.com/twitter/twemoji/master/assets/72x72/1f605.png",
":joy:": "https://raw.githubusercontent.com/twitter/twemoji/master/assets/72x72/1f602.png",
":rofl:": "https://raw.githubusercontent.com/twitter/twemoji/master/assets/72x72/1f923.png",