MySQL only_full_group_by

only_full_group_by エラー: 1 2 3 4 5 6 OperationalError: ( 1055, "Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'server.sales_sales.sales_status' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by") 対処: sql_mod に traditional を指定する ...

2023年6月30日 · 1 分

azure cognitive service

Azure Cognitive Services Azure Cognitive Services は、Microsoft Azure の製品として提供されている AI 機能作成サービスです ¹². これらのサービスは、REST API およびクライアントライブラリ SDK を使用して、人工知能を直接的に利用することなく、アプリケーションに認識、言語理解、音声、画像、検索などの機能を追加することができます ¹³. Azure Cognitive Services は、視覚、音声、言語、決定、検索などの分野を対象に AI 機能を簡単に利用することができます ¹. また、学習済みの AI モデル予測機能を活用できるのが特徴です ¹. ソース: Bing との会話 2023/6/30 (1) AI をもっと身近に!Azure Cognitive Services とは?今注目されて …. https://www.rworks.jp/cloud/azure/azure-column/azure-entry/28078/. (2) Azure Cognitive Services とは - Azure Cognitive Services. https://learn.microsoft.com/ja-jp/azure/cognitive-services/what-are-cognitive-services. (3) Cognitive Services - AI ソリューション向け API | Microsoft Azure. https://azure.microsoft.com/ja-jp/products/cognitive-services/. カテゴリ 視覚 音声 Language 決定 Azure OpenAI Service

2023年6月29日 · 1 分

Cloud Function defautl pages

AWS CloudFuntion URL 変更 AWS CloudFront Functions を使用して、ブラウザリクエストの URL を書き換えてオリジンに送信するには、HTTP リクエストを別の URL にリダイレクトする関数を作成する必要があります。 AWS ドキュメントには、CloudFront Functions を使用して HTTP リクエストを別の URL にリダイレクトする方法が記載されています ¹。 また、Classmethod 社の記事には、CloudFront Functions でオリジンに手を加えずに URL リダイレクトを行う方法が記載されています ³。 ご参考までに、以下は CloudFront Functions で HTTP リクエストを別の URL にリダイレクトする例です ²。 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 function handler(event) { var request = event.request; var headers = request.headers; var uri = request.uri; var host = headers.host.value; var newurl = null; // Check the URI is '/abc/sign-up'. if (uri === "/abc/sign-up") { newurl = `https://${host}/sign-up`; } if (newurl !== null) { return { statusCode: 301, statusDescription: "Moved Permanently", headers: { location: { value: newurl }, }, }; } return request; } この例では、URI が/abc/sign-upに一致した場合に、https://${host}/sign-upへリダイレクトしています。この例を参考に、ご自身の環境に合わせた関数を作成してください。 ...

2023年6月26日 · 2 分

unittest mock

patch.object(): メソッドを置き換える メソッドが外部のサーバーに対して API リクエストを行う テストではサーバー間 API が成功したものとして、状態だけ進める 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 from unittest.mock import patch from applies.utils import approve_to from base.tests.utils import RestTestCase from sourcing.models import PurchaseOrder def fake_cloudsign_post_document(self, *args, **kwargs): # サーバー間のAPIが成功したものとして承認状態を進める approve_to(self.purchase, "purchase_print") class PurchaseOrderTest(RestTestCase): @patch.object(PurchaseOrder, "cloudsign_post_document", new=fake_cloudsign_post_document) def test_create(self): # .... # response = client.post("/api/rest/sourcing/purchaseorder/", params) ... instance = PurchaseOrder.objects.get(id=response.json()["id]) self.assertEqual(instanc.purchase.purchase_status, "print")

2023年6月26日 · 1 分

django cache decorator

django: cache value decorator 1 2 from functools import wraps from django.core.cache import c 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 def cached_value(key=None, **kwargs): """ key で指定された値をキャッシュから取得して current に渡す reset=True が指定されるとキャッシュデータを使わない """ def _cache_controller(original_func): @wraps(original_func) def _cache_controlled(*args, **kw): current = None if kw.get("reset", False) else cache.get(key) lastest = original_func(*args, current=current, **kw) cache.set(key, lastest) return lastest return _cache_controlled return _cache_controller 1 2 3 4 5 class PurchaseOrder: @cached_value(key="webservice_accesstoken") def get_accesstoken(self, current=None, reset=False): return Token(self.company.credentials).update_token(current)

2023年6月22日 · 1 分

cp932

CP932 の最大バイト数を超えない長さで文字列を丸める 1 from itertools import accumulate 1 2 3 4 5 6 7 8 9 def cp932_substr(source, max_length): """CP932での最大バイト数(max_length) を超えない文字数で丸める""" if not source: return "" data = map(lambda i: len(i.encode("cp932")), source) target = filter(lambda i: i <= max_length, accumulate(data)) count = len(list(target)) return source[:count]

2023年6月21日 · 1 分

AWS Windows

AWS EC2 Windows AWS EC2 で起動した Windows Server を日本語設定にする コマンドプロンプト/英語モード・日本語モードの切り替え方法・chcp ALB のアクセスを CloudFront からだけに許可するように設定してみた Amazon VPC で Amazon CloudFront 用に AWS が管理するプレフィックスリストのサポートを開始 Work with AWS-managed prefix lists EC2Launch v2 を使用した Windows 管理者パスワードのリセット

2023年6月20日 · 1 分

at

at コマンド MacOS で at コマンドを有効化して使ってみる 手順: /System/Library/LaunchDaemons/com.apple.atrun.plist で、Disabled を false に変更 /System/Library/LaunchDaemons/com.apple.atrun.plist を再ロード 1 2 3 4 % sudo launchctl load -w /System/Library/LaunchDaemons/com.apple.atrun.plist /System/Library/LaunchDaemons/com.apple.atrun.plist: service already loaded Load failed: 37: Operation already in progress

2023年6月18日 · 1 分

ltsv

ltsv 形式 http://ltsv.org/ https://github.com/hekyou/python-ltsv pip install ltsv To process LTSV files in Python, you can use the ltsv package available on PyPI ². Here is an example of how to use it: 1 2 3 4 5 import ltsv with open('file.ltsv') as f: for record in ltsv.reader(f): print(record) This code will read the LTSV file line by line and print each record as a dictionary ¹. ...

2023年6月16日 · 1 分

ndjson

ndjson https://github.com/rhgrant10/ndjson Snowflake: CREATE FILE FORMAT 【Python】Python ~ ndjson を扱う ~ tablib は ndjson をサポートしていない pandas は ndjson を読み込める

2023年6月14日 · 1 分