AWS |
lambdaタグが付けられた新着投稿 - Qiita |
[AWS SAM] Preflight(OPTIONS)をLambda関数で自作する(複数originの許可対応) |
https://qiita.com/sawa-akabee/items/126da675908f607bb1f7
|
AWSSAMPreflightOPTIONSをLambda関数で自作する複数originの許可対応この問題にぶつかるまでの経緯シンプルでないリクエストでPreflightリクエストが送られるが、そこで特定の種のoriginからのリクエストのみパスさせたい本番環境ではAccessControlAllowOriginはもちろんだめなのでしかし、AccessControlAllowOriginhttpshogecomhttpshugacomのような形式で複数のoriginを指定することはApiGatewayの仕様上できないらしいではどうするか次のように考えたPreflightリクエストはOPTIONSOPTIONSメソッドを自分で作ったLambda関数に統合して、定義したホワイトリストに合致するoriginからのリクエストだった場合パスさせるようにする対応方法まとめ複数originのCORS許可対応をさせたいメソッドについて下記手順内の例ではExampleFunctionというGETメソッドを指すレスポンスヘッダーのAccessControlAllowOriginは「」とし全てのoriginをパスさせるExampleFunctionと同一エンドポイントのOPTIONSメソッドを定義レスポンスヘッダーとして、リクエスト元のフロント側originをAccessControlAllowOriginにセットする処理とする手順普通のGETPOSTメソッドなどを作るのと同様にOPTIONSメソッドを作るローカルからLambdaに渡す環境変数としてoriginのホワイトリストを定義samconfigtomlはGit管理されていないものとしているdefaultdeployparametersparameteroverridesORIGINWHITELISTioniclocalhosthttplocalhostOPTIONSを作成samconfigtomlで設定したパラメータを環境変数として設定するParametersORIGINWHITELISTTypeStringGlobalsFunctionEnvironmentVariablesORIGINWHITELISTRefORIGINWHITELISTOPTIONSを定義するResourcesExampleFunctionTypeAWSServerlessFunctionPropertiesHandlerdisthandlersexampleexampleHandlerTypescriptをJavascriptにコンパイルしているのがdist配下。 |
2022-04-03 19:26:46 |
python |
Pythonタグが付けられた新着投稿 - Qiita |
Kaggleの臨床検査データセットを使ってみた② ~特徴選択をして、重要度を可視化してみた~ |
https://qiita.com/tuk19/items/dd759caded18d0aeeb20
|
Kaggleの臨床検査データセットを使ってみた②特徴選択をして、重要度を可視化してみた概要Kaggleの血液検査データセットを使ってデータ分析をしてみた。 |
2022-04-03 19:45:09 |
python |
Pythonタグが付けられた新着投稿 - Qiita |
【AtCoder解説】PythonでABC246のA,B,C,D,E,F問題を制する! |
https://qiita.com/u2dayo/items/4896cea07b59c707df3a
|
そこで、『aをある値に固定したとき、bをいくつにすればXがN以上で最小になるか』という問題をある程度高速に解くことができれば、この問題を解けます。 |
2022-04-03 19:33:47 |
python |
Pythonタグが付けられた新着投稿 - Qiita |
migemoをWindows + Pythonで楽に使う方法 |
https://qiita.com/cat2151/items/c02cb0139ac6abd39424
|
pipしていたところpipが動かなくなり調査したところ壊れていた→getpipで解決した→scriptに含めましたmigemodllをpythonexeのある場所やPATHの通った場所に配置しないと動かない→scriptに含めましたpythonexeのあるディレクトリに書き込み権限がないとmigemodllを配置できない→権限付与したプロパティセキュリティUsersアクセス許可フルコントロールを付与した→ここに書き残しておきますpythonexeがbit版のとき、migemodllをbit版にすると動かない→ひとまずscriptはbit版決め打ちにしています→ここに書き残しておきます誤ってmigemodictファイルだけ孤立して配置するとromahiradat等を配置しないとエラーなく期待値と異なる動作をしたhogeとしか表示されなかった。 |
2022-04-03 19:11:19 |
AWS |
AWSタグが付けられた新着投稿 - Qiita |
[AWS SAM] Preflight(OPTIONS)をLambda関数で自作する(複数originの許可対応) |
https://qiita.com/sawa-akabee/items/126da675908f607bb1f7
|
AWSSAMPreflightOPTIONSをLambda関数で自作する複数originの許可対応この問題にぶつかるまでの経緯シンプルでないリクエストでPreflightリクエストが送られるが、そこで特定の種のoriginからのリクエストのみパスさせたい本番環境ではAccessControlAllowOriginはもちろんだめなのでしかし、AccessControlAllowOriginhttpshogecomhttpshugacomのような形式で複数のoriginを指定することはApiGatewayの仕様上できないらしいではどうするか次のように考えたPreflightリクエストはOPTIONSOPTIONSメソッドを自分で作ったLambda関数に統合して、定義したホワイトリストに合致するoriginからのリクエストだった場合パスさせるようにする対応方法まとめ複数originのCORS許可対応をさせたいメソッドについて下記手順内の例ではExampleFunctionというGETメソッドを指すレスポンスヘッダーのAccessControlAllowOriginは「」とし全てのoriginをパスさせるExampleFunctionと同一エンドポイントのOPTIONSメソッドを定義レスポンスヘッダーとして、リクエスト元のフロント側originをAccessControlAllowOriginにセットする処理とする手順普通のGETPOSTメソッドなどを作るのと同様にOPTIONSメソッドを作るローカルからLambdaに渡す環境変数としてoriginのホワイトリストを定義samconfigtomlはGit管理されていないものとしているdefaultdeployparametersparameteroverridesORIGINWHITELISTioniclocalhosthttplocalhostOPTIONSを作成samconfigtomlで設定したパラメータを環境変数として設定するParametersORIGINWHITELISTTypeStringGlobalsFunctionEnvironmentVariablesORIGINWHITELISTRefORIGINWHITELISTOPTIONSを定義するResourcesExampleFunctionTypeAWSServerlessFunctionPropertiesHandlerdisthandlersexampleexampleHandlerTypescriptをJavascriptにコンパイルしているのがdist配下。 |
2022-04-03 19:26:46 |
Docker |
dockerタグが付けられた新着投稿 - Qiita |
docker で nginx + php-fpm の構成で UNIX ソケットで連携させる |
https://qiita.com/centipede/items/337f33f4608d4571b11a
|
参照phpDockerfileatadccbacdfbeaaeeee·dockerlibraryphp·GitHubteephpfpmddockerconfechoglobalechodaemonizenoechoechowwwecholistenteephpfpmdzzdockerconf参考DocumentationregardingconfigurationPHPの公式DockerイメージでUNIXソケット通信しようとして罠にハマるdockercomposeでunixソケットを使った、Nginx、phpfpmコンテナを作るでは、phpfpmをUNIXソケットでlistenさせるにはどうしたら良いのかというと、phpfpmの設定は、後から読み込まれる設定で上書きされる設定ファイルは、ファイル名の昇順で読み込まれるこの仕様を利用して、usrlocaletcphpfpmdzzdockerconfよりも後に設定ファイルを読み込ませて、TCPでlistenする設定を、UNIXソケットでlistenする設定で上書きすることが必要になる。 |
2022-04-03 19:20:39 |
Docker |
dockerタグが付けられた新着投稿 - Qiita |
【備忘録】DockerでのLaravel環境の構築 |
https://qiita.com/Baum-51/items/93bde663f101c148f914
|
後述するlaravelのenvファイルのホスト名がここで設定した名前になることから、コンテナのホストネームもcontainernameで設定した値になると思われます。 |
2022-04-03 19:06:33 |
海外TECH |
DEV Community |
All side optimized Next.js translations |
https://dev.to/adrai/all-side-optimized-nextjs-translations-4n9i
|
All side optimized Next js translationsWriting Next js code blurs the lines between client side and server side The code is written once and depending on your needs it is then executed as SSG static site generation SSR server side rendering or CSR client side rendering etc So also the internationalization right Let s take the example of next inext While next inext uses inext and react inext under the hood users of next inext simply need to include their translation content as JSON files and don t have to worry about much else By default there is one next inext configuration that loads the translations from the local directory structure and renders the pages on server side This is ok it works and is optimized for SEO etc but there is more we could do What if we could power up the seo optimized website with always up to date translations without the need to redeploy your app We will discuss different setups One with an active backend and another one completely statically generated The basic target is always the same We want everything to be SEO optimized in all languages and serve always the newest translations to our users Example with a backend server Having a backend server does not mean you are forced to run your own server It can also be a PaaS or serverless solution like Vercel or Netlify etc Ok let s start with the default You followed the normal next inext setup guide and now your translations are organised more or less as such └ーpublic └ーlocales ├ーen └ーcommon json └ーde └ーcommon jsonNow let s connect to an awesome translation management system and manage your translations outside of your code Let s synchronize the translation files with locize This can be done on demand or on the CI Server or before deploying the app What to do to reach this step in locize signup at and loginin locize create a new projectin locize add all your additional languages this can also be done via API install the locize cli npm i locize cli Use the locize cliUse the locize sync command to synchronize your local repository public locales with what is published on locize Alternatively you can also use the locize download command to always download the published locize translations to your local repository public locales before bundling your app But you were talking about having always up to date translations without the need to redeploy your app Yes let s adapt for that We will use the inext locize backend plugin but only on client side Together with some other inext dependencies inext locize backendinext chained backendinext localstorage backendnpm install inext locize backend inext chained backend inext localstorage backendAnd we adapt the next inext config js file next inext config jsconst LocizeBackend require inext locize backend cjs const ChainedBackend require inext chained backend defaultconst LocalStorageBackend require inext localstorage backend defaultconst isBrowser typeof window undefined module exports debug true in defaultLocale en locales en de it backend backendOptions expirationTime hour projectId dbcf ae adb ed version latest backends isBrowser LocalStorageBackend LocizeBackend serializeConfig false use isBrowser ChainedBackend And then remove the serverSideTranslation to getStaticProps or getServerSideProps depending on your case in the page level components Without the getStaticProps or getServerSideProps function the translsations are loaded via configured inext backend export const getStaticProps async locale gt return props await serverSideTranslations locale common footer That s it Let s check the result The HTML returned from the server looks correctly translated So this is well optimized for search engines And on client side the up to date translations are directly fetched from the locize CDN This means you can fix translations without having to change your code or redeploy your app The code can be found here Additional hint If you ve configured caching for your locize version you may not need the inext localstorage backend and inext chained backend plugin next inext config jsconst LocizeBackend require inext locize backend cjs const isBrowser typeof window undefined module exports debug true in defaultLocale en locales en de it backend isBrowser projectId dbcf ae adb ed version production undefined serializeConfig false use isBrowser LocizeBackend Static Website example With this example we just need a static webserver like GitHub Pages or similar It s pretty much the same as with above example but there are some little things we need to additionally consider To work with static site generation SSG we need to use the next export command but Error in support is not compatible with next export See here for more info on deploying This happens if you re using the internationalized routing feature and are trying to generate a static HTML export by executing next export Well this features requires a Node js server or dynamic logic that cannot be computed during the build process that s why it is unsupported There is a dedicated article with a solution to that Next js problem Follow that guide first Done so Then let s continue here It s the same next inext config js config like in the previous example next inext config jsconst LocizeBackend require inext locize backend cjs const ChainedBackend require inext chained backend defaultconst LocalStorageBackend require inext localstorage backend default If you ve configured caching for your locize version you may not need the inext localstorage backend and inext chained backend plugin const isBrowser typeof window undefined module exports debug true in defaultLocale en locales en de it backend backendOptions expirationTime hour projectId dbcf ae adb ed version latest backends isBrowser LocalStorageBackend LocizeBackend serializeConfig false use isBrowser ChainedBackend Extend the makeStaticProps function with options emptyInStoreStore export function makeStaticProps ns opt return async function getStaticProps ctx const props await getInProps ctx ns if opt emptyInStoreStore let the client fetch the translations props nextINext initialInStore null return props and use it accordingly const getStaticProps makeStaticProps common footer emptyInStoreStore true export getStaticPaths getStaticProps That s it Let s check the result The generated static HTML looks correctly translated So this is well optimized for search engines And on client side the up to date translations are directly fetched from the locize CDN This means you can fix translations without having to change your code or redeploy your app And without owning an active server The code can be found here Continuous LocalizationSince we re now connected to as smart translation management system we can try to make use of its full potential save missing translations I wish newly added keys in the code would automatically be saved to locize Your wish is my command Extend the next inext config with the locize api key and set saveMissing true next inext config jsconst LocizeBackend require inext locize backend cjs const isBrowser typeof window undefined module exports debug true in defaultLocale en locales en de backend projectId dbcf ae adb ed apiKey bbefa ffc f aaaf version latest serializeConfig false use isBrowser LocizeBackend saveMissing true do not set saveMissing to true for production and also not when using the chained backend Each time you ll use a new key it will be sent to locize i e lt div gt t new key this will be added automatically lt div gt will result in locize like this but there s more Thanks to the locize lastused plugin you ll be able to find and filter in locize which keys are used or not used anymore With the help of the locize plugin you ll be able to use your app within the locize InContext Editor Lastly with the help of the auto machinetranslation workflow and the use of the saveMissing functionality new keys not only gets added to locize automatically while developing the app but are also automatically translated into the target languages using machine translation Check out this video to see how the automatic machine translation workflow looks like npm install locize lastused locizeuse them like this next inext config jsconst LocizeBackend require inext locize backend cjs const isBrowser typeof window undefined const locizeOptions projectId dbcf ae adb ed apiKey bbefa ffc f aaaf version latest module exports debug true in defaultLocale en locales en de backend locizeOptions locizeLastUsed locizeOptions serializeConfig false use isBrowser LocizeBackend require locize locizePlugin require locize lastused cjs do not use locize lastused on production saveMissing true do not set saveMissing to true for production and also not when using the chained backend Automatic machine translation Last used translations filter InContext Editor Let s prepare for production Now we prepare the app for going to production First in locize create a dedicated version for production Do not enable auto publish for that version but publish manually or via API or via CLI Lastly enable Cache Control max age for that production version Let s adapt the next inext config js file once again next inext config jsconst LocizeBackend require inext locize backend cjs const isBrowser typeof window undefined const locizeOptions projectId dbcf ae adb ed apiKey bbefa ffc f aaaf version latest module exports debug true in defaultLocale en locales en de backend locizeOptions locizeLastUsed locizeOptions serializeConfig false use isBrowser LocizeBackend require locize locizePlugin require locize lastused cjs do not use locize lastused on production saveMissing true do not set saveMissing to true for production and also not when using the chained backend Now during development you ll continue to save missing keys and to make use of lastused feature gt npm run devAnd in production environment saveMissing and lastused are disabled gt npm run build amp amp npm startCaching Merging versions The complete code can be found here Check also the code integration part in this YouTube video Congratulations Awesome Thanks to next inext inext react inext and locize your continuous localization workflow is ready to go So if you want to take your in topic to the next level it s worth to try the localization management platform locize The founders of locize are also the creators of inext So with using locize you directly support the future of inext |
2022-04-03 10:42:07 |
海外TECH |
DEV Community |
Mantis React - Open-Source M-UI Template |
https://dev.to/sm0ke/mantis-react-open-source-m-ui-template-50b4
|
Mantis React Open Source M UI TemplateHello Coders This article presents an open source React Dashboard Template crafted and released for free by CodedThemes Mantis React can be downloaded from Github MIT License and used for commercial products or eLearning activities For newcomers React is a leading JS library used to code interactive user interfaces actively supported and versioned by Facebook Thanks for reading Content provided by Admin DashboardsReact Mantis Dashboard LIVE demoReact Mantis Dashboard source code MIT License Mantis is a free and open source React Redux dashboard template made using the MUI React component library with aim of flexibility and better customizability Mantis Logo inspired from the Insect name Mantises as They have Triangular heads with Flexible Necks Also the Name is derived from two popular UI frameworks Material UI and Ant Design M Ant is Product FeaturesProfessional User Interface MUI Material UI React components Fully Responsive all modern browsers support Easy to use code structureFlexible amp High Performance codeEasy Documentation GuideSample Pages If you want to get inspiration or just show something directly to your clients you can jump start your development with our pre built example pages Thanks for reading For more resources feel free to access More Free Dashboards crafted in Django Flask and ReactMore Admin Dashboards a huge index with products |
2022-04-03 10:41:23 |
海外TECH |
DEV Community |
Hackathon submission - Interactive conversation scripts for language learning |
https://dev.to/miguelmj/hackathon-submission-interactive-conversation-scripts-for-language-learning-110c
|
Hackathon submission Interactive conversation scripts for language learning Overview of My SubmissionMy second submission consists on a tool designed for languages teachers and students Audios with recorded conversations are a common and good resource in language lessons so I thought it would be useful not only to have a transcription to read while you listen but also make them interactive to show phrase by phrase translations and to quickly navigate the audio to listen again certain part of the conversation Cover image by Julia Filirovska from Pexels Submission CategoryAccessibility AdvocatesWacky Wildcards Link to Code on GitHub MiguelMJ Scripter Create interactive scripts from recordings for language learning Deepgram DEV hackathon submission ScripterCreate interactive scripts from recordings for language learning Create interactive HTML pages with a script from a recorded conversation Powered by Deepgram Requires API key from Deepgram Submission for Deepgram DEV hackathon Yout might want to read the submission post where you will also find a demo Get the API keyDeepgram required Create an account in deepgram com and get an API key Store it in a file named deepgramApiKey in the root folder or pass it directly in the CLI using the deepgram api key argument FeaturesTune the voice recognition process with the Deepgram query parameters for transcriptions pre recorded audio with P param KEY VALUE arguments Downloads and results are cached to reduce redundant traffic but you can force it using the F force flag or directly removing the cache folder All log information outputs through stderr and the search output through stdout or a file with the o output file FILE… View on GitHub Additional Resources InfoThis time I reused most of the code from my previous submission In that one I forgot to tell a bit of background so as most of the code is the same I will do it here In spite of using Python for the program I didn t want to use the Deepgram SDK I know other participants have done the same in my case it s just because I m used to making HTTP requests for lots of things so I chose not to add more dependencies to the application I felt that the Deepgram API is accesible enough for me I ve once more used another API LibreTranslate This time the difference is that LibreTranslate is a open source API so there are different available mirrors and you can even set up one yourself so I allowed the user to specify which one to use with a H host parameter and made a quick guide on it on the README I m not actually a webdev person so the resultant HTML file might not be very polished but I thought is more than enough for a prototype I learned to use the lt audio gt element of HTML and manipulate it via JS which is nice Thanks to it and the rich information returned by the Deepgram API the interactive scripts have the following features The audio is embedded in the HTML file so it can be played directly from there as long as the path of the source audio doesn t change Each sentence of the audio is printed in a different color according to who is the speaker If you hover over a sentence the translation to your language if supported appears If you click on a sentence the audio plays only the sentence you clicked on making it more easy to replay specific parts of the audio Here s a little demonstration on this features I recorded a short sample conversation with my sister who also provided the voice recorder Some notes The translation on hover is not immediate because it uses the title HTML attribute that has a little delay If you speak Spanish or have a good ear you ll notice that for the th intervention it doesn t notice that it s a question so both the transcription and the translation are wrong That s what happens with automation In any case I think it s neat and even those little mistakes made by the audio recognition and translation can be manually fixed by the teacher and most of the work would be automatic Possible future improvementsAllow usage of output templates Add some tool for easy manual fixes Enable more flexibility on the options to use different services if the user wants to I hope you like it And if you are a language teacher or student feel free to use it and please give me some feedback |
2022-04-03 10:35:18 |
ニュース |
BBC News - Home |
Prince Andrew returned from Falklands War 'a changed man', he says in deleted post |
https://www.bbc.co.uk/news/uk-60971910?at_medium=RSS&at_campaign=KARANGA
|
instagram |
2022-04-03 10:39:50 |
ニュース |
BBC News - Home |
Pakistan heads for early election amid move to remove PM Imran Khan |
https://www.bbc.co.uk/news/world-asia-60972186?at_medium=RSS&at_campaign=KARANGA
|
decisions |
2022-04-03 10:46:42 |
北海道 |
北海道新聞 |
JR朝里―銭函間でレール脇に岩 4本運休 |
https://www.hokkaido-np.co.jp/article/664970/
|
運休 |
2022-04-03 19:34:00 |
北海道 |
北海道新聞 |
闘病中の宮川花子さんが出演 吉本110周年特別公演 |
https://www.hokkaido-np.co.jp/article/664962/
|
多発性骨髄腫 |
2022-04-03 19:18:53 |
北海道 |
北海道新聞 |
北海道をサツマイモ産地に 東京青果、真狩のベジタブルワークスと輸出へ |
https://www.hokkaido-np.co.jp/article/664942/
|
東京青果 |
2022-04-03 19:33:07 |
北海道 |
北海道新聞 |
カズ「日本全体で楽しみ増えた」 W杯の組み合わせに |
https://www.hokkaido-np.co.jp/article/664969/
|
日本フットボールリーグ |
2022-04-03 19:33:00 |
北海道 |
北海道新聞 |
米側「記者に武器向けず」 松野氏、沖縄の銃口報道巡り |
https://www.hokkaido-np.co.jp/article/664959/
|
官房長官 |
2022-04-03 19:20:17 |
北海道 |
北海道新聞 |
韓国首相に韓悳洙氏を指名 尹氏、経済通の元駐米大使 |
https://www.hokkaido-np.co.jp/article/664965/
|
首相候補 |
2022-04-03 19:18:00 |
北海道 |
北海道新聞 |
松野氏、沖縄振興アピール 知事選見据え、てこ入れ |
https://www.hokkaido-np.co.jp/article/664964/
|
名護市役所 |
2022-04-03 19:18:00 |
コメント
コメントを投稿