teleren/devto huggingface dataset:
Github Actions: using python version from .python-version file (pyenv)
Tags: ci, githubactions
Published: 2021-04-09 08:41:56

I was recently creating a CI pipeline for a toy ML project. It was to make sure that our training accuracies stay within some thresholds as we change the code. We were hosting the project on GitHub so GitHub Actions seemed like a great fit to run our CI.

I’d found GitHub’s [actions/setup-python@v2](https://github.com/actions/setup-python) to set up the specific python version, but it wasn’t clear how to set a version used [pyenv](https://github.com/pyenv/pyenv) (a great tool for managing multiple python versions btw), one written in the `.python-version` file.

Turns out combining [action contexts](https://docs.github.com/en/actions/reference/context-and-expression-syntax-for-github-actions) and [environment variables](https://docs.github.com/en/actions/reference/environment-variables) does the trick.
1. One step reads the `.python-version` file and writes that to environment variable
2. [actions/setup-python@v2](https://github.com/actions/setup-python) installs the version from the environment variable.

Here's the snippet defining the job steps
```yaml
 steps:
    - uses: actions/checkout@v2
    - name: Get python version
      run: |
        python_version=$(cat .python-version)
        echo "python_version=${python_version}" >> $GITHUB_ENV
    - name: Set up Python ${{ env.python_version }}
      uses: actions/setup-python@v2
      with:
        python-version: ${{ env.python_version }}
```
Entity Relationships Part 2: Many-To-Many
Published: 2021-04-09 08:40:20


## Creating Class Car Club & Many-To-Many

{% youtube zGr2mY8p5kg %}

[GitHub Repo Tag](https://github.com/softwaredevacademy/spring-web-app-demo/releases/tag/car-club)

## Adding Create Mappings for Many-To-Many

{% youtube uyo4lGOuNoE %}

## Adding Delete Mappings for Many-To-Many

{% youtube xytgZxGmyKQ %}

[GitHub Repo Tag](https://github.com/softwaredevacademy/spring-web-app-demo/commit/2e8677f17f411636b545280856ff2063ea77d6b0)

#### Clarification

##### Many-To-Many deletion
When you try to delete an entity on the **non-owning side** of a many-to-many relationship that has associations to the other entity you might get a 'violating foreign key constraint' error. What you would have to do then is to manually remove the associations from the non-owning entities' collection. In this case, that would be

```java
// Make sure to have a getter for clubs on Person.java
for (CarClub carClub: person.getClubs()) {
    carClub.getMembers().remove(person);
}
```

<hr>
<p style="align: center;"> <span> <a href="https://dev.to/softwaredevacademy/entity-relationships-part-1-one-to-many-3ehg">Previous article</a> | </span>
<span><a href="https://dev.to/softwaredevacademy/application-structure-4c18">Next article</a></span>
mevsim sohbet odaları
Tags: mevsimorg, sohbet, chat
Published: 2021-04-09 08:23:29

Mevsim org platformu 2015 yılında chat yayın hayatına başlayarak günümüze kadar gelmiştir. Her ne kadar günümüzde sosyal medyanın gücü tartışılmaz olsada bu durum asla eski chat geleneğini bozmamıştır.

Bu yüzden de chat alanında insanlara en iyi hizmeti sunabilmek, hayatın içinde bir nebze rahat nefes alabilmek adına kurulmuştur.

Vizyonumuz:

Türkiye'de ve Dünya da insanlara en iyi chat deneyimini yaşatarak, insanların birbirleriyle tanışmalarını sağlamak.

Misyonumuz:

Chat sitemize giriş yapan herkese kalite sohbet odaları hizmeti sunarak, insanları zihninde sosyal medya alternatifi olarak daha güvenilir bir ortamında var olduğunu sağlamak.

<a href="https://www.mevsim.org/" title="sohbet">Sohbet</a>
<a href="https://www.hersohbet.com/" title="sohbet">Chat</a>
<a href="https://www.nehir.org/" title="sohbet">Sohbet odaları</a>
<a href="https://www.mevsim.org/" title="https://www.mevsim.org/">https://www.mevsim.org/</a>
<a href="https://www.mevsim.org/lez-sohbet.html" title="lez sohbet">lez sohbet</a>
<a href="https://www.mevsim.org/cinsel-sohbet.html" title="cinsel sohbet">cinsel sohbet</a>
Remove background from images with Python
Tags: python, tutorial, showdev
Published: 2021-04-09 08:22:43

Today  I  will show you how you can remove background from your images.

I'll  use  `numpy, cv2, matplotlib`, 

[NumPy](https://numpy.org/doc/stable/user/whatisnumpy.html) is the fundamental package for scientific computing in Python. It is a Python library that provides a multidimensional array object, various derived objects (such as masked arrays and matrices), and an assortment of routines for fast operations on arrays, including mathematical, logical, shape manipulation, sorting, selecting, I/O, discrete Fourier transforms, basic linear algebra, basic statistical operations, random simulation and much more.

[OpenCV-Python](https://pypi.org/project/opencv-python/) is a library of Python bindings designed to solve computer vision problems.  
`cv2.imread()` method loads an image from the specified file. If the image cannot be read (because of missing file, improper permissions, unsupported or invalid format) then this method returns an empty matrix.

[Matplotlib](https://matplotlib.org/) is a comprehensive library for creating static, animated, and interactive visualizations in Python.

This is our test image:

![enter image description here](https://i.ibb.co/CMhxV6V/test.jpg)
Let's jump to the code

```python

import numpy as np
import cv2 as cv
from matplotlib import pyplot as plt
import sys
from  PIL  import Image

img = cv.imread('images/test.jpg', cv.IMREAD_UNCHANGED)
original = img.copy()

l = int(max(5, 6))
u = int(min(6, 6))

ed = cv.cvtColor(img, cv.COLOR_BGR2GRAY)
edges = cv.GaussianBlur(img, (21, 51), 3)
edges = cv.cvtColor(edges, cv.COLOR_BGR2GRAY)
edges = cv.Canny(edges, l, u)

_, thresh = cv.threshold(edges, 0, 255, cv.THRESH_BINARY  + cv.THRESH_OTSU)
kernel = cv.getStructuringElement(cv.MORPH_ELLIPSE, (5, 5))
mask = cv.morphologyEx(thresh, cv.MORPH_CLOSE, kernel, iterations=4)

data = mask.tolist()
sys.setrecursionlimit(10**8)
for i in  range(len(data)):
	for j in  range(len(data[i])):
		if data[i][j] !=  255:
			data[i][j] =  -1
		else:
			break
	for j in  range(len(data[i])-1, -1, -1):
		if data[i][j] !=  255:
			data[i][j] =  -1
		else:
			break
image = np.array(data)
image[image !=  -1] =  255
image[image ==  -1] =  0

mask = np.array(image, np.uint8)

result = cv.bitwise_and(original, original, mask=mask)
result[mask ==  0] =  255
cv.imwrite('bg.png', result)

img = Image.open('bg.png')
img.convert("RGBA")
datas = img.getdata()

newData = []
for item in datas:
	if item[0] ==  255  and item[1] ==  255  and item[2] ==  255:
		newData.append((255, 255, 255, 0))
	else:
		newData.append(item)

img.putdata(newData)
img.save("img.png", "PNG")

```

 This our result, it's not perfect, but the code did a good job.

![enter image description here](https://i.ibb.co/mNjBwmH/bg.png)

That's all. Keep coding.
Source transformation in a simple circuit
Published: 2021-04-09 08:17:28

In a simple electrical circuit, to find the current or voltage through an element in the circuit we use different techniques such as :- Mesh analysis, Nodal analysis, Star to delta and delta to star conversions, Source transformation etc.

One of the easiest methods of solving a circuit is source transformation technique.

**Source transformation** :-

As we know, there are two types of sources in a simple circuit that are Current source and Voltage source. To solve a simple circuit we can use the source transformation technique in the following way.

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/z8zwbn1rxk5qb63aow8b.jpg)


In this figure, the voltage source circuit is transformed into a current source circuit and vise versa with just a simple formulas and modifications in the circuit.

**Considering the voltage source to current source scenario**:-
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/cffhjq1zh2gqm0bo3fsx.JPG)


 This voltage source circuit can be transformed into a current source circuit by replacing the resistance Z from series **“multiplier”** to parallel **“shunt”** and replacing the voltage source with current source with simple formula of I=V/Z

where I = current, V = voltage and Z = resistance in series with voltage source.

We finally get the circuit:-
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/22vugkah0h57om3p6zuh.JPG)

**Considering the current source to voltage source scenario:-**
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/22vugkah0h57om3p6zuh.JPG)



This current source circuit can be transformed to voltage source by replacing the **“shunt”** resistance Z in series with the voltage source as **“multiplier”**. The current source is replaced by voltage source and it can be calculated by V=I x Z

where V= voltage, I= current and Z= parallel resistance.
Finally we get the circuit as:-
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/a9nz28x0sndh7h19pisv.JPG)
How I Wasted Two Years In Opensource Development
Tags: opensource, programming, productivity, dotnet
Published: 2021-04-09 08:15:47

I’m an open-source love. I started developing an open-source side project in 2006 and that was the secret that boosts my career. Thanks to the experiments that I have made during this trip I’m now a better developer and I give back something to the community — almost I hope.

I wrote about my vision of opensource as a driver for companies and developers growth here but that is another story 😄

In this article, I want to talk about my experience since 2018 on an open-source low-code platform called RawCms. 

This project failed but let me grow up teaching me things that I couldn't have imagined **when I do the whole project in two days instead of two years just by changing technology.**

[Read the full article for discover my failure and what you can learn from it](https://towardsdatascience.com/how-i-wasted-two-years-in-opensource-development-9be71491ce62?sk=225ba4fd88e40549e1d47ebc73adf8d0)
WWC MENTORSHIP - WEEK 2
Tags: womenintech, computerscience
Published: 2021-04-09 07:46:10

In week 1 we had gathered all the upcoming opportunities , so week 2 was all about preparing for the same .

As suggested by our mentor Urvi goel , any off campus opportunity require 2 things , apt resume and very strong hold on DSA (problem solving skills ).
So our task for this week was to build a resume and improve our problem solving skills .

Few tips suggested by our mentor while building a resume :

1)Use sites like Overleaf or Novoresume , they have amazing templates.

2)Choose a template that is not very crowded , better if its one column.

3)Make sure to add an About You section in your resume , it will give recruiter an idea about you .

4)In your education section , after writing your school and college details , accurately mention your gpa as well.

5)In your project section after briefly describing , be sure to add a working link to your project .

6)Add links to your github and linked in accounts .

7)Create a different section for your relevant coursework (DS,java ,oop)

8)Keep your resume one page .

9)Save your resume as FIRSTNAME_LASTNAME.pdf


Coming to the problem solving skills , we were advised to practise on leetcode.
Few suggestions given by our mentor:

1)Keep a target for yourself (maybe 3- 4 problems per day).

2)Don’t waste a lot of time on a problem, check the discussion
 section if feel stuck .

3)Try taking leetcode monthly challenges , they improve our consistency .

4)Give mock interviews , to see where you stand .

Week 2 was very productive for me , i always felt lost while preparing for my coding interviews , now i can finally say i have found my path.
Handle CSRF issue when upgrade Rails from 5 to 6
Tags: rails
Published: 2021-04-09 07:43:32

I would like to share my knowledge on how to handle the issue regarding the authenticated token from `csrf_meta_tags` that are not compatible between Rails 5 and 6 versions, which causes an error something like this;

![Screenshot 2564-04-09 at 13.20.27](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/jxwqwxhyhrcw80m0oxkz.png)

#### What is `csrf_meta_tags`?

It's a helper method to generate meta tags "csrf-param" and "csrf-token" with the name of the cross-site request forgery protection parameter and token. It's also a view helper that embeds the authenticity token into the HTML.

As you know, Rails 6 has a different algorithm for csrf token generation and its incompatibility, and to avoid showing errors to users, we decorated csrf generate function to catch the aforementioned errors and reset the session.

As mentioned previously, csrf token generation between Rails 5 and 6 is incompatibility so what should do is as given below;

Firstly, If you found that you got the error `ArgumentError` with `invalid base64` due to an incompatible csrf token generated in your application, then you could implement the code by using the `rescue` concept.

Putting in `application_controller.rb`

```rb
rescue_from ArgumentError do |exception|
  if request.format.html? && exception.message == "invalid base64"
    request.reset_session # reset your old existing session.
    redirect_to login_path # your login page.
  else
    raise(exception)
  end
end
```

Next, How about if your application needs to handle the AJAX request, then.

```rb
rescue_from ArgumentError do |exception|
  if request.format.html? && exception.message == "invalid base64"
    request.reset_session
    redirect_to signin_path
  elsif request.xhr? && exception.message == "invalid base64"
    request.reset_session
    render js: "window.location = '#{login_path}'"
  else
    raise(exception)
  end
end
```

From the above snippet code, You can also check whether the request is `xhr?` because the `AJAX` request is not a request from HTML format. So it would be best if you handled this case as well.

You can then redirect a user back to the login page again if a token that's generated from the `csrf_meta_tags` incompatibility.

I hope this solution may solve the special issue of `csrf_meta_tags` that comes from upgrade Rails 5 to 6 and prevent showing the error page from the user perspective.
Vaccine Go Where
Tags: javascript, jquery, bootstrap, codesandbox
Published: 2021-04-06 14:10:28

---
title: Vaccine Go Where
published: true
description: 
tags: #javascript #jquery #bootstrap #codesandbox 
//cover_image: https://direct_url_to_image.jpg
---

Kudos to Pfizer, BioNtech and Moderna for developing their vaccines to protect us from Covid-19 in such a short time frame.

Singaporeans like to choose a vaccine for inoculation. However, locating which vaccination centre for a vaccine is such a hassle. All of a sudden, I had a Eureka moment - *"Why not write an app to double confirm the vaccine before the scheduled appointment"*. Let's name it as **"Vaccine Go Where"**. 

I struggled initially because I have not been coding for a while. Before I even started coding, I had a terrible wisdom toothache.

Somehow I persisted and felt some dopamine and an element of excitement and forgot much about the pain. Moreover, I want to help fellow Singaporeans to have a choice for vaccination. I wrote the [vaccineGoWhere](https://u192k.csb.app/) app hosted freely by the awesum CodeSandBox

{% codesandbox blissful-sunset-u192k %}

Please share it or tweak it for your country's vaccine distribution.
{% github yahgoo/vaccinegowhere %}
Restart multiple azure app services
Tags: azure, powershell, azcli, azureappservice
Published: 2021-04-09 07:28:57

We sometimes need to restart all azure app services in a subscription or service plan. It's very time consuming to do manually in the portal as it has to be done per app service but using `az cli` it's really easy. =)

``` powershell
az webapp list | convertfrom-json | foreach { az webapp restart --ids $_.id }
```
Get Instant Country Flags
Tags: react, javascript, webdev
Published: 2021-04-09 07:23:10

While working on one of my projects, there is one feature where I need to display a specific flag depending upon the country code.

My first approach was to get the country flags' zip file and extract it locally from the images folder. 
You can download the list of country flags from [here] (https://flagpedia.net/download). 

I thought this can be easy. Then, I thought as the project was on ReactJs, I wonder there might be an API for the country flags.

Then I came across,
[Country Flags](https://flagcdn.com/) - A simple API to load any country flags

**So, how does it work:**

###HTML
```html
<img src="https://flagcdn.com/:size/:country_code.png">
```

###Example
```html
<img src="https://flagcdn.com/48x36/za.png">
```
---

###Simple Data Map Syntax in ReactJs

Code:
```js
function CountryList() {
  const countries_code = ["au", "af", "bd", "br", "in"];

  return (
    <div className="country-list">
      <ul>
        {countries_code.map((code, index) => (
          <li key={index} className="mr-16">
            <img src={`https://flagcdn.com/48x36/${code}.png`} alt="..." />
          </li>
        ))}
      </ul>
    </div>
  );
}
);
```

You can check out the demo link [here](https://codesandbox.io/s/country-flag-list-1or0o)

---

Conclusion
👏👏 By coming this far I hope you can implement this awesome country flag CDN & API on your project. So, I suggest you give it a try on your project and enjoy it!

Feel free to share your thoughts and opinions and leave me a comment if you have any problems or questions.

Till then,
Keep on Hacking, Cheers
The Best Live TV APP - ThopTV APP Download
Published: 2021-04-09 07:21:00

The name Thoptv is an entertainment tool that is available to free download for Android phones & tablet devices. To watch live TV channels and online streaming anywhere around the world. Enjoy by watching TV channels, Bollywood movies, videos, drama serials, world news channels, programs, live sports, IPL & PSL live matches and TV shows without any cost. Having 3000+ international and Indian channels are available on Thoptv. You may enjoy your favorite online streaming on your mobile phone. Even to watch high-quality videos on android smartphones.

It is the best way to access & watch all live online content free with thoptv that no other alternative app provides. A few time ago thoptv becomes more popular around the world and millions of users install top tv on their devices. For more, all-in-one entertainment tools to enjoy and watch live tv serials, dramas, movies, sports, shows, news, and other live channels free of cost. Download and install Thop TV to stream your favorite videos, movies, shows, serials, and more other content online.

With android popularity, Thop database has 3000 tv channels and 5000+ radio channels. Simply clicking on the below download section to get the full apk.

Download The APP from official website:  https://www.dl-thoptvapk.com/thoptv-app-latest-2021/
Watch Live IPL 2021 on Thoptv
Tags: ipl, thoptv, cricket
Published: 2021-04-09 07:14:07

IPL 2021 is kicking off from today and you can download [Thoptv](https://apkbucket.net/thoptv-apk-april-latest-dls-2021/) Android app to watch all live matches on the go. Apart from Android, Thoptv is available for Mac, Linux, and Windows too. Here are some of the features of the Thoptv Android app.

## Thoptv Features
- It brings all live sports and entertainment channels
- An ad-free live streaming with minimal site-wide ads
- It is 100% free
- Fast streaming

Thoptv features all major live sports channels from India and other geographic regions of the world. Download the latest Thoptv APK file from the link provided above and you can start watching live matches on your portal device.
10 Image SEO Tips for Devs
Tags: seo
Published: 2021-04-09 07:11:36

As devs we don't care about SEO. But the client does. Almost all clients I worked with want their web-apps to be SEO friendly. Every time I reach that stage of the project where I have to make the images look "snack" to Google I have to do a Google search. So this post is a reference to save my future self the trouble of Googling. Here is a list of features a web-app must have to make the image SEO friendly.

1. Option to name the image - The image should have a relevant name. There should be an option naming the image at the time of uploading it.
2. Option to add alt text - Helps the screen readers.
3. Option to add a caption
4. Option to add a title - For sitemap (see point number 7)
5. Format conversion to JPEG, PNG, and WebP
6. Image resizing - Option for resizing the image to different widths. This will help the web-app to serve responsive image (see point number 9). Defaults used by Wordpress are a good starting point. Wordpress resizes every uploaded image into the following formats
6.1 Thumbnail 150px by 150px
6.2 Medium - Longest size is resized to 300px
6.3 Medium Large - Resized to 768px wide
6.4 Large - Longest size resized to 1024px
6.5 Full - Original sieze

7. Images should be added to image sitemap.
8. Minify SVG files. https://github.com/svg/svgo
9. Serve responsive image by using srcset.
10. Lazy load images - Very important to follow [Google's guidelines](https://developers.google.com/web/fundamentals/performance/lazy-loading-guidance/images-and-video/)
Get Excel Worksheets Names using Java
Published: 2021-04-09 07:03:51

When you want to find the specific worksheet quickly from several Excel workbooks that containing a lot of data, you may need to get the names of these worksheets first. This article will introduce a time-saving method to get worksheets names without opening the workbook. (API: Free Spire.XLS for Java)

**Installation**
**Method 1:** Download the [free API](https://www.e-iceblue.com/Download/xls-for-java-free.html) and unzip it, then add the Spire.Xls.jar file to your project as dependency.
**Method 2:** You can also add the jar dependency to maven project by adding the following configurations to the pom.xml.
```xml
<repositories>
        <repository>
            <id>com.e-iceblue</id>
            <name>e-iceblue</name>
            <url>http://repo.e-iceblue.com/nexus/content/groups/public/</url>
        </repository>
</repositories>
<dependencies>
    <dependency>
        <groupId>e-iceblue</groupId>
        <artifactId>spire.xls.free</artifactId>
        <version>3.9.1</version>
    </dependency>
</dependencies>
```

**Relevant Code Snippet**
```java
import com.spire.xls.Workbook;
import com.spire.xls.Worksheet;

public class GetWorksheetName {
    public static void main(String[] args) {

        //Create a Workbook object
        Workbook wb = new Workbook();

        //Load a sample Excel file
        wb.loadFromFile("report.xlsx");

        //Loop through the worksheets
        for (Object sheet: wb.getWorksheets()
                ) {

            //Get worksheets names
            String sheetName = ((Worksheet) sheet).getName();
            System.out.println(sheetName);
        }
    }
}
```

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ve0v95x7yvq1ai7qqwes.jpeg)