Skip to content

Instantly share code, notes, and snippets.

@fuji44
fuji44 / README.md
Created November 3, 2023 08:32
Watch the latest action execution using GitHub CLI

Watch the latest action execution using GitHub CLI

# Run git repository dir
runId=$(gh run list -u fuji44 -b develop -L 1 --json databaseId | jq .[].databaseId)
gh run watch $runId

Example script

@fuji44
fuji44 / README.md
Created July 10, 2023 02:52
[TypeScript] Checking image URLs using magic numbers

[TypeScript] Checking image URLs using magic numbers

import axios from "axios";

class ImageUtil {
  public static async isValidImageUrl(url: string) {
    try {
      const response = await axios.get<string>(url, {
 responseType: "arraybuffer",
@fuji44
fuji44 / README.md
Created June 22, 2023 14:47
Interoperation between constant arrays and type definitions in TypeScript

Interoperation between constant arrays and type definitions in TypeScript

export const keyArray = ["key1", "key2", "key3"] as const;

export type Key = typeof keyArray[number];

export function isKey(value: string): value is Key {
  return (keyArray as readonly string[]).includes(value);
}
@fuji44
fuji44 / README.md
Last active January 15, 2024 12:17
Backup of drivers without third-party tools in Windows

Backup of drivers without third-party tools in Windows

Use the Export-WindowsDriver command.

# Run with administrator privileges PowerShell
Export-WindowsDriver -Online -Destination C:\win_drivers

The Online option indicates to target logged-in Windows.

@fuji44
fuji44 / README.md
Last active March 30, 2023 12:53
Addressing the issue of .pnpm-store being created in the project root in Devcontainer

What to do when .pnpm-store is created in the project root

When I tried to use pnpm with devcontainer, a .pnpm-store was created in the project root. It should normally be created in an appropriate path under the home directory.

This directory contains the npm package entities. My understanding is that this is a characteristic of pnpm and it is not in line with pnpm's philosophy to create it in the project root.

Solution

Explicitly specify store-dir in pnpm.

@fuji44
fuji44 / README.md
Created March 5, 2023 06:39
Download file with Python

Download file with Python

import requests

def _download_file(url: str, output_file_path: str, chunk_size: int = 8192) -> str:
    with requests.get(url, stream=True) as stream:
        stream.raise_for_status()
        with open(file=output_file_path, mode="wb") as file:
 for chunk in stream.iter_content(chunk_size=chunk_size):
@fuji44
fuji44 / README.md
Created December 29, 2022 07:06
Commands to manipulate services in Windows for PowerShell

Commands to manipulate services in Windows for PowerShell

Show

# Show all services
get-service

# Show service with the name "ssh-agent"
get-service "ssh-agent"
@fuji44
fuji44 / kakaku_com.http
Created December 25, 2022 05:56
価格.com API memo
# use. https://github.com/Huachao/vscode-restclient
# api ref. http://apiblog.kakaku.com/
@apiKey = xxxx
###
# 価格.com 商品検索
# ref. http://apiblog.kakaku.com/KakakuItemSearchV1.0.html
# @prompt keyword 検索したいキーワード ex. hx1000
GET https://api.kakaku.com/WebAPI/ItemSearch/Ver1.0/ItemSearch.aspx?ApiKey={{apiKey}}&Keyword={{keyword}}
@fuji44
fuji44 / README.md
Created December 16, 2022 10:33
Snippet code for Boolean-like use of environment variables in shell scripts

Snippet code for Boolean-like use of environment variables in shell scripts

#!/bin/sh

debug=$(echo "${BATCH_DEBUG:=false}" | tr "[:upper:]" "[:lower:]")
if [ "$debug" = "true" ] || [ "$debug" = "1" ]; then
  echo "TRUE -> $debug"
else
  echo "FALSE -> $debug"
@fuji44
fuji44 / README.md
Last active December 4, 2022 09:32
Type resolution settings when creating a web extension in Deno

Type resolution settings when creating a web extension in Deno

Type Solution

document

Set deno.json as follows so that the dom type can be resolved.

  "compilerOptions": {