teleren/devto huggingface dataset:
Ask the Experts: Understanding the API Context Maturity Model - Level 3 - Purpose and Use Defined API Calls
Published: 2023-08-16 09:00:00

**By: Mayur Upadhyaya & Jamie Beckland**

Continuing with our journey up the API Context Maturity Model, we've arrived at Level 3 - Purpose and Use Defined API Calls. As our API usage expands, so does the complexity and potential security concerns. Now, we take our API security strategy a step further by focusing on the defined purpose and use of each API call.

As a reminder, we have distilled key comments from the hundreds of technology leaders we consulted to develop the [Context Maturity Model](https://bycontxt.com/blog/introducing-the-api-context-maturity-model?utm_source=DevTo), and we are sharing their thoughts anonymously to give you the most unfiltered view of the current state of APIs.

Defining the purpose and use of API calls may seem intuitive, but it is a level that many organizations struggle to reach. At Level 3, each API call is associated with a specific purpose and use. This ensures that the system only allows API calls that match the defined purpose and use, further reducing the risk of data leaks or misuse.

One IT leader at a global retailer conveyed how defining purpose and use made a difference. "Once we began associating specific uses with each API call, we gained a better understanding of our data flows. It also helped us spot abnormal behaviors much quicker."

However, there are challenges as well. Defining the purpose and use for each API call requires a detailed understanding of the business operations and comprehensive mapping of data flows, which can be a complex process for larger organizations.

A CISO of a multinational healthcare company described their journey: "Mapping our data flows and aligning them with our API calls was quite a challenge. But the visibility it provided in terms of our data processing activities was worth it."

As organizations start defining the purpose and use of their API calls, they take a significant step toward achieving more secure and manageable API ecosystems.

In the next post of this series, we will explore the final level of the API Context Maturity Model - Level 4, where organizations achieve compliance with open standards. Stay tuned to learn about the benefits and challenges that come with reaching the peak of API maturity. As always, we encourage you to reach out with any questions or comments on your journey to better API security.
What is a Bundle ID
Published: 2023-08-16 08:59:36

What is a Bundle ID
Firstly, let's take a look at the 'Bundle ID' module. 
1. Create a Bundle ID
Click on Bundle ID
Then click on "Add" in the upper right corner to add a new Bundle ID. 
2. Modify and delete Bundle ID
By clicking on 'Settings', we can also modify the name of the Bundle ID. If it is no longer needed, we can click on' Delete '.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ome8uoyt95qwu49m3a98.png)
Crunch the frontend
Published: 2023-08-16 08:58:29

In the previous article, I talked about the different things that I tried and how I came up with an initially deployment strategy of hosting a PWA on Google PlayStore using the TWA technology

Let's talk about the work that was done on the project so far.

Note that the date of this writing is Aug 16th.

## Day 7(Aug 9th) to Day 9(Aug 11th)

In this period, I started by deleting some of the junk react native code that I added to the project when trying experimenting merging both react native and next js in the same project. 

After that, I went on the implement components for the connections, notification, settings and events page. Previously I had done the empty states of these pages but now I implemented the page with content. 

Note that since we do not have a backend api yet all of these are just staitic dummy pages. 

Also whent on to create modals that would allow users to edit their profile and invite people to the application. 


## Day 10(Aug 12th) to Day 11(Aug 13th)

These 2 days were weekends and since I had made good progress in the project, I didn't touch it at all and used that as an opportunity to catch up with friends. 

It is very important to have maintain this balance. If not one is at the risk of burn out.

It was also an opportunity to relax my mind and take a break everything



## Day 12(Aug 14th) to Day 16(Aug 17th)

I didn't do much on these days because I fell ill on Aug 15th and I am currently on medication while writing this.


However, the current plan is to test out that deployment assumption and convert the app to a PWA before moving forward. 

I would like to test that idea as early as possible so as not to be surprised when I am actually ready to deploy.


## Next steps

If I can do create the PWA quickly then I would start working on the backend. 

My strategy there is to comsume the API as I create them. 

This is the list of things that the API should be able to do:


1.Authentication
  a. Login with Google
  b. Login with Password and Email
  c. Signup with email and password
2. Create,Update and Delete Events
3. Send connection request
4. Accept connection request
5. Remove connection
6. Send emails to users:
   a. Setup email sending with AWS SES
   b. Create templates for Authentication
   c. Create templates for upcoming events reminder
   d. Create templates for 
7. Send emails when:
   a. User registers
   b. Beginning of the month with a list of upcoming events for that month
8. User can edit profile

Looks almost like I haven't even started


## Conclusion
Had a bit of set back with the illness but hopefully I'll be back very quickly and conver more grounds in this one
Import a Garoon Event to Google Calendar Bookmarklet
Tags: garoon, googlecalendar, bookmarklet, javascript
Published: 2023-08-16 08:51:09

# Import a Garoon Event to Google Calendar Bookmarklet

## Usage

Initial Setup
1. Copy the below `Garoon_to_Google_Bookmarklet.js` code block
1. Go to Bookmark manager (`chrome://bookmarks/`) > Click on the `⋮` at the top-right-corner
1. Click `Add new bookmark` & paste the code in the URL field

Importing a Garoon Event to Google Calendar
1. Go to the Garoon event's page
1. Click on the Bookmark
1. Confirm the imported event in Google Calendar & click `Save`

## Not working? 🤔
* Open browser console
  * Mac: `Command+Option+C`
  * Windows, Linux, Chrome OS: `Control+Shift+C`
* Check if you are getting an error message

## Garoon_to_Google_Bookmarklet.js

```javascript
javascript: (() => {
  const formatTimestamp = (dateString) =>
    new Date(dateString).toISOString().replaceAll(/[-:]|\.\d+/g, '');
  const bodyFormat = (inputText) => inputText.replace(/\n/g, '<br>');
  const addCalendar = (event) => {
    console.log({ event });
    const start = formatTimestamp(event.start.dateTime);
    const end = formatTimestamp(event.end.dateTime);
    const origin = location.origin.replace('.s.', '.');
    const url = `${origin}${location.pathname}?event=${event.id}`;
    const body = bodyFormat(event.notes);
    const params = new URLSearchParams({ action: 'TEMPLATE' });
    params.set('dates', `${start}/${end}`);
    params.set('text', event.subject);
    params.set('location', url);
    params.set('details', body);
    open(`https://www.google.com/calendar/render?${params.toString()}`);
  };
  const event = window.garoon?.schedule?.event?.get();
  if (event === undefined) {
    alert(
      `Error: Not on a Garoon event.\nPlease open a specific Garoon event.`
    );
    return;
  }
  addCalendar(event);
})();
```

## References
* [Google - add-event-to-calendar-docs](https://interactiondesignfoundation.github.io/add-event-to-calendar-docs/services/google.html)
* [スケジュールオブジェクト - cybozu developer network](https://cybozu.dev/ja/garoon/docs/overview/schedule-object/)
کسب درآمد دلاری
Published: 2023-08-16 08:48:17

اگر مشتاق به کسب درآمد دلاری هستید و می‌خواهید درباره‌ی کسب درآمد دلاری بیش بدانید، [آموزش کسب درآمد دلاری(۵ روش جدید ۱۴۰۲) ](https://chortkee.com/%D8%AF%D8%B1%D8%A2%D9%85%D8%AF-%D8%AF%D9%84%D8%A7%D8%B1%DB%8C/)را مطالعه نمایید
How generate images with Azure DALL·E 2 in JavaScript
Tags: javascript, node, openai
Published: 2023-08-16 08:45:02

If you're a JavaScript developer, eager to access a DALL·E 2 instance on Microsoft Azure, here's a brief workaround until the official OpenAI Node Library supports this.

I figured out the urls by reverse engineering the DALL·E playground (Preview) in the Azure AI Studio.

This is definitely not a proper solution 😅, but it should give you an idea how to do it.

```js
import { setTimeout as sleep } from "node:timers/promises";

const baseUrl = "https://{YOUR-AZURE-INSTANCE-NAME}.openai.azure.com/openai";

const headers = {
  "API-Key": "AZURE_OPENAI_API_KEY",
  "Content-Type": "application/json",
};

const requestBody = {
  prompt: "your dall-e 2 prompt",
  size: "512x512",
  n: 1,
};

const response = await fetch(
  `${baseUrl}/images/generations:submit?api-version=2023-06-01-preview`,
  {
    method: "POST",
    headers,
    body: JSON.stringify(requestBody),
  }
);

// returns { "id": "xxx", "status": "notRunning" }
const initJob = await response.json();

const jobId = initJob?.id;

/**
 * the image generation may take a while, 
 * so you need to ask the api for a status in intervals.
 * In this case I try it 5 times before giving up
 */
for (let i = 0; i < 5; i++) {
  // Wait 1.5 seconds after a request
  await sleep(1500);

  const response = await fetch(
    `${baseUrl}/operations/images/${jobId}?api-version=2023-06-01-preview`,
    {
      method: "GET",
      headers,
    }
  );

  /**
   * either returns
   * { "created": 1234567, "id": "x-x-x-x-x", "status": "running" }
   * 
   * or
   * 
   * { "created": 1234567, "expires": 7654321, "id": "x-x-x-x-x", "status": "succeeded"
        "result": { "created": 1234567,
            "data": [
                {
                    "url": "https://pathtotheimage"
                }
            ]
      }}
   */
  const job = await response.json();

  if (job.status === "succeeded") {
    console.info("DALL-E 2 image", job?.result?.data[0]);

    // exit the for-loop early since we have what we wanted
    break;
  }
}
```

And that's it - hope this helps 🙂
Create decorator to validate types of a method
Tags: python
Published: 2023-08-16 08:40:44

```python
def validate_types(func):
    def wrapper(*args, **kwargs):
        annotations = func.__annotations__
        param_types = [annotations[param_name] for param_name in annotations]
        for arg, param_type in zip(args, param_types):
            if not isinstance(arg, param_type):
                raise ValueError(f"Expected type '{param_type.__name__}', got '{type(arg).__name__}' instead")
        for param_name in kwargs:
            param_value = kwargs[param_name]
            param_type = annotations[param_name]
            if not isinstance(param_value, param_type):
                raise ValueError(f"Expected type '{param_type.__name__}', got '{type(param_value).__name__}' instead")
        return func(*args, **kwargs)
    return wrapper
```
How to use
```python
@validate_types
def add(a: int, b: int) -> int:
    return a + b
```
How To Stay Motivated While You Are Coding
Tags: webdev, productivity, coding, motivation
Published: 2023-08-16 08:39:46

Coding is a rewarding experience but maintaining motivation to code can be challenging especially when faced with complex problems and long coding sessions. Staying motivated throughout the coding process is essential to overcome obstacles and produce high quality results. Fortunately, we will be exploring several strategies in this blog post that you can employ to keep your motivation levels high and make your coding journey enjoyable.

## Set clear goals.
You must have a concrete goal in mind when you are starting out. Think what your goal is about and you should know your why when creating them. Once you have it, write it down in a place that you will see it often which will help remind you of your goals and remember to set goals that are realistic.

## Join a community.
Connect with other coders by joining an online coding communities like; [Dev Community](https://dev.to/), [freeCodeCamp](https://www.freecodecamp.org/), [Hashnode](https://hashnode.com/), [Hackernoon](https://hackernoon.com/), [Codewars](https://www.codewars.com/) and [Codenewbie](https://www.codenewbie.org/). These communities can provide support, motivation and a helping resource when you encounter problems or when you are stuck with your project or when learning a programming language. Other coders can also provide feedback on your project.

## Celebrate small wins.
Acknowledge your achievements no matter how small whether it is successfully debugging a piece of code or implementing a new feature or completing coding tasks, these mini-wins can provide a continuous stream of motivation. Rewarding yourself boosts your confidence and keeps your motivation high.

## Create a comfortable workplace.
Your physical workspace plays a significant role in your motivation. A well-organized workspace can boost your focus, creativity and help you stay engaged in your coding tasks. Personalize your workspace with elements that inspire you such as motivational quotes.

## Stay curious and learn continuously.
Cultivate curiosity and embrace the opportunity to learn new technologies because technology is rapidly evolving. Exploring new languages, libraries and frameworks can keep coding exciting and prevent stagnation.

## Take breaks.
Take breaks in between your coding sessions, use the [pomodoro technique](https://todoist.com/productivity-methods/pomodoro-technique) and use these breaks to stretch or take a walk. Returning to code with a refreshed mind can reignite your motivation.

## Embrace challenges.
Instead of feeling discouraged by coding challenges view them as opportunities for growth. The sense of achievement you will experience after conquering a difficult task can be a strong motivator.

## Conclusion
Staying motivated while coding is an essential skill that can lead to increased productivity, better code quality and an overall positive coding experience. By implementing the above strategies you can maintain your love for coding throughout your journey as a developer.
What is side-effect in ReactJS and how to handle it?
Tags: webdev, react, javascript, beginners
Published: 2023-08-16 08:36:28

**What is side Effects**

ReactJS is a UI library. It’s job is to render the UI and update it on user's interaction or events. Eg: if a user has clicked on a button then update the UI accordingly. However, there are many events which doesn't require any user's interaction or event. Eg: API data on load of application, a user has logged in and we want to keep the users information and update the themes, or other information. Such requirements which doesn't need any user events, or interaction is known as "side effects" in ReactJS

**Why we need side effects**

There are a lot more operations in ReactJS which won't require user's events/interactions but they are crucial to do the application work.


**what is useEffect hook**

useEffect() is a hook by ReactJS and it allows us to handle such side effects in the react component. It give us the correct way to handle the side effects in ReactJS code.

_Loved this blog? I have created a video on the same topic and in Hindi:(Learn useEffect in less than 15 mins) [https://youtu.be/Jbb_xJfURhI]_

**syntax of useEffect**

```JavaScript
   useEffect(() => {}, []);
```

`useEffect()` has 2 parts: 

1. method : Here we will write our side effect code

2. dependencies : Dependencies array is a place where we declare dependencies and which will decide when useEffect() should execute

**useEffect() & dependency array**

useEffect() also works as the lifecycle hook in ReactJS. This would depends on the dependency array.

**1 . Omit dependency array**

```javascript
 useEffect(() => { 
  console.log('I am running');
})
```

This will run every time the component will re-render and 1st time too. This is `componentDidMount`, and `componentDidUpdate` lifecycle hooks.

We should keep those side effects here which you want every time when the component is re-rendering.

**2 . Blank dependency array**

```javascript
 useEffect(() => { 
  console.log('I am running');
},[])
```

This will run only once at the initial mount of the component and after that it won't run. You can have those side effects which you only want at the first time of mounting of your component. Eg: API request.

**3 . Value in dependency Array**

```javascript
 useEffect(() => { 
  console.log('I am running');
},[ count ])
```

Here we have added a state in the dependency array. This will make the useEffect to run once at the load time, and then whenever the state count will change. This will act as the `componentDidUpdate` and `componentDidMount`

**4 . cleanup**

If we need to do any cleanup of side-effect before the unmounting, and component re-render before the component re-render due to change in the state we can use the useEffect to do the same. 

Please remember this is optional

```javascript
 useEffect(() => { 
  console.log('I am running');
   return () => {
      // your clean up code
   }
},[ count ])
```

Happy Learning!!
How to active nektos/act with Rancher Desktop on MacOS
Tags: docker, rancher, githubactions
Published: 2023-08-16 08:32:50

act supports running github actions locally

https://github.com/nektos/act

How to active it with Rancher Desktop on MacOS

requires::
* act was installed
* Rancher Desktop was installed

## Fixed the docker.sock issue

fist after running act you will see below

```bash
$ act
```

> daemon Docker Engine socket not found and containerDaemonSocket option was not set


you can fix by below

```
sudo ln -s ~/.rd/docker.sock /var/run/docker.sock
```
LLM Systems
Tags: llm, ai, deeplearning
Published: 2023-08-16 08:07:46

Hi!

We have started work on introducing LLM into our corporate system, but we cannot choose which model to choose. Who has experience using it? Which LLM was used?

There are the following criteria:
1. Open source
2. No need to transfer your data to the developer's server during further training
3. Minimization of computing resources without loss of accuracy.

I will be glad of your advice!

P.S. We considered BERT-like systems, Lama, T5, BAR, BLOOM
Socolive trực tiếp, Trực tiếp bóng đá Socolive tốc độ cao
Published: 2023-08-16 08:06:20

Socolive trực tiếp - Xem trực tiếp bóng đá Socolive tốc độ cao miễn phí tại dichungnao.vn, chuyên bình luận trực tiếp bóng đá trực tuyến với đội ngũ BLV chuyên.
Website :       https://dichungnao.vn/
SĐT 0988 776 556
Địa chỉ 66 Lê Duẩn, Phường 3, Quận Hoàn Kiếm, thành phố Hà Nội

https://twitter.com/dichungnao

https://www.linkedin.com/in/dichungnao/

https://about.me/dichungnao

https://www.youtube.com/@dichungnao/about

https://www.reddit.com/user/dichungnaovn

https://www.pinterest.com/dichungnaovn/

https://www.flickr.com/people/dichungnao/

https://www.tumblr.com/dichungnao

https://dribbble.com/dichungnao/about

https://tapas.io/dichungnaovn

https://replit.com/@dichungnaovn

https://www.instapaper.com/read/1626876570

https://hub.docker.com/u/dichungnao

https://sketchfab.com/dichungnaovn

https://www.diigo.com/profile/dichungnaovn

https://linkhay.com/u/dichungnaovn

https://www.twitch.tv/dichungnao/about

https://en.gravatar.com/dichungnao

https://www.openstreetmap.org/user/dichungnao

https://folkd.com/user/dichungnaovn

https://gab.com/dichungnao
Kotlin Code Smell 29 - Taming the RegEx Beast for Cleaner Code
Tags: kotlin, codesmells, cleancode, programming
Published: 2023-08-16 12:08:26

---
title: Kotlin Code Smell 29 - Taming the RegEx Beast for Cleaner Code
published: true
date: 2023-08-16 08:00:09 UTC
tags: kotlin,codesmells,cleancode,programming
canonical_url: https://yonatankarp.com/kotlin-code-smell-29-taming-the-regex-beast-for-cleaner-code
---

_RegEx is a wonderful tool, we should use them carefully and not look smart._

## Problem

- Readability

- Maintainability

- Testability

- Intention Revealing

## Solution

1. Use regular expressions just for string validation.

2. If you need to manipulate objects, don't make them strings.

## Sample Code

### Wrong

```kotlin
val regex = "^\\+(?:[0-9a-zA-Z][-]?){6,14}[0-9a-zA-Z]$".toRegex()

```

### Right

```kotlin
val prefix = """\+"""
val digit = "[0-9a-zA-Z]"
val space = "[-]"
val phoneRegex = "^$prefix(?:$digit$space?){6,14}$digit$".toRegex()
```

## Conclusion

Regular expressions are a great tool for string validation. We must use them in a declarative way and just for strings.

Names are very important to understand pattern meanings.

If we need to manipulate objects or hierarchies, we should do it in an _object way_.

Unless we have a conclusive benchmark of **impressive** performance improvement.

* * *

I hope you enjoyed this journey and learned something new. If you want to stay updated with my latest thoughts and ideas, feel free to register for my [**newsletter**](https://yonatankarp.com/newsletter). You can also find me on [**LinkedIn**](https://www.linkedin.com/in/yonatankarp/) or [**Twitter**](https://twitter.com/yonatan_karp). Let's stay connected and keep the conversation going!

* * *

## Credits

- [Code Smell 41 - Regular Expression Abusers](https://maximilianocontieri.com/code-smell-41-regular-expression-abusers) by [Maxi Contieri](https://hashnode.com/@mcsee)
Giving an eye to Master CSS
Tags: css, mastercss
Published: 2023-08-16 07:59:16

[Master CSS](https://css.master.co/) presented itself as **A Virtual CSS language with enhanced syntax.**

I have been tempted to use Tailwind, but I felt uncomfortabled with all the tooling needed.

Master CSS seems simpler, at least for me.

I intend to share my experience while using it, stay tuned...