メルキュール長野
↓
善光寺観光
↓
ハーベスト ナガイファーム 軽井沢店
https://tabelog.com/nagano/A2003/A200301/20009286/
↓
ささくら
https://tabelog.com/nagano/A2003/A200301/20000585/
↓
ハーベスト軽井沢
ホテル関連
【書籍】株の投資大全

結構面白い
【書籍】ファンダメンタル分析の手法と実例

Google Geminiを使ってみた!
1. Pythonライブラリのインストール
pip install google-cloud-aiplatform Successfully installed google-auth-2.25.2 google-cloud-aiplatform-1.38.1 google-cloud-resource-manager-1.11.0 google-cloud-storage-2.14.0 google-resumable-media-2.7.0 grpc-google-iam-v1-0.13.0 shapely-2.0.2
2. サンプルのテスト
テストプログラム作成
vi gemini_test.py
コード抜粋
chat = chat_model.start_chat( context="My name is Miles. You are an astronomer, knowledgeable about the solar system.", examples=[ InputOutputTextPair( input_text="How many moons does Mars have?", output_text="The planet Mars has two moons, Phobos and Deimos.", ), ], )
- 実行
Google Cloud上のサーバで実行しました。
python3 gemini_test.py
- ちゃんと結果が来た
Response from Model: There are eight planets in the solar system: Mercury, Venus, Earth, Mars, Jupiter, Saturn, Uranus, and Neptune.
使い方
3分でできる!Google 翻訳API
1. APIコンソールを開く
APIコンソールを開いて、有効化されていることを確認
https://console.cloud.google.com/apis/library?hl=ja
2. サーバに資格認証の設定をする
gcloud auth application-default login
3. pip install
$ pip install google-cloud-translate
4. テストコードを作成
def translate_text(target: str, text: str) -> dict: """Translates text into the target language. Target must be an ISO 639-1 language code. See https://g.co/cloud/translate/v2/translate-reference#supported_languages """ from google.cloud import translate_v2 as translate translate_client = translate.Client() if isinstance(text, bytes): text = text.decode("utf-8") # Text can also be a sequence of strings, in which case this method # will return a sequence of results for each text. result = translate_client.translate(text, target_language=target) print("Text: {}".format(result["input"])) print("Translation: {}".format(result["translatedText"])) print("Detected source language: {}".format(result["detectedSourceLanguage"])) return result translate_text("ja","this is test")
5. 翻訳実行!
$ python3 gcloud_translate.py Text: this is test Translation: これはテストです Detected source language: en
yfinance がバグったので直してみた
株価取得プログラムが動かない
原因調査のため、サンプルプログラムを作成して、実行
import mysql.connector import yfinance as yf import json ticker = yf.Ticker("GOOG") print(ticker.info)
File "/usr/local/lib/python3.9/dist-packages/yfinance/data.py", line 209, in get_raw_json response.raise_for_status() File "/usr/local/lib/python3.9/dist-packages/requests/models.py", line 1021, in raise_for_status raise HTTPError(http_error_msg, response=self) requests.exceptions.HTTPError: 401 Client Error: Unauthorized for url: https://query2.finance.yahoo.com/v10/finance/quoteSummary/GOOG?modules=summaryProfile%2CfinancialData%2CquoteType%2CdefaultKeyStatistics%2CassetProfile%2CsummaryDetail&ssl=true
確かにエラーになる。。ふむふむ、これは調査せねば
GitHubを調べた
https://github.com/ranaroussi/yfinance/issues/1592
HTTPError: 401 Client Error: Unauthorized for url
とある。これだな。
これはサードパーティのライブラリで、
Yahoo側もいろいろ差し替えるから、いたちごっこなんだろう
対応方法
pip をアップデート
$ pip install yfinance -U Requirement already satisfied: yfinance in /usr/local/lib/python3.9/dist-packages (0.2.18) Collecting yfinance Downloading yfinance-0.2.26-py2.py3-none-any.whl (62 kB) |????????????????????????????????| 62 kB 705 kB/s Requirement already satisfied: html5lib>=1.1 in /usr/local/lib/python3.9/dist-packages (from yfinance) (1.1) Requirement already satisfied: multitasking>=0.0.7 in /usr/local/lib/python3.9/dist-packages (from yfinance) (0.0.11) Requirement already satisfied: frozendict>=2.3.4 in /usr/local/lib/python3.9/dist-packages (from yfinance) (2.3.8) Requirement already satisfied: requests>=2.31 in /usr/local/lib/python3.9/dist-packages (from yfinance) (2.31.0) Requirement already satisfied: lxml>=4.9.1 in /usr/local/lib/python3.9/dist-packages (from yfinance) (4.9.2) Requirement already satisfied: numpy>=1.16.5 in /usr/local/lib/python3.9/dist-packages (from yfinance) (1.24.3) Requirement already satisfied: appdirs>=1.4.4 in /usr/local/lib/python3.9/dist-packages (from yfinance) (1.4.4) Requirement already satisfied: beautifulsoup4>=4.11.1 in /usr/local/lib/python3.9/dist-packages (from yfinance) (4.12.2) Requirement already satisfied: pandas>=1.3.0 in /usr/local/lib/python3.9/dist-packages (from yfinance) (2.0.2) Requirement already satisfied: pytz>=2022.5 in /usr/local/lib/python3.9/dist-packages (from yfinance) (2023.3) Requirement already satisfied: soupsieve>1.2 in /usr/local/lib/python3.9/dist-packages (from beautifulsoup4>=4.11.1->yfinance) (2.4.1) Requirement already satisfied: six>=1.9 in /usr/lib/python3/dist-packages (from html5lib>=1.1->yfinance) (1.16.0) Requirement already satisfied: webencodings in /usr/local/lib/python3.9/dist-packages (from html5lib>=1.1->yfinance) (0.5.1) Requirement already satisfied: python-dateutil>=2.8.2 in /usr/local/lib/python3.9/dist-packages (from pandas>=1.3.0->yfinance) (2.8.2) Requirement already satisfied: tzdata>=2022.1 in /usr/local/lib/python3.9/dist-packages (from pandas>=1.3.0->yfinance) (2023.3) Requirement already satisfied: charset-normalizer<4,>=2 in /usr/local/lib/python3.9/dist-packages (from requests>=2.31->yfinance) (3.1.0) Requirement already satisfied: idna<4,>=2.5 in /usr/lib/python3/dist-packages (from requests>=2.31->yfinance) (2.10) Requirement already satisfied: certifi>=2017.4.17 in /usr/lib/python3/dist-packages (from requests>=2.31->yfinance) (2020.6.20) Requirement already satisfied: urllib3<3,>=1.21.1 in /usr/lib/python3/dist-packages (from requests>=2.31->yfinance) (1.26.5) Installing collected packages: yfinance WARNING: The script sample is installed in '/home/hiroshi855/.local/bin' which is not on PATH. Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location. Successfully installed yfinance-0.2.26
修正確認
なおった。よかったー
h$ python3 yfinance_test.py {'address1': '1600 Amphitheatre Parkway', 'city': 'Mountain View', 'state': 'CA', 'zip': '94043', 'country': 'United States', 'phone': '650 253 0000', 'website': 'https://www.abc.xyz', 'industry': 'Internet Content & Information', 'industryDisp': 'Internet Content & Information', 'sector': 'Communication Services', 'longBusinessSummary': 'Alphabet Inc. offers various products and platforms in the United States, Europe, the Middle East, Africa, the Asia-Pacific, Canada, and Latin America. It operates through Google Services, Google Cloud, and Other Bets segments. The Google Services segment provides products and services, including ads, Android, Chrome, hardware, Gmail, Google Drive, Google Maps, Google Photos, Google Play, Search, and YouTube. It is also involved in the sale of apps and in-app purchases and digital content in the Google Play store; and Fitbit wearable devices, Google Nest home products, Pixel phones, and other devices, as well as in the provision of YouTube non-advertising services. The Google Cloud segment offers infrastructure, cybersecurity, data, analytics, AI, and machine learning, and other services; Google Workspace that include cloud-based collaboration tools for enterprises, such as Gmail, Docs, Drive, Calendar, and Meet; and other services for enterprise customers. The Other Bets segment sells health technology and internet services. The company was founded in 1998 and is headquartered in Mountain View, California.', 'fullTimeEmployees': 190711, 'companyOfficers': [{'maxAge': 1, 'name': 'Mr. Sundar Pichai', 'age': 49, 'title': 'CEO & Director', 'yearBorn': 1973, 'fiscalYear': 2022, 'totalPay': 7947461, 'exercisedValue': 39618220, 'unexercisedValue': 0}, {'maxAge': 1, 'name': 'Mr. Lawrence Edward Page', 'age': 49, 'title': 'Co-Founder & Director', 'yearBorn': 1973, 'fiscalYear': 2022, 'totalPay': 1, 'exercisedValue': 0
無料のSSL証明書を使う (初期構築)
Ubuntu の場合のLet’s encrypt 利用手順
certbotインストール
$ sudo apt install -y certbot
証明書作成(自己証明書)
$ sudo certbot certonly --webroot -w /var/www/html -d <domain_name> <mail address>
ApacheへのSSL設定
$ sudo vi /etc/apache2/sites-available/default-ssl.conf SSLCertificateFile /etc/letsencrypt/live/<domain_name>/cert.pem SSLCertificateKeyFile /etc/letsencrypt/live/<domain_name>/privkey.pem SSLCertificateChainFile /etc/letsencrypt/live/<domain_name>/chain.pem
SSL有効化
$ sudo a2ensite default-ssl $ sudo a2enmod ssl $ sudo systemctl restart apache2
無料のWordPressを立てる(Google Cloud Free)
Google Cloud とは
Google Cloud とは、Googleが運営するクラウド環境で、期限なしで利用できる無料枠が使える
VMの作成方法
Cloud Shellを起動して以下を実行する
$ gcloud compute instances create instance1 --project=bigquery-315414 --zone=us-central1-a --machine-type=e2-micro
ディスクサイズを30GBに拡張できる
$ gcloud compute instances stop instance1 --zone=us-central1-a $ gcloud compute disks resize instance1 --size 30 --zone=us-central1-a $ gcloud compute instances start instance1 --zone=us-central1-a