海外TECH |
MakeUseOf |
How Smartphones Steal Your Attention and How to Protect Your Mental Health |
https://www.makeuseof.com/how-smartphones-steal-attention-protect-mental-health/
|
How Smartphones Steal Your Attention and How to Protect Your Mental HealthSmartphones and mobile apps increasingly demand your attention Here s how they do it and tips to manage the attention you give to your devices |
2023-08-07 20:30:23 |
海外TECH |
MakeUseOf |
Do You Prefer Wired or Wireless Headphones More? [Poll] |
https://www.makeuseof.com/wired-or-wireless-headphones-poll/
|
headphones |
2023-08-07 20:26:25 |
海外TECH |
MakeUseOf |
How to Protect Your Project From GitHub RepoJacking |
https://www.makeuseof.com/protect-project-from-github-repojacking/
|
github |
2023-08-07 20:00:24 |
海外TECH |
DEV Community |
Build a Serverless Web Application with AWS Lambda, API Gateway,Amplify,DynamoDB and Cognito |
https://dev.to/subashkumar/build-a-serverless-web-application-with-aws-lambda-api-gatewayamplifydynamodb-and-cognito-1kd9
|
Build a Serverless Web Application with AWS Lambda API Gateway Amplify DynamoDB and Cognito Introduction Build a serverless web application to follow step by step instructions to create a simple serverless web application that enables users to request unicorn rides from the Wild Rydes fleet Prerequisites AWS accountArcGIS Account to add mapping to your appText editor VS CODE AWS Lambda AWS API Gateway AWS AmplifyAmazon DynamoDB Amazon Cognito Application Architecture Diagram The application architecture uses AWS Lambda Amazon API Gateway Amazon DynamoDB Amazon Cognito and AWS Amplify Console Amplify Console provides continuous deployment and hosting of the static web resources including HTML CSS JavaScript and image files which are loaded in the user s browser JavaScript executed in the browser sends and receives data from a public backend API built using Lambda and API Gateway Amazon Cognito provides user management and authentication functions to secure the backend API Finally DynamoDB provides a persistence layer where data can be stored by the API s Lambda function AWS Amplify You will configure AWS Amplify to host the static resources for your web application with continuous deployment built in The Amplify Console provides a git based workflow for continuous deployment and hosting of full stack web apps In subsequent modules you will add dynamic functionality to these pages using JavaScript to call remote RESTful APIs built with AWS Lambda and Amazon API Gateway Follow step by step to configure aws Go to AWS Console and Choose your aws region Create a Git repository using Codecommit free Tier or GitHub Open the AWS CodeCommit consoleNote I use AWS Codecommit and AWS cloudshell for terminalSelect Create Repository and set the repo name to wildrydes site Select CreateNow that the repository is created set up an IAM user with Git credentials in the IAM console following these instructions Recommended to use IAM user for this project Back in the CodeCommit console from the Clone URL dropdown select Clone HTTPSFrom a terminal window run git clone and the HTTPS URL of the repository git clone Enter username and password from Git credential HTTPS connections Link to Setup Step Note You appear to have cloned an empty repository Now we have created git repository and cloned empty repository locally Next we push the code to wildrydes site repo manually Change directory into your repository cd wildrydes sitecopy the static files from S aws s cp s wildrydes us east WebApplication StaticWebHosting website recursiveCommit the files to your Git service git add git commit m first git pushWe have pushed the code to AWS codecommit wildrydes site repository successfully Enable web Hosting with the AWS Amplify console Launch the Amplify Console console page and Click Get Started under Deploy with Amplify ConsoleGo to New App on the top right and choose Host Web App Select CodeCommit under Get started with Amplify HostingSelect the Repository service provider used today and select Next On the Configure build settings page leave all the defaults Select Allow AWS Amplify to automatically deploy all files hosted in your project root directory and select Next On the Review page select Save and deploy The process takes a couple of minutes for Amplify Console to create the necessary resources and to deploy your code Successfully Code Deployed User Management Amazon Cognito You will create an Amazon Cognito user pool to manage your users accounts You ll deploy pages that enable customers to register as a new user verify their email address and sign into the site When users visit your website they will first register a new user account For the purposes of this workshop we ll only require them to provide an email address and password to register However you can configure Amazon Cognito to require additional attributes in your own applications After users submit their registration Amazon Cognito will send a confirmation email with a verification code to the address they provided To confirm their account users will return to your site and enter their email address and the verification code they received You can also confirm user accounts using the Amazon Cognito console with a fake email addresses for testing After users have a confirmed account either using the email verification process or a manual confirmation through the console they will be able to sign in When users sign in they enter their username or email and password A JavaScript function then communicates with Amazon Cognito authenticates using the Secure Remote Password protocol SRP and receives back a set of JSON Web Tokens JWT The JWTs contain claims about the identity of the user and will be used in the next module to authenticate against the RESTful API you build with Amazon API Gateway Create An Amazon Cognito User Pool and Integrate an App to Your User Pool Amazon Cognito provides two different mechanisms for authenticating users Cognito User Pools to add sign up and sign in functionality to your application Choose Create user pool to authenticate users through social identity providers such as Facebook Twitter or Amazon with SAML identity solutions or by using your own identity system Note We use Cognito User Pools for this authentication Open Cognito from AWS search bar Choose Create user pool On the Configure sign in experience page in the Cognito user pool sign in options section select User name Keep the defaults for the other settings such as Provider types in the Authentication providers section Choose Next On the Configure security requirements page keep the Password policy mode as Cognito defaults You can choose to configure multi factor authentication MFA or choose No MFA and keep other configurations as default Choose Next On the Configure sign up experience page keep everything as default Choose Next On the Configure message delivery page for Email provider confirm that Send email with Amazon SES Recommended is selected In the FROM email address field select an email address that you have verified with Amazon SES following these instructions from the Amazon SES Developer Guide On the Integrate your app page provide a name for your user pool such as WildRydes Under Initial app client give the app client a name such as WildRydesWebApp and keep other settings as default On the Review and create page choose Create user pool Note Note the Pool ID and the App client ID on the Pool details page of your newly created user pool Update the Website Config The js config js file contains settings for the user pool ID app client ID and Region Update this file with the settings from the user pool and app you created in the previous steps and upload the file back to your bucketFrom your local machine open wildryde site js config js in a text editor of your choice Update the cognito section with the correct values for the user pool and app you just created You can find the value for userPoolId on the Pool details page of the Amazon Cognito console after you select the user pool that you created You can find the value for userPoolClientId by selecting App clients from the left navigation bar Use the value from the App client id field for the app you created in the previous section The value for region should be the AWS Region code where you created your user pool E g us east for the N Virginia Region or us west for the Oregon Region If you re not sure which code to use you can look at the Pool ARN value on the Pool details page The Region code is the part of the ARN immediately after arn aws cognito idp The updated config js file should look like this Note that the actual values for your file will be different window config cognito userPoolId us west uXboGpAb e g us east uXboGpAb userPoolClientId ddkmjvhfsfvruhpfinhv e g ddkmjvhfsfvruhpfinhv region us west e g us east api invokeUrl e g Save the modified file and push it to your Git repository to have it automatically deploy to Amplify Console git add git commit m new config git pushValidate your implementation Visit register html under your website domain or choose the Giddy Up button on the homepage of your site Complete the registration form and choose Let s Ryde You can use your own email or enter a fake email Make sure to choose a password that contains at least one upper case letter a number and a special character Don t forget the password you entered for later You should see an alert that confirms that your user has been created Confirm your new user using one of the two following methods If you used an email address you control you can complete the account verification process by visiting verify html under your website domain and entering the verification code that is emailed to you Please note the verification email may end up in your spam folder For real deployments we recommend configuring your user pool to use Amazon Simple Email Service to send emails from a domain you own If you used a dummy email address you must confirm the user manually through the Cognito console From the AWS console click Services then select Cognito under Security Identity amp Compliance Choose Manage your User PoolsSelect the WildRydes user pool and click Users and groups in the left navigation bar Choose Confirm user to finalize the account creation process After confirming the new user using either the verify html page or the Cognito console visit signin html and log in using the email address and password you entered during the registration step If successful you should be redirected to ride html You should see a notification that the API is not configured Serverless Service Backend You will use AWS Lambda and Amazon DynamoDB to build a backend process for handling requests for your web application The browser application that you deployed in the first module allows users to request that a unicorn be sent to a location of their choice To fulfill those requests the JavaScript running in the browser will need to invoke a service running in the cloud Create an Amazon DynaMoDB Table Use the Amazon DynamoDB console to create a new DynamoDB table Call your table Rides and give it a partition key called RideId with type String The table name and partition key are case sensitive Make sure you use the exact IDs provided Use the defaults for all other settings After you ve created the table note the ARN for use in the next step From the AWS Management Console choose Services then select DynamoDB under Databases Choose Create table Enter Rides for the Table name This field is case sensitive Enter RideId for the Partition key and select String for the key type This field is case sensitive Check the Use default settings box and choose Create Navigate to the Tables page in the DynamoDB console and wait for your table creation to complete Once it is completed select your table name Scroll to the bottom of the Overview section of your new table and choose Additional info Note the ARN You will use this in the next section Create an IAM Role for your Lambda Function From the AWS Management Console click on Services and then select IAM in the Security Identity amp Compliance section Select Roles in the left navigation pane and then choose Create Role Underneath Trusted Entity Type select AWS service For Use case select Lambda then choose Next Begin typing AWSLambdaBasicExecutionRole in the Filter text box and check the box next to that role Choose Next Step Enter WildRydesLambda for the Role Name Keep other parameters as default Choose Create Role Type WildRydesLambda into the filter box on the Roles page and choose the role you just created On the Permissions tab on the left under Add permissions choose Create Inline PolicySelect Choose a service Begin typing DynamoDB into the search box labeled Find a service and select DynamoDB when it appears Choose Select actions Begin typing PutItem into the search box labeled Filter actions and check the box next to PutItem when it appears Select the Resources section With the Specific option selected choose the Add ARN link in the table section Paste the ARN of the table you created in the previous section in the Specify ARN for table field and choose Add Choose Review Policy Enter DynamoDBWriteAccess for the policy name and choose Create policy Create a Lambda Function for Handling Requests AWS Lambda will run your code in response to events such as an HTTP request In this step you ll build the core function that will process API requests from the web application to dispatch a unicorn In the next module you ll use Amazon API Gateway to create a RESTful API that will expose an HTTP endpoint that can be invoked from your users browsers You ll then connect the Lambda function you create in this step to that API in order to create a fully functional backend for your web application Make sure to configure your function to use the WildRydesLambda IAM role you created in the previous section Choose Services then select Lambda in the Compute section Click Create function Keep the default Author from scratch card selected Enter RequestUnicorn in the Name field Select Node js x for the Runtime newer versions of Node js will not work in this tutorial Ensure Use an existing role is selected from the Change default execution role dropdown Select WildRydesLambda from the Existing Role dropdown Click on Create function Scroll down to the Code source section and replace the existing code in the index js code editor with this code const randomBytes require crypto const DynamoDBClient PutItemCommand require aws sdk client dynamodb const marshall require aws sdk util dynamodb const ddbClient new DynamoDBClient region us east Update with your desired regionconst fleet Name Bucephalus Color Golden Gender Male Name Shadowfax Color White Gender Male Name Rocinante Color Yellow Gender Female exports handler async event gt if event requestContext authorizer return errorResponse Authorization not configured event requestContext requestId const rideId toUrlString randomBytes console log Received event rideId event const username event requestContext authorizer claims cognito username const requestBody JSON parse event body const pickupLocation requestBody PickupLocation const unicorn findUnicorn pickupLocation try await recordRide rideId username unicorn return statusCode body JSON stringify RideId rideId Unicorn unicorn UnicornName unicorn Name Eta seconds Rider username headers Access Control Allow Origin catch err console error err return errorResponse err message event requestContext requestId function findUnicorn pickupLocation console log Finding unicorn for pickupLocation Latitude pickupLocation Longitude return fleet Math floor Math random fleet length async function recordRide rideId username unicorn const params TableName Rides Item marshall RideId rideId User username Unicorn unicorn UnicornName unicorn Name RequestTime new Date toISOString await ddbClient send new PutItemCommand params function toUrlString buffer return buffer toString base replace g replace g replace g function errorResponse errorMessage awsRequestId return statusCode body JSON stringify Error errorMessage Reference awsRequestId headers Access Control Allow Origin Choose Deploy Validate Your Implementation From the main edit screen for your function select Test and choose Configure test event from the dropdown Keep Create new event selected Enter TestRequestEvent in the Event name fieldCopy and paste the following test event into the editor path ride httpMethod POST headers Accept Authorization eyJraWQiOiJLTzRVMWZs content type application json charset UTF queryStringParameters null pathParameters null requestContext authorizer claims cognito username the username body PickupLocation Latitude Longitude Choose Save On the main function edit screen click Test with TestRequestEvent selected in the dropdown Scroll to the top of the page and expand the Details section of the Execution result section Verify that the execution succeeded and that the function result looks like the following statusCode body RideId SvLnijIAtginAFUBRT Fg Unicorn Name Rocinante Color Yellow Gender Female Eta seconds headers Access Control Allow Origin Deploy a Restful API you will use Amazon API Gateway to expose the Lambda function you built in the previous module as a RESTful API This API will be accessible on the public Internet It will be secured using the Amazon Cognito user pool you created in the previous module Using this configuration you will then turn your statically hosted website into a dynamic web application by adding client side JavaScript that makes AJAX calls to the exposed APIs Create a New REST API In the AWS Management Console click Services then select API Gateway under Application ServicesChoose Create API Underneath the Create new API section make sure New API is selected Select Build under REST API and enter WildRydes for the API Name Choose Edge optimized in the Endpoint Type dropdown Note Edge optimized are best for public services being accessed from the Internet Regional endpoints are typically used for APIs that are accessed primarily from within the same AWS Region Choose Create APICreate a New resource and method In the left nav click on Resources under your WildRydes API From the Actions dropdown select Create Resource Enter ride as the Resource Name d Ensure the Resource Path is set to ride e Select Enable API Gateway CORS for the resource f Click Create Resource g With the newly created ride resource selected from the Action dropdown select Create Method Select POST from the new dropdown that appears then click the checkmark Select Lambda Function for the integration type Check the box for Use Lambda Proxy integration Select the Region you are using for Lambda Region Enter the name of the function you created in the previous module RequestUnicorn for Lambda Function Choose Save Please note if you get an error that your function does not exist check that the region you selected matches the one you used in the previous module When prompted to give Amazon API Gateway permission to invoke your function choose OK Choose on the Method Request card Choose the pencil icon next to Authorization Select the WildRydes Cognito user pool authorizer from the drop down list and click the checkmark icon Deploy Your API From the Amazon API Gateway console choose Actions Deploy API You ll be prompted to create a new stage You can use prod for the stage name In the Actions drop down list select Deploy API Select New Stage in the Deployment stage drop down list Enter prod for the Stage Name Choose Deploy Note the Invoke URL You will use it in the next section Update the Website Config Update the js config js file in your website deployment to include the invoke URL of the stage you just created You should copy the invoke URL directly from the top of the stage editor page on the Amazon API Gateway console and paste it into the config api invokeUrl key of your sites js config js file Make sure when you update the config file it still contains the updates you made in the previous module for your Cognito user pool Open the config js file in a text editor Update the invokeUrl setting under the api key in the config js file Set the value to the Invoke URL for the deployment stage your created in the previous section window config cognito userPoolId us west uXboGpAb e g us east uXboGpAb userPoolClientId ddkmjvhfsfvruhpfinhv e g ddkmjvhfsfvruhpfinhv region us west e g us east api invokeUrl e g Save the modified file and push it to your Git repository to have it automatically deploy to Amplify Console git add git commit m new configuration git pushValidate your implementation Note It is possible that you will see a delay between updating the config js file in your S bucket and when the updated content is visible in your browser You should also ensure that you clear your browser cache before executing the following steps Update the ArcGIS JS version from to newer versions will not work in this tutorial in the ride html file as lt script src gt lt script gt lt link rel stylesheet href gt Save the modified file and push it to your Git repository to have it automatically deploy to Amplify Console Visit ride html under your website domain If you are redirected to the ArcGIS sign in page After the map has loaded click anywhere on the map to set a pickup location Choose Request Unicorn You should see a notification in the right sidebar that a unicorn is on its way and then see a unicorn icon fly to your pickup local Terminate Resources Delete your app in Amplify Delete your Amazon Cognito user poolDelete your Serverless backendDelete your Rest APIDelete your CloudWatch Log We have successfully Build a Serverless Web Application with AWS Lambda Amazon API Gateway AWS Amplify Amazon DynamoDB and Amazon Cognito Thank you for reading Follow and like this Post for more tech content |
2023-08-07 20:40:52 |
海外TECH |
DEV Community |
Choose a startup vs established company |
https://dev.to/adam_cyclones/choose-a-startup-vs-established-company-4c10
|
Choose a startup vs established companyI know somebody who has to choose between a startup or established company and they would be new to the role at that level The worry is the mentoring might not be available and the startup could chew them up This person is not afraid to hit the ground running however What can this person do to work out what is stable and what is not stable |
2023-08-07 20:32:15 |
海外TECH |
DEV Community |
ChatGPT Prompt Engineering for Developers |
https://dev.to/stefanalfbo/chatgpt-prompt-engineering-for-developers-169i
|
ChatGPT Prompt Engineering for DevelopersI have recently finished the ChatGPT Prompt Engineering for Developers a course made by DeepLearning AI This is one of their short courses that they offer for free The course has nine lessons where each lesson has a video about minutes and a supplementary Jupyter notebook Python to aid the learning of the current topic It s a great starting course if you want to know more about this topic The lessons are IntroductionIntroduces the course and is led by experts Isa Fulford and Andrew Ng The course will explore instruction tuned LLMs GuidelinesGoes through two key principles of prompting Key principles are clear instructions and giving the model time to think Each principle has some tactics that involve delimiters structured outputs checking conditions and few shot prompting There is also a section about hallucinations and how to reduce them IterativeWalks us through the iterative prompt development process SummarizingThis lesson demonstrates how to use ChatGPT for text summarization It covers summarizing reviews modifying prompts for specific purposes and extracting information Also it shows a workflow to summarize multiple reviews efficiently for better insights InferringShows how to inferring with ChatGPT where the model analyzes text to extract information like sentiment topics and emotions from reviews as an example TransformingHere we explores the capabilities transforming text Demonstrations of translation between languages conversion of tones and formats proofreading for grammar and spelling errors and generating compelling and formatted content using various prompts ExpandingThis lesson is the contrary to the Summarizing lesson Expanding involves generating longer text from shorter prompts It showcases personalized email generation leveraging sentiment analysis and customization It also introduces the parameter temperature of LLMs to control response variety ChatbotWalks through how to build a custom chatbot The OrderBot example demonstrates building a conversational pizza order assistant Shows that customization and persona building are possible by adjusting system messages and how to work with context ConclusionA summary of the complete course |
2023-08-07 20:27:58 |
海外TECH |
DEV Community |
SEO and Web Components - 2023 Edition |
https://dev.to/stuffbreaker/seo-and-web-components-2023-edition-3l6i
|
SEO and Web Components Editiontl dr Web components are SEO friendly I had read a number of articles that discussed SEO and web component compatibility and saw that many of them stated web components were not SEO friendly These articles were at least a few years old so I thought they were out of date but I didn t see anything recently that contradicted those articles So I decided to test some things out and see what the story was for myself Creating a Test SiteI created a simple web page with a static vanilla web component to test if search providers would render and index content in the shadow root The site can be viewed here and the source code can be viewed here Google TestGoogle commands the lion s share of search traffic so this seemed like a good place to start the test After creating my page and adding the property to my Google Search Console account I went to URL inspection and clicked on VIEW CRAWLED PAGE In the preview window I can see that the lt h gt and lt h gt tags in the shadow DOM were rendered and can be indexed by Google s web crawler Bing TestAlthough Bing is not the most popular search engine its index is used to power many other search engines including Yahoo DuckDuckGo Neeva and You com I added my page to the Bing Webmaster Tools and selected URL Inspection clicked the Live URL tab at the top of the page and clicked the View Tested Page Button When I look at the tested page s HTML I notice that none of my custom elements have rendered their shadow DOM contents and I am seeing error messages about missing H tags As a huge proponent of web components I was extremely concerned about these results so I reached out to some of my co workers on the Bing team to find out what was going on and figure out how we could fix this The good news is that after looking into it they told me the issue is a bug in the Bing Webmaster Tools and that the content does get rendered and indexed The great news was that they have prioritized the bug and are looking to have it resolved by the end of this month August ConclusionDo to a bug in some of the tools there have been some misconceptions about how compatible web components are for SEO Fortunately that should be resolved soon and teams can continue using web components know their content is searchable |
2023-08-07 20:21:21 |
海外TECH |
DEV Community |
What does it feel like when you’re alone in a crowd? |
https://dev.to/endgame/what-does-it-feel-like-when-youre-alone-in-a-crowd-1ge8
|
What does it feel like when you re alone in a crowd Photo from Unsplash by Daniel ThomasI started at a community college drawn into a computer science class based in C by an enthusiastic chemistry professor who also knew some basic to intermediate C The class was intense and interesting and after meandering through a series of courses in a half hearted attempt to prep for medical school and pivot from nursing I was left with a sense of pride once I finished the class I had a working project a now basic C program that calculated an integral and also performed a Riemann sum until the Riemann sum was within an error tolerance I was also left with a sense of being alone The class wasn t small and out of the people there I was one of only a few women there and the only Black woman However everyone in class was pleasant and cooperative and it was a great experience I didn t let that sense of feeling out of place stop me after graduating high school at and starting college at I was used to being out of place with my peers I spent a little time soul searching then quickly applied and was accepted into a OSU OSU was a different experience all together It took a long time to find other s like me even with the resources of slack and discord and group projects to this day I only know four other Black female software engineers and a handful of Black men from my school All of these I sought out myself and introduced myself and formed a sort of community I started to do more research and found the disheartening statistics of the field I read up on factors of why Black people aren t entering into CS degrees the difficulties in being hired and seen as competent I felt the impostor syndrome on a personal level I learned the history of black women in computing and felt and lived parts of the movie Hidden Figures in real life When I started interning I was faced with even more hurdles and triumphs than I had ever anticipated I was left with a feeling of exhaustion I joke with friends and family that the title of the book “Black Girls Must Die Exhausted by Jayne Allen sums up my life It wasn t the work it was the complex intersection of people and me It was the raised eyebrows the looks the comments the stares at my different hairstyles the feeling of needing to police my every breath so as to not cause anymore strain to those who were already offended or standoffish about me taking up space in a club I how somehow gotten admittance to I felt the words unsaid and said hang around my neck like a weight so heavy some days Slowly begrudgingly I gained respect and each day each new person was a new battle I was not presumed to have a level of competence when I walked in I learned to speak up for myself I learned to bite my tongue I learned to learn more I learned to know the answer before asking the question if possible I learned to hide my true feelings I ran in the cold every night after finishing up work each day at one internship F ice on the streets I ran letting the cold leech out the heat I felt at the day s events Letting the burn of my muscles sear away the anxiety and anger I felt Letting each puff of air I exhaled melt away the stress hour hours sometimes I went to bed too tired to feel ready for the next day even when I wasn t As someone of two minorities in computer science this is a question I have known the answer to since starting my journey The answer to this question has been felt in emotions stares comments and so much more throughout my education and blossoming professional career For some who read this post the topic I am about to discuss might seem like a downer or too heavy for blog I am writing But when asked to discuss my career and my experiences and my education I am drawn back to how the world see s me first I am not my skills first I am not my creativity I am not my drive or passion I am Black I am a woman Everything else comes second when the first two are known Black women make up around of computer science jobs Daley This statistic to some seems insignificant I am sure some of you reading this will roll your eyes and click away citing “woke agenda or not wanting to read something you have little interest in But for the rest of you here is how my journey has started in computer science and then I will tell you how I want it to end Why does all I have written above even matter It matters when you are in a class and it s a group of men and when during the course of casual conversation a student brings up faking sexual assault to get out of a class and makes it a joke It matters when you are interning at a company and you ask your boss the best way to stand out and without even knowing you he says “be nice with the passive aggressive tone you know to well reeking of the implied “Angry Black Woman stereotype you have to tone done your whole being to avoid even giving any credence too It matters when you are the only woman on a team time and time again and other engineers make comments like joking that only a “friend can touch your privates then laughing crassly after only just saying moments before “I know this isn t PC but I will say it anyway It matters when they don t care for your discomfort and only for their amusement It matters when every time you are hired you have to fight the side looks and side whispers that you are hired for your skin for DEI metrics for pictures It matters when you attend a new intern event filled with over a hundred people none of which look like yourself you walk into a room head held high as eyes turn and you are called to the front to show prominently for when there are photos and media taken It matters when you have to take almost a year off for recuperating and soul searching after a horrible internship experience you have to strongly about if you even want to continue in CS anymore And it matters when you choose to come back and to push on so that one day some girl who is maybe not even born will be the last person to experience the things you have Now you have the answer of how it feels to be alone in a crowd and not to just be part of the crowd “Do the best until you know better Then when you know better do better Maya AngelouDaley S March Women in tech statistics show the industry has a long way to go Built In Retrieved January from |
2023-08-07 20:12:10 |
海外TECH |
DEV Community |
Understanding Next.JS Docker Images |
https://dev.to/code42cate/understanding-nextjs-docker-images-2g08
|
Understanding Next JS Docker ImagesIf you ve tried to containerize a NextJS app you ve probably found the official documentation to be a bit lacking Especially for beginners the provided Dockerfile might be confusing In this post we ll go over the Dockerfile and explain what exactly is going on The DockerfileLet s start by looking at the Dockerfile provided by the wonderful NextJS team The Dockerfile can be broken down into parts the base image the dependency installation the build and the runtime The Base ImageThe first part and first line of the Dockerfile is the base image that the Docker Image is built on top of Similar to an operating system like Linux or Windows the base image provides the foundation and structure for the rest of the image In this case we use node alpine which is a small but powerful image that contains NodeJS The refers to the version of NodeJS If you want to use a different version you could replace the with a or Dependency InstallationAs always with Next JS projects we first need to install our dependencies This is done in the next block But before we install our dependencies we see the line RUN apk add no cache libc compatWhy is this line here Well the node alpine image is based on Alpine Linux which is a very small Linux distribution However it is so small that it doesn t have all the libraries that some NodeJS packages need The libc compat package provides some of these libraries reducing the chance of errors when installing dependencies This line isn t always needed but it s a good idea to include it just in case If you want a more in depth explanation of why this might be needed check out this Github Repo Now we can finally start working on our dependencies To keep everything neat and tidy we first create a new directory called app and set it as our working directory Then we copy over the package json package lock json yarn lock and pnpm lock yaml files Now you might be looking at your own Next JS app and only see one or two of these files That s okay The Dockerfile is designed to work with all three of the most popular NodeJS package managers npm yarn and pnpm Because this Dockerfile is designed to work with all three package managers the next part is also a bit more complicated RUN if f yarn lock then yarn frozen lockfile elif f package lock json then npm ci elif f pnpm lock yaml then yarn global add pnpm amp amp pnpm i frozen lockfile else echo Lockfile not found amp amp exit fiThis block of code checks which package manager you re using by checking which lockfile exists If you re using yarn it will run yarn frozen lockfile If you re using npm it will run npm ci If you re using pnpm it will run yarn global add pnpm amp amp pnpm i frozen lockfile If you re using something else it will print an error message and exit If you know which package manager you re using you can simplify this part of the Dockerfile For example if you re using npm you can remove the yarn lock and pnpm lock yaml files and replace the entire block with COPY package json package lock json RUN npm ciTry it out and see if it works If not feel free to write a comment below and I ll be happy to help you out The BuildThe next part of the Dockerfile contains the actual build process where we compile our NextJS app As before we first start a new image layer and set our working directory to app Then we copy over the node modules folder from our previous image layer After copying the node modules folder we copy over the rest of our app This is done in two steps to improve build times If we copied over the entire app first then every time we made a change to our app we would have to reinstall our dependencies By copying over the node modules folder first we can skip the dependency installation step if we haven t changed our dependencies Smart right Finally we run yarn build to execute the command that is defined in our package json file This command is usually next build but it can be changed to whatever you want It doesn t really matter if we use yarn or npm here because we already installed our dependencies in the previous step and the package manager doesn t really matter for the build process The RuntimeAnd finally we are done with installing our dependencies and building our app The last part of the Dockerfile is the runtime where we actually run our app This part is a bit longer so let s go through it step by step Again we start by creating a new image layer and setting our working directory to app We then set the NODE ENV environment variable to PRODUCTION This signals to NextJS that we are running in production mode which will improve performance This can also affect other parts of your app and NodeJS Check out this awesome documentation page for more information Next we create a new group and user This is done to improve security If we didn t do this our app would run as root which can be a security issue Generally you want to try to follow the Principle of least privilege which states that you should only give your app the permissions that it needs In this case our app doesn t need root permissions so we create a new user and group for it We then finally switch to this new user with USER nextjs Now we can finally copy over the build artifacts from the previous image layer We first copy over the public folder which includes all of our static assets Then we copy over the next standalone and next static folders which include all of our compiled code This step will only work if you set your output mode in your Next JS Config If you don t set your output mode your dependencies will not be included At this point we have improved security enabled production mode and copied over all the build artifacts The next lines are all about networking and making our Next JS app available to the the network We first expose port to the network with EXPOSE This doesn t actually do anything but it s a good practice to include it so that other developers know which port the Docker Container will be running on Next we set the PORT environment variable to This is used by NextJS to determine which port to run on Finally we set the HOST environment variable to localhost The last line is the actual command that is run when the Docker Container is started and is not executed during the image build process Since we compiled the Next JS app to a standalone file we can simply start it with node server js That s it We re done ConclusionThat was a long one good job I hope this post helped you understand the NextJS Dockerfile a bit better If you have any questions feel free to leave a comment below and I ll be happy to help you out If you have any suggestions for future posts I d love to hear them as well Thanks for reading Want to host your next cool dockerized Next JS project Check out Sliplane |
2023-08-07 20:07:24 |
海外TECH |
Engadget |
Scientists have reproduced last year's nuclear fusion breakthrough |
https://www.engadget.com/scientists-have-reproduced-last-years-nuclear-fusion-breakthrough-200611282.html?src=rss
|
Scientists have reproduced last year x s nuclear fusion breakthroughScientists at a federally funded research center in the US have successfully conducted a second nuclear fusion reaction experiment that resulted in a net energy gain The Lawrence Livermore National Laboratory LLNL said scientists at the National Ignition Facility NIF generated a higher energy yield than in their December breakthrough as Reuters reports The nuclear fusion approach is very similar to the process that results in stars being able to emit light and heat The scientists used a laser aimed at fuel to combine two light atoms into a denser one This releases a great deal of energy The process is said to have a lot of potential as a source of sustainable low carbon energy that could help combat climate change In the initial experiment in December the laser delivered megajoules to the target The scientists achieved fusion ignition by generating megajoules of energy output That s a net yield of around megajoules which is equivalent to kWh ーenough energy to power a watt LED TV for six hours It s not yet clear exactly how much of a net energy yield was obtained from the latest successful experiment which was carried out on July th An LLNL spokesperson told Reuters that researchers are still analyzing the final results There s quite some way to go until fusion ignition becomes a viable option for mainstream energy production with the capability of powering homes For one thing scientists will have to scale up the system substantially In any case showing that it was possible to repeat the experiment and surpass the previous results is a positive step forward for clean energy This article originally appeared on Engadget at |
2023-08-07 20:06:11 |
海外TECH |
CodeProject Latest Articles |
Cinchoo ETL - JSON Reader |
https://www.codeproject.com/Articles/5268371/Cinchoo-ETL-JSON-Reader
|
cinchoo |
2023-08-07 20:48:00 |
ニュース |
BBC News - Home |
Ukraine war: Five killed in Russian missile strike eastern Ukraine, officials say |
https://www.bbc.co.uk/news/world-europe-66429344?at_medium=RSS&at_campaign=KARANGA
|
building |
2023-08-07 20:05:43 |
ニュース |
BBC News - Home |
Andrew Malkinson: Greater Manchester Police criticised over trial evidence |
https://www.bbc.co.uk/news/uk-england-manchester-66428490?at_medium=RSS&at_campaign=KARANGA
|
conviction |
2023-08-07 20:06:31 |
ニュース |
BBC News - Home |
The Hundred 2023: Manchester Originals beat Birmingham Phoenix for first victory |
https://www.bbc.co.uk/sport/cricket/66434201?at_medium=RSS&at_campaign=KARANGA
|
The Hundred Manchester Originals beat Birmingham Phoenix for first victoryManchester Originals beat Birmingham Phoenix by runs at Emirates Old Trafford to secure their first victory of this year s Hundred |
2023-08-07 20:44:24 |
ビジネス |
ダイヤモンド・オンライン - 新着記事 |
老害リーダー続投で農家から「見放され」必至!JA共済連、全農、全中の保身丸出しトップ人事 - DOL特別レポート |
https://diamond.jp/articles/-/327326
|
|
2023-08-08 05:45:00 |
ビジネス |
ダイヤモンド・オンライン - 新着記事 |
韓国サムスン電子が営業利益95%減、日米欧の半導体「自国生産」回帰に取り残される恐れ - 今週のキーワード 真壁昭夫 |
https://diamond.jp/articles/-/327311
|
韓国サムスン電子が営業利益減、日米欧の半導体「自国生産」回帰に取り残される恐れ今週のキーワード真壁昭夫韓国サムスン電子の業績が悪化している。 |
2023-08-08 05:30:00 |
ビジネス |
ダイヤモンド・オンライン - 新着記事 |
【独占・衝撃告発】疑惑渦中の日本カストディ銀行田中前社長「土屋社長が全て知っている」の真意は? - DX利権 日本カストディ銀行の悪事 |
https://diamond.jp/articles/-/326791
|
田中嘉一 |
2023-08-08 05:25:00 |
ビジネス |
ダイヤモンド・オンライン - 新着記事 |
日本の出生率と女性人口の「西高東低」、少子化対策の鍵握る“女性に選ばれない”地域 - 政策・マーケットラボ |
https://diamond.jp/articles/-/327320
|
少子化対策 |
2023-08-08 05:20:00 |
ビジネス |
ダイヤモンド・オンライン - 新着記事 |
元東電エリートの新電力大手トップが不祥事とは別の文脈で「送配電事業の再編はあっていい」と語る理由 - エネルギー動乱 |
https://diamond.jp/articles/-/327319
|
最高経営責任者 |
2023-08-08 05:15:00 |
ビジネス |
ダイヤモンド・オンライン - 新着記事 |
エヌビディアをAI王者にした「キングメーカー」台湾クアンタ、20年の蜜月関係をひもとく - エヌビディア AI王者と台湾の黒子 |
https://diamond.jp/articles/-/327199
|
|
2023-08-08 05:10:00 |
ビジネス |
ダイヤモンド・オンライン - 新着記事 |
中国「反スパイ法改正」で“日本人の拘束リスク”は上昇必至…注意すべきことは? - 加藤嘉一「中国民主化研究」揺れる巨人は何処へ |
https://diamond.jp/articles/-/327318
|
加藤嘉一 |
2023-08-08 05:05:00 |
ビジネス |
電通報 | 広告業界動向とマーケティングのコラム・ニュース |
クロちゃん“なのに”本格的? Paravi「クロちゃんずラブ」に見るコンテンツ&プロモーションの秘訣 |
https://dentsu-ho.com/articles/8644
|
paravi |
2023-08-08 06:00:00 |
ビジネス |
東洋経済オンライン |
日野と三菱ふそう「経営統合」、2つの関門の越え方 M&A専門家に聞く、日野の法的リスクへの対処法 | 経営 | 東洋経済オンライン |
https://toyokeizai.net/articles/-/691478?utm_source=rss&utm_medium=http&utm_campaign=link_back
|
mampa |
2023-08-08 05:40:00 |
ビジネス |
東洋経済オンライン |
「蛍光ペンを引きまくる人」東大生語る大きな盲点 意外な使い方を紹介、ボールペンの活用法も | 生まれつきの才能は不要 東大「逆転合格」の作法 | 東洋経済オンライン |
https://toyokeizai.net/articles/-/692823?utm_source=rss&utm_medium=http&utm_campaign=link_back
|
東洋経済オンライン |
2023-08-08 05:30:00 |
ビジネス |
東洋経済オンライン |
伊藤忠がCTCに「3800億円の巨額投資」をする事情 アクセンチュア台頭でIT業界の競争環境が激変 | 卸売・物流・商社 | 東洋経済オンライン |
https://toyokeizai.net/articles/-/692943?utm_source=rss&utm_medium=http&utm_campaign=link_back
|
伊藤忠テクノソリューションズ |
2023-08-08 05:10:00 |
コメント
コメントを投稿