投稿時間:2023-02-16 00:28:29 RSSフィード2023-02-16 00:00 分まとめ(32件)

カテゴリー等 サイト名等 記事タイトル・トレンドワード等 リンクURL 頻出ワード・要約等/検索ボリューム 登録日
IT ITmedia 総合記事一覧 [ITmedia ビジネスオンライン] カルビー、「絶品かっぱえびせん 石垣の塩と炙り明太子」復活 「酒のつまみ需要」に応える https://www.itmedia.co.jp/business/articles/2302/13/news134.html itmedia 2023-02-15 23:13:00
python Pythonタグが付けられた新着投稿 - Qiita Lappinna技術部始動! https://qiita.com/Lapinna/items/74716e572359993147f0 深い意味 2023-02-15 23:31:41
js JavaScriptタグが付けられた新着投稿 - Qiita Lappinna技術部始動! https://qiita.com/Lapinna/items/74716e572359993147f0 深い意味 2023-02-15 23:31:41
AWS AWSタグが付けられた新着投稿 - Qiita AWS IAM関連リソースをCLIでつくってみた。 https://qiita.com/Fromi_Frog/items/0b11e2c34a0fe9318b4e awsclicommandreference 2023-02-15 23:26:11
Docker dockerタグが付けられた新着投稿 - Qiita 【Nginx】Dockerの公式イメージを使用する際にはCMDに注意が必要 https://qiita.com/P-man_Brown/items/9ef35c347c9d858acdbb dockerentrypoints 2023-02-15 23:55:21
Docker dockerタグが付けられた新着投稿 - Qiita Docker環境でPHPのエラーログを出力する https://qiita.com/epirock/items/56324203355382b63f0e gtfgt 2023-02-15 23:04:39
golang Goタグが付けられた新着投稿 - Qiita Golangでdlvが動作してない件(ブレイクポイントで止まらない件)(忘備録) https://qiita.com/wk0012345/items/312303e920ed63e3fb8d godelve 2023-02-15 23:05:46
GCP gcpタグが付けられた新着投稿 - Qiita GCP PCS合格記(2023/2/15投稿) https://qiita.com/handy-dd18/items/3fa22b081ed5685c1679 cloud 2023-02-15 23:38:13
技術ブログ Developers.IO flutter_nearby_connectionsによるP2P通信をiOS Simulatorのデバイス間で試してみた https://dev.classmethod.jp/articles/flutter-nearby-connections-ios-simulator/ delivery 2023-02-15 14:45:50
海外TECH MakeUseOf What Do We Know About the M3 Apple Silicon Chip? https://www.makeuseof.com/m3-apple-silicon-chip-rumors/ apple 2023-02-15 14:15:17
海外TECH MakeUseOf Tecno Megabook T1 Review: An Affordable Thin and Light Productivity Laptop https://www.makeuseof.com/tecno-megabook-t1-review/ Tecno Megabook T Review An Affordable Thin and Light Productivity LaptopPowerful yet affordable Tecno s Megabook T features a Core i GB RAM GB SSD a quot screen and four hour battery life 2023-02-15 14:05:15
海外TECH DEV Community 👀 Visualizing: Execution Context in JavaScript https://dev.to/catherineisonline/visualizing-execution-context-in-javascript-50k Visualizing Execution Context in JavaScriptWhen the JavaScript runs in the browser it needs to be converted to the machine code as it cannot directly understand it When the browser s JavaScript engine encounters JavaScript it creates a special environment for it where it handles the translation and execution of the JavaScript code we wrote This environment is called the execution context In this article I am going to visually explain how it works as precisely as I can Execution context can have global scope and function scope The very first time JavaScript starts running it creates a global scope Next the JavaScript is parsed and saves the variable and function declarations into the memory which will be used later on to execute different functions Finally the code gets executed where the variables saved in the memory are used Difference between global and function execution contextAs mentioned above when the JavaScript engine encounters JavaScript for the first time it creates a default execution context which is global anything that is not inside a function When the engine encounters functions then it creates another execution context called function execution context where it executes the code located inside the function It s important to note that for every script file there is only one execution context and so is for function execution context How is execution context created Execution context has two phases Creation phaseExecution phase Creation phaseThe creation phase has stages During this stage the execution context is associated with the execution context object which is defined as the properties of this object Creation of the variable objectCreation of scope chainSetting the this value️⃣The variable objectThe variable object is an object like container that stores variable and function declarations within the current execution context Every time we create a variable with the keyword var it s added to the variable object as a property that points to the variable but it doesn t come along with its value yet only the declaration In this variable object environment the value assigned to the variable is undefined Remember the very first example with the console log That is exactly why we saw an output of undefined When we create variables with the keyword let and const the process is almost the same but technically a little different Instead of a variable object environment we have a lexical object environment The variable object is technically also a lexical environment for specifically the var keyword only So what happens with the variables declared with const and let They are also saved in the lexical environment object but instead of undefined they have a default value of uninitialized Finally if you remember I have also mentioned that the execution context saves function declarations Just as the variable doesn t come along with the assigned values the same applies to functions Instead of the entire function the default value of it is a reference to this function When I mention a function be aware that this doesn t work with function expressions because we save a function in a variable and it will be saved as a variable whether it s var let or const This process of storing variable and function declarations in memory prior to execution is called hoisting which we will discuss in more detail next time ️⃣The scope chainScope in JavaScript is something like a box feature that determines whether variables located in it are accessible outside of it We have scopes like global scope function scope and block scope The variables declared with var are global scoped and function scoped while let and const are function scoped and block scoped I already wrote a post about how variables act in different scopes As we already mentioned above we also have function execution context which is created based on what the functions hold and each function execution context has its own scope Besides a function in another function can have access to everything in the parent function even if we have several functions in a function However the parent function may not have access to the variables in the child scope if they are function scoped The type of behavior is called lexical scope This doesn t work backward This means that the parent function cannot retrieve variables declared inside its child functions because they are function scoped This link between scopes is called the scope chain It s something like a Matryoshka doll aka stacking dolls where in each doll is nested another doll It means that inner dolls can access the outside doll variable but outside dolls cannot access inside dolls This means that the scope chain starts from the inner scope all the way up ️⃣Setting the this valueOnce the scope chain is done the next step is setting up the value for this keyword This keyword refers to the scope of the current execution context In an execution context where we have global scope this refers to the global object window So anything we declare with var whether it s a function or a variable will belong to the window object and be attached as properties or methods But what happens in a function execution context Function execution context in functions depends on how it is invoked If it s invoked in the global context so a regular way we usually do it this keyword will refer to the global window so the environment where it was defined What do you think will be the output for each function Each of them will console log the same   apple because all of them refer to the global window object where our fruit is located But what if we use a function as a method of an object In this case not all console logs will show an apple The very last one will be orange Why Because the this keyword will refer to the inner object context of this object This means that the current context of the object is separated from the global scope so this refers to the fruit located inside the object myObj Execution phaseOnce all three phases of the creation phase are done the JavaScript engine will check the variable object one more time and start assigning the values to continue with the code execution Next let me remind you one more time about the execution context When the JavaScript is being parsed the very first execution context is created in the global scope Next when we create objects or functions for each function another function execution context is created So you will have additional function execution contexts as many as you have functions or objects So imagine I have functions which means I have function execution contexts All these execution contexts are piled up into an execution stack Now another important thing about JavaScript I know it never ends haha JavaScript is a single threaded language which means that several actions cannot execute at the same When function execution context is created it goes to the top of the execution context which is currently executingthis execution is on top of the execution stackand becomes an active execution contextSo as a result the active execution context is the one that is going to execute the first Then comes another active one and it gets executed second and so on Note execution stack is also known as the call stack Let s try to visualize the processFinally when all the functions execute the global execution context is removed from the execution context aka the call stack ConclusionIn conclusion understanding how execution context works in JavaScript is crucial for developing effective and efficient code Each time the JavaScript engine encounters code it creates a special environment called the execution context which can have global scope or function scope During the creation phase the variable object scope chain and this keyword are set up and in the execution phase the code is executed Additionally the use of var let and const for variable declaration function hoisting and scope chain determines the accessibility of variables within and outside of functions If it s still very confusing for you I advise you not to worry too much and slowly try to understand it one by one I spent hours trying to understand all of this in detail and I still know that I didn t cover everything and maybe I didn t explain everything exactly how it works In any case it was a great experience to read through such details and I am getting closer I also didn t cover many things in more detail like hoisting however I will get back to it later on Did this help you in any way Please let me know 2023-02-15 14:36:08
海外TECH DEV Community Readable code: Why it matters and how to do it https://dev.to/marek/readable-code-why-it-matters-and-how-to-do-it-1gf5 Readable code Why it matters and how to do itThere s a joke in programming that some code is write only It s a reference to the fact that code can be impossible to read and that the only moment when it can be understood is at the moment of writing The reality is that code readability is a big deal with significant consequences There are many competing priorities when developing software and readability can sometimes become a send thought It s easier to make the case that code should be fast and bug free and shipped quickly But I m making the case that readability can be a number one priority too In fact it can you help achieve all of the other priorities it makes it easier to write faster code it makes bugs more discoverable and it allows you to ship faster Who is it for When you re putting effort into making code readable who are you doing it for In some cases the person who will be reading it is your future self You might have all the context about the code in your mind right now and you might think you re going to understand it in the future But the reality is that we forget quickly Making your code readable is a gift to your future self It s a gift of time and convenience because it will help you get back into the code faster and spend less time trying to figure out what s going on Aside from being a gift to your future self it s also a gift to anyone else who will be reading your code This includes your co workers and collaborators who will be reviewing your code in the immediate future But it also includes people who you don t currently know future collaborators or people who will be maintaining your code long after you might be gone from your position or role Sometimes you re on a team and you can ask co workers to explain the code that they wrote But there are many times when that s not the case the original authors of the code might be unavailable or they might have left the company or the project long ago I ve had situations where I ve wanted to ask the code author for an explanation of what they wrote only to find out that they re no longer at the company Writing readable code is also a gift to those who are learning What best practices of readability do you want to pass down to future developers It s a great opportunity instead of gatekeeping our knowledge we can make it easier for newcomers into the profession to read and learn How to write readable code Put yourself into the shoes of someone who is reading the code for the first time and doesn t have a lot of context about how it works What do they care about First make the intent clear what is the code intending to do The two main tools you have at your disposal for clear intent are descriptive names and intentful comments Descriptive names apply to function names and variable names in particular Here the idea is to stuff more information about what a function is intended to do into the name itself Variable names can also have a lot of meaning stuffed into their name what data the contain and what that data is for The best descriptive names are consistent in their level of detail And they can evolve In a simple project you can survive with short names that don t need to specify a lot of detail But once the number of functions are variables gets large then you really start to benefit from longer and more descriptive names That s because with growing complexity there s more to be said about how each name is different from the others The second tool is writing intentful comments This is what I call comments that carry intent They describe not just what a piece of code is doing but what it s intending to do This might mean answering the why behind the code A good why explanation doesn t just explain the reasons behind the way that the code was written but it also mentions the alternative implementations that were considered but were not used Intentful comments can be the most useful help when debugging if you re trying to figure out a bug and you see a discrepancy between how the code functions and how its intent is described this can be very valuable information for narrowing down the location of the bug Writing readable code makes you a better programmerIn conclusion it s worth making readable code a priority It pays off in the future making it easier for you to come back to your old code and quickly get right back into it and also making it easier for collaborators to work on it Writing readable code makes you practice empathy as a programmer It forces you to think about the state of mind of someone who will be reading the code without all the context and understand that you have in the moment And that s a great exercise to make you a better developer 2023-02-15 14:23:26
海外TECH DEV Community Unity3D Scriptable Object guide https://dev.to/kiranjodhani/unity3d-scriptable-object-guide-cbj UnityD Scriptable Object guideThe main objective of this articles is to give you an idea about ScriptableObject in UnityD What are Scriptable Objects ScriptableObject is a serializable Unity class that allows you to store large quantities of shared data independent from script instances Using ScriptableObjects makes it easier to manage changes and debugging You can build in a level of flexible communication between the different systems in your game so that it s more manageable to change and adapt them throughout production as well as reuse components Every time you instantiate that Prefab it will get its own copy of that data Instead of using the method and storing duplicated data you can use a ScriptableObject to store the data and then access it by reference from all of the Prefabs This means that there is one copy of the data in memory Just like MonoBehaviours ScriptableObjects derive from the base Unity object but unlike MonoBehaviours you can not attach a ScriptableObject to a GameObject Instead you need to save them as Assets in your Project When you use the Editor you can save data to ScriptableObjects while editing and at run time because ScriptableObjects use the Editor namespace and Editor scripting In a deployed build however you can t use ScriptableObjects to save data but you can use the saved data from the ScriptableObject Assets that you set up during development Data that you save from Editor Tools to ScriptableObjects as an asset is written to disk and is therefore persistent between sessions Using a ScriptableObjectThe main use cases for ScriptableObjects are Saving and storing data during an Editor sessionSaving data as an Asset in your Project to use at run timeTo use a ScriptableObject create a script in your application s Assets folder and make it inherit from the ScriptableObject class You can use the CreateAssetMenu attribute to make it easy to create custom assets using your class For example using UnityEngine CreateAssetMenu fileName Data menuName ScriptableObjects SpawnManagerScriptableObject order public class SpawnManagerScriptableObject ScriptableObject public string prefabName public int numberOfPrefabsToCreate public Vector spawnPoints With the above script in your Assets folder you can create an instance of your ScriptableObject by navigating to Assets gt Create gt ScriptableObjects gt SpawnManagerScriptableObject Give your new ScriptableObject instance a meaningful name and alter the values To use these values you need to create a new script that references your ScriptableObject in this case a SpawnManagerScriptableObject For example using UnityEngine public class Spawner MonoBehaviour The GameObject to instantiate public GameObject entityToSpawn An instance of the ScriptableObject defined above public SpawnManagerScriptableObject spawnManagerValues This will be appended to the name of the created entities and increment when each is created int instanceNumber void Start SpawnEntities void SpawnEntities int currentSpawnPointIndex for int i i lt spawnManagerValues numberOfPrefabsToCreate i Creates an instance of the prefab at the current spawn point GameObject currentEntity Instantiate entityToSpawn spawnManagerValues spawnPoints currentSpawnPointIndex Quaternion identity Sets the name of the instantiated entity to be the string defined in the ScriptableObject and then appends it with a unique number currentEntity name spawnManagerValues prefabName instanceNumber Moves to the next spawn point index If it goes out of range it wraps back to the start currentSpawnPointIndex currentSpawnPointIndex spawnManagerValues spawnPoints Length instanceNumber Attach the above script to a GameObject in your Scene Then in the Inspector set the Spawn Manager Values field to the new SpawnManagerScriptableObject that you set up Set the Entity To Spawn field to any Prefab in your Assets folder then click Play in the Editor The Prefab you referenced in the Spawner instantiates using the values you set in the SpawnManagerScriptableObject instance If you re working with ScriptableObject references in the Inspector you can double click the reference field to open the Inspector for your ScriptableObject You can also create a custom Editor to define the look of the Inspector for your type to help manage the data that it represents 2023-02-15 14:22:31
海外TECH DEV Community Build a serverless subscription system with Stripe and Appwrite for premium user roles in Nuxt https://dev.to/hackmamba/build-a-serverless-subscription-system-with-stripe-and-appwrite-for-premium-user-roles-in-nuxt-2agg Build a serverless subscription system with Stripe and Appwrite for premium user roles in NuxtServerless functions lambda functions functions as a service FAAS and serverless frameworks among others are some innovations leveraging serverless architecture Such an architecture allows developers to build robust applications with improved resilience reduced cost and unburdened with the overhead of maintaining servers In this post we will learn how to build a metric tracker with premium features in a Nuxt js application with Appwrite s serverless function and Stripe GitHub LinksThe project source codes are below Appwrite function with Node jsNuxt app PrerequisitesTo fully grasp the concepts presented in this tutorial the following are required Basic understanding of JavaScript and Vue jsDocker installationAn Appwrite instance check out this article on how to set up an instance or install with one click on DigitalOcean or GitpodAppwrite CLI installedA Stripe account sign up for a trial account it is completely free Set up a Stripe account to process paymentsTo get started we need to log into our Stripe account to get our Secret Key The Secret Key will come in handy for processing payments in our application To do this navigate to the Developers tab and copy the Secret Key Integrate Appwrite function with StripeBy default Appwrite supports Node js as a runtime for creating serverless functions To get started we need to log into our Appwrite console click the Create project button input metric tracker as the name and then click Create Initialize function directoryWith our project created on Appwrite we can now create a directory that our function will use to process payments using Stripe To do this we first need to navigate to the desired directory and run the command below mkdir metric stripe function amp amp cd metric stripe functionThe command creates a project folder called metric stripe function and navigates into this folder Secondly we need to log in to the Appwrite server using the command line interface CLI appwrite loginWe will be prompted to input an email and password which need to be the credentials we used to sign up for the Appwrite console Lastly we need to link our function directory to the Appwrite project created earlier by running the command below appwrite init projectWe will be prompted with some questions on how to set up the project and we can answer as shown below How would you like to start lt select Link this directory to an existing Appwrite project gt Choose your Appwrite project lt select metric tracker gt Create Appwrite function inside the projectWith our project succesfully set up we can now proceed to creating a function by running the command below appwrite init functionWe will also be prompted with some questions about how to set up our function we can answer as shown below What would you like to name your function lt input metric stripe function gt What ID would you like to have for your function unique lt press enter gt What runtime would you like to use lt scroll to node and press enter gt The command will create a starter Node js project Secondly we need to install the required dependency by running the command below cd functions metric stripe function npm i axiosThirdly we need to modify the index js file inside the src folder as shown below const axios require axios module exports async function req res const data amount currency usd payment method pm card visa const body amount data amount amp currency data currency amp payment method data payment method await axios post body headers Content Type application x www form urlencoded auth username REPLACE WITH STRIPE SECRET KEY then gt res json status message Subscription processed successfully catch gt res json status message Error processing subscription The snippet above does the following Imports the required dependencyLines create an API body that consists of amount currency and payment method of type card and using a test card pm card visa Lines make an API call to Stripe by passing in the body set the authentication using the Secret Key and return the appropriate responseNote We hardcoded the amount currency and payment method in this post However Stripe supports multiple payment methods and options we can adopt in a production environment Lastly we must navigate to the project terminal and deploy our function cd appwrite deploy functionWe will also be prompted about the function we would like to deploy Select the metric stripe function function by pressing the spacebar key to select and the enter key to confirm the selection We can also confirm the deployment by navigating to the Function tab on the Appwrite console Lastly we must update the deployed function permission since we need to call it from our Nuxt application To do so navigate to the Settings tab scroll to the Execute Access section select Any and click Update Create a Nuxt app and set up databaseWith our function deployed and ready to accept payment via Stripe we can now set up a Nuxt project To get started we need to clone the project by navigating to the desired directory and running the command below git clone amp amp cd metric trackerSetting up the projectFirst we need to add Appwrite as a dependency by running the command below npm i appwrite amp amp npm iThen we can run our project using the command below npm run devCreate a database and add sample dataFirst we need to create a database with the corresponding collection attributes document and add sample data as shown below nameisSubscribedJohn TravoltafalseLastly we need to update our collection permission to manage them accordingly To do this navigate to the Settings tab scroll down to the Update Permissions section select Any mark accordingly and Update Building the metric tracker with subscription systemTo get started we first need to create a components utils js to abstract the application logic from the UI and add the snippet below import Client Databases Account Functions from appwrite const PROJECT ID REPLACE WITH PROJECT ID const DATABASE ID REPLACE WITH DATABASE ID const COLLECTION ID REPLACE WITH COLLECTION ID const FUNCTION ID REPLACE WITH FUNCTION ID const DOCUMENT ID REPLACE WITH DOCUMENT ID const client new Client const databases new Databases client client setEndpoint http localhost v setProject PROJECT ID export const account new Account client export const getUserDetails gt databases getDocument DATABASE ID COLLECTION ID DOCUMENT ID export const createSubscription gt const functions new Functions client return functions createExecution FUNCTION ID export const updateUserSubscription name isSubscribed gt const data name isSubscribed return databases updateDocument DATABASE ID COLLECTION ID DOCUMENT ID data The snippet above does the following Imports the required dependencyInitializes Appwrite client and databases with required argumentsCreates account getUserDetails createSubscription and updateUserSubscription functions for managing user sessions obtaining user details creating the subscription and updating user subscription status PS We can get the required IDs on our Appwrite Console Secondly we need to update the app vue file to use the account helper function to check if a user has a valid session lt template gt lt div class min h screen bg brand bg lg flex lg justify between gt lt Sidebar gt lt section class w full h auto px py lg px gt lt NuxtPage gt lt NuxtPage gt lt section gt lt div gt lt template gt lt script setup gt import account from components utils check sessiononMounted async gt account get then catch gt account createAnonymousSession lt script gt Thirdly we need to update the metrics vue file in the pages folder as shown below metrics vue Logic lt script setup gt import getUserDetails from components utils stateconst user ref null get user detailsonMounted async gt getUserDetails then res gt user value res catch gt alert Error loading user details lt script gt The snippet above does the following Imports the required dependencyCreates application state and retrieves user details upon page load using the getUserDetails helper functionmetrics vue UI lt template gt lt div class mt gt lt section class flex items center mb gt lt h class text xl font bold inline block mr gt Metrics lt h gt lt p class px text sm bg indigo bg opacity text indigo rounded full gt premium lt p gt lt section gt lt section class flex v if user isSubscribed gt lt div class border w full flex justify center flex col items center h mr rounded md gt lt p class text gray mb gt Daily insight lt p gt lt h class text xl font bold gt lt h gt lt div gt lt div class border w full flex justify center flex col items center h mr rounded md gt lt p class text gray mb gt Total insight lt p gt lt h class text xl font bold gt lt h gt lt div gt lt section gt lt Locked v else name user name gt lt div gt lt template gt The snippet above does the following Conditionally shows premium metrics using the user s subscription statusUpdates the Locked component to receive name propsLastly we need to update the Locked vue file in the components folder as shown below lt template gt lt div class flex w full flex col items center justify center h gt lt p class text center justify center mb gt Oops Looks like you don t have access to this page lt p gt lt p class text center justify center mb gt Get full access for by subscribing lt p gt lt button class px py bg indigo text white rounded hover bg indigo click onSubmit gt Upgrade to paid lt button gt lt div gt lt template gt lt script setup gt import createSubscription updateUserSubscription from components utils const props defineProps name const onSubmit gt createSubscription then gt updateUserSubscription props name true then gt alert Subscription created successfully window location reload catch gt alert Error subscribing user catch gt alert Error subscribing user lt script gt The snippet above does the following Imports the required dependencyDefines the expected component propsCreates an onSubmit function that uses the createSubscription and updateUserSubscription helper functions to manage subscriptionUpdates the UI to use the onSubmit functionWith that done we can restart a development server using the command below npm run devWe can validate the subscription by checking the Appwrite function Executions tab and Stripe Log tab ConclusionThis post discussed how to build a metric tracker with protected premium features using Appwrite and Stripe The demo is a base implementation demonstrating Appwrite s support for building serverless architecture Appwrite gives developers the magic wand to build medium to large scale applications at a reduced cost and excellent developer experience These resources may also be helpful Appwrite official documentationAppwrite Node SDKAppwrite FunctionStripe payment intentStripe payment guideNuxt official documentation 2023-02-15 14:04:30
海外TECH DEV Community Don't miss on the cloud revolution, learn serverless on AWS the right way https://dev.to/kumo/dont-miss-on-the-cloud-revolution-learn-serverless-on-aws-the-right-way-1kac Don x t miss on the cloud revolution learn serverless on AWS the right wayIn this article we will learn how to get started with serverless on AWS It will require to create an AWS account and a credit card but don t worry it s free to start TL DRIn this article I teach you how to get started with serverless on AWS If you already have an AWS account feel free to skip to the Create an AWS CDK project section I plan to release a series of articles about serverless to learn step by step the specificities of this technology so stay tuned Why serverless A massive gold rush towards cloud technologies has begun during these last years The cloud is becoming the new standard for software development It is a revolution that is changing the way we develop software and it is far from being over As developers we have an important role to play is this transformation and it is an opportunity for us to claim our place in this new paradigm When using the cloud we think less about the infrastructure of our servers If used properly it allows us to focus of the business logic of the features we build the spotlight is on the code we write not on the servers we run it on This is a huge advantage for developers as it allows us to focus on what we do best writing code Serverless is the pinnacle of this cloud revolution servers are gone developers become architects and when paired with powerful IaC Infrastructure as Code tools it allows us to build complex architectures in a matter of minutes This revolution is still in its infancy and in my opinion NOW is the time to get on the train Serverless and infrastructure as codeServerless is a cloud computing execution model where the cloud provider dynamically manages the allocation and provisioning of servers You bring some code and it is ran on demand on the cloud as many times as there are users Its principal argument is that it s pay per use applications scale to zero and are basically free to develop until there are users Serverless is a very broad term and it can be applied to many different cloud providers In this article we will focus on AWS as it is the most popular cloud provider and it is the one I am most familiar with Infrastructure as code IaC is a way to manage your infrastructure using code It allows you to automate the creation modification and deletion of your infrastructure Paired with serverless it allows you to build complex architectures using your favorite programming language without the need of complex configuration files Getting started on AWS Create an AWS account and configure your credentialsTo get started you will need to create an AWS account You can do so by going to You will need to provide a credit card but don t worry until you have a large number of users you won t be charged anything Once you have created your account you will need to configure your credentials You can do so by going to the AWS console and clicking on your username in the top right corner Then click on My Security Credentials You will then be able to create a new access key You will need to save this key somewhere safe as it will be used to authenticate your requests to AWS ️It is best practice to not use the root account for development as it has full access to all AWS services Instead you should create a new user with the least amount of permissions possible check this tutorial for more information Install the AWS CLIThe idea behind serverless is to be able to develop the business logic of your application locally on your computer while deploying it on the cloud once everything is ready you don t want to code directly in google chrome You will need a CLI to do so The AWS CLI is a tool that allows you to interact with AWS using the command line You can install it by following the instructions on this page Once you are done you can configure a profile by running the following command aws configureProvide the access key that you generated earlier specify your AWS region eu west in europe for example and the output format json Create an AWS CDK projectThe AWS Cloud Development Kit CDK is an open source software development framework used to provision your cloud infrastructure Basically CDK allows you to describe with code the infrastructure you want to deploy on AWS it is called Infrastructure as Code IaC CDK supports many programming languages I will focus on TypeScript in this article but JavaScript for example works almost the same way To create your project run the following command in your CLI mkdir my first app amp amp cd my first appnpx cdk init app language typescriptnpm run cdk bootstrapIt will create a new repository install the dependencies and bootstrap your project on the AWS cloud And you are DONE with the setup Time to start coding Lambda functionsLambda functions are the core of serverless They are small architectural blocks that can execute code on the cloud on demand They are tiny servers that are provisioned on demand to answer to user requests In theory a single Lambda function can answer to millions of requests per second Best fact they are pay per use so you only pay for the time they are running it is basically free while your app is in development In this part you are going to create your first Lambda function and deploy it on AWS It will be a simple Hello World function but enough to get started Let s have a look at the code that was generated by the CDK You will find it in the lib folder You will see that there is a file called my first app stack ts This is the file where you will write your infrastructure as code Let s start by creating a simple Lambda function import as cdk from aws cdk lib import Construct from constructs import path from path export class MyFirstAppClass extends cdk Stack constructor scope Construct id string props cdk StackProps super scope id props new cdk aws lambda nodejs NodejsFunction this myFirstLambda entry path join dirname myFirstLambda handler ts handler handler If you encounter an error with the import of path add esModuleInterop true in the compilerOptions of your tsconfig json file In this code snippet I create a new Lambda function called myFirstLambda using the NodejsFunction construct This construct allows to easily create a Lambda function using Node js taking care of packaging for you you won t have to worry about importing dependencies etc it also supports TypeScript natively The entry parameter is the path to the handler file defining the code that will be executed on the cloud The handler parameter is the name of the JavaScript function that will be executed when the Lambda is invoked This means that you will need to create a folder called myFirstLambda in the lib folder and a file called handler ts in it This file should export a handlerfunction For example the content of this file could be the following export const handler Promise lt string gt gt Promise resolve Hello World A simple rule of thumbs is that the code executed by Lambda functions always must be asynchronous in reality it s a bit more complicated but for now remember their return type should be a Promise Here I use Promise resolve to return a string asynchronously even if everything is synchronous in this example npm run cdk deployOOPS An error occurs I forgot to add esbuild as a dev dependency Esbuild is the tool used to package the NodejsFunction I just need to run the following command to fix it npm i save dev esbuildLet s re run the deploy command It should work fine now On the AWS console I can see that a new Lambda function has been created Click on it and head to the test tab You can invoke the Lambda function by clicking on the Test button In green you can see the logs of the invocation Hello World You just created your first Lambda function A first look at AWS API GatewayYour first Lambda function is nice but it s not very useful Nobody can access it from the internet and it doesn t do anything useful To fix this you will need an API like in classic serverful applications The AWS API Gateway services provides functionalities to create REST APIs that can invoke Lambda functions gt it is everything needed for now Let s fix that by creating a new Lambda function plugged an API endpoint that will invoke it You will use Api Gateway and the CDK for that First let s create a REST API that will be used to invoke our Lambda function To do so we will use the RestApi construct Add the following code to your my first app stack ts file Under the instantiation of your first Lambda functionconst myFirstApi new cdk aws apigateway RestApi this myFirstApi const diceResource myFirstApi root addResource dice I also added a resource called dice to the API It basically tells AWS our API now has a dice API route registered For example if the API is deployed on the endpoint will be Let s create a rollADice Lambda function that will return a random number between and Create a new folder called rollADice in the lib folder and a file called handler ts in it The content of this file should be the following export const handler async Promise lt statusCode number body number gt gt const randomNumber Math floor Math random return Promise resolve statusCode body randomNumber Notice the return type of the function It is a Promise of an object with a statusCode and a body This is the format expected by API Gateway to be returned by a Lambda function Finally let s associate this source code to a Lambda function Add the following code to your my first app stack ts file Under the instantiation of the API resourceconst rollADiceFunction new cdk aws lambda nodejs NodejsFunction this rollADiceFunction entry path join dirname rollADice handler ts handler handler diceResource addMethod GET new cdk aws apigateway LambdaIntegration rollADiceFunction At the same time I created a new Lambda function and associated it s execution with the route dice and the http method GET POST PUT etc are also available Time to re deploy the infrastructure On the AWS console you should see your new API Gateway Click on it and head to the stages tab You can see the URL of your API Copy it and paste it in your browser or in postman and add dice at the end You should see a number between and in the body of the response If you pay attention to the delay of the first response you will notice that it is quite long ms This is because the Lambda function is cold It means that it has not been invoked for a while and the AWS infrastructure needs to spin up a new instance of the Lambda function to execute it New executions will be faster in fact you will feel like the Lambda function is running on your computer Homework Now that you have a basic understanding of how to create a Lambda function and an API endpoint it s time to create your own Lambda function and API endpoint My proposition is to create a Lambda that rolls any number of dices and returns the result For example if you call the endpoint GET dice it should return a random number between and My only tip is how to use path parameters in API Gateway Like we did on root to create a first resource add a resource to diceResource with diceCount as value This will create a new route with a path parameter called diceCount that you can use in your Lambda function Just create a new Lambda and use the type pathParameters diceCount pathParameters nbOfDices string as the input of your new handler The rest should be easy to figure out Do not hesitate to ask for help if you get stuck I will be happy to help you You can also check this repository on my github to see the solution and the previous two Lambda functions we created together ConclusionI plan to continue this series of articles on a bi monthly basis I will cover new topics like storing data in a database creating event driven applications and more If you have any suggestions do not hesitate to contact me I would really appreciate if you could react and share this article with your friends and colleagues It will help me a lot to grow my audience Also don t forget to subscribe to be updated when the next article comes out I you want to stay in touch here is my twitter account 2023-02-15 14:03:26
海外TECH DEV Community Asking AI what it thinks programming languages look like! https://dev.to/grahamthedev/asking-ai-what-it-thinks-programming-languages-look-like-37j4 Asking AI what it thinks programming languages look like Hey all long time no see Just a random fun post for you today am I back am I not Who knows but I just wanted to share this Oh and if you are wondering who the hell I am and why you are getting notifications for my stuff I was known as InHuOfficial hope that helps AI and programming languagesSo I have been playing with AI art generation lately mainly through MidJourney AI One thing that is always interesting is when you try and generate an image on a specific thing and it is very evident the AI has no idea what that thing is So I wondered does AI have any awareness of programming languages Even more interestingly when it doesn t have any knowledge of something what does it generate instead So that is the idea I generated images for different programming related languages and now it is up to you to try and guess which image is what language Have fun The languagesI generated images for different languages related to programming notice how I nicely side stepped calling HTML and CSS programming languages to avoid that debate These are HTMLCSSJavaScriptTypeScriptPythonRustDartGoSwiftC C KotlinRubyRuby on RailsPHPCOBOL haha JavaNow that you have that list see how many of the following you can get I have given each one a rating on MY perceived difficulty to get them The imagesLet s start you off with an easy one Difficulty Easy Difficulty Easy Difficulty Easy Difficulty Easy Medium Difficulty Medium Difficulty Hard Difficulty Very Easy Difficulty Easy Difficulty Easy Medium Difficulty Hard Difficulty Medium hard Difficulty Medium hard Difficulty Easy Difficulty Medium Difficulty Easy Difficulty Easy Medium Difficulty Hard The answers spoilers duh Check how many you got right PythonJavaRuby on RailsPHPC HTMLDartRustTypeScriptCSSCOBOLSwiftKotlinC GoRubyJavaScript How did you do I hope you enjoyed this silly post let me know how many you got right in the comments below Have a great week everyone see you soon maybe 2023-02-15 14:01:52
Apple AppleInsider - Frontpage News Norwegian banks ally to say that Apple Pay should be opened up https://appleinsider.com/articles/23/02/15/norwegian-banks-ally-to-say-that-apple-pay-should-be-opened-up?utm_medium=rss Norwegian banks ally to say that Apple Pay should be opened upThe coalition of banks that formed Norwegian payment app Vipps wants to see antitrust action taken against Apple unless Apple Pay s NFC tech is opened up Credit AppleThe European Union held a closed hearing over Apple s alleged antitrust behavior on Tuesday but following it Norway firm Vipps says that it wants to see decisive action taken against Apple Pay Read more 2023-02-15 14:47:48
Apple AppleInsider - Frontpage News Adobe's Figma buy blocked, until EU decides if it can proceed https://appleinsider.com/articles/23/02/15/adobes-figma-buy-blocked-until-eu-decides-if-it-can-proceed?utm_medium=rss Adobe x s Figma buy blocked until EU decides if it can proceedAnti trust regulators in the European Commission are going to assess Adobe s recent decision to acquire design rival Figma to see if it would decrease competition The EU will assess the Figma buyoutAdobe announced the beginning of a definitive merger agreement to acquire Figma in September for approximately billion in stock and cash Figma s creators would join Adobe and the deal was expected to clear the regulatory approval process in Read more 2023-02-15 14:39:15
Apple AppleInsider - Frontpage News Apple backs groups conserving forests in the Deep South https://appleinsider.com/articles/23/02/15/apple-backs-groups-conserving-forests-in-the-deep-south?utm_medium=rss Apple backs groups conserving forests in the Deep SouthApple has highlighted the work of conservatory groups including McIntosh S E E D who run the first Black owned community forest in the US Working with The Conservation Fund Apple says that it partners with community groups like McIntosh S E E D across the Deep South It s in order to scale up sustainable land retention specifically in Black and Brown communities To promote justice and address climate change we have to share resources and partner with organizations that have real on the ground expertise Lisa Jackson Apple s vice president of Environment Policy and Social Initiatives said in a press release I ve always believed the most powerful solutions come from centering the most vulnerable communities not ignoring them Read more 2023-02-15 14:27:23
Apple AppleInsider - Frontpage News Climate change drama 'Extrapolations' coming to Apple TV+ on March 17 https://appleinsider.com/articles/23/02/15/climate-change-drama-extrapolations-coming-to-apple-tv-on-march-17?utm_medium=rss Climate change drama x Extrapolations x coming to Apple TV on March Apple has unveiled its star studded trailer for Extrapolations a climate change drama by Inconvenient Truth creator Scott Z Burns Image Credit Apple Extrapolations will tell intimate stories of how the upcoming changes to the planet will affect love faith work and family The stories will be interwoven through the eight episode season and follow the worldwide battle for mutual survival Read more 2023-02-15 14:23:53
Apple AppleInsider - Frontpage News Daily Deals Feb. 15: $550 off MacBook Pro 14", iPad Air 5 for $499, 20% off at eBay & more https://appleinsider.com/articles/23/02/15/daily-deals-feb-15-550-off-macbook-pro-14-ipad-air-5-for-499-20-off-at-ebay-more?utm_medium=rss Daily Deals Feb off MacBook Pro quot iPad Air for off at eBay amp moreTop discounts this Wednesday include up to off MacBook Pros off a HP Firefly ZBook off a Samsung Odyssey gaming monitor and off a GoPro HERO Black Holiday Bundle Save on a MacBook ProThe AppleInsider team combs the web for the most valuable deals at online stores to develop a list of discounts on the top tech products including discounts on Apple products TVs accessories and other gadgets We share the top deals in our Daily Deals list to help you stretch your dollar Read more 2023-02-15 14:19:15
Apple AppleInsider - Frontpage News Engwe EP-2 Pro review: Taking mountain biking to the next level https://appleinsider.com/articles/23/02/14/enguie-ep-2-pro-review-taking-mountain-biking-to-the-next-level?utm_medium=rss Engwe EP Pro review Taking mountain biking to the next levelThe Engwe EP Pro electric bike offers comfort and power and excels at being a good mountain bike when the engine is off Electric bikes also known as e bikes have become popular lately ーespecially in metropolitan areas ーbecause they allow for the ease of biking with the convince of an electric scooter when you want it With a modern and simplistic design a strong and durable build mode customization a foldable design and ease of use the EP Pro is an electric bike you should consider if you are in the market for one Read more 2023-02-15 14:35:58
Cisco Cisco Blog Empowering hybrid work – a governmental imperative https://feedpress.me/link/23532/15977235/empowering-hybrid-work-a-governmental-imperative Empowering hybrid work a governmental imperativeBecause work is no longer where you go but what you do the modern hybrid workplace includes not only the traditional office but the home and any “workspace an employee can contribute from Government hybrid work requirements however can be more stringent than a commercial enterprise See what Cisco is doing to help empower hybrid work in the government space 2023-02-15 14:22:21
海外TECH CodeProject Latest Articles Database First with Entity Framework https://www.codeproject.com/Articles/5354627/Database-First-with-Entity-Framework framework 2023-02-15 14:48:00
金融 RSS FILE - 日本証券業協会 株式投資型クラウドファンディングの統計情報・取扱状況 https://www.jsda.or.jp/shiryoshitsu/toukei/kabucrowdfunding/index.html 株式投資 2023-02-15 15:30:00
金融 RSS FILE - 日本証券業協会 株主コミュニティの統計情報・取扱状況 https://www.jsda.or.jp/shiryoshitsu/toukei/kabucommunity/index.html 株主コミュニティ 2023-02-15 15:30:00
ニュース BBC News - Home Nicola Bulley: Mother a high-risk missing person, police say https://www.bbc.co.uk/news/uk-england-lancashire-64646582?at_medium=RSS&at_campaign=KARANGA specific 2023-02-15 14:36:20
ニュース BBC News - Home Teachers in England will not back down over pay, says union https://www.bbc.co.uk/news/education-64651654?at_medium=RSS&at_campaign=KARANGA strikes 2023-02-15 14:45:35
ニュース BBC News - Home Linda Davis: Electric scooter rider, 14, admits causing woman's death https://www.bbc.co.uk/news/uk-england-nottinghamshire-64652020?at_medium=RSS&at_campaign=KARANGA davis 2023-02-15 14:01:03
ニュース BBC News - Home McDonald's puts up prices on five menu items https://www.bbc.co.uk/news/business-64651800?at_medium=RSS&at_campaign=KARANGA costs 2023-02-15 14:39:52
ニュース BBC News - Home Nicola Sturgeon: Winner who fell short of ultimate prize https://www.bbc.co.uk/news/uk-politics-64648617?at_medium=RSS&at_campaign=KARANGA departure 2023-02-15 14:15:59

コメント

このブログの人気の投稿

投稿時間:2021-06-17 22:08:45 RSSフィード2021-06-17 22:00 分まとめ(2089件)

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

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