投稿時間:2022-01-01 12:13:24 RSSフィード2022-01-01 12:00 分まとめ(17件)

カテゴリー等 サイト名等 記事タイトル・トレンドワード等 リンクURL 頻出ワード・要約等/検索ボリューム 登録日
IT 気になる、記になる… Apple、中国などで虎の絵文字を刻印した限定デザインの「AirPods Pro」を発売 https://taisy0.com/2022/01/01/150302.html airpodspro 2022-01-01 02:17:51
IT 気になる、記になる… Apple、「Apple Books」や「Apple TV」で正月限定セールを開催中 https://taisy0.com/2022/01/01/150298.html apple 2022-01-01 02:09:45
TECH Engadget Japanese ポケモンGOお正月イベント開催 新規衣装ポケモンとタイムチャレンジ https://japanese.engadget.com/pokemon-go-2022-new-year-event-024807840.html 開催 2022-01-01 02:48:07
TECH Techable(テッカブル) メタバースで「電子マグロNFT」の初競りオークション開催! 1月3日から10日まで https://techable.jp/archives/170146 nanaku 2022-01-01 02:00:12
python Pythonタグが付けられた新着投稿 - Qiita ボードゲームをWEB化してみたシリーズ<THE GAME> https://qiita.com/yanaitti/items/9260848503809c7a857d ゲームの全容テーブル上には、山場と、つのカード置き場カードはからまでの組計枚のカードゲームのルール最初にプレイヤーに配る手札の数は、人数により調整最初につのカード置き場には、→というカードと、→というカードを枚ずつ、合計枚配置プレイヤーは枚以上カードを出す必要がある枚以上なら手札分を全部おいてもよし配置した枚のカードには、→の場合には、直前に出されているカードより大きい数字のカードを置く→の場合には、直前に出されているカードより小さい数字のカードを置くプレイヤーのターンが終わったら、出したカード分を山札から補充する特殊ルール「もどし」これは直前に出されているカードより小さい大きいカードを出すことが可能勝利条件勝利条件は下記の通りありますが、これは枚数を見て判断すればいいので、機能は実装しません枚以下なら「勝利」枚なら「完全勝利」枚以上なら「敗北」最重要ルールこのゲームは、協力ゲームであり、みんなで協力して手持ちのカードなるべく出せるようにすることが大事です。 2022-01-01 11:23:22
Program [全てのタグ]の新着質問一覧|teratail(テラテイル) SDRAMのアドレスとバンクアドレスの関係について https://teratail.com/questions/376239?rss=all SDRAMのアドレスとバンクアドレスの関係についてソフトコアプロセッサでSDRAMへのメモリアクセスを検討しています。 2022-01-01 11:34:47
Program [全てのタグ]の新着質問一覧|teratail(テラテイル) 複数の文字列を一度に置換する方法について https://teratail.com/questions/376238?rss=all 複数の文字列を一度に置換する方法についてwwwokoopokprintresubokresubwwwgtgtgtoopaposokoopokaposの中のaposaposとaposokaposを置換したいのですがresubquotokquotnbspaposaposresubquotquotnbspaposaposwwwこのようにresubを回使うのが何となく好きではありません。 2022-01-01 11:33:01
Program [全てのタグ]の新着質問一覧|teratail(テラテイル) arduino i2cとシリアル通信について https://teratail.com/questions/376237?rss=all arduinoicとシリアル通信についてpythonでをシリアルで送信→masterで受け取り→icでSlaveが受け取り、をシリアルプリントloopの中でという動作を期待したいですが、現状ic受け取り時、シリアルプリントに何も表示されないのでloopの中でも何も表示されないです。 2022-01-01 11:07:24
AWS AWSタグが付けられた新着投稿 - Qiita AWS Amazon Linux2 インスタンスに BWA をインストールする https://qiita.com/quryu/items/e713fefb645b0283580a sudoyuminstallgccsudoyuminstallzlibdevel上記のパッケージをインストールしないと、以下のように失敗します。 2022-01-01 11:27:59
海外TECH DEV Community Doctoring your application configuration https://dev.to/dev_dull/doctoring-your-application-configuration-31f Doctoring your application configuration Opinion Code for configuration handling is uglyIf you ve ever written a statement that looks something like my setting config value if config value else some default and hated it then I expect we can agree that handling application configuration is a miserable thing to code for Its boring to write ugly to read and annoying to ensure that all user configuration options have sane default values The argparse library can go a long way to making things better but if you need to set dozens of options or if your application supports plugins with configuration requirements unknown to the main program it becomes harder to simply add argument our way back to sanity In these cases it makes more sense to opt for a configuration file Also it would be nice if our application code didn t care about the configuration file at all where we had a single source of truth to count on being correct Getting ClassyWhen I ve hit the point in my development process where I have the basic functionality working and I ve settled on the basics of how the program will flow I like to create a new python file constfig py and define the class C where the C stands for both constants and config and that s good enough for me Both config and constants start with C By convention I lead the with an underscore to signal to the other developers on the project that the class isn t intended to be implemented directly and at the end of the file I create an instance of C called C which can be imported and will contain all the information needed by the application For example let s implement a simple dice rolling API endpoint using Flask which returns a JSON formatted string For this type of application we would want to be able to easily configure the IP address and port that the service listens on so let s define our C class establish the variable names pre populate the variables with some reasonable default values and then create an instance of our class named C which the user is meant to import from our file class C object def init self self LISTEN IP self LISTEN PORT C C We also have certain values which will never change at runtime but if our specification changes later we don t want to have to hunt down all instances of that value in our code so let s also add our constant values class C object def init self Constant values self JSON RESPONSE KEYWORD DROLL d roll User configurable values self LISTEN IP self LISTEN PORT C C Now that we have our constant values and our configurable variables with sane defaults let s import C the instance of C into our main Flask application from constfig import C Our constants config constfigfrom random import randintfrom flask import Flask jsonifyapp Flask name app route rolld def roll d value C JSON RESPONSE KEYWORD DROLL randint return jsonify value if name main app run host C LISTEN IP port C LISTEN PORT We can now give it a quick run user host python roll py Serving Flask app roll lazy loading Environment production WARNING This is a development server Do not use it in a production deployment Use a production WSGI server instead Debug mode offINFO werkzeug Running on Press CTRL C to quit and test to make sure all looks good so far user host curl s localhost rolld python m json tool d value ‍️Operate on your selfNow that we have our application and our C class we re ready for it to poke at its own guts Let s add the function load config which will open up our configuration file config yaml and then use the setattr function to update our own values at startup when Python runs from constfig import C Python s ability to alter its own state is knows as reflection or reflective programming import yamlimport loggingclass C object def init self Constant values and a gotcha self JSON RESPONSE KEYWORD DROLL d roll User configurable values self LISTEN IP self LISTEN PORT Load user config override defaults above self load config def load config self try config file open config yaml r config string config file read config file close configuration yaml load config string Loader yaml SafeLoader Don t handle badly formatted YAML Let the parser inform the user of the error if isinstance configuration dict for variable name value in configuration items setattr self variable name value else raise yaml scanner ScannerError f The file config yaml should be structured as type dict but got type type configuration except FileNotFoundError logging warning Configuration file config yaml is missing Using default values C C We can now create our config yaml file containing key value pairs where the key matches the name of our configuration itemsLISTEN IP LISTEN PORT Let s fire up the service again user host python roll py Serving Flask app roll lazy loading Environment production WARNING This is a development server Do not use it in a production deployment Use a production WSGI server instead Debug mode off Running on Press CTRL C to quit and this time we see that the default values have been overridden by those in the configuration file Specifically we re now listening on the loopback IP and that our port number has changed as expected Gotta catch that gotcha The problem with this method is that we open ourselves up to having the configuration file change values that should not be changed For example if we set JSON RESPONSE KEYWORD DROLL this is bad in config yaml then make a request to our endpoint we see that we ve indirectly altered our application s response user host curl s rolld python m json tool this is bad While the fix here isn t hard this bad behavior underscores the importance of the order in which we set out values Let s move our constant values to where they are being set after the values in our configuration file by adding a finally clause to our try except block on load config and call our new method set constants import yamlimport loggingclass C object def init self User configurable values self LISTEN IP self LISTEN PORT Load user config override defaults above self load config def set constants self Constant values self JSON RESPONSE KEYWORD DROLL d value def load config self try config file open config yaml r config string config file read config file close configuration yaml load config string Loader yaml SafeLoader Don t handle badly formatted YAML Let the parser inform the user of the error if isinstance configuration dict for variable name value in configuration items setattr self variable name value else raise yaml scanner ScannerError f The file config yaml should be structured as type dict but got type type configuration except FileNotFoundError logging warning Configuration file config yaml is missing Using default values finally self set constants C C then launch again using our bad which tries to set JSON RESPONSE KEYWORD DROLL configuration file user host python roll py Serving Flask app roll lazy loading Environment production WARNING This is a development server Do not use it in a production deployment Use a production WSGI server instead Debug mode off Running on Press CTRL C to quit and of course test the result user host curl s rolld python m json tool d value Tada A single source of truth for your Python application You hate this but I need validationYes I hear you bemoan I ve got a children s song about cookies stuck in my head I m half way through a pack of Oreos and this seems like an abstraction that makes it harder to see how the configuration is loaded Yeah this solution is probably not for everyone but I ve hidden the superpower of this method behind a mild mannered alter ego The real power is automatic validation of your configuration simply by importing C To do this let s define the function validate config write some basic assertions to validate the configuration and then call the function after we have successfully loaded the yaml file and set the constant values in our class import yamlimport loggingclass C object def init self Default values for user configurable items self LISTEN IP self LISTEN PORT Load user config override defaults above self load config def set constants self Constant values self JSON RESPONSE KEYWORD DROLL d value def load config self try config file open config yaml r config string config file read config file close configuration yaml load config string Loader yaml SafeLoader Don t handle badly formatted YAML Let the parser inform the user of the error if isinstance configuration dict for variable name value in configuration items setattr self variable name value else raise yaml scanner ScannerError f The file config yaml should be structured as type dict but got type type configuration except FileNotFoundError logging warning Configuration file config yaml is missing Using default values finally self set constants self validate config Validate our config file def validate config self Validate LISTEN IP assert isinstance self LISTEN IP str LISTEN IP is not a string value assert len self LISTEN IP split LISTEN IP has an unexpected number of octets assert all ip isnumeric for ip in self LISTEN IP split LISTEN IP is not a valid IP address assert all lt int ip lt for ip in self LISTEN IP split LISTEN IP is not a valid IP address Validate LISTEN PORT if isinstance self LISTEN PORT str assert self LISTEN PORT isnumeric LISTEN PORT must be a whole number self LISTEN PORT int C LISTEN PORT assert lt self LISTEN PORT lt LISTEN PORT is outside expected range C C and just as an example let s put a deliberate typo in our configuration file LISTEN IP x My fingers are fat LISTEN PORT Now have a couple of opportunities to validate our configuration For example at runtime user host python roll py Traceback most recent call last File roll py line in lt module gt from constfig import C Our constants config constfig File Users adrong PycharmProjects constfig constfig py line in lt module gt validate config File Users adrong PycharmProjects constfig constfig py line in validate config assert all a isnumeric for a in C LISTEN IP split LISTEN IP is not a valid IP address AssertionError LISTEN IP is not a valid IP address or run constfig py directly to validate your configuration in your test or deployment pipelines user host python constfig py Traceback most recent call last File constfig py line in lt module gt validate config File constfig py line in validate config assert all a isnumeric for a in C LISTEN IP split LISTEN IP is not a valid IP address AssertionError LISTEN IP is not a valid IP address Small but mightyThis is a relatively small amount of code that with some tweaks can source configuration from a database from environment variables from command line arguments and can have validation code that can reconcile configuration from any combination of those sources This pattern for handling configuration has enabled me to quickly create configuration handling in a standardized way across multiple tools that members of other teams have found approachable and easy to manage 2022-01-01 02:15:00
海外TECH Engadget Hyundai built an air purifier out of recycled Ioniq 5 EV parts https://www.engadget.com/hyundai-ioniq-5-ev-air-purifier-013047535.html?src=rss Hyundai built an air purifier out of recycled Ioniq EV partsEvery car is the result of a long development process in which automakers build many pre production vehicles that never see the light of day Rather than scrapping one of its Ioniq test vehicles entirely Hyundai repurposed the car s parts to make an air purifier According to a YouTube video description the model quot went through numerous tests to ensure our safety quot The video notes that over the course of a year the vehicle was used to test the likes of the Acoustic Vehicle Alerting System pass by noise regulation and wind tunnel noise The video shows Hyundai engineers stripping the Ioniq to its bones then designing a completely different product using the components Among other parts they used the cooling fan door panels LED tail lamp infotainment unit and of course the filter unit The engineers put a inch alloy wheel on the top of the case so the purifier is probably pretty large while the car s emblem adds some professional branding Although many car parts are already recyclable including batteries this is a neat experiment It suggests there are other sustainable ways to repurpose a car that s otherwise outlived its usefulness Meanwhile Hyundai started deliveries of the Ioniq in the US this month 2022-01-01 02:00:47
金融 ニュース - 保険市場TIMES 第一生命、日常的なコミュニケーションを実現するサイト「ミラシル」提供開始 https://www.hokende.com/news/blog/entry/2022/01/01/120000 第一生命、日常的なコミュニケーションを実現するサイト「ミラシル」提供開始月日月より提供開始第一生命保険株式会社以下、第一生命は、人と暮らしや健康、お金、保険などの情報コンテンツ発信などを行う情報サイト「ミラシル」の提供を、年月日月より開始した。 2022-01-01 12:00:00
ニュース BBC News - Home Betty White: Biden leads tributes for Golden Girls actress https://www.bbc.co.uk/news/world-us-canada-59843627?at_medium=RSS&at_campaign=KARANGA career 2022-01-01 02:09:02
京都 烏丸経済新聞 京都で初日の出 小雪舞う中新年を祝う http://karasuma.keizai.biz/headline/3648/ 初日の出 2022-01-01 11:31:02
北海道 北海道新聞 陸別で氷点下26・1度 JR運休 道内、暴風雪に注意 https://www.hokkaido-np.co.jp/article/629369/ 冬型の気圧配置 2022-01-01 11:06:21
北海道 北海道新聞 皇居・宮殿で新年祝賀の儀 愛子さま、成年皇族の初公務 https://www.hokkaido-np.co.jp/article/629373/ 三権の長 2022-01-01 11:06:00
北海道 北海道新聞 市民癒やす心のふるさと アルテピアッツァ美唄30周年 https://www.hokkaido-np.co.jp/article/629242/ 落合町栄町 2022-01-01 11:04:12

コメント

このブログの人気の投稿

投稿時間:2021-06-17 05:05:34 RSSフィード2021-06-17 05:00 分まとめ(1274件)

投稿時間:2021-06-20 02:06:12 RSSフィード2021-06-20 02:00 分まとめ(3871件)

投稿時間:2020-12-01 09:41:49 RSSフィード2020-12-01 09:00 分まとめ(69件)