【OpenAI/ChatGPT】API リクエストしたら「You exceeded your current quota, please check your plan and billing details.」

無料で3ヶ月間、18ドル分使えるというので。


openai.api_key = os.getenv("OPENAI_API_KEY")
try:
  response = openai.Completion.create(
    engine="davinci",
    # engine="gpt-3.5-turbo",
    prompt="Hello, world!",
    max_tokens=5
  )
  print(response.choices[0].text)
except Exception as e:
  print(f"{e=}, {type(e)=}")

NGでした。


e=RateLimitError(message='You exceeded your current quota, please check your plan and billing details.', http_status=429, request_id=None), type(e)=<class 'openai.error.RateLimitError'>

利用量の確認をします。

Below you'll find a summary of API usage for your organization. All dates and times are UTC-based, and data may be delayed up to 5 minutes.
👉 Account - OpenAI API hatena-bookmark

利用の記録はないです。

無料18ドル分も付与されてない雰囲気。

「アカウント作成から3ヶ月以内。」ということですがそれは満たしている。

どういうことなんすかね!?

👉 How can I get Free Trial Credits? - General API discussion - OpenAI API Community Forum hatena-bookmark


Excel / Spreadsheet / Numbers の列の文字列を一括でQRコードで表示する方法

Google Chart API を使ったりプラグインやエクステンションを使ったりする方法もありますが、通信を使わずに完全にローカル処理のみで表示します。

パスワードやシークレットキーなどセキュリティ的に最重要な文字列をQRコードで表示したいこともありますよね。

 

🔑 準備

Pure python QR Code generator を使います。


pip install qrcode

👉 lincolnloop/python-qrcode: Python QR Code image generator hatena-bookmark

今回は、サンプルデータとして以下のCSVファイルを作成しました。


title,url
blog,https://android.benigumo.com
facebook,https://www.facebook.com/androidbenigumocom
twitter,https://twitter.com/maochanz

 

🔑 作成する

CSVファイルをExcel系アプリ(Apple Numbers)で開きます。

Excel / Spreadsheet / Numbers の列の文字列を一括でQRコードで表示する方法

QRコードで表示したい列をコピーします。

Excel / Spreadsheet / Numbers の列の文字列を一括でQRコードで表示する方法

以下をターミナルで実行すると連続で表示されます。


for uri in $(pbpaste); do qr "$uri";echo "$uri\n\n"; done


Excel / Spreadsheet / Numbers の列の文字列を一括でQRコードで表示する方法

以上です。

次回は、これをパスワードマネージャーデータの移行に使います。


【macOS】Android Studio 埋め込み JDK の Home のパスを取得する

毎回どこなのかググるので。

まずは、mdfind で Android Studio のインストールされているパスを取得します。

👉 mdfind – macOSのCLIでもSpotlightを使ってファイルを高速全文検索する | DevelopersIO hatena-bookmark


❯ mdfind kMDItemCFBundleIdentifier="com.google.android.studio*"
/Users/mao/Library/Application Support/JetBrains/Toolbox/apps/AndroidStudio/ch-0/221.6008.13.2211.9477386/Android Studio.app
/Users/mao/Library/Application Support/JetBrains/Toolbox/apps/AndroidStudio/ch-1/223.7571.182.2231.9523943/Android Studio Preview.app

JetBrains Toolbox で Android Studio Preview版 も入れてるので複数見つかります。

👉 JetBrains Toolbox で Android Studio の Stable/Beta/Canary が同時に管理できる? hatena-bookmark

パス内の 221.6008.13.2211.9477386 のような文字列は、Android Studio のリリースバージョンです。

Android Studio Releases List

👉 Android Studio Releases List | IntelliJ Platform Plugin SDK hatena-bookmark

find | grep して JDK の Home を探します。


❯ find "/Users/mao/Library/Application Support/JetBrains/Toolbox/apps/AndroidStudio/ch-0/221.6008.13.2211.9477386/Android Studio.app" \
  | grep -E "/(jdk|jbr)/Contents/Home$"
/Users/mao/Library/Application Support/JetBrains/Toolbox/apps/AndroidStudio/ch-0/221.6008.13.2211.9477386/Android Studio.app/Contents/jbr/Contents/Home

Home のパスが見つかったらバージョンを確認してみます。


"/Users/mao/Library/Application Support/JetBrains/Toolbox/apps/AndroidStudio/ch-0/221.6008.13.2211.9477386/Android Studio.app/Contents/jbr/Contents/Home/bin/java" --version
openjdk 11.0.15 2022-04-19
OpenJDK Runtime Environment (build 11.0.15+0-b2043.56-8887301)
OpenJDK 64-Bit Server VM (build 11.0.15+0-b2043.56-8887301, mixed mode)

というかんじをスクリプトにしておきます。



JDK の Home パスとバージョンが表示されます。


❯ find-androidstudio-embedded-jdk.sh
"/Users/mao/Library/Application Support/JetBrains/Toolbox/apps/AndroidStudio/ch-0/221.6008.13.2211.9477386/Android Studio.app/Contents/jbr/Contents/Home"
openjdk 11.0.15 2022-04-19
OpenJDK Runtime Environment (build 11.0.15+0-b2043.56-8887301)
OpenJDK 64-Bit Server VM (build 11.0.15+0-b2043.56-8887301, mixed mode)

"/Users/mao/Library/Application Support/JetBrains/Toolbox/apps/AndroidStudio/ch-1/223.7571.182.2231.9523943/Android Studio Preview.app/Contents/jbr/Contents/Home"
openjdk 17.0.5 2022-10-18
OpenJDK Runtime Environment (build 17.0.5+0-17.0.5b653.25-9484017)
OpenJDK 64-Bit Server VM (build 17.0.5+0-17.0.5b653.25-9484017, mixed mode)

https://plugins.jetbrains.com/docs/intellij/android-studio-releases-list.html

mdfind って便利で高速です。

👉 Android Studio Electric Eel | 2022.1.1 の JDK11 設定 hatena-bookmark
👉 macOS (Intel) + Homebrew の JDK の現状を確認する hatena-bookmark