IT |
ITmedia 総合記事一覧 |
[ITmedia News] 女性声優の“存在しない”水着画像をAIで作成、販売……法的に問題ないの? 弁護士に聞いた |
https://www.itmedia.co.jp/news/articles/2306/12/news175.html
|
itmedia |
2023-06-12 19:11:00 |
IT |
ITmedia 総合記事一覧 |
[ITmedia News] デジ庁がイラスト素材を無料配布へ マイナカードのイメージなど Web・アプリ開発で活用OK |
https://www.itmedia.co.jp/news/articles/2306/12/news177.html
|
itmedia |
2023-06-12 19:04:00 |
TECH |
Techable(テッカブル) |
営業スキルを可視化し、個人の強み・弱みを把握!成果のばらつきをなくす営業育成DXツール登場 |
https://techable.jp/archives/211246
|
salespot |
2023-06-12 10:00:40 |
python |
Pythonタグが付けられた新着投稿 - Qiita |
Python3エンジニア基礎試験_模擬試験の復習④ |
https://qiita.com/myitoutput/items/4c8b5b44091ce45be5cb
|
hitashibatakimuraexmentor |
2023-06-12 19:15:18 |
js |
JavaScriptタグが付けられた新着投稿 - Qiita |
Flask + JavaScript (Confirm)との組み合わせについて |
https://qiita.com/akeyi2018/items/b47fcc77a965357afeb0
|
confirm |
2023-06-12 19:43:37 |
golang |
Goタグが付けられた新着投稿 - Qiita |
protovalidate を試す |
https://qiita.com/daisuke-yamamoto/items/6d366626c29c00e72c52
|
protovalidate |
2023-06-12 19:32:05 |
技術ブログ |
Mercari Engineering Blog |
協調フィルタリングとベクトル検索エンジンを利用した商品推薦精度改善の試み |
https://engineering.mercari.com/blog/entry/20230612-cf-similar-item/
|
hellip |
2023-06-12 11:00:10 |
技術ブログ |
Developers.IO |
[RDS.12] IAM 認証は RDS クラスター用に設定する必要があります |
https://dev.classmethod.jp/articles/securityhub-fsbp-remediation-rds-12/
|
awssecurityhub |
2023-06-12 10:04:07 |
海外TECH |
MakeUseOf |
The 4 Best Free Drawing Apps for macOS |
https://www.makeuseof.com/best-free-drawing-apps-mac/
|
drawing |
2023-06-12 10:45:18 |
海外TECH |
MakeUseOf |
How to Downgrade From the iOS 17 Beta to iOS 16 Right Now |
https://www.makeuseof.com/how-to-downgrade-from-ios-beta-to-ios/
|
downgrade |
2023-06-12 10:31:17 |
海外TECH |
MakeUseOf |
How to Fix Contacts Not Showing Up on Your iPhone |
https://www.makeuseof.com/fix-contacts-not-showing-iphone/
|
contacts |
2023-06-12 10:15:18 |
海外TECH |
DEV Community |
What is MQTT Protocol in IoT? Basics Explained |
https://dev.to/marynaaaa_b/what-is-mqtt-protocol-in-iot-basics-explained-4h56
|
What is MQTT Protocol in IoT Basics ExplainedHave you ever wondered how devices communicate with each other Whether it s your phone syncing data to the cloud or your activity data being sent to a phone application you ve experienced machine to machine communications in some way One example of using these communications is the Message Queuing Telemetry Transport MQTT protocol In this article we will share more about the basics of MQTT protocol in IoT how MQTT works in IoT the key components that exist in every MQTT project and some of the most used features in the MQTT protocol What is MQTT protocol in IoT As mentioned the MQTT protocol is used in machine to machine communications particularly in Internet of Things IoT devices Some common examples include smart sensors wearable trackers and even global positioning systems The MQTT protocol uses a publish subscribe model and is most commonly used in networks with low latency or unreliable networks How did the MQTT protocol come about MQTT was created in by IBM and designed for monitoring oil pipelines within an industrial control system At that time there was a need to send data from far away pipeline sensors to remote servers in a reliable and cost effective manner Since then the MQTT protocol has evolved significantly and anyone can adapt and implement it according to their needs The MQTT protocol specification has also undergone several upgrades since its initial creation As of the MQTT specification version was released which includes features like better error reporting shared subscriptions message and session expires What are the benefits of using the MQTT protocol We ve already mentioned a few advantages of using MQTT like cost effectiveness and reliability The MQTT protocol s binary format and support for Quality of Service QoS levels helps to minimize message size reduce network traffic and optimize device performance But what other benefits are there Easy to implement and useThe MQTT protocol is user friendly and has an intuitive syntax that helps make it easy for new users to understand and send process messages On top of that there are many libraries tools and other resources available for building your next IoT project and testing the MQTT protocol in action Flexible and scalableWith the MQTT protocol devices can publish and subscribe to multiple topics as well as handle connections and messages quickly and reliably Users can customize devices subscriptions and connections according to their projects needs This enables users to customize their own setup of the MQTT protocol in IoT projects and handle millions of connections without compromising speed and reliability Now that you have a better understanding of the MQTT protocol and the advantages of using it let s dive deeper into the key components involved in MQTT Components of MQTTWhile MQTT projects will vary depending on the needs there are several common components that will exist in every project like Broker Establishes and maintains connections with clients and processes messages Client Device that publishes or receives messages from the MQTT broker Topic A way to filter messages and ensure that the right clients receive the right messages Payload The message content that is sent and delivered in MQTT message transmissions Publish subscribe Messages are delivered from a client publisher to a broker then from the broker to all clients subscribed to the topic the message was sent to subscriber BrokerThe MQTT broker is at the center of all MQTT message transmissions It is in charge of establishing and maintaining secure connections with clients and routing messages to the right clients If you d like more details about the MQTT broker and how it works you should check out this article ClientClients are devices that operate an MQTT library and establish a connection to a broker There are two roles an MQTT client can have Publisher a client that publishes a message to a topic Subscriber a client that receives all messages from the subscribed topic For more information about MQTT clients read this TopicTopics are a kind of filter that the MQTT broker uses in message transmissions A typical MQTT message transmission looks like this A publisher sends a message to the broker on a topic The broker filters all connected clients for that particular topic Broker forwards the message to the clients subscribed to that topic If you d like a more detailed explanation of MQTT topics read this PayloadThis refers to the actual message content that is being sent in MQTT message transmissions There is no fixed format for payloads but they are usually in JSON XML or text Read this article for more information about MQTT payloads Publish subscribeThe MQTT protocol employs a publish subscribe model This means that the publisher never interacts directly with a subscriber Instead all communications are sent to a broker and the broker routes the messages to the respective subscribers If you d like to start using the MQTT protocol in IoT projects you should explore the Management Center MMC MQTT client It s a web application that makes it easier to manage Pro Mosquitto broker instances and clusters It also provides access to other features like user and access control management REST APIs and topic free visualisation Key features of MQTTWith a better idea of what MQTT message transmissions typically entail let s dive deeper into some of the key features of using the MQTT protocol Topics and WildcardsIn the MQTT protocol wildcards are used together with topics As mentioned earlier topics are filters that enable the broker forward the messages from a topic to the right clients This means that only the clients subscribed to that topic would receive these messages Wildcards are special characters that let the MQTT broker know that a client wants to subscribe to topics matching the specified pattern It is important to note that wildcards can only be used when subscribing to topics Quality of Service QoS In the MQTT protocol QoS is the level of service that serves as a consensus to successfully deliver a message There are at least two sides in every message delivery a publisher and a broker and the broker and a subscriber There are three possible QoS levels QoS at most once QoS at least once and QoS exactly once When publishers and subscribers have the same QoS MQTT message transmissions are straightforward but with different QoS things can get a bit complicated To find out more about QoS and when to use each QoS read this Last Will and Testament LWT Similar to how wills are used in the real world MQTT s LWT is used to inform parties of abnormal behavior in MQTT connections For example if a client unexpectedly disconnects or goes offline the broker publishes a last will message to a topic This helps to ensure that subscribers are informed of the disconnection The message and topic are predefined in the LWT Other parameters in LWT include lastWillRetain and lastWillQoS Persistent sessionsAs the name suggests persistent sessions enable messages and data to be stored for a longer period of time This means that messages can be stored for multiple network connections in the MQTT protocol Persistent sessions help to avoid loss of messages during offline periods or sudden disconnections reduce the need to subscribe repeatedly across different sessions and also ensure that QoS and QoS messages are not affected by any network outages Wrap upMQTT is typically used for machine to machine communications and a common use case is in IoT devices This means devices like mobile devices smart sensors wearable trackers Machine to machine communications happen more often than you d think A common example is wearing an activity tracker like FitBit and checking your activity on your phone application The MQTT protocol is a lightweight cost effective and reliable way to monitor devices remotely Besides that there are other benefits of using the MQTT protocol like ease of implementation and use as well as flexibility and scalability MQTT uses a publish subscribe model and is highly customizable MQTT projects can vary significantly there will always be the broker clients topic and payload Depending on your needs your MQTT project could employ one or more of these features in the MQTT protocol Topics and wildcards Topics are filters the broker uses to forward messages to the right clients and wildcards let the MQTT broker know that clients want to subscribe to topics matching the specified pattern Quality of service QoS A consensus of service level between an MQTT broker and a client publishing or subscribing There are three different QoS QoS at most once QoS at least once or QoS exactly once Last Will and Testament LWT Used to inform clients of abnormal behavior in MQTT connections like network outages and sudden disconnections Persistent sessions A way of enabling messages to be retained across multiple network connections Lastly leverage the Management Center MMC MQTT client to easily manage Pro Mosquitto broker instances and clusters You can also get access to other key MQTT features such as user and access control management REST APIs topic free visualization and more |
2023-06-12 10:48:35 |
海外TECH |
DEV Community |
Create a desktop entry for postman in ubuntu |
https://dev.to/shaikhalamin/create-a-desktop-entry-for-postman-in-ubuntu-3dn7
|
Create a desktop entry for postman in ubuntuDownload postman and extract it in your home folder Create a postman desktop file in local share folder and paste the following script in your local share file nano local share applications postman desktop Desktop Entry Version Type ApplicationName PostmanIcon home user name Postman app icons icon x pngExec home user name Postman PostmanComment Supercharge your API workflowOnlyShowIn Unity GNOME StartupNotify falseStartupWMClass PostmanX UnityGenerated trueCategories Development IDE Here replace your username with your |
2023-06-12 10:48:34 |
海外TECH |
DEV Community |
Getting to know Django Signals |
https://dev.to/ahmadsalah/getting-to-know-django-signals-39i9
|
Getting to know Django SignalsIf you ve been working with Django for a while you ve probably heard of Django Signals But what are they and why should you care Well my friend you re in for a treat In this article we ll dive deep into the world of Django Signals and discover how they can supercharge your app what are Django Signals Simply put they re a way for different parts of your app to communicate with each other without being tightly coupled Think of them as the secret sauce that makes your app more flexible scalable and maintainable With signals you can easily trigger actions based on certain events or conditions without having to write custom code for each one When should you use signals The short answer is whenever you need to perform an action based on some event or condition but you don t want to tightly couple your code For example let s say you have a blog app and you want to send an email notification whenever a new post is published You could write a custom function to do that but that would tightly couple your code and make it harder to maintain With signals you can simply listen for the post save signal and trigger your email function when the event occurs How does Django Signal work At a high level signals are just a way for different parts of your app to communicate with each other When an event occurs a signal is sent out and any listeners that have registered for that signal will be notified The listeners can then perform their own actions based on the eventCreating a signal is easyYou simply define a Signal object in your code like this from django dispatch import Signalmy signal Signal Now anyone can send a signal using the send method like this my signal send sender self message Hello world To listen for a signal you define a function and use the receiver decorator to register it with the signal like this from django dispatch import receiver receiver my signal def my listener sender message kwargs print f Received message message from sender Finally to connect a signal to a specific model or action you can use the connect method For example to listen for the post save signal on a specific model from django db models signals import post savefrom myapp models import MyModel receiver post save sender MyModel def my post save handler sender instance created kwargs Do something hereAnd that s it Now whenever a MyModel object is saved your my post save handler function will be called There are also many built in signals available in Django such as pre init post init pre save post save pre delete post delete and mm changed These signals allow you to hook into various stages of the object lifecycle and perform custom actions In conclusion Django Signals are a powerful tool that can help you write more flexible scalable and maintainable apps By using signals to communicate between different parts of your app you can reduce coupling and make your code more modular So why not give signals a try in your next project Your future self will thank you |
2023-06-12 10:48:18 |
海外TECH |
DEV Community |
Meme Monday |
https://dev.to/ben/meme-monday-54bo
|
Meme MondayMeme Monday Today s cover image comes from last week s thread DEV is an inclusive space Humor in poor taste will be downvoted by mods |
2023-06-12 10:44:28 |
海外TECH |
DEV Community |
Yet Another Newsletter LOL: Living on the Edge |
https://dev.to/nickytonline/yet-another-newsletter-lol-living-on-the-edge-1ae9
|
Yet Another Newsletter LOL Living on the EdgeAnother week another newsletter Let s get to it Around the WebIf you blog at all or are looking for some tips to your writing this could be the article for you People Don t Read OnlineーThey Scan This Is How to Write for Them My co worker Ryan Carniato gave a great talk at BeJS Revolutionary Signals Check it out to learn more about signals The Astro team released v this week Lots of goodies in there middleware hybrid SSR output mode custom client directives CSS inlining and more I caught Chris Coyier s talk at RenderATL It was really great He s now written a blog post based on his talk Definitely check out Modern CSS in Real LifeFun StuffOH NOS LOL kitze thekitze the future PM Jun Words of Wisdom for the WeekI ve only been to my second in person conference so these conference tips from James are great James Q Quick jamesqquick tips for your next conference talk to as many people as you can be intentional about the talks you attend visit the booths you never know who has your next role take breaks to recharge take notes before hand on who you want to meet and who to follow up with PM Jun Shameless PlugsGlauber Costa joined me on nickyt live this week to talk about Turso a new edge database We discussed the project provisioned a database created replicas worldwide and wrapped it up with a demo Node js CLI app that loads data from the database Here s a highlight from the Twitch stream The recording will be up on YouTube early next week Remember to give a follow on Twitch and subscribe on YouTube so you can catch all the great guests Coming up this week it s a doubleheader Austin Gil and Nick Nisi join me on my Twitch stream Check out the schedule for their slots and other upcoming guests JobsFullstack Software Engineer L Resilience Engineering at Netflix Remote USI post jobs in the iamdeveloper com community plus all other kinds of content as do others If you re looking for another friendly nook of the internet head to discord iamdeveloper com If you liked this newsletter you can subscribe or if RSS is your jam you can also subscribe via RSS |
2023-06-12 10:40:53 |
海外TECH |
DEV Community |
Unit testing: Jest - Angular Tour of heroes app 100% code coverage |
https://dev.to/kristiyan_velkov/unit-testing-jest-angular-tour-of-heroes-app-100-code-coverage-1k49
|
Unit testing Jest Angular Tour of heroes app code coverage What is unit testing Unit testing is a software testing approach that involves testing individual units or components of a software system in isolation to ensure they function correctly I know that a lot of people struggle to write good unit tests So I decide to prepare clear example of most popular angular learning app Tour of heroes with code coverage REPOSITORY angular tour of heroes jest coverageI hope the repository will help many people If you like my work and want to support me to work hard please donate via Revolut website payment or use the QR code above Thanks a bunch for supporting me It means a LOT |
2023-06-12 10:38:28 |
海外TECH |
DEV Community |
Create and Publish a GitHub Action in Typescript - ULTIMATE 2023 GUIDE |
https://dev.to/this-is-learning/create-and-publish-a-github-action-in-typescript-ultimate-2023-guide-4igk
|
Create and Publish a GitHub Action in Typescript ULTIMATE GUIDEGitHub Actions are a powerful tool to automate your workflow They can be used to run tests deploy your code publish a package and much more The cool thing is there s a GitHub Actions Marketplace where you can find a lot of actions created by the community But what if you can t find the action you need You can create your own and publish it there In this tutorial we re going to see in detail how to Create a GitHub Action in TypescriptExpand our Action to support custom inputsIntegrate with GitHub s API to add labels to Pull RequestsUnit testing our actionDebugging in Visual Studio CodePublishing our action to the GitHub MarketplaceUsing our action in another repositorySome final touches to make our project more robust How to use this tutorialThis post will be much longer than usual you can skip through the chapters from the table of contents below but I d recommend you to follow each step and not skip anything One more great piece of advice is to create a new repository and follow along with the steps This way you ll have a working action at the end of the post and you ll be able to play with it and experiment rather than just reading a long tutorial and forgetting about of it The full code of this tutorial is available on GitHub on this repo so you can always refer to it if you get stuck Last but not least I also recorded a video version of this tutorial so if you prefer to watch it instead of reading you can do so here How to use this tutorialBuilding an MVPAction DefinitionProject setupProject codeBuilding the actionCreating the repositoryRunning the ActionCreating a workflowRunning the workflowRunning the action locallyReading inputsAdd inputs to the action definitionRead the input in the action codeUpdate the workflowRun the hello actionUse case Adding a label to new Pull RequestsUpdate the action codeUpdate the action definitionUpdate the workflowRun the actionRun the action Testing the actionSetupAdditional changesWriting the testsRunning the testsDebugging the actionSetupDebuggingInputsPublishing the actionBrandingPublishingGoing live on the GitHub MarketplaceUsing your actionFinal touchesKeeping dist up to dateFormatting amp LintingClosing Building an MVPLet s begin with an MVP Minimum Viable Product of our GitHub Action We ll start simple with an action having only the required parts to understand the basics then we ll add more features to it Action DefinitionThe definition is stored in the action yml file put directly in the root of the repository name My Custom Action description Say Hello author Leonardo Montini runs using node main dist index js The most minimal action definition is composed of a name and a runs object to define how the action is executed and what file to run description and author are optional In case your action has some inputs they will be defined in the action yml file as well in the inputs object inputs name description The name of the person to greet required true default World When publishing the action to the store you might want to customize the appearance of the action in the marketplace This can be done by adding a branding object to the action yml file branding icon activity color green Anyway for this MVP the first snippet will be enough Project setupLet s create an empty node project with npm init y You can now open package json and add the build script scripts build tsc Since we want to use Typescript we ll need to install it as a dev dependency npm install D typescriptThen we ll create a tsconfig json by running npx tsc init and we ll edit it to match our needs compilerOptions target ES module commonjs outDir lib esModuleInterop true forceConsistentCasingInFileNames true strict true skipLibCheck true Project codeWe can now create the src index ts file and start writing our action console log Hello World We re building an MVP right So let s keep it simple for now and focus on all the required steps We ll have time to expand it later Building the actionWe can now build the action by running npm run build which will execute the tsc command as we defined in the package json file This will create a dist folder containing the compiled code dist└ーindex jsIn case you see index js generated in the root of the project or inside src you might want to add make sure the outDir option to the tsconfig json file is properly set to dist Creating the repositoryIn case you haven t done it yet it s time to create a git repository as we ll need to push our code to GitHub soon git initDon t forget to add a gitignore file to the project to avoid committing files that shouldn t be tracked by git for example the node modules folder A quick way to do it is by running npx gitignore node which will create a gitignore file with the most common entries for a node project Note in this particular case we want to push the dist folder to GitHub so we ll need to remove the dist entry from the gitignore file git add git commit m Initial commit git remote add origingit push u origin main Running the ActionWe re all set It s time to run our action Creating a workflowOn GitHub Actions are executed by workflows A workflow is defined in a yml file stored in the github workflows folder of the repository so let s create it mkdir p github workflowstouch github workflows greet ymlThe name of the file doesn t matter but it s good practice to give it a meaningful name What matters is the content of the file which defines the workflow To keep it simple here are the minimal instructions you need name Say Helloon workflow dispatch jobs run my action name Checks if this action works runs on ubuntu latest steps uses actions checkout v uses In this case the action will checkout the current repository and then run the action we just created We put as the action path because we want to run the action from the current repository but we could also use a different repository How does GitHub know what action to run It s defined in the action yml file we created earlier One more line worth mentioning is on workflow dispatch which tells GitHub to run the workflow when we manually trigger it from the Actions tab I recorded a dedicated video about running GitHub Actions manually if you want to learn more about it Running the workflowWe can now push our code to GitHub and see the action in action git add git commit m Add workflow git pushOnce the code is pushed we can go to the Actions tab and trigger the workflow manually The workflow will start running and we ll see the logs of the action in the console Congratulations You just created and ran your first GitHub Action Running the action locallyIn case you want to run the action locally without having to commit push every time you can use the act tool npm install g actThen you can run the action by executing act in the root of the repository actYou can find more in my video about running GitHub Actions locally Reading inputsLet s make our action a bit more interesting by reading an input from the workflow Add inputs to the action definitionAs usual the first step is to define the input in the action yml file inputs name description The name of the person to greet required true default World Read the input in the action codeThen we can read the input in the action code const name getInput name console log Hello name But where does the getInput function come from It s defined in the actions core package which we need to install npm install actions coreAnd then add the import on top of the index ts file import getInput from actions core Update the workflowFinally we need to update the workflow to pass the input to the action uses with name Leonardo By adding the with section we re passing the name input to the action Run the hello actionWe can now run the action again and see the input being passed to the action If it doesn t work Error Cannot find module actions core that s ok we ll fix it in the next section when we inluce vercel ncc in the workflow Use case Adding a label to new Pull RequestsWe learned the basics we have our MVP ready to be expanded so let s do it We ll create a new action that will automatically run every time a new Pull Request is created and it will add a needs review label to it Update the action codeIn order to add a label to a Pull Request we need to use the GitHub REST API We can use the Octokit client to make the API calls Luckily for us there s an official package we can use npm install actions githubThen we can import the Octokit client and use it to add the label to the Pull Request Here s the full code import getInput setFailed from actions core import context getOctokit from actions github async function run const token getInput gh token const label getInput label const octokit getOctokit token const pullRequest context payload pull request try if pullRequest throw new Error This action can only be run on Pull Requests await octokit rest issues addLabels owner context repo owner repo context repo repo issue number pullRequest number labels label catch error setFailed error as Error message Unknown error run What happened here We read the gh token and label inputs from the workflow The token is a personal access token that we need to create and pass to the action More on that later The label is the name of the label we want to add to the Pull Request We create an instance of the Octokit client using the token We get the Pull Request number from the context payload pull request object This object is only available when the action is triggered by a Pull Request event We call the octokit rest issues addLabels method to add the label to the Pull Request In case something fails we catch the error and we set the workflow as failed with the setFailed function also coming from the actions core package Update the action definitionWe also need to update the action definition to add the new inputs inputs gh token description The GitHub token for authentication required true label description The label to be applied to the pull request required true Update the workflowFinally we need to update the workflow to run when PRs are opened or reopened on pull request types opened reopened and to pass the new inputs to the action uses with gh token secrets GITHUB TOKEN label needs review We re passing the GITHUB TOKEN secret to the action It usually does not require you any extra action as GitHub automatically creates it for you In case you get an error that says Resource not accessible by integration you need to make sure your token on that repository has write access You can do that by going to the Settings tab gt Actions gt General and scroll down to the Workflow permissions section Setting it to Read and write permissions will be enough Run the actionWe can now run the action again and see the label is added to the Pull Request However let s not forget to run npm run build first then we can commit and push the changes The reason is that we told GitHub that the action is located in the dist folder so we need to make sure that folder is up to date npm run buildgit add git commit m Add label to new Pull Requests git pushCool We can now create a new branch change a file and open a Pull Request We ll see the action running and adding the label to the Pull Request aaaand Error Cannot find module actions core What happened here If you look at your file in dist index js you ll see that the actions core package is not there That s because we didn t tell TypeScript to include it in the build A good way to include packages and condense everything in one file is with the tool vercel ncc Let s install it npm install vercel nccThen we can update our build script in package json to use it build tsc amp amp ncc build lib index js We also need to change outDir in tsconfig json to lib outDir lib You might also want to double check that lib is in your gitignore file but dist is not This is our desired behavior as lib will only have our code in javascript but dist will have the whole action Run the action We can now run npm run build again then commit and push the changes Create a new branch change a file and open a Pull Request This time you ll see the action running and adding the label to the Pull Request Testing the actionYou wouldn t push code into production without testing it right So let s write some tests for our action SetupWe ll use Jest to write our tests It works out of the box with Javascript but needs a little bit of configuration to work with TypeScript npm install D jest ts jest types jestWe also need to create a new config file for jest in the root of our project called jest config json preset ts jest testEnvironment node collectCoverage true coverageReporters lcov text summary collectCoverageFrom src ts coveragePathIgnorePatterns node modules tests testPathIgnorePatterns node modules We re telling jest to use the ts jest preset to run the tests in node to collect coverage and to ignore some files Additional changesWithout any extra configuration the build will also include test files which we don t want On tsconfig json we can add a new exclude property exclude node modules test ts And also if we d run tests now everything would run twice Why Because at the end of our index ts file we re calling the run function This is the entry point of our action and we want to run it when the action is triggered However we don t want it to run by default when we import the file in our tests A possible solution is to wrap the call to run in an if statement that checks if a jest environment variable is set if process env JEST WORKER ID run Writing the testsWe can now create a new file called index test ts in the src tests folder This is where we ll write our tests I have to say I m a bit lazy so I asked GitHub Copilot to write the tests for me guess what I also made a video on this topic At first they were not passing but after a few tweaks I got them to pass Here s an extract but you can find the full file in the repository import run from index import getInput setFailed from actions core import context getOctokit from actions github Mock getInput and setFailed functionsjest mock actions core gt getInput jest fn setFailed jest fn Mock context and getOctokit functionsjest mock actions github gt context payload pull request number repo owner owner repo repo getOctokit jest fn describe run gt beforeEach gt Clear all mock function calls and reset mock implementation jest clearAllMocks it should add label to the pull request async gt Mock the return values for getInput getInput as jest Mock mockReturnValueOnce gh token value getInput as jest Mock mockReturnValueOnce label value context as any payload pull request number Mock the Octokit instance and the addLabels method const mockAddLabels jest fn const mockOctokit rest issues addLabels mockAddLabels getOctokit as jest Mock mockReturnValueOnce mockOctokit Run the function await run Assertions expect getInput toHaveBeenCalledWith gh token expect getInput toHaveBeenCalledWith label expect getOctokit toHaveBeenCalledWith gh token value expect mockAddLabels toHaveBeenCalledWith owner owner repo repo issue number labels label value expect setFailed not toHaveBeenCalled Running the testsNow it s finally time to get rid of that test echo Error no test specified amp amp exit script in package json Just replace it with test jest This will run jest with the configuration we just created If you want to run the tests in watch mode you can use jest watch We can now run npm test to run the tests You should see something like this Our action works as intended and we have some tests to prove it Debugging the actionOur favourite tool is flooding the code with console log but we all know there s a better way to debug code Let s see how we can debug our action with Visual Studio Code SetupTo get started we need one more package in our dev dependencies ts node This will allow us to run our action directly from the source code without having to build it first npm install D ts nodeWith vscode the launch configuration is stored in a file called launch json We can create it by clicking on the debug icon in the sidebar and then on the gear icon or manually by creating a vscode launch json file with this content version configurations name ts node type node request launch args src index ts runtimeArgs r ts node register cwd workspaceRoot internalConsoleOptions openOnSessionStart DebuggingYou can now put a breakpoint in your code and click on the play button in the debug sidebar This will start the debugger and run your action You can also use the F key to start the debugger In this specific example there isn t too much to debug but if you re working on a more complex action this can be a lifesaver InputsAh I almost forgot what if your action has some inputs How can you debug it You can store them directly in your launch configuration as environment variables with the following rules the will get picked up by getInput prefix the name of the input with INPUT name the input in uppercaseIn our example it would be something like this version configurations name ts node type node request launch args src index ts runtimeArgs r ts node register cwd workspaceRoot internalConsoleOptions openOnSessionStart env INPUT GH TOKEN secret token INPUT LABEL needs review If you now hit F to start the debugger you ll see that the environment variables are available in your action and are properly read by getInput Publishing the actionThe paragraph you ve all been waiting for I m sure you also skipped the previous one about debugging to jump straight to this one BrandingHold on for a second if you remember we mentioned the branding section in the action yml file Let s see what it s all about branding icon activity color green This will add a nice icon and a color to your action in the GitHub Marketplace You can find the list of available icons here PublishingOk here we are How do we publish our action Just look at your GitHub repo If you ve properly set up an action yml file you should see a banner at the top of the page like this one Going live on the GitHub MarketplaceClick on Draft a release and you will get to a page where you can set up all the required missing information for example a well written and informative README mdfile You can decide if you only want to make the action available to everyone or you also want it to be published and discoverable in the GitHub Marketplace You can also select a primary and a secondary category from the list of available ones The next step will be creating a tag and an official release for your action Almost there click the Publish release green button and you re done Congratulations you ve just published your first GitHub Action Using your actionNow that you ve published your action everyone can use it in their workflows Just create a new file in your repo for example github workflows label yml and add the following content name Label PRon pull request types opened reopened jobs label runs on ubuntu latest steps uses actions checkout main uses Balastrong gh aciton test latest with gh token secrets GITHUB TOKEN label needs reviewTo specify the version you can either use owner repo version with version being the tagged version on the repo like v or owner repo branch Final touchesThe action is complete it s live in the store and it works on all GitHub repositories but unless it s complete and you won t ever update it again you still have some room for improvements for a better developer experience DX is quite trending these days Keeping dist up to dateOne thing which will annoy you in this workflow is pushing new code and forgetting to also update the dist content I mean all you have to do is just make sure to run npm run build before pushing but if something relies on just remember to do it well good luck A simple way to solve this is to use a git hook You can use the pre commit hook to run a script at each commit in your repository This will work for you but what if you re working with other people Ah just kindly tell them to install the hook as well did I already say good luck A Dog Yes specifically a Husky Husky is a tool which allows you to easily add git hooks to your project It s very easy to set up and it will make sure that everyone who clones your repo will have the hooks installed as well as they are part of the project and get installed with the dependencies right after running npm install No need to rely on people remembering to install them Let s follow the official docs and install it npx husky init amp amp npm installYou will now find a husky folder in your project with a pre commit file in it Open it and replace the content with this npm run buildNow make sure to run npm install once to update the hook This will make sure that every time you commit the dist folder will be updated Formatting amp LintingSince we already set up our pre commit hook we can also add some formatting and linting to it This will make sure that the code is always properly formatted and that there are no linting errors Let s install Prettier and ESLint npm install D prettier eslint lint stagedWe will also need to install some plugins for ESLint npm install D typescript eslint eslint plugin latest eslint plugin jest latestWe can now configure eslint and prettier Create a eslintrc file in the root of your project and add the following content plugins jest typescript eslint parser typescript eslint parser extends eslint recommended plugin typescript eslint recommended env node true jest globals true ignorePatterns test ts Let s also add a prettierrc file trailingComma es printWidth tabWidth Last touch we want to run these two only on the staged files which means one more config file for lint staged Create a lintstagedrc file and add the following content src js ts prettier write eslint max warnings Now we can update our pre commit hook to run lint staged as well npx husky add husky pre commit npx lint staged One more npm install and we re done ClosingIf you followed all steps you now have a pretty solid GitHub Action published in the GitHub Marketplace which is automatically built and linted on each commit Ready to make a great Open Source project If you want to see the final result you can check out the GitHub Action I created while writing this article You can also use it as a reference if you missed some steps Want to see me following along the steps in this article Check out the video here What else to say I hope you enjoyed this article and that you learned something new If you have any questions feel free to add a comment below or reach out to me on Twitter This was much longer than usual I had a lot of fun writing it and I learned a lot myself in the process Would you like more long articles like this one Let me know See you next time Thanks for reading this article I hope you found it interesting I recently launched my Discord server to talk about Open Source and Web Development feel free to join Do you like my content You might consider subscribing to my YouTube channel It means a lot to me ️You can find it here Feel free to follow me to get notified when new articles are out Leonardo MontiniFollow I talk about Open Source GitHub and Web Development I also run a YouTube channel called DevLeonardo see you there |
2023-06-12 10:37:13 |
海外TECH |
DEV Community |
WEEK #1 🔥: 10 Dev tools🛠️for Developers 👨💻 |
https://dev.to/elliot_brenya/week-1-10-dev-tools-for-developers-1jak
|
WEEK Dev tools️for Developers Welcome to my exciting new series in this series I will be introducing a wide range of developer tools every single week Let s kick off week one with an extraordinary topic that will undoubtedly pique your interest Today I have the pleasure of introducing you to not just one or two but a whopping ten exceptional Dev tools that every developer should be familiar with TypoAn intelligent Engineering Management platform that integrates with your tech tool stack amp provides real time visibility insights amp tools modern software teams need to maximize engineering efficiency WaspWasp is a full stack web framework for React amp Node js with unique twist that it uses a special config language giving it superpowers Wasp solve the common problems you face when you start developing a web app choosing all the parts of the stack figuring out how to stitch them together in the best way adding auth and running cron jobs BuildlessBuildless caches compiled code and makes it available over the internet to exponentially accelerate developer velocity LightyearLightyear helps developers write powerful integrations in a few lines of code Focus on solving your core problems With built in authentications and serverless infrastructure Lightyear takes the complexity out of API automation Webhooks Wizard Webhooks Wizard helps you manage your webhooks through the entire lifecycle from delivering monitoring disaster recovery and support CodeguideCodeguide is an open source tool for creating and viewing code guides For onboarding explaining the context of a code review and more StreamDocs Online StreamDocs Online will simplify your web app development process with secure cloud based access to our PDF API Generate a few lines of code that will seamlessly integrate our PDF viewer into your projects Gain fast high fidelity rendering PDF customization analytics and more Feedbug Feedbug is visual feedback tool that helps builders gather more feedback from their MVP users Feedback is provided through sticky notes on the screen reducing friction for users Builders can sort the feedback visually to prioritize the requests that matter AirboxAirbox is a platform for developers Tools and utilities for the developers programming needs all in one place CronToolCronTool is a free tool to debug edit learn and view crontab cron expressions Write cron schedules with ease no registration required ConclusionBy introducing you to these tools my aim is to equip you with the knowledge and resources to excel in the ever evolving world of technology As we progress through this series we will continue to uncover more exciting developer tools unravel their functionalities and understand how they can empower you as a developer |
2023-06-12 10:23:23 |
海外TECH |
DEV Community |
I Published 4 Free ReactJS Coding Challenges: Build Functionality for Responsive UI |
https://dev.to/abdulbasit313/i-published-4-free-reactjs-coding-challenges-build-functionality-for-responsive-ui-35o
|
I Published Free ReactJS Coding Challenges Build Functionality for Responsive UIFront end developers play multiple roles in software companies If we categorize these roles we will see two broad categories UI developers and business logic developers The UI developer implements the design while the other implements the logic and makes the app functional The second one requires sound logic practice because you have to make UI work accordingly We are here with some interesting Reactjs Challenges for you that will help you test your ReactJS skills These are basically coding challenges in which the user interface is already built in Reactjs and it is also responsive but not functional and your job is to make them functional by writing business logic using Reactjs mainly Javascript In the section below User Stories are given so to make the UI functional you have to fulfill all the User Stories Tech Stack ReactJS with Typescript Who Can Use these ReactJS Coding Challenges Beginner developers looking for a fun little frontend coding challenges to test their ReactJS logic building skillsDevelopers interested in building small tools that they can convert into micro SAASCompanies looking for ReactJS hiring challenges to assess their candidate s ReactJS coding skills List of Reactjs ChallengesAll challenges are free I wanted the challenges to be different and designed them carefully In each challenge I have covered different skill sets of JavaScript and Reactjs from the array to object the string to regex and Reactjs hooks Challenge Text Analyzer ToolIt is an easy challenge in which you have to build logic for a text analyzer that will count the number of words letters paragraphs and more of the text written in the textarea Challenge Description Demo App Challenge React Password GeneratorThis challenge is suitable for beginners as well In this challenge you will develop logic for a password generator including options for creating and validating a password with a specified strength copying the password and passwords with desired characters Challenge Description Demo App Challenge Random Quote GeneratorChallenge yourself to build a random quote generator using ReactJS and showcase your front end development skills Flourish your creativity with this fun code challenge This challenge differs slightly from Text Analyzer and Password Generator because you need to fetch data from json server using Axios Challenge Description Demo App Challenge CRUD Typescript Tasklist AppThis React Typescript Tasklist Todo challenge requires you to perform CRUD operations with instructions to write clean reusable manageable and scalable code This challenge is different and more challenging than the last three challenges you have completed If you can complete this ReactJS Typescript Tasklist challenge independently you can be easily hired as an intern junior React developer Challenge Description Demo App What to do when you complete ReactJS challenge Compare your code with mine As there are many ways to do coding challenges and build logic you can go through my code to compare and learn to write less lines of code Add to your Portfolio You can also add these challenges to your portfolio but after changing the overall layout of the tool You can use your own theme and customize it in any way to make it more impressive Since we are using themes for CSS you only have to replace or add variables in the theme file Share on your Twitter handle You can also share your answer or your experience of ReactJS coding challenge on Twitter by adding codevertiser DaysOfCode if you are following the journey frontEndChallenges reactjsChallenges Can you star the ReactJS Challenges GitHub repo I love creating free content that helps developers start their jobs and excel in their careers Each challenge requires a lot of time to create First I brainstorm the challenge idea Then I collaborate with a freelance UI UX designer to design the idea After that I convert the design into code and write content for the challenge It s a lengthy process that requires time energy and resources By starring ReactJS Coding Challenges repository you will motivate me to create more free content like this |
2023-06-12 10:19:53 |
Apple |
AppleInsider - Frontpage News |
Sony refuses to increase Vision Pro screen production capacity for Apple |
https://appleinsider.com/articles/23/06/12/sony-refuses-to-increase-vision-pro-screen-production-capacity-for-apple?utm_medium=rss
|
Sony refuses to increase Vision Pro screen production capacity for AppleEven as analysts predict limited supplies of the Apple Vision Pro at launch Apple has apparently asked Sony to make more of the headset s eye screens ーand Sony has said no It had been expected that a small number of Apple Vision Pro headsets might be on sale for the holidays until Tim Cook quashed that by saying they ll go on sale early in Whenever the headset is available to buy though it s believed that Apple will start by making a limited number of under devices in its first year Apple is already looking to the future though and not only with the rumors of a lower cost second edition of the headset According to The Elec Apple has asked Sony to be ready to make more Read more |
2023-06-12 10:54:06 |
Apple |
AppleInsider - Frontpage News |
15-inch MacBook Air vs 14-inch and 16-inch MacBook Pro -- compared |
https://appleinsider.com/inside/macbook-air/vs/15-inch-macbook-air-vs-14-inch-and-16-inch-macbook-pro----compared?utm_medium=rss
|
inch MacBook Air vs inch and inch MacBook Pro comparedApple s inch MacBook Air fits into a size gap between the inch MacBook Pro and inch MacBook Pro but while not as powerful it s still a great value notebook Here s how the specs compare inch MacBook Air left inch and inch MacBook Pro right The inch MacBook Air has always been the value oriented offering in the MacBook line While it didn t necessarily offer blistering specifications it was pitched as being able to handle a typical user s on the go computing needs while still being light and easy to carry Read more |
2023-06-12 10:42:10 |
Apple |
AppleInsider - Frontpage News |
How to get started with macOS AppleScript: dictionaries, syntax, and more |
https://appleinsider.com/inside/macos/tips/how-to-get-started-with-macos-applescript-dictionaries-syntax-and-more?utm_medium=rss
|
How to get started with macOS AppleScript dictionaries syntax and moreAppleScript is Apple s powerful automation language for macOS Here s how to use it to speed up your workflow when using your Mac HistoryAppleScript was born in the early s at Apple in an attempt to modernize the Mac s OS It was partly derived from an earlier script language designed by one of the original Mac architects Bill Atkinson who wrote the original Mac s graphics system QuickDraw Read more |
2023-06-12 10:07:28 |
ラズパイ |
Raspberry Pi |
Introducing the Hello World newsletter |
https://www.raspberrypi.org/blog/hello-world-newsletter/
|
Introducing the Hello World newsletterLaunched six years ago Hello World magazine is the education magazine about computing and digital making It s made for educators by educators and a community of teachers around the world reads and contributes to every issue We re now starting a monthly Hello World newsletter to bring you more great content for computing educators while you The post Introducing the Hello World newsletter appeared first on Raspberry Pi Foundation |
2023-06-12 10:33:07 |
医療系 |
医療介護 CBnews |
介護DBオープンデータに施設類型の集計を追加へ-匿名LIFE情報も 厚労省 |
https://www.cbnews.jp/news/entry/20230612190722
|
介護保険 |
2023-06-12 19:20:00 |
医療系 |
医療介護 CBnews |
インフル患者2週連続減も過去10年同期比で最多-学級閉鎖の報告続く、厚労省が発生状況を公表 |
https://www.cbnews.jp/news/entry/20230612190825
|
厚生労働省 |
2023-06-12 19:15:00 |
金融 |
金融庁ホームページ |
入札公告等を更新しました。 |
https://www.fsa.go.jp/choutatu/choutatu_j/nyusatu_menu.html
|
公告 |
2023-06-12 11:00:00 |
金融 |
金融庁ホームページ |
「気候変動リスク・機会の評価等に向けたシナリオ・データ関係機関懇談会」(第6回)の開催を公表しました。 |
https://www.fsa.go.jp/news/r4/singi/20230614.html
|
気候変動 |
2023-06-12 10:59:00 |
金融 |
金融庁ホームページ |
「気候変動リスク・機会の評価等に向けたシナリオ・データ関係機関懇談会」(第5回)議事次第を公表しました。 |
https://www.fsa.go.jp/singi/scenario_data/siryou/20230517.html
|
気候変動 |
2023-06-12 10:58:00 |
金融 |
金融庁ホームページ |
「気候変動リスク・機会の評価等に向けたシナリオ・データ関係機関懇談会」(第5回)議事要旨を公表しました。 |
https://www.fsa.go.jp/singi/scenario_data/gijiyousi/20230517.html
|
気候変動 |
2023-06-12 10:58:00 |
海外ニュース |
Japan Times latest articles |
What you need to know about the revision of Japan’s asylum law |
https://www.japantimes.co.jp/news/2023/06/12/national/asylum-law-revision-explainer/
|
What you need to know about the revision of Japan s asylum lawThe law which has prompted widespread debate seeks to address perceived drawbacks of Japan s existing legislation and standard handling of asylum matters |
2023-06-12 19:21:52 |
海外ニュース |
Japan Times latest articles |
Culture at Johnny’s to be scrutinized amid investigation into abuse claims |
https://www.japantimes.co.jp/news/2023/06/12/national/johnny-kitagawa-abuse-organizational-culture/
|
Culture at Johnny s to be scrutinized amid investigation into abuse claimsA team of experts hired by the talent agency have said they will “independently and “exclusively investigate claims of sexual assaults by late founder Johnny |
2023-06-12 19:17:49 |
ニュース |
BBC News - Home |
Woman arrested after children's deaths at Stoke-on-Trent home |
https://www.bbc.co.uk/news/uk-england-stoke-staffordshire-65875658?at_medium=RSS&at_campaign=KARANGA
|
homethe |
2023-06-12 10:50:30 |
ニュース |
BBC News - Home |
Warning UK mortgage rates set to rise further |
https://www.bbc.co.uk/news/business-65876570?at_medium=RSS&at_campaign=KARANGA
|
deals |
2023-06-12 10:21:53 |
ニュース |
BBC News - Home |
Chloe Mitchell: Brandon John Rainey, 26, on murder charge |
https://www.bbc.co.uk/news/uk-northern-ireland-65875297?at_medium=RSS&at_campaign=KARANGA
|
ballymena |
2023-06-12 10:32:50 |
ニュース |
BBC News - Home |
Three Britons dead after boat fire - tour operator |
https://www.bbc.co.uk/news/uk-65876322?at_medium=RSS&at_campaign=KARANGA
|
foreign |
2023-06-12 10:26:06 |
ニュース |
BBC News - Home |
Ofsted school inspections to change after Ruth Perry's family campaign |
https://www.bbc.co.uk/news/education-65856139?at_medium=RSS&at_campaign=KARANGA
|
campaignreforms |
2023-06-12 10:10:46 |
ニュース |
BBC News - Home |
Silvio Berlusconi: AC Milan pay tribute to 'unforgettable' owner, who has died at 86 |
https://www.bbc.co.uk/sport/football/65876633?at_medium=RSS&at_campaign=KARANGA
|
Silvio Berlusconi AC Milan pay tribute to x unforgettable x owner who has died at AC Milan have paid tribute to unforgettable former owner Silvio Berlusconi following his death at the age of on Monday |
2023-06-12 10:53:28 |
ニュース |
BBC News - Home |
Women's Ashes 2023: Kate Cross in England Test squad after parasite illness |
https://www.bbc.co.uk/sport/cricket/65877302?at_medium=RSS&at_campaign=KARANGA
|
Women x s Ashes Kate Cross in England Test squad after parasite illnessKate Cross England s most senior bowler is named in the Ashes Test squad after multiple rounds of antibiotics to treat a parasite infection |
2023-06-12 10:54:34 |
IT |
週刊アスキー |
『Lies of P』体験版が配布からわずか3日で世界累計100万DLを突破!! |
https://weekly.ascii.jp/elem/000/004/140/4140622/
|
liesofp |
2023-06-12 19:55:00 |
IT |
週刊アスキー |
いよいよ明日朝7時から!「カプコンショーケース 2023.6.13」ミラー配信チャンネルを公開 |
https://weekly.ascii.jp/elem/000/004/140/4140620/
|
日本時間 |
2023-06-12 19:50:00 |
コメント
コメントを投稿