teleren/devto huggingface dataset:
Days10_Show Me the $$
Published: 2023-03-21 10:15:25

Code basic math principles (+, -, *, /), build your own tip calculator, and never calculate numbers again!

```
#Nesting Dolls Code
#
#20 MARCH 2023

def exercise_1():
  adding = 4+3
  subtraction = 8-9
  multiplication = 4*12
  division = 50/5
  squared = 5**2
  
  modulo = 15 % 4
  divisor = 15 // 2
  print(adding,subtraction,multiplication,division,squared,modulo,divisor)
  
def exercise_2():
  a = 3.4
  b = 6.8
  c = 2467
  d = 4673
  e = 10
  f = a*b
  g = c/d
  h = e^2
  print(f,g,h)
  

def cell():
  exercise_1()
  exercise_2()
cell()
```
Making of Among Us in Discord - DEVBLOG 2 - Buttons and New Possibilities
Tags: 100daysofcode, python, gamedev, discord
Published: 2023-03-21 10:13:15

{% embed https://twitter.com/MrStiK101/status/1638118091342196737?s=20 %}

Heya, This is Mr.StiK, again, again

So, this post is quite fast since I take 24 hours to post, this is less than that... that's because I took a lot of progress today

To start of, I again switched to PyCharm because Thonny was having... some issues... with UI (I'll come to that later). So yeah, back to the IDE I hate, but this time, I made my own file rather than a project, so PyCharm can't harm me this time, HAH!

And I completed embeds... with `set_author()`. And I mastered EMBEDS...

The next thing I had in my bucket_list.txt file was... Buttons... which was kind of cool, to be honest, and I want to try it out...

[insert AFTER 1 ETERNITY meme here]

It took me 2 AND AN HALF HOUR TO FIX IT and solution was TO GO BACK TO PYCHARM WHAT THE~

~back to the point.

Thanks to some awesome geek~ I mean, 'programmers' in the discord.py discord server, I actually got the solution... not only should I change my IDE, I should also use buttons using Classes, which was not the way I was doing...

So, yeah, that's done...

Then I managed to make the 1st step to actually making the bot... Start Screen...

And I did, not finished but still, it's good for me!

That's it for today's progress... I got to study for exams, wish me luck!

```
PS: Here's people who helped me with this much progress;
CHATGPT for explaining each code with examples (true programmers use ChatGPT for that, not for generating code for your work 😎 )

Little Furret, and Invisible on the Discord Server...

And finally my beta-tester and trustworthy friend: PakinDe
```
Toodles!
Body Mass Index (BMI) calculator using the graphical user interface (GUI) library Tkinter
Published: 2023-03-21 10:04:12




---
title:  Body Mass Index (BMI) calculator using the graphical user interface (GUI) library Tkinter
published: true
description: 
tags: 
# cover_image: https://direct_url_to_image.jpg
# Use a ratio of 100:42 for best results.
# published_at: 2023-03-21 09:57 +0000
---

https://github.com/jcvillainfo/BMICalculator

       This is a Python program that creates a Body Mass Index (BMI) calculator using the graphical user interface (GUI) library Tkinter. BMI is a measure of body fat based on a person's height and weight. The program consists of a main window divided into two sections: the left side with labels, input fields, and a calculate button, and the right side with a result display area.
	The program defines a class called BMI that initializes the GUI window and its components. It also creates different frames (subsections of the window) to organize the layout of the interface. The left frame contains the input fields for height and weight, a calculate button, and a reset button. The right frame displays the calculated BMI and a status message.
	The program uses various functions to perform tasks such as resetting the input fields, calculating the BMI, and exiting the application. It also uses different types of variables to store the user's input and the calculated result.
	The labels, buttons, and frames are customized with different colors, fonts, and dimensions. The program also displays a message at the bottom of the window explaining how healthcare providers and researchers can use a BMI app to track and collect data on their patients' health.


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/uhqkpq9si5e7gdde3cjd.jpeg)
Why Salesforce Commerce Cloud is Essential for Online Business?
Tags: salesforce, cloud, consultant, partners
Published: 2023-03-21 09:58:08


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/f6oeuq0v2uv2u11op07b.jpg)
Salesforce Commerce Cloud is a powerful e-commerce platform that helps businesses improve their online presence and offer a hassle-free shopping experience to their customers. With the rise in online shopping globally, SFCC is an essential tool for e-tailers looking to optimize their business processes. The platform offers various features to revolutionize how businesses connect with users at every stage of the consumer journey, including order management, predictive intelligence, online store, and smartphone point of sale. SFCC also offers benefits such as data analysis, predictive intelligence, improved shopping experiences, customization, marketing tools, mobile compatibility, and quality customer support. Innovadel Technologies is a [Certified Salesforce Commerce Cloud Consulting Partner](https://www.innovadeltech.com/salesforce-commerce-cloud/) that can provide expert support for businesses looking to leverage the platform.


Read about this amazing platform in detail for better understanding [Salesforce Commerce Cloud](https://www.innovadeltech.com/why-salesforce-commerce-cloud-is-essential-for-online-business/)
statisch oder dynamisch getypt: Eine Fragerunde
Tags: discuss, programming
Published: 2023-03-21 09:55:04

Es kommt natürlich drauf an, … worauf ?
Also für mich gilt folgendes:

- Programmiersprache: statisch
- berufliches Vorwärtskommen ( Karriere ): dynamisch
- Gehalt: dynamisch
- Tagesablauf: statisch
- Unterhaltungen: dynamisch

Dabei sind dies meine _Vorzüge_.
Wie siehst du das ?

Bring auch gerne eigene Punkte mit ein, ich mag es wie gesagt, wenn Unterhaltungen dynamisch sind :-)

Beste Grüße,
Mustafa
How do you test filepath.Abs failure in your Go code?
Tags: go, tdd, testing
Published: 2023-03-21 09:47:28

In this video, I provide three ways to tackle this question:  Mocking/injection, triggering a legitimate error, and finally, simply not testing!  What are the pros and cons to each? Which one should you choose? Watch to find out!

{% youtube https://youtu.be/-7Bn3j8gkQo %}
How to make public repository of private fork
Tags: github, git, beginners, tutorial
Published: 2023-03-21 09:43:24

While studying Fullstack development with [Integrify](https://integrify.academy/international/)'s bootcamp, I have created a couple of private forks from repositories from the different assignments I had to do to learn.
This is all great until the moment you actually need to showcase your portfolio and what you have done during this intense but great learning.
I have faced the issue of making public repository of private fork.

Here are the commands:

1. [Create an empty public repository](https://docs.github.com/en/get-started/quickstart/create-a-repo)

2. Open Terminal
3. Create a bare clone of the repository. (This is temporary and will be removed so just do it wherever.)
`$ git clone --bare https://github.com/exampleuser/private_repo.git`

4. Mirror-push to the new repository
`$ cd private_repo.git`
`$ git push --mirror https://github.com/yourname/public_repo.git`

5. Remove the temporary local repository you created earlier
`$ cd ..`
`$ rm -rf private_repo.git`

Here you are with your former private fork/repository in your new public one ready to be showcased!

Hope this explanation helps you as much as it helps me!
Streaming ChatGPT API responses with python and JavaScript
Published: 2023-03-21 05:36:14


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/xuwchzhud2hniypb01bc.gif)

It took me a while to figure out how to get a python flask server and web client to support streaming OpenAI completions so I figured I'd share.

```python
from flask import Flask, stream_template, request, Response
import openai
from dotenv import load_dotenv
import os

load_dotenv()
# put these values in an .env file parallel to this file
openai.organization = os.environ.get("OPENAI_ORG")
openai.api_key = os.environ.get('OPENAI_API_KEY')
def send_messages(messages):
    return openai.ChatCompletion.create(
        model="gpt-3.5-turbo",
        messages=messages,
        stream=True
    )

app = Flask(__name__)

@app.route('/chat', methods=['GET', 'POST'])
def chat():
    if request.method == 'POST':
        messages = request.json['messages']
        def event_stream():
            for line in send_messages(messages=messages):
                print(line)
                text = line.choices[0].delta.get('content', '')
                if len(text): 
                    yield text

        return Response(event_stream(), mimetype='text/event-stream')
    else:
        return stream_template('./chat.html')

if __name__ == '__main__':
    app.run()

```

chat.html
```html
<!DOCTYPE html>
<html>
  <head>
    <title>Chat</title>
  </head>
  <body>
    <h1>Chat</h1>
    <form id="chat-form">
      <label for="message">Message:</label>
      <input type="text" id="message" name="message">
      <button type="submit">Send</button>
    </form>
    <div id="chat-log"></div>
    <script src="{{ url_for('static', filename='chat.js') }}">
    </script>
  </body>
</html>
```

You can't use `EventSource` for this if you want to use POST method, this uses fetch API instead.

chat.js
```js
const form = document.querySelector("#chat-form");
const chatlog = document.querySelector("#chat-log");

form.addEventListener("submit", async (event) => {
  event.preventDefault();

  // Get the user's message from the form
  const message = form.elements.message.value;

  // Send a request to the Flask server with the user's message
  const response = await fetch("/chat", {
    method: "POST",
    headers: {
      "Content-Type": "application/json",
    },
    body: JSON.stringify({ messages: [{ role: "user", content: message }] }),
  });

  // Create a new TextDecoder to decode the streamed response text
  const decoder = new TextDecoder();

  // Set up a new ReadableStream to read the response body
  const reader = response.body.getReader();
  let chunks = "";

  // Read the response stream as chunks and append them to the chat log
  while (true) {
    const { done, value } = await reader.read();
    if (done) break;
    chunks += decoder.decode(value);
    chatlog.innerHTML = chunks;
  }
});
```

Obviously this is not an optimal chat user experience but it'll get you started.
Serverless querying and evaluating of Logs using Athena Part 2
Tags: security, devops, aws, cdk
Published: 2023-03-21 09:08:22

In part one of this blog series, "Serverless Querying and Evaluating of Logs Using Athena," we discussed the importance of logging and monitoring in your organization and how to implement it in a serverless way for the most critical AWS services. We also showed you how to use partition projection in Athena to fully automate partition management. These partition projections are configured through Glue parameters, with each table having an account parameter that includes all AWS Account IDs required as partitions to query for.

However, the question arises of how to keep these parameters automated and up-to-date with the current status of the AWS Organization. New accounts can be created at any time, or accounts can join the AWS Organization via invitation. To avoid manually maintaining all parameters of the Glue tables for these events, we have an automation solution for you.

ℹ️ We actually decided to not remove AWS Account Ids from the partition parameter whenever an AWS Account leaves the AWS Organizations or will be SUSPENDED, because the logs are still valid and maybe needed whenever an request for this account from the past is made in the future.



### Architecture Overview
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/wo0p8rljq3s80ug521ie.png)

Our automation creates an EventBridge where the Management Account of our AWS Organization has access to perform a "PutEvent" action. This PutEvent action to our central EventBridge will be performed each time a new AWS Account is successfully created in our AWS Organization (CreateAccountResult) or an existing AWS Account accepts the AWS Organization invitation (AcceptHandshake). This event will trigger a Lambda function through our central EventBridge, which will update our existing Glue tables for the new AWS Account ID for the specific Glue table parameter required as input for the AWS Accounts partition. After this automated update, you will be able to query your logs immediately after your new AWS Accounts have been created or your AWS Account has joined your AWS Organization.

### Open Source
We have published the complete code of the solution freely on [Github](https://github.com/daknhh/cdk-glue-autoupdate) as we want to give something back to the community. We hope you find this solution helpful in automating your indexes for Glue / Athena tables! If you have any feedback about the solution, please feel free to reach out to us or open a github [issue](https://github.com/daknhh/cdk-glue-autoupdate/issues).

### Conclusion
Automating the Glue partitions will help you with your daily work so that no one needs to worry about adding new AWS Accounts to the partition parameters. This ensures that decisions due to missing information in log queries are prevented, and your queries for the information sources are kept up to date.
This week’s newsletter is out! (21-03-2023) - Mid-week special: Catching up
Tags: javascript, tech, webdev, discuss
Published: 2023-03-21 08:56:02

---
title: This week’s newsletter is out! (21-03-2023) - Mid-week special: Catching up
published: true
description: Another week of great javascript, tech and web development links.
tags: javascript, tech, webdev, discuss
---

Mid-week special: Catching up

https://markjgsmith.substack.com/p/mark-smiths-newsletter-21-03-2023

Would love to hear any comments and feedback you have.

[@markjgsmith](https://twitter.com/markjgsmith)
MspHub a US based cybersecurity company
Tags: cybersecurity, cloud
Published: 2023-03-21 08:43:52

MSPHUB's parent company Comtech is a 24-year-old government solutions & staffing services firm that works as a strategic partner to the various levels of government (federal, state, and local), as well as many of the market's top government contractors throughout the United States As a company that is headquartered near our nation's capital Comtech client portfolio includes largest government contractors. MSPHUB's Purpose is to empower all companies with cybersecurity Readiness, investigation, containment & remediation services. Our Cybersecurity and Managed services solutions have been designed to meet each client's operational, budgetary, deadline, and security objectives.

Vision & Mission,
We aim to assist businesses in reaching the best of their abilities by helping them with concrete and robust solutions to boost their business. As a company, our mission also involves providing the most seasoned Cybersecurity & Managed services including and not limited to XDR, SOAR, and SIEM, and assisting all compliances like- PIPEDA, HIPAA, NIST, GDPR, CMMI, and CMMC.

MSPHUB can provide guidance and consulting services for scalable migration to the Cloud, including the planning of site deployment, zero-touch provisioning, resource tagging for cost center management, and infrastructure as code approaches towards scalable and agile deployments of complex environments.

Visit our website here:
[https://msphub.io/home](https://msphub.io/home)

Contact us here:
[https://msphub.io/contact-us](https://msphub.io/contact-us)
Must use libraries with react -> Framework ;)
Tags: react, webdev, frontend, node
Published: 2023-03-21 08:37:44

<link rel="me" href="https://twitter.com/twitterdev"> </link>


Hey folks, a lot of us struggle to work with react, where to start, how to do, because of wide variety of libraries, frameworks are available to use with react.

with new react.js documentation out, it's now time to upgrade our web development workflow, In this article we will going to see some react libraries to make react a complete framework.

----

## Libraries

- React Router Dom [📃](https://reactrouter.com/en/main)

It's hard to navigate between different routes using only react library, by using context, state hooks may make it possible but it's get harder and harder when the app complexity grows. 

Handling dynamic routes, user navigation, navigation history are some of the key features of this library. It's among top libraries in the npmjs for routing.

- Formik

Another useful library to handle forms in react is Formik, they have drip'in title saying **Build forms in React, without the tears**. Sure forms can be handled using useRef hooks but if you're using typescript this hooks can be painful, also more errors like type of HTML Input element you are using in the component.

This library contains hooks like ```useField, useFormik``` to ease the form building, validation and error handling process. You'll love it just give it a try. [Link](https://formik.org/)

- UI library

Creating custom components, that too with responsive and good design is time taking. You can use UI library components like MUI [Link](https://mui.com/), React-Bootstrap [Link](https://react-bootstrap.github.io/), there are some new libraries you must try out like Fluent UI by microsoft [Link](https://developer.microsoft.com/en-us/fluentui#/), Ant Design [Link](https://ant.design/)

- Build Tools

CRA (create react app) is now deprecated, even new official react documentation is not supporting it. You should be using frameworks like Vite [Link](https://vitejs.dev/), metaframeworks like Next.js [Link](https://nextjs.org/) to work with react.


----

That's it for this article, hope you get something useful. Share your thoughts on this article in socials.

Let's Connect - 
<a class="twitter-share-button" href="https://twitter.com/intent/tweet?text=Hey%20folks%20i%20recently%20read%20this%20article%20about%20React%20Libraries%20%20Framework%20on%20Dev.to%20by%20Kunal.py3%20do%20check%20this%20out#webdev%20#react%20#" data-size="large">Tweet Thanks</a>
https://linktr.ee/kunal.dev
🦈 Shark Attacks in New Caledonia 📈
Tags: opendata, datascience, python, jupyter
Published: 2023-03-21 08:32:07

## 🤔 Context

After tragic shark attacks in New-Caledonia, The mayor of Nouméa has banned swimming until December 31st, 2023:

[![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/wa0r6mdk5pkj3yjk0mhu.png)](https://www.noumea.nc/sites/default/files/publications/2023-911-arrete-portant-interdiction-temporaire-toute-baignade-bande-littorale-300-metres-noumea-du.pdf)

Here is a brief about the decision:

{% embed https://la1ere.francetvinfo.fr/nouvellecaledonie/province-sud/noumea/risque-requin-noumea-a-pris-l-arrete-qui-interdira-la-baignade-jusqu-au-31-decembre-et-autorisera-les-activites-nautiques-aux-risques-et-perils-des-usagers-1376142.html %}

After all these **numerous recent dramatic events ** I wanted to know more about these attacks... but I was a bit disappointed by the lack of local and easy to use data.

So I decided to start to do something:

- 📥 **Get** the data
- 🧽 **Cleanup** and standardize (dates, locations,...)
- 💉 **Put data under steroids**(with **keys that allow the use of local datasets** from [`data.gouv.nc`](https://data.gouv.nc/pages/accueil/)) and international codes (`ISO2`,...)
- 🎀 **Help discover** the data and its possibilities

## 🗃️ Kaggle dataset

I decided to **prepare a dedicated dataset** on Kaggle with : 

- ✅ Very clean `csv` files
- ✅ A ready to use [`sqlite`](https://sqlite.org/index.html) database

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/twfeiryoi97btgf7wz25.png)

And data about : 

- 🛡️ **Sharks conservation status** (from [IUCN Red List of Threatened Species](https://www.iucnredlist.org/))
- 🌝 **Lunar phasis** in New Caledonia
- 📅 **Shark attacks** (date, day of week, season, attack type, commune, codes to local cities open data keys, province/state, activity/age/sex of the victim, injury, fatal or not, shark species involved, shark size,... )
- 🦈 **Sharks species** we have in New Caledonia

{% embed https://www.kaggle.com/datasets/adriensales/shark-attack-nouvelle-caldonie/settings %}

## 💯 Data Usability first❕

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/939fylg3mxexqblchzlo.png)


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/5qr9iggrgy4sb4gz6sr0.png)

## 📊 Then a first notebook

[![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/cndabkmaee325dq7a00g.png)](https://www.kaggle.com/code/adriensales/shark-attacks-new-caledonia-for-dummies)

{% twitter 1636923470180417538 %}

## 📰 Related press resources

{% embed https://www.lemonde.fr/planete/article/2023/03/08/la-nouvelle-caledonie-mise-sur-l-abattage-des-requins-apres-de-graves-attaques_6164691_3244.html %}

{% embed https://la1ere.francetvinfo.fr/nouvellecaledonie/la-caledonie-est-un-hot-spot-mondial-du-risque-requin-selon-le-chercheur-francois-taglioni-1364026.html %}
Best Ecommerce Managed Services | eMarspro
Tags: services, ecommerce
Published: 2023-03-21 08:08:07

eMarspro Inc is an e-commerce marketing company based in the United States, Texas. We provide [ecommerce management services](https://emarspro.com/ecommerce-management-services/) with trusted outsourced commerce solutions for platforms such as eBay, Amazon, Walmart, Etsy, Shopify and over 60 other marketplaces. We use effective tactics and strategies that very few brands or retailers know about to succeed on e-commerce platforms. We have a team of people ready to support your brand sales and marketing!
We Care health website
Tags: javascript, html, css, beginners
Published: 2023-03-21 07:57:32

My friend and I created this prototype website designed to help people get medicine online and rescue those in emergency situations. Please take a look at the [website]
(https://wecare.karthikg8.repl.co/.).

This was built purely on HTML, CSS and JavaScript. Feel free to take a look at the source code on my [Github repo](https://github.com/kaarthikrishna/We-care)
Create a blog with Supabase and Next.js - part 4 - SSR
Tags: nextjs, supabase, typescript, webdev
Published: 2023-03-21 07:56:06

---
title: Create a blog with Supabase and Next.js - part 4 - SSR
description: Lets do some server side rendering
tags: nextjs, supabase, typescript, webdev
cover_image: https://revolugame.com/p/create-a-blog-with-supabase-and-nextjs-part-4/pexels-nubia-navarro-%28nubikini%29-1110355_hu3d03a01dcc18bc5be0e67db3d8d209a6_3400528_1600x0_resize_q75_box.jpg
canonical_url: https://revolugame.com/p/create-a-blog-with-supabase-and-nextjs-part-4/
published: true
series: Create a blog with Supabase and Next.js
---


> If you want to jump straight to the source code, here's the link to the [github repository](https://github.com/po8rewq/tuto-blog-nextjs-supabase).

One thing we haven't done yet is server side rendering. We are currently fetching the posts using the `useEffect` hook. This means that the posts won't be available until the component is mounted. We can do better by using the `getStaticProps` function from nextjs to fetch the posts on the server.

Lets use the `/posts/[id]` page to do just that.

```tsx
export const getServerSideProps = async (ctx: GetServerSidePropsContext) => {
  const supabase = createServerSupabaseClient(ctx); // from '@supabase/auth-helpers-nextjs';
  const { data } = await supabase
    .from('posts')
    .select('*')
    .eq('id', ctx.params?.id)
    .single();

  if (!data) {
    // if the post doesn't exist, return 404
    return {
      notFound: true,
    };
  }

  // return the post a prop
  return {
    props: {
      post: data,
    },
  };
};
```

By using `getServerSideProps`, we can now fetch the post on the server and pass it to the component as a prop. Our `PostPage` component already have the `post` prop so we can just use it (see [part 2](/p/create-a-blog-with-supabase-and-nextjs-part-2/#the-post-page-and-the-edit-page-)).