This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# MySQLTuner: https://github.com/major/MySQLTuner-perl | |
# Open Bash with the container. | |
docker exec [mariadb_or_mysql] bash | |
# Change the working directory to `/tmp`. | |
cd /tmp | |
# Install wget. | |
apt-get update |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
javascript:(function(){ | |
var q, location; | |
/* 選択された文字列を取得 */ | |
/* 選択されてなければダイアログから文字列を取得 */ | |
q = ""+(window.getSelection?window.getSelection():document.getSelection()); | |
if(!q) q = prompt("Amazon search... ",""); | |
/* urlエスケープした上でAmazonにリクエスト */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"""Stream output of `asyncio.create_subprocess_exec()`""" | |
import asyncio | |
import sys | |
async def run(program: str, args: list[str]): | |
"""Capture output (stdout and stderr) while running external command.""" | |
proc = await asyncio.create_subprocess_exec( | |
program, *args, stdout=asyncio.subprocess.PIPE, stderr=asyncio.subprocess.PIPE | |
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"""A sample to send message on Google Chat group with Python requests. | |
Prerequisites: | |
- Google API v1 | |
- A webhook URL taken | |
- Python 3 | |
- Requests (last tested with 2.31.0) | |
Usage: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def confirm(message: str) -> bool: | |
answer = input(f"{message} [yes/No]: ").strip().lower() | |
return answer in ["y", "yes"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const axios = require(`axios`) | |
// Pass incoming webhook URL with environment variable `WEBHOOK_URL`. | |
const WEBHOOK_URL = process.env.WEBHOOK_URL | |
const title = `Hi` | |
const subtitle = `Hello` | |
const paragraph = `Hasta La Vista, Baby.` | |
const widget = { textParagraph: { text: paragraph } } | |
axios.post(WEBHOOK_URL, { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
add_action( 'init', 'themeslug_add_font_collections' ); | |
/** | |
* フォントコレクションを追加する | |
*/ | |
function themeslug_add_font_collections() { | |
// フォントファミリーの定義: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
add_filter( 'upload_dir', 'themeslug_upload_dir' ); | |
/** | |
* Use user ids as subfolders for uploaded media files. | |
*/ | |
function themeslug_upload_dir( $uploads ) { | |
$user_id = get_current_user_id() ?: 'anonymous'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { useState, useEffect, useRef } from 'react' | |
function useElementSize() { | |
const ref = useRef(null) | |
const [size, setSize] = useState({ | |
width: 0, | |
height: 0, | |
}) | |
useEffect(() => { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
add_action( 'init', function () { | |
register_meta( | |
'post', | |
'book-genre', | |
[ | |
'show_in_rest' => true, | |
'single' => true, |
NewerOlder