投稿時間:2023-06-19 00:20:19 RSSフィード2023-06-19 00:00 分まとめ(23件)

カテゴリー等 サイト名等 記事タイトル・トレンドワード等 リンクURL 頻出ワード・要約等/検索ボリューム 登録日
TECH Techable(テッカブル) IoT開発運用SaaS「WIZIoT」と各社IoTデバイスが連携強化。遠隔監視環境をスピーディーに構築! https://techable.jp/archives/211767 株式会社ネクス 2023-06-18 14:30:48
python Pythonタグが付けられた新着投稿 - Qiita PDFをテキスト変換 https://qiita.com/LumSymph/items/9b55c775243f634494bf pythonllamaindex 2023-06-18 23:48:52
python Pythonタグが付けられた新着投稿 - Qiita 線形回帰① https://qiita.com/892noske/items/99a34a6dedb6d7ac2c94 tythetathetaxcdotsthetan 2023-06-18 23:28:38
python Pythonタグが付けられた新着投稿 - Qiita [備忘録] スマホだけでkaggleのタイタニック号生存者予測コンペやってみた https://qiita.com/yta-m/items/5c6140418b4c2d2c9314 chatgpt 2023-06-18 23:00:49
Docker dockerタグが付けられた新着投稿 - Qiita docker コマンドメモ https://qiita.com/qiita-oy/items/b6731244913d31505619 binbash 2023-06-18 23:21:16
Ruby Railsタグが付けられた新着投稿 - Qiita Railsアプリ作成からコントローラ作成まで https://qiita.com/yukisakakima/items/8a5f56d6717760c4ac66 rails 2023-06-18 23:48:55
Ruby Railsタグが付けられた新着投稿 - Qiita RSpecによるRailsテスト入門は、いい本でした! https://qiita.com/hiiragiya/items/b85cd782838e33150ba8 everydayrailsrspec 2023-06-18 23:17:10
海外TECH MakeUseOf How to Build a Web App With ChatGPT https://www.makeuseof.com/chatgpt-how-build-web-app/ queries 2023-06-18 14:31:19
海外TECH MakeUseOf How to Troubleshoot a Printer Connection in Windows https://www.makeuseof.com/troubleshoot-printer-connection-windows/ windows 2023-06-18 14:15:19
海外TECH MakeUseOf Mercedes-AMG One Hybrid Hypercar Is Packed With Formula 1-Inspired Technology https://www.makeuseof.com/mercedes-amg-one-f1-inspired-technologies/ Mercedes AMG One Hybrid Hypercar Is Packed With Formula Inspired TechnologyIf you want to experience similar feelings as Lewis Hamilton during an F race the AMG One allows you to do it in a road legal car 2023-06-18 14:10:20
海外TECH DEV Community How well should I know React before applying to my first job? https://dev.to/scastiel/how-well-should-i-know-react-before-applying-to-my-first-job-3dmm How well should I know React before applying to my first job A recurring question I hear from people learning React “how do I know if I m ready to apply to junior React developer jobs Very often they re ready before they know If you ve built a couple of applications using React your portfolio a side project… I bet you re ready If you haven t what not checking out my React workshop In this article I listed some things you don t have to know and some you do My goal is to prepare you to your first technical interview Let s start with what you think you might need to know but definitely don t You don t have to know everythingIt s okay not to know how React works internallyReact is complex and not many developers know how it works internally Although it s a fascinating topic don t feel you have to learn it unless you want to apply at Meta to work on React It s okay not to have dozens of projects with ReactShowing you worked on a couple projects is more than enough The more different they are the better especially if you re able to tell how they were different and how it made the challenges different too It s okay not to have built a huge project with ReactOf course if you worked on a big project it s an advantage But don t do it just to increase your chances at your first job interview it isn t worth it If you get the job you might work on a big project you ll tell about at the interview for your next job It s okay not to know how to bootstrap a complex React appDo you know how to bootstrap an app with the right npm or yarn command It s enough Actually looking for it in the documentation is enough Bootstraping an entreprise app is a useless skill as only one person will do it in any project and will probably forget about it before the next project It s okay not to know how to set up a deployment pipeline for ReactSetting up a deployment pipeline is not something expected from a junior developer Plus all applications are different and a pipeline at one company might differ from the one at another company It s okay not to know Redux Xstate Tailwind Next js…It may be seen as an advantage to have used an external library in a React project but there s a huge chance that the one you learned is not the one used where you re applying So don t overthink it too much It s okay to go find answers on the webSenior developers go find answers on Google StackOverflow or ChatGPT all the time No one will expect you to know how to build an application without using resources you can find on the web Alhought it s okay to go on the web to find some information example answers there are basics you should know very well before going to your first technical interview But there are some things you should knowKnow JavaScriptI know it isn t technically React but if you don t master JavaScript s basics during the interview it isn t a good start Know how to declare constants functions how to use the spread syntax to update arrays and objects or how to use promises…Know how to create a componentYou should know how to create a new component as a function with basic HTML content and display it in your browser Know how to display data conditionnaly and how to perform iterationsBe prepared to use the ternary operator to display data depending on a condition and to use map to display several elements from an array and don t forget to use the key prop Know how to add a local state to the componentuseState is the most useful hook and you should know how to use it how to declare a state how to update it how to deal with complex states such as arrays or objects…Know how to add some form inputs in itDealing with a text input is something you ll have to do in many apps Better be able to show you can do it without leaving your IDE Know how to update the state when the user types somethingDisplaying an input is nice but you should also know how to use the change event to update the state accordingly Know how to perform a fetch request when the component is loadedMaybe you won t have to use fetch but you should at least know how to call an async function in the component…well in a useEffect without forgetting to define the dependency array Know how to update the state depending on the fetch request resultStoring the result of an async request using a combination of useState and useEffect is a very common pattern If you show you can do it eyes closed the recruiter will be impressed Know how to extract some logic in another component passing propsComponents are at the core of React so you should know how to create a new component accepting props and use it in the one you already created Know what you don t knowEven if you don t know how to use them be able to mention the other hooks that exist and what they can be used for useReducer useRef…You can also read about server side rendering global state management libraries such as Redux…Do you feel more confident now Even if you don t know some of the points I mentioned you must admit it s not that much if you learned React already you shouldn t need too much time to learn what you re missing Also it s okay if you don t do perfectly well during the interview The most important is that you don t feel blocked If you do tell the interviewers and they ll unblock you Hopefully you feel more prepared now or at least you know what to prepare next If you need any help to get ready for your first or next job interview have a look at the mentoring services I m offering I can help by answering questions reviewing your portfolio and even make you pass a mock interview Cover photo by Lautaro Andreani 2023-06-18 14:53:06
海外TECH DEV Community Errors Received When Migrating Next.js 13 to New App Folder https://dev.to/perssondennis/errors-received-when-migrating-nextjs-13-to-new-app-folder-1of5 Errors Received When Migrating Next js to New App FolderNext js is evolving Fairly recently Next js has added a new powerful routing mechanism which is used but adding files to the a app folder instead of the old pages folder With new routing and new features like Server Components comes also new errors to detect This article will present solutions to four errors which are likely to happen the first hour of trying out the new Next js features In This ArticleExporting Async Server Component When Fetching DataServer Components Are Not the Same as Client ComponentsUsing Client Side Hooks in Server ComponentsInfinite Loading With Next js Development ServerShould You Use Next js Exporting Async Server Component When Fetching DataError MyComponent cannot be used as a JSX component Its return type Promise is not a valid JSX elementReason to error You are using an old version of TypeScriptSolution Bump TypeScript or suppress the error with ts expect errorNote This error is a TypeScript error Next js is TypeScript first which means you have to opt out of it if you don t want itTo fetch data in server components Next js recommends trying out their built in fetch API which is based on an RFC Their example code for that uses an async Page function The problem arise when trying to use an async component like that in another page component Doing that will result in a TypeScript error MyComponent cannot be used as a JSX component Its return type Promise lt Element gt is not a valid JSX element Type Promise lt Element gt is missing the following properties from type ReactElement lt any any gt type props keyThe error is thrown since the used TypeScript version doesn t recognize the async component The issue has been solved recently in TypeScript version but if you are bootstrapping templates or if you are checking out old git repositories you may have an outdated TypeScript version The solution is therefore to bump TypeScript version If that for some reason cannot be done you can suppress the warning with ts expect error which was the recommended solution from Next js before it was fixed in TypeScript export default function Home return lt main gt ts expect error Server Component lt MyComponent gt lt main gt How To Make a Hero Image in Next js Dennis Persson・Jul ・ min read react webdev nextjs css Server Components Are Not the Same as Client ComponentsError You re importing a component that needs useState It only works in a Client ComponentReason to error You are using client side only functionality in a Server ComponentSolution Add use client directive to convert the Server Component to a Client ComponentThe most fundamental part when upgrading to Next js is to understand Server Components and Client Components Traditionally in React and Single Page Applications SPA overall the application has been rendered on the client side in contrast to even more traditional websites that were rendered on the server In modern programming rendering is shared between the client and the server Next js gives you the full power to granularly fine tune where you want to render each of your component either on client or server dependent on your needs If you don t actively state that a Client Component should be a Client Component you will run into a ReactServerComponentsError error ReactServerComponentsError You re importing a component that needs useState It only works in a Client Component but none of its parents are marked with use client so they re Server Components by default path to file MyComponent ts import useState from react The error above will show up when you have a component or hook which uses some client side only functionality but which isn t explicitly declared with a use client directive import useState from react const MyComponent gt const value setValue useState Some code return lt div gt value lt div gt export default MyComponentTo fix the error simply add the use client directive at the top of the file use client import useState from react const MyComponent gt const value setValue useState Some code return lt div gt value lt div gt export default MyComponentBefore you convert your component to a Client Component take a minute to reflect over if you really need a Client Component or if you are better off with a Server Component I think Next js explains very well which one to use with a simple table A good rule of thumb only use a Client Component if you need browser functionality or keeping a stateIn short one can say components and hooks which uses useState useReducer and useEffect are client side components hooks Secondly components which relies on user interactions via the DOM tree are client side which means that DOM elements which have attached listeners like onClick and onChange belongs to Client Components A third case is also when the component or hook relies on a web API such as Geolocation API There exist a lot of Web APIs and they are often meant to run in a browser React Anti Patterns and Best Practices Do s and Don ts Dennis Persson・Feb ・ min read react javascript webdev programming Using Client Side Hooks in Server ComponentsError Attempted to call the default export of path to file file ts from the server but it s on the clientReason to error You are using client side functions in a Server ComponentSolution Convert the component to a Client Component or create a sub client component which uses the hookIn the previous header we learned briefly what Server Components and Client Components are and that we have to mark Client Components with the use client directive That error was then resolved by using the directive since Client Components can be used anywhere in Server Components However if the component you converted to a client component is a hook you may see another error as well Let s say we have this hook use client import useState from react const useSomeClientOnlyCode gt const value setValue useState Some code return value export default useSomeClientOnlyCodeThen we use it in a Server Component as follow import useSomeClientOnlyCode from hooks useSomeClientOnlyCode const MyServerComponent async gt const value useSomeClientOnlyCode return lt div gt value lt div gt If we run this code we will see an error like this Error Attempted to call the default export of path to file useSomeClientOnlyCode ts from the server but it s on the client It s not possible to invoke a client function from the server it can only be rendered as a Component or passed to props of a Client Component at Component app server components MyServerComponent tsx at stringify lt anonymous gt What is happening here is that the hook contains client side only code and is used in a Server Component Whilst Next js supports Client Components in Server Component they don t support client functions or hooks to be used in Server Components Hooks are essentially just a part of a component so if a hook uses client side logic then the whole component must be a client side Component as well The trivial way to solve this error is therefore to declare the component which uses the hook as a Client Component by using the use client directive use client import useSomeClientOnlyCode from hooks useSomeClientOnlyCode const MyServerComponent async gt const value useSomeClientOnlyCode return lt div gt value lt div gt If you don t want to convert your whole component to a Client Component you can always lift out the parts of the component which utilizes the hook into a child component and then make the child component a Client Component const MyServerComponent async gt return lt div gt lt MyClientComponentWhichUsesTheHook gt lt div gt Some other server rendered elements lt div gt lt div gt Infinite Loading With Next js Development ServerError Node js development server does not workReason to error Varies in my case I had an async Client ComponentSolution In this case remove the async keywordNext js introduces a new app folder which offers a new and improved way to perform routing I have been using Next js a long time with the old pages folder without any issues with the development server or build but as soon as I tried to use the new app folder I ran into severe problems The development server wasn t working What happened in detail was that the web page never finished loading Next js hot reloading didn t work and the page stopped responding Even when I stopped the development server it continued to serve a non working build on the port I read GitHub threads as Next js dev server gets stuck after a while requests just spin and browsed Stack Overflow for similar errors Nothing could fix my problem Changing ports didn t help and neither did upgrading or downgrading versions of node or packages Removing node modules next folder and package lock json or swapping to Turbopack did nothing good It was really frustrating to troubleshoot when Next js development server didn t work And when I finally found the solution the culprit wasn t more than five characters long You recognize that feeling don t you My mistake was a silly copy paste mistake after having tested out to use fetch in a Server Component Lesson learned there look out so you don t have any Client Components with the async keyword Only Server Components can be async in Next js If you find any async Client Component in your code remove the async keyword and start the development server again on another port with next dev p Should You Use Next js If you already are using Next js and are thinking if you should migrate to version I would say do it Next js is more or less backward compatible You can bump to and partly upgrade to use the new features according to your time and requirements See their migration guide here If starting a new project or migrating an existing one to version you should know that some of the features are still in beta The app folder routing which is discussed in this article is production ready since version If you are not using Next js at all try it out Remember that React itself is still just a library Next js is a complete framework based on React which have just made it all better I m here to extend you didn t sound as good Dennis PerssonFollow I m a former teacher writing articles about software development and everything around it My ambition is to provide people all around the world with free education and humorous reading 2023-06-18 14:46:19
海外TECH DEV Community Beginner's Guide to Node Mailer with Node.js https://dev.to/scofieldidehen/beginners-guide-to-node-mailer-with-nodejs-4a0d Beginner x s Guide to Node Mailer with Node jsSending emails is a fundamental part of many web applications and Node js provides a powerful solution This article will explore nodemailer a popular Node js library that simplifies sending emails from your applications Whether you re a beginner in web development or already familiar with Node js this guide will help you get started with nodemailer and provide answers to common questions Why Nodemailer is ImportantNodemailer is a widely used library in the Node js ecosystem due to its simplicity and versatility It allows developers to send emails effortlessly from their Node js applications making it an essential tool for user verification password resets notifications and more tasks Nodemailer offers a range of features including support for various email services attachments HTML content and error handling With its user friendly API nodemailer enables developers to integrate email functionality seamlessly into their projects Getting Started with NodemailerTo begin using nodemailer you must install it as a dependency in your Node js project Open your terminal and run the following command npm install nodemailerOnce nodemailer is installed you can start using it in your application Here s an example of a basic email sending script using nodemailer Require nodemailerconst nodemailer require nodemailer Create a transporter objectconst transporter nodemailer createTransport service gmail auth user your email com pass yourpassword Define email optionsconst mailOptions from Your Name amp lt your email com amp gt to recipient email com subject Subject Line text Plain text content html amp lt b amp gt HTML amp lt b amp gt content Send the emailtransporter sendMail mailOptions error info amp gt if error console log error else console log Email sent info response In the above code we first require nodemailer and create a transporter object specifying the email service and authentication details Then we define the email options including the sender recipient subject and content plain text and HTML Finally we use the transporter object s sendMail method to send the email handle any errors or log the successful response How to integrate Nodemailer with GmailIntegrating Nodemailer with Google requires configuring your Gmail account to allow access from the application Here s a step by step guide to help you integrate Nodemailer with Google Install NodemailerIf you haven t already install Nodemailer by running the following command in your project s terminal npm install nodemailerCreate a Gmail AccountIf you don t already have a Gmail account create one at This account will be used to send emails from your application Enable Less Secure AppsBy default Gmail blocks access from less secure apps to protect your account Since Nodemailer uses SMTP to send emails you need to enable access to less secure apps Follow these steps Go to your Google Account settings at Click on the Security tab on the left hand side Scroll down to the Less secure app access section Turn on the Allow less secure apps option Remember that this option makes your account more vulnerable to unauthorized access so use it only for development or trusted applications Generate an App PasswordTo authenticate your application with Gmail you must generate an App Password since Nodemailer does not support direct password based authentication Follow these steps to generate an App Password Go to your Google Account settings at Click on the Security tab on the left hand side Under the Signing in to Google section find the App Passwords option and click on it You may be prompted to enter your account password again for security purposes In the App Passwords section select the app you want to generate a password for choose Mail if available Select your device from the drop down menu Click on the Generate button Google will generate a unique app password Note this password as you will use it in your Node js application Set up Nodemailer in your applicationNow that your Gmail account is configured you can set up Nodemailer in your Node js application Here s an example of how to configure Nodemailer with your Gmail credentials const nodemailer require nodemailer const transporter nodemailer createTransport service gmail auth user your gmail com pass your app password Rest of the code for sending emails using NodemailerReplace your gmail com with your Gmail account email address and your app password with the App Password you generated in Step Send Test EmailYou can try sending a test email from your Node js application to test if the integration is working correctly Use the code snippet provided in the previous sections and customize the mailOptions object to include the recipient subject and email content const mailOptions from your gmail com to recipient example com subject Test Email text This is a test email sent from Nodemailer with Google integration transporter sendMail mailOptions error info amp gt if error console log error else console log Email sent info response Replace recipient example com with the email address where you want to receive the test email Run your Node js application and if everything is set up correctly you should see a success message indicating that the email has been sent Congratulations You have successfully integrated Nodemailer with Google Now you can use Nodemailer to send emails from your Node js application using your Gmail account Remember to handle errors and implement appropriate error handling and logging in your application to ensure reliable email delivery Additionally you can explore the various features of Nodemailer such as sending attachments HTML content and customizing email headers to enhance your email functionality Note In a production environment it s recommended to use a dedicated email service provider or SMTP relay service instead of enabling Allow less secure apps and using your personal Gmail account This provides better security and ensures that your emails are delivered reliably If you encounter any issues or have further questions refer to the Nodemailer documentation for detailed information on the library s capabilities and configuration options FAQ Frequently Asked Questions Can I use nodemailer with different email service providers Yes nodemailer supports various email service providers such as Gmail Outlook and Yahoo You can configure the transporter object with your desired email provider s appropriate service and authentication details How can I send email attachments using nodemailer Nodemailer allows you to include attachments in your emails You can add attachments by providing an array in the mailOptions object specifying the file path filename and content type Is it possible to send personalized emails to multiple recipients using nodemailer Absolutely Nodemailer provides flexibility in sending personalized emails to multiple recipients You can dynamically modify the to field in the mailOptions object for each email recipient How can I handle errors when sending emails with nodemailer The transporter sendMail method accepts a callback function where you can handle errors The error object will be passed to the callback function if an error occurs during the email sending process You can log the error details or implement appropriate error handling logic Can I send HTML content in my emails with nodemailer Yes nodemailer allows you to send HTML content in your emails in addition to plain text In the mailOptions object you can include an html property that contains your HTML content You can use HTML tags styling and embed images or links within your HTML email Nodemailer will send the email with the specified HTML content How can I handle email delivery status or track if the email was successfully sent Nodemailer provides information about the email delivery status through the info object returned in the callback function of transporter sendMail The info response property contains the response from the email service provider which typically includes information such as the unique message ID timestamp and other details You can use this information to track the status of your emails and log or handle it as needed Can I use nodemailer with frameworks like Express js or React js Yes nodemailer can be integrated with popular Node js frameworks like Express js or React js You can use nodemailer within your server side code e g Express js to handle email functionality like sending email confirmations or notifications In the case of React js you can use nodemailer on the server side to send emails based on form submissions or user actions Are any additional configuration steps required for using nodemailer with specific email services Certain email service providers may require additional configuration steps to work with nodemailer For example Gmail may require enabling Less Secure Apps or setting up an App Password to authenticate with nodemailer It s recommended to refer to the documentation of your chosen email service provider to ensure proper configuration Can nodemailer be used for sending bulk emails or newsletters A While Nodemailer can handle multiple emails it is primarily designed for transactional emails rather than bulk email sending or newsletters For sending bulk emails it s recommended to use specialized email marketing services that offer features like email list management personalization and analytics ConclusionNodemailer is a powerful and beginner friendly library for sending emails from Node js applications In this article we covered the basics of nodemailer including installation creating a transporter object specifying email options and sending emails We also addressed common questions about nodemailer s features handling errors sending HTML content and integrating with frameworks With nodemailer you have the flexibility to incorporate email functionality seamlessly into your Node js projects enabling you to send notifications user communications and more So go ahead harness the power of nodemailer and enhance your web applications with reliable and efficient email sending capabilities If you find this post exciting find more exciting posts like this on Learnhub Blog we write everything tech from Cloud computing to Frontend Dev Cybersecurity AI and Blockchain Resource How to send an email with NodeMailer Javascript Email Framework Node Documentation 2023-06-18 14:36:27
海外TECH DEV Community Lambda Extension with Golang https://dev.to/aws-builders/lambda-extension-with-golang-35a9 Lambda Extension with GolangFor full disclosure I ve been writing Lambda function code since and I completely breezed over the release of Lambda Extensions back in Here s the release announcement At the core of extensions you have internal and external options For the balance of this article I m going to focus on building a Lambda extension with Golang and lean into the external style approach Extensions and WhyTaking a quick step back why extensions From an architect level of thinking extensions give me the ability to have cross team reuse of code without being tied to a particular language or build process For something like Node or Python you could use a standard Layer to package your Lambda reuse But for something like Golang where your code is packaged at build time and not run time then you sort of have to look at the shared library I wrote about that here But what if you wanted to create some shared functionality that was usable regardless of which language you built your Lamabda in That seems to have some serious appeal for my current projects where teams are using different stacks to build their APIs due to need and comfort The other component when deciding to use extensions depends upon whether you d like to participate in the Lambda lifecycle events This diagram courtesy of the AWS Compute Blog shows what that looks like Journey through the Sample CodeWith the above stated I was working on something related to rewriting our platforms IAM and Permission evaluation platform As we started to get towards the end of the design phase I wanted to build some tools that helped the engineering team more easily take advantage of the new platform One of my favorite things is building when it helps others build faster I tend to like building for the builders vs building for a non technical customer but that s an article for another day I obviously can t share the private code that was worked on As I get more markers in production showing performance I m going to share the benefits of using Momento in front of DynamoDB I will surely touch upon some of the why though as we work through this So what I ended up doing is taking a small part of what I learned and packaging it up in a sample that we could walk through The premise of this sample is that I want to build a Lambda Extension with Golang that takes advantage of providing a consistent API for querying but the extension abstracts away the fact that a caching layer using Momento is in front of DynamoDB The architecture for this look like the below Building The Extension RegistrationAs I explained earlier up in the article this is going to demonstrate an external extension This means that I m going to need to leverage registering the extension with the Extension API Registering the Client looks like this func e Client Register ctx context Context filename string RegisterResponse error const action register url e baseURL action reqBody err json Marshal map string interface events EventType Invoke Shutdown if err nil return nil err httpReq err http NewRequestWithContext ctx POST url bytes NewBuffer reqBody if err nil return nil err httpReq Header Set extensionNameHeader filename httpRes err e httpClient Do httpReq if err nil return nil err if httpRes StatusCode return nil fmt Errorf request failed with status s httpRes Status defer httpRes Body Close body err ioutil ReadAll httpRes Body if err nil return nil err res RegisterResponse err json Unmarshal body amp res if err nil return nil err e extensionID httpRes Header Get extensionIdentiferHeader print e extensionID return amp res nil This should look familiar to this AWS Repository I m still personally exploring more of how I can customize and instrument some of this code but the extension is registered and ready for use by this function Defining the APINow think of the extension as a sidecar to your Lambda It s running in an external process but in the same shared space as your primary Lambda code This code is simply then exposed over an HTTP API of your choosing Pretty cool isn t it This again opens up the world for however you want to define your micro HTTP server For this use case I m going to use Chi Defining the route in this case will have a basic key definition func startHTTPServer port string config Config r chi NewRouter r Get key handleValue config logrus Infof Starting server on s port err http ListenAndServe fmt Sprintf s port r if err nil logrus WithFields logrus Fields err err Error error starting the server os Exit And since the main loop is waiting for Lambda events and not the Web Server I m going to fire this server off in a Go Channel I ll highlight the main loop here in a bit Start begins running the sidecarfunc Start port string config Config go startHTTPServer port config Implementing the Route HandlerThis implementation will be specific to Chi but again you could be coding this in anything you want and it could look like the mux of your choice I will advise you that keeping your layers small and efficient is something you should pay attention to You can t do much better than going with Golang for this choice but that s also my bias speaking func handleValue config Config http HandlerFunc return func w http ResponseWriter r http Request v chi URLParam r key m err config CacheRepository ReadCache r Context v if err nil http Error w err Error http StatusNotFound return if m nil logrus Debug Cache miss reading from table i err config DbRepository ReadItem r Context v if err nil i nil http Error w err Error http StatusNotFound return config CacheRepository WriteCache r Context i b json Marshal amp i w Write b else logrus Debug Cache hit returning from Momento b json Marshal amp m w Write b This is the meat of the extension Let s walk through what it does It accepts a route and fetches the id from the path Attempts to read the item by key from the Momento Cache If the item is found and marshaled it returns the item If the item is not found it then attempts to look up the item by key from DynamoDB If the item is found there it then writes that item into the Momento cache Then returns the item If the item wasn t found in the cache or the table it returns a not found errorThis a simple read through cache example but again shows the power of abstracting this away so any Lambda can take advantage of this very simple API Main Event LoopAs I mentioned the Web Server is launched in a Go Routine but the main event loop is waiting on events from the attached Lambda Invocation Execution Shutdown etcfunc main ctx cancel context WithCancel context Background other code omitted processEvents ctx func processEvents ctx context Context for select case lt ctx Done this lambda is done return default handle the next event err extensionClient NextEvent ctx if err nil logrus WithFields logrus Fields err err Error Error occurred Exiting the extension return It s a really basic loop But you could get more specific based on the type of event you are handling For me I don t care to handle specific events I just want this thing running beside my primary function ready to fetch some data Packaging and Publishing the ExtensionFor convenience I ve added a Makefile to the sample code but to highlight what all needs to happen When compiling you need to tell Golang the OS and Architecture that you are building for You want that to match the Lambda execution environmentGOOS linux GOARCH amdNext the runtime will look for extensions defined in the extensions directory I m not sure if you can change this almost positive you can t but I m all for conventions Finally push up the layer aws lambda publish layer version layer name lambda cache layer region us west zip file fileb extension zip Do make note of the LayerVersionArn that comes back when you run this command as it ll be needed when you attach the layer to your functions To tie it all together like I said here s the Makefilebuild cd src ext GOOS linux GOARCH amd go build o bin extensions lambda cache layer main gopackage build cd src ext bin zip r extension zip extensions deploy build package cd src ext bin aws lambda publish layer version layer name lambda cache layer region us west zip file fileb extension zip profile dev Using The ExtensionNow that I ve built and deployed a Lambda Extension with Golang how do I use it in a Lambda of my choosing Remember how I mentioned the sidecar model To picture it I like to think of my Lambda having a buddy like this Including the Lambda as a LayerAs with all my articles I m going to build this infrastructure with CDKHere s the TypeScript code for bringing in the layer defining the Lambda and then granting access to the secret and table buildTopLevelResources scope Construct resource IResource table Table gt const layer LayerVersion fromLayerVersionArn scope CacheLayer arn aws lambda lt region gt lt account id gt layer lt extension name gt lt version gt const func new GoFunction scope SampleFunction entry path join dirname src sample functionName lambda extension cache sample timeout Duration seconds layers layer environment IS LOCAL false LOG LEVEL debug resource addMethod GET new LambdaIntegration func proxy true table grantReadData func const s Secret fromSecretNameV this Secrets lt momento api token gt s grantRead func I want to walk through a few sections of this I haven t shown code before in my articles with layers Below is how you define one in TypeScript for CDK You need to give it a name and specify the arn which includes Region AccountId Layer Name Version this part mattersconst layer LayerVersion fromLayerVersionArn scope CacheLayer arn aws lambda lt region gt lt account id gt layer lt extension name gt lt version gt The second part of this block is the granting of access to the AWS Secret that is storing my Momento Token For more on that process and my previous write up on using Momento with Golang here is an articleconst s Secret fromSecretNameV this Secrets lt momento api token gt s grantRead func Leveraging the Layer in CodeWhen building a Lambda Extension with Golang the final step of making good with the extension code is to execute it No surprise I m going to do that with another Golang function However here s the piece that I want you to take away about using extensions Your function code doesn t have to be in the same code as your layer My teams are currently writing Lambdas in Python Golang and Node But since this extension is running externally and is being accessed over an HTTP API it s reusable This to me is a big advantage Especially when you have code that say a platforms or architecture team could be working on that is dropped into your feature teams type Model struct Id string json id FieldOne string json fieldOne FieldTwo string json fieldTwo func getModel id string Model error request http NewRequest GET fmt Sprintf http localhost s id nil c amp http Client request Header Set Content Type application json charset UTF response error c Do request if error nil return nil error defer response Body Close if response StatusCode logrus Debug Item not found by key return nil nil resBody ioutil ReadAll response Body var model Model err json Unmarshal resBody amp model return amp model err Not a whole lot going on with this code It requests the extension on localhost and fetches a model by the ID supplied This came from the API Request Path If found it Unmarshals the byte into the struct and returns it to the caller Again the reuse here is incredible as the code could be Node or Python or any other language you prefer Testing the ExtensionWhat would a walkthrough be without showing you how to execute the code So when building a Lambda Extension with Golang your primary handler can be anything you want The event source might be Kinesis SQS EventBridge or whatever In this case I m using API Gateway First let s put a record in the DynamoDB CacheSample table id fieldOne abc fieldTwo def Now let s make the API GET request via curl to run the API So if you remember our extension was a read through cache implementation The first time through it ll miss on the cache then read from DynamoDB and then write the cache into the store The second time through you ll get the hit and return First time Second time Amazing right Wrap up and conclusionsSo I want to touch upon a few things I love about this approach ReuseI ve mentioned this a few times but by building a Lambda Extension with Golang you gain reuse beyond just your language and framework of choice This is also true if you built a Lambda Extension with insert your language As an architect or a lead this is powerful Separation of concernsBy deploying certain concerns separately like this you can isolate them so that your code is doing one thing and doing that well Now of course if you don t need reuse then this just adds overhead So it s always a balance so treat that carefully CostThis one more pertains to caching and speed For this example I ve clocked things down to almost savings on compute when a cache hit occurs I m going to do some future performance write ups when I get more volume of the catalyst for this article in production So I m going from say ms down to ms This matters because honestly the user isn t going to notice this That s less than a blink of an eye But if I elevate my thinking up a level to say one of the AWS well architected pillars then I m thinking about cost And millions of executions with savings by using Momento well you do the math It s solid though trust me on that And lastly as always here is the GitHub Repository containing the working sample You can simply run through the steps above and you ll have a sample caching Lambda Extension built with Golang that you can start having fun with Hope this was helpful 2023-06-18 14:31:59
海外TECH DEV Community Your journey as a mid-level Ruby on Rails developer https://dev.to/rubycademy/your-journey-as-a-mid-level-ruby-on-rails-developer-49if Your journey as a mid level Ruby on Rails developerYou have been a Ruby on Rails developer for a couple of years You can finish a ticket from A to Z with a little technical help You want to strengthen your Ruby amp Rails knowledge and skills Get on board and let s sail beyond the horizon ️‍ ️ ️This little voiceYou have probably written enough lines of Ruby to feel that you are in your comfort zone That s great But this little voice makes you feel uncomfortable about your stagnation So you probably started to dedicate a part of your time to learning new things a little bit of StimulusJS a little bit of ActiveRecord etc You feel like you re not making significant progress No worries You are actually in the right mindset The only thing you need is guidance ️Your Treasure mapTo become a better Rubyist you must take a month or two to learn the main concepts of OOP in Ruby Here is an exhaustive list of concepts with resources Ruby Object ModelThe EigenclassPrivate amp protected message handlingWhat are modulesWhat are modules Part IIThe super keyword in RubyThe yield keyword in RubyAfter mastering these key concepts you ll surely be more confident about the code you write To go furtherYou can follow us on Twitter as we re very active on this platform Indeed we post elaborate code snippets every day Also we created RubyCademy Premium which is a weekly newsletter We deep dive into ADVANCED TOPICS with multiple CASE STUDIES and we answer all of your QUESTIONS Join us and get access to our exclusive content gt gt gt lt lt lt ️An Overview of the premium content ️ 2023-06-18 14:31:18
海外TECH DEV Community Codegarden 2023 https://dev.to/kevinjump/codegarden-2023-37km Codegarden I m Just back from Codegarden if you don t know plenty of people will tell you what that is For me its a place I struggled and failed to get to last year because the UK government wouldn t let me leave the country delayed passport So much so that I had to give a talk last year remotely package development fun and profit Giving a talk at a conference is scary great For one once you have given a talk people will already know who you are and you get a free conversation started to ease awkward situations but the pre talk stress does eat in to your enjoyment of the rest of the event so this time I had chance to enjoy the whole event stress free I went to a wide variety of talks and as always is the ones you least expect that give you the new insight or way of thinking The talks I went to could probably be put into three groups Current AKA you can do it now stuff Just Say No To Rebuilds The Strangler Fig Pattern Adam PrendergastPritesh TailorThe Death of Web Config Navigating the New Landscape of ASP NET Mathew HartMigrating from HTTPHandlers and Modules to Middleware Poornima NayarFinding Contentment Lee KelleherUpgrading Umbraco from to and everything in between Lennard FonteijnFor me the talks that covered current e g not the new backoffice things seemed to have a theme Migrations Now that might be because i see these things through the lense of my own code uSync Migrations but they made me have thoughts The talks on the Strangled Fig bit by bit migration web config replacement and Middleware had my head spinning with package ideas about how we could have some sort of migration dashboard that lets you define which bits of your site are in v and which have made it over to v Lee s talk on contentment just confirmed its not worth me doing any customization work on properties in the Backoffice because Lee has probably already done it with Contentment Future AKA The New Backoffice Exploring the new Backoffice Jacob OvergaardWeb components in Umbraco crash course advanced Julia GruszczynskaThe Backender s Guide Vite UUI and everything Callum WhyteFuture of property editors A Collaborative discussion Niels Lyngsøand Jacob OvergaardThere was a lot of chat and talks around the new Backoffice and I personally can t wait to get home and write a dashboard with an incremental counter on it because that was demoed a lot In all seriousness the people giving talks did a great job at demystifying web components and how we will all be able to work with the new Backoffice Both Jacob and Julia s talks gave me a real insight into how Web components will actually work and Callum helped close the gaps on how we might actually start to build packages with the new tech but one of the most valuable sessions for me was the CMS backstage collaborative discussion around property editors There Niels Lyngsø and Jacob Overgaard went over how you might build a property editor But more importantly they took questions about the whole process and integrations I may have asked quite a few questions but their answers and willingness to dive into any bit of the code to show us examples really helped me understand and begin to work out how things might actually work Despite the alpha release there are still some rough edges that probably need to be ironed out before anything to technical can be achieved by package developers How we will do custom Backoffice to front office communication isn t fully clear and I have been hanging out for localization mainly as a marker to me that its probably ready enough to commit some serious time to but see below for more ThinkingThe compassionate developer in open source Laura Weatherhead World s Best Kept Secret Going from Dungeons amp Dragons to Fortune Elise BentleyThey are not everyone s cup of tea but I like a good thinking talk and there a couple I missed that I wish I had seen Laura s talk gave a great overview of how different people s personalities and skills contribute to the world of open source and left me wondering if i need to be a bigger spanner in the world of Umbraco in this sense that s a good thing not a spanner in the works The talk by Elise from TinyMCE was the last talk I could attend before I had to leave for home and it really sealed the deal on an amazing Codegarden for me TinyMCE are a successful global company build on the foundation of an open source editor that was first build for a specific thing dungeons and dragons forums and has since become used well everywhere Now they have a core open source tool with paid for add ons and its proving they can run a successful company that way Their open source core model resonated with me because that is so how we operate with uSync a core free model with value added extra coolness in the paid product uSync Complete The talk left me buzzing with some validation that what we are doing is OK and does make sense and ideas especially on how we can close the feedback loop with uSync and complete I expect we will be doing some outreach very soon to see if we can help people who can help us to see where we can improve people s pain points and make it all even more awesomerrer The post conference conference workshop the SAS lounge at Copenhagen Airport Firstly many many shoutouts to Jacob Overgaard who told us the secret that is the SAS lounge surprisingly cheap if you are already flying with SAS and really much much better than hanging around it the main airport paying for food and drinks Both Marc Goodson and Myself had a wonderful chat with Jacob while we waited for our flights about all sorts of things from Umbraco cloud to heated butter dishes I mean of course But then Jacob gets out his laptop and we well mostly him started tackling the problem of localization in the new Backoffice Jacob had lots of ideas and before long he was coding away on possible solutions while we quaffed the free coffee and fishcakes I felt a little guilty that I might have nerd sniped him into this but he seemed really happy Even when we had to leave him coding away as our flight was called All in all I am so fortunate that part of what I call my job involves spending time with some many friendly and clever people who like to spend time at the conference that is code garden Not so stress free There have been a number of posts since Codegarden from people describing just how hard it can be to attend a conference like Codegarden when you are alone And it is really hard I had those times throughout codegarden when I was floating around to afraid to approach anyone or start a conversation and its scary hard and well scary I have in the past walked out of conferences in fear of talking to people before now I am so lucky that something like uSync makes for an ice breaker for so many people What I can say is I have never had anyone at Codegarden or any Umbraco event turn me away and some of the best friends I now have I have met at Codegarden Umbraco events over the years So the scary can be worth it If you see me at a Conference please do come and talk to me I like cycling butter dish warming solutions code and have far to much knowledge about localized advertising in Odense but I am also interesting in almost anything like did you notice how sharp the corners of the badges where this year 2023-06-18 14:25:27
海外TECH DEV Community How to prepare test data via openAI API in Postman https://dev.to/n_demia/how-to-prepare-test-data-via-openai-api-in-postman-5con How to prepare test data via openAI API in PostmanHow to generate diverse test data And what if you need a realistic dataset for a product demonstration Test data generation can be a challenging task However with the advent of AI it has become much easier This article demonstrates how to generate test data using the OpenAI API in Postman and automatically send it to your server But let s start with an introduction If we have an environment designed specifically for testing the data often consists of identical values with the word test It is quite difficult to navigate through such a set We can use random data generators but in this case we lose the relevance to the subject area of the tested product The realism of test data is especially important for a product demo Manual creation of test data is an option but if the schema of one data object is complex and a large number of objects are needed it becomes time consuming and impractical So how to generate realistic and diverse test data without high time costs To obtain such result AI generation can be used Let s assume we have a web application with a catalog of the most popular laptops And in our test environment the products themselves don t exist yet so we need to create them To do this we will use the public API which provides the ability to write our data via POST request in the following format name String data Object That is according to the API documentation the structure should contain a name and any data as an object Let s see how to create test data for our application in a few simple steps Step Determine test data object schemaLet each product in our application contain the following data name Apple MacBook Pro data year price currency USD CPU model Intel Core i Hard disk size TB So the schema of the items we should generate is the following name String data year Number price Number currency String CPU model String Hard disk size String Agreed manually creating a dozen different and realistic items for subsequent testing can be challenging This is where the OpenAI API comes to our aid Step Generate test data object via OpenAI APITo generate the items we need to send a request to the following endpoint which allows us to obtain a response for the given chat conversation Let s create a collection called Create Test Data and the first request called Generate Test Data We ll construct the request to the OpenAI API In the content field we specify what we want to receive from the model in response with the exact expected JSON structure defined on the Step The temperature parameter allows us to adjust the predictability of the model s responses Higher values like will make the output more random while lower values like will make it more focused and deterministic It accepts values from to If the API of your application can accept an array of products for creation you can add the n parameter which allows you to configure the number of responses Another way to generate a dataset is to change request on something like Generate array length of objects describing a laptop items using the following structure… The way to generate a set affects on how to extract the information for the next request Since our test API only accepts one object at a time we use the request for single object generation and do not pass the n parameter and by default it is set to To try the example you can import the following curl to your Postman workspace curl location header Content Type application json header Authorization Bearer OPENAI API KEY data model gpt turbo messages role user content Generate object describing a single laptop item using the following JSON structure name String data year Number price Number currency String CPU model String Hard disk size String temperature OPENAI API KEY is your authentication key Please visit your API Keys page to retrieve the API key you will use for your request You can play with the parameters to make the result suitable for your purposes See OpenAI API documentation for more information The response to our request will be in the following id chatcmpl SBrzphTMzpBVrLDtUknZyPQjez object chat completion created model gpt turbo usage prompt tokens completion tokens total tokens choices message role assistant content n name Dell Inspiron n data n year n price n currency USD n CPU model Intel Core i G n Hard disk size GB SSD n n finish reason stop index So in the content field we receive the test data that we wanted to generate realistic and matching our schema Now let s store them in a collection variable for subsequent sending in the body of the next request Step Store generated data as collection variableTo do this in the Test tab of Generate Test Data request we will write the following script var jsonData pm response json const item JSON parse jsonData choices message content pm collectionVariables set item item Now after sending the request the script will execute and store the received response in the collection variable named item The test data is ready and it s time to use them Step Send data to your serverLet s create another request in the collection called Send Data curl location header Content Type application json As the request body we will send the JSON that was saved in the collection variable The collection is ready To generate multiple products let s setup the configuration to run multiple iterations As a result our application now has various real test data Quickly and easily Please share in the comments how do you utilize the OpenAI API for testing purposes 2023-06-18 14:18:11
金融 ◇◇ 保険デイリーニュース ◇◇(損保担当者必携!) 保険デイリーニュース(06/19) http://www.yanaharu.com/ins/?p=5227 損害保険ジャパン 2023-06-18 15:00:06
金融 ニュース - 保険市場TIMES 明治安田生命「ふれあいコンサート2023」開催 https://www.hokende.com/news/blog/entry/2023/06/19/000000 明治安田生命「ふれあいコンサート」開催障がいのある子どもたちに「生の音楽」を明治安田生命保険相互会社以下、明治安田生命は、障がいのある子どもたちに「生の音楽」を届けることを目的とした「ふれあいコンサート」を開催すると月日に発表した。 2023-06-19 00:00:00
ニュース BBC News - Home Michael Gove would not vote for Johnson Partygate report https://www.bbc.co.uk/news/uk-politics-65942837?at_medium=RSS&at_campaign=KARANGA commons 2023-06-18 14:04:08
ニュース BBC News - Home Nottingham Open 2023 results: Katie Boulter beats Jodie Burrage to win first WTA title https://www.bbc.co.uk/sport/tennis/65943414?at_medium=RSS&at_campaign=KARANGA Nottingham Open results Katie Boulter beats Jodie Burrage to win first WTA titleKatie Boulter wins her first WTA title with a dominant victory in Nottingham over Jodie Burrage in the first all British tour level final in years 2023-06-18 14:32:52
ニュース BBC News - Home The Ashes 2023: Australia's Cameron Green removes England's Ben Duckett for 19 https://www.bbc.co.uk/sport/av/cricket/65943630?at_medium=RSS&at_campaign=KARANGA The Ashes Australia x s Cameron Green removes England x s Ben Duckett for Watch as Australia s Cameron Green takes an excellent catch to remove England s Ben Duckett on day three of the first Ashes Test 2023-06-18 14:53:56
ニュース BBC News - Home Ruben Neves: Wolves captain set to join Saudi Arabia's Al Hilal in £47m deal https://www.bbc.co.uk/sport/football/65945030?at_medium=RSS&at_campaign=KARANGA hilal 2023-06-18 14:07:53

コメント

このブログの人気の投稿

投稿時間: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件)