Skip to content

Instantly share code, notes, and snippets.

View gh640's full-sized avatar
🦔

Goto Hayato gh640

🦔
View GitHub Profile
@gh640
gh640 / fontawesome
Created April 5, 2024 01:56
Material for MkDocs icons (fontawesome)
material/templates/.icons/fontawesome
├── LICENSE.txt
├── brands
│   ├── 42-group.svg
│   ├── 500px.svg
│   ├── accessible-icon.svg
│   ├── accusoft.svg
│   ├── adn.svg
│   ├── adversal.svg
│   ├── affiliatetheme.svg
@gh640
gh640 / material
Created April 5, 2024 01:55
Material for MkDocs icons (material)
ab-testing.svg
abacus.svg
abjad-arabic.svg
abjad-hebrew.svg
abugida-devanagari.svg
abugida-thai.svg
access-point-check.svg
access-point-minus.svg
access-point-network-off.svg
access-point-network.svg
@gh640
gh640 / simple
Created April 5, 2024 01:52
Material for MkDocs icons (simple)
1001tracklists.svg
1password.svg
2k.svg
365datascience.svg
3m.svg
42.svg
4chan.svg
4d.svg
500px.svg
7zip.svg
@gh640
gh640 / openai_assistants_stream.py
Last active March 14, 2024 06:48
サンプル: OpenAI Assistants stream API を使う
"""OpenAI の Assistant stream API を使う
Usage:
python -m pip install 'openai==1.14.0'
export OPENAI_API_KEY='...'
python openai_assistant_stream.py
See: https://platform.openai.com/docs/assistants/overview?context=with-streaming
"""
@gh640
gh640 / dropbox-ignore.sh
Created February 13, 2024 04:09
Ignoring a direcotry in Dropbox on macOS
# Ignore
xattr -w 'com.apple.fileprovider.ignore#P' 1 my-directory
# Disable ignoring
xattr -d 'com.apple.fileprovider.ignore#P' my-directory
# My aliases
alias dropbox-exclude="xattr -w 'com.apple.fileprovider.ignore#P' 1"
alias dropbox-include="xattr -d 'com.apple.fileprovider.ignore#P'"
@gh640
gh640 / enumerate.py
Last active December 8, 2023 05:59
Prefix lines with natural numbers.
#!/usr/bin/env python3
"""Prefix lines with natural numbers."""
import sys
from typing import Literal
NUMBER_SUFFIX = "."
def main() -> str | Literal[0]:
if sys.stdin.isatty():
@gh640
gh640 / waitFor.js
Created November 21, 2023 05:51
JavaScript: async `waitFor` function
/**
* Wait for the specified milliseconds.
*/
async function waitFor(msec) {
await new Promise((resolve) => setTimeout(resolve, msec));
}
@gh640
gh640 / use-WP_HTML_Tag_Processor.php
Created June 18, 2023 07:46
Sample: Using `WP_HTML_Tag_Processor` that is introduced WordPress 6.2.0
<?php
/**
* `WP_HTML_Tag_Processor` Modifies attributes in an HTML document for tags matching a query.
*/
$html = '<span><img src="hello.webp" alt="hello"></span>';
// Create an instance
$tags = new WP_HTML_Tag_Processor( $html );
@gh640
gh640 / saveFile.js
Created June 15, 2023 07:18
Saving a string as a file in browser console
// Function:
async function saveFile(fh, content) {
const stream = await fh.createWritable();
await stream.write(content, {type: "text/plain"});
await stream.close();
}
// Usage:
const content = 'Hello world';
const fh = await window.showSaveFilePicker();
@gh640
gh640 / apache2.conf
Last active June 8, 2023 01:45
Sample: Apache conf to ignore `internal dummy connection` in Docker image `php:8.0-apache`
# Exclude log records for internal dummy connections.
SetEnvIf Remote_Addr "127\.0\.0\.1" loopback
CustomLog ${APACHE_LOG_DIR}/access.log combined env=!loopback