Skip to content

Instantly share code, notes, and snippets.

View attakei's full-sized avatar

Kazuya Takei attakei

View GitHub Profile
@attakei
attakei / 202402-21-atproto-shortcut-functions
Last active February 20, 2024 18:11
shortcut functions to send post using atproto
Please see `shorcuts.py`
@attakei
attakei / collect_footnotes.py
Last active January 8, 2023 18:20
Simple extension to collect scattered footnotes on document into last
"""
Copyright 2023 attakei
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, software
@attakei
attakei / hide-sitebar.js
Last active July 8, 2022 10:12
UserScript to hide timeline-trend of side-bar on Twitter
// ==UserScript==
// @name Hide sidebar
// @namespace http://tampermonkey.net/
// @version 0.1
// @description Hide sidebar of Twitter
// @author attakei
// @match https://twitter.com/*
// @icon https://www.google.com/s2/favicons?sz=64&domain=twitter.com
// @grant none
// ==/UserScript==
@attakei
attakei / gist:2aee35dbffc8509fb4dc04d182fa82ad
Last active May 8, 2022 11:24
Example of redering HTML from PyScript with docutils
<html>
<head>
<script defer src="https://pyscript.net/alpha/pyscript.js"></script>
<py-env>
- docutils
- BeautifulSoup4
</py-env>
<py-script output="output">
from bs4 import BeautifulSoup
from docutils.core import publish_string
@attakei
attakei / sphinx-for-bulma.py
Created March 12, 2022 16:07
Render message(message-header, message-body) from admonitions of reStructuredText
from typing import Optional
from docutils import nodes
from sphinx.application import Sphinx
from sphinx.locale import admonitionlabels
from sphinx.writers.html5 import HTML5Translator
def visit_admonition(name: Optional[str] = None):
class_ = "message" if name is None else f"message is-{name}"
@attakei
attakei / PKGBUILD
Created December 18, 2021 08:28
Install gh(GitHub CLI) fy pacman likely AUR
# Maintainer: Your Name <youremail@domain.com>
pkgname=gh-bin
pkgver=2.3.0
pkgrel=1
epoch=
pkgdesc="GitHub’s official command line tool (private AUR for install from binary)"
arch=('x86_64')
url="https://github.com/cli/cli/tree/v2.3.0"
license=('MIT')
groups=()
@attakei
attakei / commit-msg
Created December 4, 2021 08:21
Git commit-msg hook for Conventional Commits
#!/usr/bin/env python
import re
import sys
from pathlib import Path
VALID_TYPES = [
# Rule 1 and 2.
"feat", "fix",
# Rule 4.(Optional)

FastAPI Middleware to forwarding hostname

Overview

FastAPI middleware to override Host header value by X-Forwarded-Host header value if it is exists.

FastAPI(Starlette) can make response used by X-Forwarded-Host header for slash-tailed redirection.

@attakei
attakei / conf.py
Last active February 28, 2021 07:15
.readme.md
project = 'sphinx-revealjs-issue'
copyright = '2021, Kazuya Takei'
author = 'Kazuya Takei'
release = '2021.2.28'
extensions = [
'sphinx.ext.todo',
'sphinx_revealjs',
]
templates_path = ['_templates']
@attakei
attakei / python_google_home_notify_ja.md
Last active November 23, 2020 13:56
Google home notifications by python

Pythonを使ってGoogle Homeに指定したテキストを喋らせる

使い方

  1. これをcloneする
  2. virtualenvを用意する
  3. pip install -r requirements.txtで依存パッケージをインストールする
  4. python server.pyでサーバーを起動する
  5. ブラウザで、サーバーにアクセスして、フォームにテキストと言語を指定して「喋る」ボタンを押す
  6. Google Homeが喋った!