Skip to content

Instantly share code, notes, and snippets.

View KenjiOhtsuka's full-sized avatar
👍
Hello, World!

Kenji Otsuka KenjiOhtsuka

👍
Hello, World!
View GitHub Profile
@KenjiOhtsuka
KenjiOhtsuka / video_ascii_conversion.py
Last active June 6, 2023 01:39
Convert Video to ASCII
import cv2
import numpy as np
cap = cv2.VideoCapture(0)
# replace each pixel with a character from array
chars = ["B", "S", "#", "&", "@", "$", "%", "*", "!", ":", "."]
chars = chars[::-1]
while True:
@KenjiOhtsuka
KenjiOhtsuka / README.ja.md
Last active May 25, 2023 10:13
HTTPS Server for Redirection

これは、OAuth 2.x 認証サーバーからのリダイレクトである localhost への HTTPS GET リクエストを受信するために作成された単純なサーバーのコードです。 リダイレクトURIに、SSL/TLS を必要とする HTTPS URL しか登録できない場合に使えます。 server.py は HTTPS GET リクエストを受信すると、パラメータをつけたまま http://localhost にリダイレクトします。

使い方

ステップ1

次のコマンドを実行して暗号化キーを作成します。

@KenjiOhtsuka
KenjiOhtsuka / How to change Theme fonts in Microsoft Word.md
Last active May 14, 2023 23:31
How to change Theme fonts in Microsoft Word

How to change Theme fonts in Microsoft Word

Here, I explain how to change headings and body font in Microsoft Word. I used Microsoft Word for Mac Version 16.70. In Microsoft Word, there are default fonts and I couldn’t find a way to change them via GUI. When I change the theme, they are changed but it was hard to find a theme that uses the font I wanted to use. Then, I changed them with VBA. Code

I changed the default font as follows.

To change fonts to Times New Roman

@KenjiOhtsuka
KenjiOhtsuka / README.md
Created May 2, 2023 08:59
Karabiner-Elements: 「かな」を入力言語切り替えに使う

JOSN 配置場所

JSONはフォルダ

/Users/{{USER}}/.config/karabiner/assets/complex_modifications/

の中に入れる。

BEM

  • Block
    • nameは目的を説明する
    • 再利用可能な、機能的に独立したページ コンポーネント。
    • 見え方を表すものではない
    • ブロックは互いに入れ子にすることができる。ネストレベルに制限はない。
  • Element
    • 単体では使えないブロックの複合パーツ。ブロックの中で使用される。
  • nameは目的を説明する。
@KenjiOhtsuka
KenjiOhtsuka / Racket.md
Last active April 14, 2023 22:24
Racketの文法まとめ
  • Racket のファイルは #lang racket から始める。
  • 真偽値
    • #t, #f
  • 関数定義
    • (define x expression)
      • e: Expression
      ; lambda を使った関数定義
      (define a (lambda (x) (+ 1 x))

; 引数と一緒に関数定義

@KenjiOhtsuka
KenjiOhtsuka / bash.sh
Created March 11, 2023 20:10
Processs each character in a file
#!bin/bash
while IFS= read -r line
do
for i in $(seq 0 $(expr length "$line"))
do
# print each character
c="${line:$i:1}"
echo -n c
done
@KenjiOhtsuka
KenjiOhtsuka / generate.sh
Created February 18, 2023 02:42
Generate azure private endpoint host file
for sub in $(az account list -o tsv --query '[].name'); do
echo "# subscription = $sub"
for id in $(az network private-endpoint list --subscription $sub --query '[] | networkInterfaces[].id' -o tsv); do
address=$(az network nic show --ids $id --query 'ipConfigurations[].privateIpAddress' -o tsv)
for fqdn in $(az network nic show --ids $id --query 'ipConfigurations[].privateLinkConnectionProperties.fqdns' -o tsv); do
if [ -z "$fqdn" ]; then
continue
fi
echo "$address $fqdn"
done
@KenjiOhtsuka
KenjiOhtsuka / SQLExecutionSample.fs
Last active January 26, 2023 07:00
FSharp SQL Execution
open Microsoft.Data.SqlClient
module Sample =
[<Literal>]
let connectionString = "Server=sample.database.windows.net;Database=db_name;User Id=user_id;Password=password;"
let run() =
use connection = new SqlConnection(connectionString)
use command = new SqlCommand("SELECT * FROM sample", connection)
connection.Open()
@KenjiOhtsuka
KenjiOhtsuka / GmailReader.fs
Last active January 20, 2023 07:51
Read GMail
open Google.Apis.Auth.OAuth2
open Google.Apis.Gmail.v1
open Google.Apis.Http
open Google.Apis.Services
open Google.Apis.Util.Store
open System
open System.Threading
type EmailFinder() =
let configDir: string = Environment.GetFolderPath(Environment.SpecialFolder.UserProfile) + "/.gmail_config"