teleren/devto huggingface dataset:
Github Branch Naming Convention
Tags: tutorial, webdev, beginners, github
Published: 2021-04-04 14:13:03

<p><span class='first-letter'>A</span> consistent branch naming convention is part of code review best practices.</p>

<img src="https://i.imgur.com/JDpvyFK.png" alt="JIRA issue ID with description" />

1. Use ticket ID in your branch names

    If you use ticket ID, then it will be very easy to track the ticket also the ticket will be unique.

    It doesn't take much time to think about branch name and it more convenient to use it.

2. After prefixing ticket ID, add a short description of the task

    If you work with multiple member on same ticket, then it will be really great to add small description after the ticket ID.



<b> There are 2 main naming convention styles within Git. Hyphen(-) separated or slash(/) separated. </b>

1.  feature/XXX 

example: features/homepage

2.  release/XXX 

example: releases/1.1

3.  hotfix/XXX 

example: hotfix/search

You can also integrate <b>push rules</b> into your project, it seems very cool and easy as well. It definitely improves code commit structuring.

### How we integrate Push rules in GitLab 🤔

Push rules are essentially `pre-receive Git hooks` that are easy to enable in a user-friendly interface. 

In GitLab account go to <mark>Project => Settings => Repository => Push Rules</mark>

You can define it per project as well, so you can have different rules to different projects.

1. **Commit messages with a specific reference**

    Let's assume every commit should reference a JIRA issue.

    Exmaple: JIRA-11

    Then we can write a regular expression that requires JIRA issue in the commit message like `JIRA\-\d+` .

2. **Restrict branch names**

    If your company has a strict policy for branch names, you may want the branches to start with a certain name.This approach enables different GitLab CI/CD jobs (such as feature, hotfix, docker, android) that rely on the branch name.

    Any branch name that doesn’t match your push rule is rejected.

3. **Enabling push rules**
4. **Prevent pushing secrets to the repository**

### Reference 🧐

- <a href="https://community.atlassian.com/t5/Git-questions/What-branch-name-conventions-do-you-use/qaq-p/510537">Atlassian</a>
- <a href="https://git-scm.com/book/en/v2/Customizing-Git-Git-Hooks">pre-receive Git hooks</a>
- <a href="https://docs.gitlab.com/ee/push_rules/push_rules.html">Push Rules</a>

<table>
  <tbody>
    <tr>
      <td>
        🌟 <a href="https://twitter.com/suprabhasupi"> Twitter</a>
      </td>
      <td>
        👩🏻‍💻 <a href="https://www.suprabha.me/"> suprabha.me</a>
      </td>
<td>
        🌟 <a href="https://www.instagram.com/suprabhasupi/"> Instagram</a>
      </td>
    </tr>
  </tbody>
</table>
Driver class not found: com.sap.cloud.db.jdbc.Driver
Tags: java, springboot, cloud, microservices
Published: 2021-04-04 14:10:51

Me and my friend decided to start a project with the applications of Microservices, Spring Data JPA, Spring framework.
As a part of that, we implemented our databases on SAP HANA. In order to use it in our Java applications, as we all know, we need to include the dependency in our `POM.xml`.
The dependency I included is
```
<dependency>
    <groupId>com.sap.cloud.db.jdbc</groupId>
    <artifactId>ngdbc</artifactId>
    <version>2.7.15</version>
    <type>pom</type>
    <scope>test</scope>
</dependency>
```

The sets up the `application.properties` and ran our application. But oopss..... We were getting `Driver class not found` error.
What!!!! I once again checked the `pom.xml` file and yes the driver class dependency is added. Once again the program was run and the same error pops out.
The next step is quite similar for every developer. I started checking this on stack overflow and other resources. I even implemented a `CloudConfig` class which is actually of no use.. WOW!!!
There were many answers that was shown up, but nothing matches our error.
We stopped that day and continued on this the next day. Once again examined the `pom.xml` and yes, there is something special in the `pom.xml`. If everyone noticed, its great because it took almost 2 days for me to not that.

I was giving the `<scope>test</scope>`. 
> This scope indicates that the dependency is not required for normal use of the application, and is only available for the test compilation and execution phases.

So that was the problem and the class was not being used for the normal purpose. So I just removed it and yeah!!! The application started successfully and we took one more step ahead in our project.

The Updated `pom.xml`
```
<dependency>

<groupId>com.sap.cloud.db.jdbc</groupId>
<artifactId>ngdbc</artifactId>
<version>2.7.14</version>
</dependency>
```

Looking forward with more challenges in this project....
pymetry library
Published: 2021-04-04 14:09:45

# Pymetry
Pymetry easy library into use in Python
### How to use in Pymetry
With this python library, you can draw shapes in just one line of code from the turtle module.
### Draw square in Pymetry
```markdown
import pymetry
pym = pymetry
pym.square(100, "orange", 5)
#100 => distance
#"orange" => color line
#5 => line size
```
### Draw triangle in Pymetry
```markdown
import pymetry
pymetry.triangle(90, 135, 100, "orange", 0)
#90 => corner
#135 => corner
```
### Draw corner in Pymetry
```markdown
import pymetry
pym = pymetry
pym.corner(20, 100, "black", 2)
#20 => corner
```
### Draw rectangle in Pymetry
```markdown
import pymetry
pym = pymetry
pym.rect(100, "gray", 7)
```
### Draw circle in Pymetry
```markdown
import pymetry
pymetry.circle(60, "brown", 4)
```
### Draw pentagon in Pymetry
```markdown
import pymetry
pym = pymetry
pym.pentagon(150, "yellow", 8)
```
### Draw hexagon in Pymetry
```markdown
import pymetry
pym = pymetry
pym.hexagon(200, "yellow", 8)
```
### Draw heptagon in Pymetry
```markdown
import pymetry
pym = pymetry
pym.heptagon(100, "yellow", 8)
```
### Draw octagon in Pymetry
```markdown
import pymetry
pym = pymetry
pym.octagon(150, "yellow", 8)
```
### Draw polygon in Pymetry
```markdown
import pymetry
pym = pymetry
pym.polygon("blue", 3)
```
### Turtle shape in Pymetry
```markdown
import pymetry
pym = pymetry
pym.trsize("1, 20, 15)
```
Unzip an archive and attach images to Active Record model objects
Tags: rails, ruby, beginners
Published: 2021-04-04 13:50:24

Recently I worked on a project where I had to upload a zip archive of images and then attach those images to `Active Record` model objects on the Rails server.

* Note:
This example uses `Active Storage` to attach images to `Active Record` objects.

Here is how I got it all working

# Install Gem

Include this gem
```ruby
gem 'rubyzip'
```
then do
```
bundle install
```
## Unzipping and file attachment
We suppose an `Active Record` model named `Product`, which has an `Active Storage` attribute called `product_image`
```ruby
class OrderItem < ApplicationRecord
  has_one_attached :product_image
end
```
The controller which renders a zip upload form in the action `zip_upload_form` (view template code is not provided here) and the form gets posted to the `zip_file` action, which then processes the zip file by calling the `process_zip_file` method. It's better to put such code in a service but for the sake of this tutorial let's just put in the controller.

```ruby
require 'zip'

class UnzipController < ApplicationController
  
  # GET
  def zip_upload_form
    # this action renders form for zip file upload
  end
  
  # POST
  def zip_file
    # the form is posted to this action
    # this action processes the uploaded zip file
    
    # params[:zip] is the uploaded zip file    
    if params[:zip]
      process_zip_file(params[:zip])
    else
      redirect_to zip_upload_form_path
    end
  end

  private
  
  def process_zip_file(tmpfile_zip)
    Zip::File.open(tmpfile_zip.path) do |zipfile|
      
      # iterating through all the entries found in the zip file
      zipfile.each do |entry|
        if entry.file?
          puts "#{entry.name} is a file!"
          attach_file_to_model_obj(entry)
        
        elsif entry.directory?
          puts "#{entry.name} is a directory!"
        
        elsif entry.symlink?
          puts "#{entry.name} is a symlink!"
        end
        
      end
    end
  end
  
  def attach_file_to_model_obj(entry)
    # first we create a temp file from the file found in the zip archive
    # then attach the temp file to model obj
    
    Tempfile.open(["my-filename", ".#{put_extension_here}"]) do |tmp|
      # this line creates the temp file
      entry.extract(tmp.path) { true }
      
      # attaching the temp image file to active record object
      Product.first
             .product_image
             .attach(io: File.open(tmp.path), filename: "my-filename.#{put_extension_here}")
    end
  end

end
```


Cover Image by <a href="https://unsplash.com/@heytowner?utm_source=unsplash&utm_medium=referral&utm_content=creditCopyText">JOHN TOWNER</a> on <a href="https://unsplash.com/?utm_source=unsplash&utm_medium=referral&utm_content=creditCopyText">Unsplash</a>
what's the advantage of golang instead of java or C# ?
Tags: go
Published: 2021-04-04 12:45:56

There are a few reasons why I prefer [Go](https://golang.org/) over [Java](https://www.java.com/) and [C#](http://csharp.net/), not least of which is the standard library. You can install plenty of packages to do almost anything you want, but Go's standard library is minimalistic and very readable ([what is golang](https://golangr.com/what-is-the-go-language/)?).

The big advantage of golang is that the code is less verbose and easier to read and write. The syntax is easier than java, and borrowing some syntax from [python](pythonprogramminglanguage.com/) make it more natural for me than C#.

```go
package main
 
import "fmt"
 
func main() {
    fmt.Println("Hello World!")
}
```

## What is Go?

Go is a *programming language* (**golang**) with a culture that is growing out of the love for software tooling. I'll say that again. Go was built from ground up with the singular purpose of creating an ecosystem of reusable tooling that serves as the foundation for the language itself.

Go is a language that is powerful enough to be the foundation of such things as the Docker system, but simple enough that you can learn it quickly.

## Why Go?

To be honest, the real reason I start to use golang is that it's supported by Heroku (and has a free tier) and DigitalOcean (not free). That make it very easy to try, with almost no cost. 

If you try go in production, you'll probably have a little cost. At least it's possible to pay 0 if you're lucky (0$/month and 0$/hour for its free plan) and that's great.

Go is also very [easy to learn](https://golangr.com/) if you know another language such as java or C#.

Go is really focused on back-end development. For front-end you can use something like [Angular](https://angular.io/) or [Vue](https://vuejsexamples.net/)
Manage multiple node versions in windows
Tags: node, nvm, volta
Published: 2021-04-04 12:39:17

I am gonna introduce you to a tool named [Volta](volta.sh) which is a [nvm](nvm.sh) alternative.
Volta is not limited to Node JS but also manages other JS tools like global npm packages, package managers for node, etc.

#### How to use Volta
```bash
# install Volta
curl https://get.volta.sh | bash

# install Node
volta install node 
OR
volta install node@version

# start using Node
node

# change node version
volta pin node@version
 ```
For more information check out [volta website](https://docs.volta.sh/guide/)
Using Netify Redirect
Published: 2021-04-04 12:07:58

Recently, I had two annoying errors which I had to deal with on Netlify and the "_redirects" file solved both for me.

The first issue I encountered was
####CORS

![CORS](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/9m2cph9c5a7lvw2r82bt.png)
>Access to fetch at blocked by cors policy no 'access-control-allow-origin' header is present

The Almighty CORS issues - The annoying thing about CORS for me is the fact that I test all the APIs on Postman, tell the backend developer it's working - only for me to start the integration and viola - nothing works because of CORS. 

The normal approach will be to tell the backend developer to make the necessary adjustment - but in my case, this was a public API I have no control over.

- My first solution was to use **https://cors-anywhere.herokuapp.com/corsdemo**. Works fine in production but highly restricted on production.

- The second solution that came to mind was to write a quick API - call the endpoint in my API which then serves my front-end. That's a longer but secure route which I unfortunately didn't implement.

- The third solution was using **redirects** which is what I used eventually

### Here are the steps using React 
1. Create a *_redirects* file in your _public_ directory. i.e your_project_folder/public/_redirects
2. Using the format below, redirect to the endpoint
```
/api/fetchCorsEndpointData https://corsendpoint.com/data 200
```

Now anytime you want to fetch data from https://corsendpoint.com/data, make an api call to https://yoursubdomain.netlify.app/api/fetchCorsEndpointData and viola - you get your data.

The second issue was 
####Mixed Content

![Mixed Content: The page at was loaded over HTTPS, but requested an insecure resource ''. This request has been blocked; the content must be served over HTTPS.](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/5p5i1ow68z4qxustc3s1.png)
>Mixed Content: The page at was loaded over HTTPS, but requested an insecure resource ''. This request has been blocked; the content must be served over HTTPS.

The public API I was accessing was deployed on HTTP and not HTTPS - using the method specified above, I was able to access resources on the endpoint on Netlify. Specify in your `_redirects` file

```
/api/unsecureRoute http://unsecureendpoint.com/data 200
```

In your codebase, simply call `https://yoursubdomain.netlify.app/api/unsecureRoute` and it will fetch the resource on `http://unsecureendpoint.com/data`


#BONUS
The third use case for me is
####Page Refresh 

![Page Not Found](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/m9pwq8mwte18dbbochcd.png)
>Looks like you've followed a broken link or entered a url that doesn't exist on this site.

I get "Page Not Found" on refresh of a page on Netlify - the fix for me was to add the snippet below as the last line in my `_redirects` file
```
/* /index.html 200
```
I hope this helped fix whatever issue you have when deploying your React App on Netlify - let me know your thought in the comment section.

Viola✨✨✨✨
Daily Developer Jokes - Sunday, Apr 4, 2021
Tags: jokes, dailydeveloperjokes
Published: 2021-04-04 12:00:11

---
title: "Daily Developer Jokes - Sunday, Apr 4, 2021"
description: "Check out today's daily developer joke! (a project by Fred Adams at xtrp.io)"
series: "Daily Developer Jokes"
cover_image: "https://private.xtrp.io/projects/DailyDeveloperJokes/thumbnail_generator/?date=Sunday%2C%20Apr%204%2C%202021"
published: true
tags: #jokes, #dailydeveloperjokes
---

Generated by Daily Developer Jokes, a project by [Fred Adams](https://xtrp.io/) ([@xtrp](https://dev.to/xtrp) on DEV)

___Read about Daily Developer Jokes on [this blog post](https://xtrp.io/blog/2020/01/12/daily-jokes-bot-release/), and check out the [Daily Developer Jokes Website](https://dailydeveloperjokes.github.io/).___
### Today's Joke is...
![Joke Image](https://private.xtrp.io/projects/DailyDeveloperJokes/public_image_server/images/5e12596bcfd66.png)

---
*Have a joke idea for a future post? Email ___[xtrp@xtrp.io](mailto:xtrp@xtrp.io)___ with your suggestions!*

*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:___ What was Grace Hopper's favorite car?

___A:___ VW Bug
 -->
Weekly Challenge 106
Tags: perl, perlweeklychallenge, weeklychallenge
Published: 2021-04-04 11:45:56

I'm back after a few weeks away on holiday. Hope you haven't missed me :)

[Tasks](https://perlweeklychallenge.org/blog/perl-weekly-challenge-106/), [My solutions](https://github.com/manwar/perlweeklychallenge-club/tree/master/challenge-106/sgreen)

# TASK #1 › Maximum Gap

## Task

You are given an array of integers `@N`.

Write a script to display the maximum difference between two successive elements once the array is sorted.

If the array contains only 1 element then display `0`.

## My solution

This is relatively straight forward. After checking that all inputs are integers, I sort the array numerically. Then I use a foreach loop to find the maximum difference between each number.

## One liner

or as a one liner

```
» perl -E 'use List::Util "max"; my @a = sort { $a <=> $b } @ARGV; say max(0, map { $a[$_] - $a[$_-1] } (1 .. $#a) )' 1 3 8 2 0
5
```

## Examples

```
» ./ch-1.pl 2 9 3 5
4

» ./ch-1.pl 1 3 8 2 0
5

» ./ch-1.pl 5
0
```

# TASK #2 › Decimal String

## Task
You are given numerator and denominator i.e. $N and $D.

Write a script to convert the fraction into decimal string. If the fractional part is recurring then put it in parenthesis.

## My solution

As I mentioned in a previous blog post, the last time I did serious algebra was in college about 25 years ago. These days there is a Wikipedia link on [repeating decimals](https://en.wikipedia.org/wiki/Repeating_decimal) to help me.

For this task, I'm following the principle of doing long division to get to a point where we've already found a remainder. This indicates that we've found where a repetition pattern starts, and can add the parenthesis in the correct place. The Wikipedia page has an example of this, so I won't repeat it here.

## Examples

```
» ./ch-2.pl 1 3
0.(3)

» ./ch-2.pl 1 2
0.5

» ./ch-2.pl 5 66
0.0(75)
```
Statik Docker Uygulaması Oluşturma
Tags: docker, containers, linux, static
Published: 2021-04-04 11:37:45


Docker konteyner'larının en büyük dezavantajı kendi libc kütüphanesini veya uygulamalara ait diğer bağımlılıkların konteyner içerisinde olması gerekmektedir. Bunu aşmak için statik uygulamalar oluşturmak en kolay yollardan birisi.


## Bir Örnek

Bir uygulama örneği oluşturalım. Mesela, bir merhaba dünya kodu oluşturalım ve bunu `hello.cc` dosyası içerisine yazdıralım.

```c
#include<iostream>

using namespace std;
int main(){
    cout << "Merhaba, dünya!\n ";
    return 0;
}
```

GCC kullanarak bu kodu derleyelim

```bash
g++ -o hello hello.cc
```

Bu şekilde derlemiş olduğumuz kodlar dinamik olarak linklenmiş olur. Ve bu uygulamanın bağımlılıklarını `ldd` ile listeleyelim.

```bash
ldd hello
        linux-vdso.so.1 =>  (0x00007ffc0075c000)
        libstdc++.so.6 => /usr/lib/x86_64-linux-gnu/libstdc++.so.6 (0x00007f88c92d0000)
        libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f88c8f06000)
        libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007f88c8bfc000)
        /lib64/ld-linux-x86-64.so.2 (0x0000558132cbf000)
        libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007f88c89e6000)
```

Eğer ki bu kodu ikili dosyayı `scratch` docker imajı içerisinde çalıştırmaya çalışırsak muhtemel olarak hata alacağız ve çalışmayacak. Eğer çalışmasını istersek yukarıdaki bağımlılıkları imaj içerisine eklememiz gerekecek ve bu sebeple imaj şişecek.

 Ancak biz bu uygulamayı statik olarak linklersek bu hataya maruz kalmadan ve imajı şişirmeden ve bağımlılıklarla boğuşmadan ikili çalıştırılabilir dosyalar elde ederiz. Bunun için mevcut komut `-static` parametresi eklemek yeterlidir.

```bash
g++ -o hello -static hello.cc
```

Şimdi de bağımlılıkları kontrol edelim.

```bash
ldd hello
        not a dynamic executable
```

Bu şekilde statik derlenmiş ikili dosyalar docker imajı içerisinde ek bir dosyaya veya bağımlılığa ihtiyaç duymadan çalışır. Şimdi de bir Dockerfile oluşturalım.

```dockerfile
cat > Dockerfile <<EOF
FROM scratch
ADD hello /
CMD ["/hello"]
EOF
```

Bu Dockerfile ile bir imaj inşaa edelim.

```bash
docker build --tag hello .
```

Şimdi de docker imajını çalıştıralım.

```bash
docker run hello
Merhaba, dünya!
```

Örnekte gördüğünüz gibi daha küçük docker imajları oluşturmak veya  gereksiz bağımlılıklardan kurtulmak için bu yöntemi kullanabilirsiniz.
Build Flutter TODO app with APITO
Tags: flutter, apito, tutorial
Published: 2021-04-04 11:32:37

{% youtube UduPsFoOHAc %}

For those who aren't familiar with [Apito](https://apito.io/) yet, [Apito](https://apito.io/) helps you build your API on Cloud with Authentication, Authorization, CDN, Webhooks, Custom Functions gives you a Content Management Console through a unified API powered by both GraphQL & RESTApi.

So, In this tutorial we are going to build a simple flutter TODO app to understand the basic functionalities of [Apito](https://apito.io/) in a comfortable way. For this time we will be using [Apito](https://apito.io/) RESTApi service. 

First login in [Apito](https://apito.io/) (Register if you haven't already). Create a new project (Name it "TODO Notes").

### 1) Go to Models tab and create a new model named Note: 
![Create Model](https://res.cloudinary.com/squad-head/image/upload/v1611864898/apito_model_p4485k.png)

Note 
* title - Single line text field
* note - single line text field
* timestamp - double

### 2) Go to Contents tab and create some demo data: 
![Create Content](https://res.cloudinary.com/squad-head/image/upload/v1611921843/apito_2_p1cqqd.png)

### 3) Get permission token: 

For creating reading or making any change into database from client side we must have a token for prohibiting any unwanted access. As of now we will be use one admin token for everyone, so our notes will be publicly accessible. Later we will implement login/register functionality.

For this, go to **setting->Api Secrets**

Create a new token, Give any name to it, choose role "Admin" and set expiration date.

![Create Token](https://res.cloudinary.com/squad-head/image/upload/v1611922421/apito_3_qwsuji.png)

### 4) Flutter part:
Now go to [Git repo](https://github.com/ambanikousik/flutter_apito_note_taking_app), clone this skeleton flutter project and open it in your favorite IDE. 

in the project directory go open **lib/infrustructure/note_provider.dart**

![note_provider.dart](https://res.cloudinary.com/squad-head/image/upload/v1617533420/flutter-apito-note_efo5td.png)

In line 11 and 12 place your project base url and token.Then run the app and see the magic !! 
 
[This post is also published in SquadHead](https://www.squadhead.com/blog/apito-flutter-note)
![aptio todo 1](https://res.cloudinary.com/squad-head/image/upload/v1617539079/portfolio/HiShoot_20210404_160252_ba2bds.png)

![aptio todo 2](https://res.cloudinary.com/squad-head/image/upload/v1617538784/portfolio/HiShoot_20210404_160231_uvn3xz.png)
Live Test stream featuring
Tags: machinelearning
Published: 2021-04-04 11:28:52

Test stream featuring ;
SDR Console V3 / Spectrum Lab with RTLSDR Dongle RTL2832U V3
5 Element 2M Yagi Antenna facing direction of Graves Radar here in France  
Stellarium - Stars - satellites - etc
Live Sky Camera facing direction of the Graves Radar here in France
Flight Feeder feeding ADSB Exchange (unfiltered) Aircraft Tracker live - currently using web version for now
For the moment the setup is only 1 antenna (passive forward scatter radar) reflections only
https://youtu.be/nOiK4XTRRko
bash: semanage: command not found
Published: 2021-04-04 11:25:41

While trying to install semanage and it returns the below error?
[root@yuvarajan]# yum install -y semanage
Failed to set locale, defaulting to C
No package semanage available.
Error: Nothing to do

To identify which package in the RPM provides a similar option to be available, execute the below command.
$ yum provides /usr/sbin/semanage [OR]
$ yum whatprovides semanage

It will reveal the list of supporting packages like below.
policycoreutils-python-2.2.5-11.el7.x86_64 : SELinux policy core python utilities
Repo        : rhui-rhel-7-server-rhui-rpms
Matched from:
Filename    : /usr/sbin/semanage

policycoreutils-python-2.2.5-11.el7_0.1.x86_64 : SELinux policy core python utilities
Repo        : rhui-rhel-7-server-rhui-rpms
Matched from:
Filename    : /usr/sbin/semanage

Then proceed to install any one of the package further which semanage will be available in the local client.