teleren/devto huggingface dataset:
787. Cheapest Flights Within K Stops
Tags: java, leetcode, 100daysofcode, algorithms
Published: 2023-01-26 08:39:41

**Problem Statement:**

There are n cities connected by some number of flights. You are given an array flights where flights[i] = [fromi, toi, pricei] indicates that there is a flight from city fromi to city toi with cost pricei.

You are also given three integers src, dst, and k, return the cheapest price from src to dst with at most k stops. If there is no such route, return -1.

 

**Example 1:**
**Input:** n = 4, flights = [[0,1,100],[1,2,100],[2,0,100],[1,3,600],[2,3,200]], src = 0, dst = 3, k = 1
**Output:** 700
**Explanation:**
The graph is shown above.
The optimal path with at most 1 stop from city 0 to 3 is marked in red and has cost 100 + 600 = 700.
Note that the path through cities [0,1,2,3] is cheaper but is invalid because it uses 2 stops.


**Example 2:**
**Input:** n = 3, flights = [[0,1,100],[1,2,100],[0,2,500]], src = 0, dst = 2, k = 1
**Output:** 200
**Explanation:**
The graph is shown above.
The optimal path with at most 1 stop from city 0 to 2 is marked in red and has cost 100 + 100 = 200.

**Example 3:**

**Input:** n = 3, flights = [[0,1,100],[1,2,100],[0,2,500]], src = 0, dst = 2, k = 0
**Output:** 500
**Explanation:**
The graph is shown above.
The optimal path with no stops from city 0 to 2 is marked in red and has cost 500.
 

**Constraints:**

- 1 <= n <= 100
- 0 <= flights.length <= (n * (n - 1) / 2)
- flights[i].length == 3
- 0 <= fromi, toi < n
- fromi != toi
- 1 <= pricei <= 104
- There will not be any multiple flights between two cities.
- 0 <= src, dst, k < n
- src != dst

**Solution:**

**Algorithm:**

1. Create a 2D array of size (k+2) * n
2. Fill the first row with 0 and rest with Integer.MAX_VALUE
3. Iterate over the flights array and update the dp array
4. Return the minimum value in the last row

**Code:**
```
class Solution {
    public int findCheapestPrice(int n, int[][] flights, int src, int dst, int k) {

        int[][] dp = new int[k+2][n];
        for(int i=0; i<k+2; i++){
            Arrays.fill(dp[i], Integer.MAX_VALUE);
        }
        dp[0][src] = 0;
        for(int i=1; i<k+2; i++){
            for(int[] flight: flights){
                int from = flight[0];
                int to = flight[1];
                int price = flight[2];
                if(dp[i-1][from] != Integer.MAX_VALUE){
                    dp[i][to] = Math.min(dp[i][to], dp[i-1][from] + price);
                }
            }
        }
        int res = Integer.MAX_VALUE;
        for(int i=1; i<k+2; i++){
            res = Math.min(res, dp[i][dst]);
        }
        return res == Integer.MAX_VALUE ? -1 : res;
    }
}

```

**Time Complexity:**
O(n^2)
**Space Complexity:**
O(n^2)
使用GitHub作为Markdown图床
Published: 2023-06-26 00:00:57

---
title: 使用GitHub作为Markdown图床
published: true
date: 2023-01-26 08:36:24 UTC
tags: 
canonical_url: https://blog.csdn.net/hu_zhenghui/article/details/128766110
---

本文讲解如何使用GitHub Actions将Markdown文件中图片的相对路径转换为绝对路径， 后续将Markdown文件复制到其他位置可以保持图片链接地址，也就是使用GitHub作为Markdown图床。 目前网站已发布在 已经同步发布在
Tutorial for Weather app using API in Dart.
Tags: webdev, beginners, programming, tutorial
Published: 2023-01-26 08:33:42

REQUIREMENTS TO DEVELOP WEATHER APP IN DART:

1. First of all install the packages i.e. http in pubspec.yaml file and import in main file. Also include the packages to take input and also the packages that convert json string into Map.

2.Make a main function as an asynchronous because it gets the value at future time call the function which is in future time.

3.Make a Future class and give the name of a function now get the Weather API from the internet and sends request to fetch the data.

4.Now Get the resource from the response and print using response.body or any other variable.

5.Now convert the json String into map and it into list of map.
Converting json string to map is done by json.decode.

6.Now get the information of your requirement of the projects using by map manipulation.

7.At first while entering a city it will give latitude and longitude which helps to get weather in next API call where you get information as much you can.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/sxuqci909nkcsdtxay3o.png)
Menguasai Tipe Data dan Pernyataan Logika di Python
Tags: webdev, programming, tutorial, python
Published: 2023-01-26 08:31:39

Studi Kasus: Sistem Penjualan Otomatis

Dalam sistem penjualan otomatis ini, user akan memasukkan jumlah uang yang ingin dikeluarkan untuk membeli produk. Sistem akan mengecek jumlah uang yang diterima dan mengecek apakah jumlah uang cukup untuk membeli produk tersebut atau tidak. Jika jumlah uang cukup, maka sistem akan mengeluarkan produk dan mengeluarkan kembalian. Namun jika jumlah uang tidak cukup, maka sistem akan mengeluarkan pesan "Uang tidak cukup"

**note** :

- Tipe data integer untuk menyimpan jumlah uang yang diterima dan harga produk.
- Tipe data string untuk menyimpan pesan yang akan ditampilkan ke user.

Alur Program :

1. kita akan menerima input dari user untuk jumlah uang yang dikeluarkan dengan menggunakan **built-in function** "**input**()". Namun, input yang diterima dari user sebagian besar berupa **string**, sehingga kita harus mengubah tipe datanya menjadi **integer** dengan menggunakan **built-in function** "**int**()".

2. Kemudian kita akan mengecek apakah jumlah uang yang diterima cukup untuk membeli produk atau tidak dengan menggunakan **pernyataan logika** if-else. 

> Jika jumlah uang cukup, kita akan mengeluarkan produk dan menghitung kembalian dengan menggunakan **operator aritmatika**. Kemudian kita akan menggunakan built-in function "print()" untuk menampilkan pesan "Produk dikeluarkan" dan jumlah kembalian ke user. 

> Namun jika jumlah uang tidak cukup, kita akan menampilkan pesan "Uang tidak cukup" dengan menggunakan built-in function "print()".

Dalam kasus ini, program telah menggunakan konversi tipe data dan pernyataan logika untuk mengolah data yang diterima dari user dan mengontrol aliran logika dalam program. Dengan mengkonversi tipe data yang tidak sesuai menjadi tipe data yang sesuai dan menggunakan pernyataan logika yang benar, kita dapat menjamin bahwa program akan mengeluarkan produk dan kembalian yang sesuai dengan jumlah uang yang diterima dari user.

```
#menerima input dari user untuk jumlah uang yang dikeluarkan
uang = int(input("Masukkan jumlah uang: "))

#harga produk
harga = 5000

#mengecek apakah jumlah uang cukup untuk membeli produk
if uang >= harga:
    #menghitung kembalian
    kembalian = uang - harga
    #menampilkan pesan dan kembalian
    print("Produk dikeluarkan. Kembalian: ", kembalian)
else:
    #menampilkan pesan "Uang tidak cukup"
    print("Uang tidak cukup.")

```
Kuda transfer ussd code and latest kuda bank information
Tags: kudabankussdcode, kudabanktransfercode
Published: 2023-01-26 08:31:38


[https://www.bankfanz.com/kuda-bank-transfer-code/](https://www.bankfanz.com/kuda-bank-transfer-code/#utm_source=backlinks&utm_medium=search&utm_campaign=darry+ring+us&utm_content=Michelle)

https://visual.ly/users/Kuda_transfer_ussd_code6/portfolio/
https://plaza.rakuten.co.jp/gtbtransfer2023/diary/202301260000/
https://www.divephotoguide.com/user/Kudaussdcode6
https://www.producthunt.com/@kuda_transfer_ussd_code6
https://www.provenexpert.com/kudatransferussdcode6/
https://vocal.media/authors/kuda-transfer-ussd-code6
https://wakelet.com/@Kudatransferussdcode6536
https://www.lifeofpix.com/photographers/kuda_transfer_ussd_code6/
https://rosalind.info/users/Kuda_transfer_ussd_code6/
http://phillipsservices.net/UserProfile/tabid/43/userId/195795/Default.aspx
https://camp-fire.jp/profile/Kuda_transfer_ussd_code6
https://app.roll20.net/users/11552558/kuda-transfer-ussd-code-6-h
https://seedandspark.com/user/kuda-transfer-ussd-code6
https://plazapublica.cdmx.gob.mx/profiles/Kuda_transfer_ussd6/activity
https://www.zintro.com/profile/kuda_transfer_ussd_code6
https://peatix.com/user/15676576/view
https://www.metal-archives.com/users/Kuda_transfer_ussd_code6
https://trabajo.merca20.com/author/kuda_transfer_ussd_code6/
https://www.intensedebate.com/people/Kuda_transfer6
https://www.mifare.net/support/forum/users/kuda_transfer_ussd_code6
https://pinshape.com/users/2561286-kuda-transfer-ussd-code6
https://www.kiva.org/lender/kudatransfer4604
https://www.credly.com/users/kuda-transfer-ussd-code6/badges
https://www.myminifactory.com/users/kudaussdcode6
https://www.sqlservercentral.com/forums/user/kuda_transfer_ussd_code6
https://guides.co/a/kuda-transfer-7815
http://foxsheets.com/UserProfile/tabid/57/userId/118963/Default.aspx
https://storium.com/user/kuda_transfer_ussd_code6
https://speakerdeck.com/kuda_transfer_ussd_code6
https://www.kompasiana.com/kudatransferussdcode6
https://www.longisland.com/profile/Kuda_transfer_ussd_code
https://leanin.org/circles/kuda-transfer-ussd-code
https://myanimelist.net/profile/Kuda_transfer_c6
Unit Test best practices in Reactjs
Tags: react, testing, webdev
Published: 2023-01-26 08:21:42

## 1. Test individual components in isolation: 

Test each component separately to ensure that it works as expected and to make it easier to debug issues.

## 2. Test both the state and the props of a component: 

Test how a component behaves when it receives different props and how it behaves when its internal state changes.

## 3. Use a test runner: 

A test runner like Jest can help you easily run your tests and generate test coverage reports.

## 4. Use a test utility library: 

A utility library like Enzyme can help you easily manipulate and assert on the output of React components.

## 5. Test edge cases: 

Test how your components behave when they receive unexpected input or when they are in an unexpected state.

## 6. Test for accessibility: 

Test that your components are accessible to assistive technologies.

## 7. Test for performance: 

Test the performance of your components, especially if they are complex or have a lot of data.

## 8. Keep your tests simple and readable: 

Avoid complex logic in your tests and use clear and descriptive test names.

## 9. Keep your tests fast: 

Avoid unnecessary set-up and tear-down operations, and avoid hitting external services or APIs.

## 10. Test-drive development: 

Write your tests before you write your components, this way you can ensure that your components are working as expected and you don't miss any functionality.
Today's Daily Humor For Devs - Daily Developer Jokes
Tags: jokes, dailydeveloperjokes, watercooler
Published: 2023-01-26 08:00:02

---
title: "Today's Daily Humor For Devs - Daily Developer Jokes"
description: "Check out today's daily developer joke! (a project by Fred Adams at xtrp.io)"
series: "Daily Developer Jokes"
published: true
tags: #jokes, #dailydeveloperjokes, #watercooler
---

Hi there! Here's today's Daily Developer Joke. We hope you enjoy it; it's a good one.

![Joke Image](https://private.xtrp.io/projects/DailyDeveloperJokes/public_image_server/images/5e1258d992c4e.png)

---

For more jokes, and to submit your own joke to get featured, check out the [Daily Developer Jokes Website](https://dailydeveloperjokes.github.io/). We're also open sourced, so feel free to view [our GitHub Profile](https://github.com/dailydeveloperjokes).

### Leave this post a ❤️ if you liked today's joke, and stay tuned for tomorrow's joke too!

_This joke comes from [Dad-Jokes GitHub Repo by Wes Bos](https://github.com/wesbos/dad-jokes) (thank you!), whose owner has given me permission to use this joke with credit._

<!--
Joke text:
___Q:___ How do programming pirates pass method parameters?

___A:___ Varrrrarrrgs.
 -->
How to deal with dates, dates with timezones and dates with particular formats with python and pandas (code snippets for...
Tags: pandas, python, technical
Published: 2023-01-26 19:42:50

---
title: How to deal with dates, dates with timezones and dates with particular formats with python and pandas (code snippets for...
published: true
date: 2023-01-26 08:00:00 UTC
tags: pandas,python,technical
canonical_url: https://diegocarrasco.com/how-to-deal-with-dates-dates-with-timezones-and-dates-with-particular-formats-with-python-and-pandas-code-snippets-for-different-use-cases/
---

### Context

When dealing with dates, I’ve sometimes problems because the source is not clean, or not all the rows have the same format. Additionally, dates can be simple (year-month-day) or really complicate like a timestamp with timezone.

Here are some code snippets for several use cases.

### How to read dates with python and pandas

```python 
# import pandas
import pandas as pd

# df is a dataframe with a column 'column_with_date' with a date like this '19.01.2023 16:45:46 +01:00'
# convert date string to datetime with pd.to_datetime
pd.to_datetime(df['column_with_date'])

# sometimes the format is a bit weird and pandas cannot recognize it. In this case we give the date format as argument.
# for this format 19.01.2023 16:45:46 +01:00 we can use:
pd.to_datetime(df['column_with_date'], format='%Y-%m-%d %H:%M:%S%z')

# if your string has timezone, use utr=True
pd.to_datetime(df['column_with_date'], format='%Y-%m-%d %H:%M:%S%z', utc=True)

# sometimes your columns are as objects (strings) and numbers (floats, ints) and to_datetime cannot process it. 
# You can force the type string to the whole column before giving it to to_datetime.

pd.to_datetime(df['column_with_date'].astype(str), format='%Y-%m-%d %H:%M:%S%z', utc=True)

# pd.to_datetime does not modify the column values in place, so you have to assign it to the same column.

df['column_with_date'] = pd.to_datetime(df['column_with_date'].astype(str), format='%Y-%m-%d %H:%M:%S%z', utc=True)

# or save it to another (new) column if you want to save the original value
df['column_with_date_2'] = pd.to_datetime(df['column_with_date'].astype(str), format='%Y-%m-%d %H:%M:%S%z', utc=True)

```

### How to save dates with UTC (tiemzone) to an Excel-File with Pandas

Saving `datetime` columns with timezones in pandas is not supported, and you will get the following error if you try:

```
ValueError: Excel does not support datetimes with timezones. Please ensure that datetimes are timezone unaware before writing to Excel.

```

To remove the timezone from a `datefield` (column `dtype` `datetime64[ns, UTC]`) you can use `.dt.date()`

```python 
# remove timezones for excel
df['column_with_date'] = df['column_with_date'].apply(lambda d: pd.to_datetime(d).date()) 

# save te file as usual
df.to_excel('filename.xlsx')
```

### References

- https://stackoverflow.com/a/63238008/624088
- https://docs.python.org/3/library/datetime.html#strftime-and-strptime-format-codes -> format codes for datetime strings
- try and error :)
The Role of Surveys in Understanding Consumer Behavior
Published: 2023-01-26 07:45:21


Surveys are an important tool for understanding consumer behaviour. They allow businesses to gather valuable information about their target market and make informed decisions about products, services, and marketing strategies.

One of the key benefits of surveys is that they provide insight into customer needs and preferences. By asking questions about demographics, purchasing habits, and satisfaction levels, surveys can help businesses understand what their customers want and how to best meet those needs. This information can be used to develop new products, improve existing ones, or create more effective marketing campaigns.

Surveys can also be used to identify trends in consumer behaviour. By tracking responses over time, businesses can identify patterns and changes in customer attitudes and preferences. This can help them stay ahead of the curve and make strategic decisions about their products and services.

Surveyduniya.com offers a range of survey tools that can help businesses gather and analyze this information. Our user-friendly platform makes it easy to create and distribute surveys, and our advanced analytics tools allow businesses to quickly and easily analyze the results. We also offer a variety of templates and questionnaires that can be customized to suit the specific needs of each business.

In addition, Surveyduniya.com offers a wide range of features that can help businesses to better understand their customers. We offer advanced reporting and analysis tools that allow businesses to segment their data by demographic, geographic, and other criteria. This makes it easy to identify trends and patterns in customer behaviour and to make data-driven decisions about products, services, and marketing strategies.

In conclusion, Surveys are an essential tool for understanding consumer behaviour and making informed business decisions. By gathering and analyzing data on customer needs and preferences, businesses can develop effective products, services, and marketing strategies that will help them succeed in today's competitive marketplace. Surveyduniya.com offers a range of survey tools and analytics that can help businesses make the most of this data, and gain a deeper understanding of their customers.
The Role of Surveys in Understanding Consumer Behavior
Published: 2023-01-26 07:37:41

The Role of Surveys in Understanding Consumer Behavior

Surveys are an important tool for understanding consumer behaviour. They allow businesses to gather valuable information about their target market and make informed decisions about products, services, and marketing strategies.

One of the key benefits of surveys is that they provide insight into customer needs and preferences. By asking questions about demographics, purchasing habits, and satisfaction levels, surveys can help businesses understand what their customers want and how to best meet those needs. This information can be used to develop new products, improve existing ones, or create more effective marketing campaigns.

Surveys can also be used to identify trends in consumer behaviour. By tracking responses over time, businesses can identify patterns and changes in customer attitudes and preferences. This can help them stay ahead of the curve and make strategic decisions about their products and services.

Surveyduniya.com offers a range of survey tools that can help businesses gather and analyze this information. Our user-friendly platform makes it easy to create and distribute surveys, and our advanced analytics tools allow businesses to quickly and easily analyze the results. We also offer a variety of templates and questionnaires that can be customized to suit the specific needs of each business.

In addition, Surveyduniya.com offers a wide range of features that can help businesses to better understand their customers. We offer advanced reporting and analysis tools that allow businesses to segment their data by demographic, geographic, and other criteria. This makes it easy to identify trends and patterns in customer behaviour and to make data-driven decisions about products, services, and marketing strategies.

In conclusion, Surveys are an essential tool for understanding consumer behaviour and making informed business decisions. By gathering and analyzing data on customer needs and preferences, businesses can develop effective products, services, and marketing strategies that will help them succeed in today's competitive marketplace. Surveyduniya.com offers a range of survey tools and analytics that can help businesses make the most of this data, and gain a deeper understanding of their customers.
CORS - As Simple As Possible
Tags: cors, webdev, programming
Published: 2023-01-26 07:26:39

Today, I ran into a CORS error while working on a project so I decided to dig a bit deeper into what it is, and why it happened. Now, a lot of the articles I found are pretty complex, so I decided to give a go at describing it in a short, concise way how it works.


---

## What?
A technology to specify which domains can access a servers resources.

## Why?
Security.
You can read more about it here: [](https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS#:~:text=The%20CORS%20mechanism%20supports%20secure,of%20cross%2Dorigin%20HTTP%20requests.)

## How?

A request gets sent to access something (in this example an image on my portfolio).

```HTML
<img src="https://mattiasvelamsson.me/media/avatar.png" />
```
Server checks the request and it’s header.

➡ **Request** ✅ 
It will respond with a 200(OK!) and the image will display on your site.

![Avatar.png](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/1bpn74l89k3gmk71cuu2.png)

➡ **Request** ❌ 
It will respond with a 5xx(DENIED!) and the image will appear broken, and you will have a status code in your console.

![CORS error console](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/31km0rq4cpm206i4hgui.png)

![Error](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/7raohrauigjjp7j4rmta.png)

## Errors?

The simple answer is usually one of two:

- The type of request (method) you are sending is not allowed. GET / PATCH / POST / DELETE

- Typos in your URL

**_I solemnly swear I have quadrouple-checked the two options above._**

- CORS is not enabled on the server (_if you’re not the owner, tough luck. Journey ends here._)

It is enabled but still doesn’t work?
- Open the console > Network > Your Request and double check that you can see “Access-Control-Allow-Origin header” in the list.

![developer console.png](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/0z0vpw2kfz4bls7lydp3.png)

- If not, you need to add middleware.
- If it is but doesn’t work, check if it is a non-standard HTTP request (not GET, PUT, PATCH, DELETE) and you’ll need to add them.

**I checked everything?**

- Sometimes errors thrown in your project are displayed as text, and when the server outputs them it actually throws in headers as well that in turn will trigger CORS policy. And even if the server error does not print as text but is handled via an HTTP code that is not 200, you will also get the CORS policy error.

---


## Middleware

The keys you throw into your CORS policies, stating what is allowed and what is not. It allows you to customize it.


## Preflight

With Preflight you can add extra options such as checking if the request you want to do is allowed and ok or not, before sending the request. Now, this can also be cached in Preflight Cache with a TTL(Time To Live). You can read more about it here: [https://developer.mozilla.org/en-US/docs/Glossary/Preflight_request](url)

---

Alright. There’s obviously way more abut this, but this is a quick overview. Ciao!
INTERACTING WITH SERVICES PROVIDED BY AWS
Tags: aws, cloudskills, devops, linux
Published: 2023-01-26 07:21:38




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

**For interaction  services provided by AWS we have various ways :**
1. Web UI
2. CLI
3. API
4. Cloud Formation 

First 3 approaches are Monotonous and harder in terms of Management .  

For Example , in CLI we have scripted or Imperative approach where we have to tell 
1. What to do 
2. How to do 

but Approach 4 is Declarative Approach where we only have to tell
1. What to do 

AWS has its own tool service called as CLOUD FORMATION that help us with Automation and is declarative.
You NEED to TRY this Tool!!
Tags: typescript, webdev, node, javascript
Published: 2023-01-26 07:07:24

Hey guys! I always hated setting up new typescript projects cuz I had to copy over so many files and install packages that took quite sometime.

So I developed a typescript project generator and it is pretty fast. You'll have a project running in under 30s.

You can try it out RIGHT NOW.
```
npx ts-make-gen
```

Its called TSMake.
If you would like to check out the code... heres the link
https://github.com/vaderdev/tsmake