teleren/devto huggingface dataset:
Go private packages
Tags: go, git, webdev
Published: 2020-10-04 07:33:07

---
title: Go private packages
published: true
description: How to deal with private packages on Go
tags: go, git, gitlab, webdev
cover_image: https://cdn.ednsquare.com/s/*/f2be2b1f-dc93-4540-966c-e3f316aca376.png
---

**TL;DR**
_git submodules_ 

## **What's the matter?**

Imagine a situation when you're following best practices, splitting your code on different parts, and ... facing an issue to collect them.
Unfortunately, go does not support private packages well.

## **So, how?**

I'll describe the situation I faced. Private go mod packages, located in the GitLab subgroup (let's say `gitlab.com/org/department/repo1.git` just for example)

First, go not actually supports GitLab subgroups. To bypass that issue, we need to set GOPRIVATE env variable and add .git in the end:

```bash
$ GOPRIVATE="gitlab.com/org/department" go get gitlab.com/org/department/repo1.git 
```

Second barrier is access to that repo. SSH key must be added to the platform, I didn't found a way to fetch with https.

Pros:
- Native experience (go get, which handles `go.mod` changes itself)  

Cons:
- SSH key must be set
- go.mod package name must fully correspond that naming (with `.git` in the end)

## **Problem is solved ... or not?**

The first problem was faced in just after half an hour. It's a CI/CD, or just building step.
As we understood from previous "summary", SSH key must be added. We are using Docker to build our project, and passing SSH key to the Dockerfile build actually is a security problem.

## Alternative way

I found a solution in **_git submodules_** and **_replace_** feature for the `go.mod`.
Just add needed repo as a project submodule with `git submodule add` and add naming replacement in the `go.mod`.
For example:

Adding submodule
```
$ git submodule add ../repo1
```

Pulling newly added repo
```
$ git submodule update --init
```

Adding `go.mod` replacement
```
replace gitlab.com/org/department/repo1.git => ./repo1
```

And that's all! Handling package as a submodule is much easier than go package.

P.S. Don't forget to add submodules pulling in your CI! In case of GitLab it's `GIT_SUBMODULE_STRATEGY: recursive` variable.

Thank you for reading!
Spam on dev.to? 
Tags: meta
Published: 2020-10-04 07:29:09

I have seen a dozen of blatant spam on dev.to since today morning from atleast 3 different accounts, which I have subsequently reported. 

Please refrain from harming this great community. As for others who have witnessed similar things on your feed, please report them as well.

It will also be great if dev.to imposes a stricter spam avoidance mechanism on posting to feed, since shitoberfest is already a real thing now. 😔


<hr>
PS. I have screen recorded my feed if needed later on, but would prefer not to doxx anyone or violate anyone's privacy.

Thanks to Karl Heinz Marbaise,  https://dev.to/search?q=customer%20care%20number&filters=class_name:Article filters out these reports for ease of removal.
Day 3_ Building Consistency
Published: 2020-10-03 22:35:34

I didn't do much coding today. I just finished a Hacker rank challenge and today it was on operators. Did I forget how to do something and spend almost thirty minutes on the question? Yes, yes I did. At least I understood the question well this time... I forgot to input the parameter values and didn't understand why the code was failing. I had to do a quick search on how to call a function before I realised my horrible silly mistake.

Apart from that, I spent the whole day wireframing and planning out an app for my systems analysis and design class. I think it came out okay although Figma was giving me a hard time selecting and grouping components at some point. 

Tomorrow I'll work on more assignments and the mobile view of my web technologies group project. I'll also make sure to start an actual project. There seems to be less and less time daily.

Therefore, Hi Lily!
Today you did great. You completed a whole assignment in a day, attended two events and did your challenge. Not only that, but you were able to document it (sort of). I know you're tired, I know it won't be easy everyday and you may be more tired in the future especially with you internship starting in a few days. It will be worth it though. Don't forget it.
What exactly does Indexing in a Database do?
Tags: todayilearned, sql, database, beginners
Published: 2020-10-04 07:18:12

Hey there! While working with the database, I came to know how important it is to use index on a table which holds a large number of records. In this article, I will be explaining 
what difference does it make to add an index to a table.

Consider the below student table is created in Oracle SQL Database.

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/korkvlwrvphmi5rm0v6a.PNG)

Now I want to get the details of the students who are in Primary Grade. Obviously I need to write a select query.

Select * from student where student_grade = “Primary”;

Now what happens? 

Internally it identifies the column student_grade and searches sequentially all the records which match Primary.

It finds the first record matching primary and returns the row. It finds the second record matching primary and returns the row. It continues its process of finding Primary. Skips third record and finds fourth record matching primary. Now does it stop? No. It still continues to go till the end of the table searching for primary. 

It will look fine for a table with just 5 rows but what if I have a table with 10000 records. 

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/780qwrkwbilhu80vb2uo.PNG)

Lot of time gets involved and who would respect such a time delay?

Here is where our Indexing comes to save the time. We are all aware of what indexing means. It keeps references for quicker access. A cliche example would be a index of a textbook keeping page references to topics covered in the book.

Now lets create a index on the column Student_grade and see what happens.

Create index student_student_grade_I on student(student_grade);

student_student_grade_I is the index_name.

With the addition of index on our table, a new data structure gets created which will hold the student_grade and a pointer that references the original record in the table. The Data Structure is BTree which offers the advantage that it has all the records sorted. A index would look similar to the below table on the left.

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/6po1amwc1xe2kwbi6e0b.PNG)

It now finds 2,3,4 records matching primary. Stops executing and returns the records with the help of record_pointer.

References

1)https://www.youtube.com/watch?v=aZjYr87r1b8
2)https://chartio.com/learn/databases/how-does-indexing-work/
How to run real-time Object-detection on Raspberry pi | 24fps
Tags: raspberrypi, ai, python, opencv
Published: 2020-10-04 07:09:27

Hi, I'm Sakindu from Sri Lanka...
I'm new to Dev and this is my first post.

So, many developers face issues when running advanced projects like object-detection on platforms like [Rasberry pi](https://rasberrypi.org) that don't have GPU support. I tried out some popular ways of object-detection but it didn't work. So, 
I went through the internet to see what other devs had to say about this.. 
    At last, I found '[Xailient](https://www.xailient.com)':it's a cloud-based platform for computer-vision which is an efficient way to perform object-detection on raspberry pi. You can read more on that [here](https://xailient-docs.readthedocs.io/en/latest/).

![Raspberry pi](https://encrypted-tbn0.gstatic.com/images?q=tbn%3AANd9GcRHwD3DtDMLcA9z_AJQMwMVxR9F_BdayLJM0A&usqp=CAU)

#*Prerequisites*
**I assume that you have set up the following,**
* An account in Xailient(to get a private SDK link to the 
      SDK).
+ A raspberry pi 3B/B+(I'm using 3B)(may require minimum 
      storage of 16GB).
+ A working knowledge of **Python** and **[OpenCV](https://opencv.org)**
![opencv](https://opencv.org/wp-content/uploads/2020/07/cropped-OpenCV_logo_white_600x.png)

#**Let's get it done**

##Download SDK
Ok, when all is set up, you will have to install opencv on raspberry pi via PIP..just enter the following command on a new terminal.

```python
sudo apt install -y python3-opencv
```

After that, go to [Xailient manage SDK](https://console.xailient.com/user/listModel) page, build the face SDK(ARM32 for raspi) and you will have to download the SDK from that page and unzip it...

##Add shared library to path
This is required as the library depends on some dynamically loaded shared Libraries.You can add library path to bashrc script so that you dont need to export everytime you login.

```python
echo “export LD_LIBRARY_PATH=$LD_LIBRABRY_PATH:$<pathofSDK>/Shared_arm32” >> .bashrc
```
##Install Xailient FaceSDK
To install the Xailient FaceSDK, run the Install.sh file that is inside the SDK folder. Go to the FaceSDK folder from your terminal and run the following command:
```python
./Install.sh
```
For more details on the installation process, you can refer to the Readme file that comes along with the FaceSDK.

##**Run sample face-detection code**
The FaceSDK comes with sample code that demonstrates how to use and
interact with the Xailient Face Detector Python library.


Go to samples folder and run the *picam_streaming_demo.py* script to run real-time face detection.

![face detection](https://cdn-images-1.medium.com/max/1600/1*PnQINQZTniF2VmHteTfkVQ.gif)

Voila!!! You have your face detection project ready!!!

If you have any issues, feel free to comment in comments section...
Day 1 - Beginning [Python for Students]
Published: 2020-10-04 07:00:16

# Day 1 - Beginning

Python was created by **Guido van Rossum** in 1991. Since then there are enhancements getting added. Current Python version is 3 which we will be using in our learning (as of 2020).

To start python you need to open **Command** prompt in **Windows** and then type `python` or `python3` or `py`

Here we will learn the basic `print()` command and we will print different texts in the Python window.

```python
print("Hello Everyone")
```
On on the first day we will get comfortable with our laptop and learn how to start Python and use it by simply printing some text. This will help you get used to this new way of working with computers, that is programming in computers.

I will highly recommend that with the guidance of your seniors, practice it for some time until you get comfortable. Then follow the exercises below to have fun with Python interpreter.

## Watch the Video

{% youtube suuy827J18A %}

In next exercise we will understand how we can use variable to store the text and use it again and again.

To clear the Python prompt type `cls` in **Windows** and `clear` in **Linux**.

When you are done then you can use `exit()` to come out of Python Interpreter

## Day 1 - Exercise

1. Print your name in the python interpreter window.
2. Print your favorite movie name.
3. Print the name of your school.
4. Close the Python window and open it again to print the name of your favorite food.
How to reset a file to an old revision
Tags: git, beginners, tutorial, productivity
Published: 2020-10-04 06:54:11

---
title: How to reset a file to an old revision
published: true
tags: git, beginners, tutorial, productivity
canonical_url: https://gitbetter.substack.com/p/how-to-reset-a-file-to-an-old-revision
---
![](https://cdn.substack.com/image/fetch/w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2F1d25e844-6d65-4fef-85e6-2dfbb21d3bb3_885x332.png)

> #### This post was originally posted in the newsletter [GitBetter](https://gitbetter.substack.com/). If you are interested in leveling up your game in Git, you can subscribe to it.

In this post let’s see different ways of resetting a file to a particular revision. This may come in handy in many situations.

#### Using checkout

```
git checkout <commit_hash_id> -- <file_path>

Example
git checkout cc1d4a7 -- example.py
```

I think the above command is very self-explanatory.

You are reverting a file to a particular commit. In other words, git will take the mentioned file and apply the mentioned commit changes to it.

You can mention multiple files to revert too.

```
git checkout cc1d4a7 -- example.py index.py
```

#### Using restore

```
git restore --source <commit_hash_id> <file_path>

Example
git restore --source cc1d4a7 index.py
```

We have seen **restore** in our previous edition. Restore is a new command and it helps in restoring a particular revision.

In the above command, we are using the **—source** option to tell restore to use only the particular commit hash. And we have also mentioned the file path to apply the changes only to the mentioned file.

You can use any of the above commands to reset a file. My personal favorite is **restore**.


Thank you for reading :)

> #### This post was originally posted in the newsletter [GitBetter](https://gitbetter.substack.com/). If you are interested in leveling up your game in Git, you can subscribe to it.
Temporary Private Message
Tags: devops, security, privacy
Published: 2020-10-04 06:37:14

Temporary Private Message service with encryption, self-destruction and many other security features. [**Private Message**](https://privatemessages.co/) allows you to share notes and messages with end-to-end encryption and a link that expires automatically. So you can keep what you share privately and make sure your stuff doesn't stay online forever.

##What is the private note or private message?
Have you ever tried to send sensitive information to your family or friends in your work environment but were scared of it on the Internet because you could be spied on by any malicious hackers? The private note is a free, web-based service that enables you to share highly secret notes over the internet. It is fast, easy and needs no user registration or password at all. With the private note, you can create messages which will self-destruct after being read or after a timer expires if they won't be read in time. We have a strong emphasis on security and privacy. Only those who have the complete note URL can decrypt/read the message which means that we can't give decrypted messages to third-parties or even to our own admins, even if we wanted to!

##Why use a secure temporary message service?
If you need to send a password or some other form of simple but sensitive information to someone you can not send it over IM or email. These methods are not secure, anyone with little knowledge can intercept this information during transmission. Using the private note as the "middle man" you can safely and securely transfer this data to your recipient. The private note in other words self destruct note is a web-based service that allows you to share a note or a message over the internet confidently. Write your private message, and the system will generate a secure link. Then you can copy that link into an email or instant message then you can send it to the person you want to read the note. When that person first clicks the link they will see the note in their browser and the note will immediately delete itself, which ensures that no one (even the same person) will read the note again. The link will no longer accessible.

**https://privatemessages.co**
Day 0 - Setting it up [Python for Students]
Tags: python, student, programming
Published: 2020-10-04 06:25:47

# Day 0 - Setting up the Laptop/Desktop

Course requires a very simple setup. There are two important to which will be used during this course,

- Microsoft Teams
- Python runtime

However, the **MS Teams** and **Python** installation are optional because you can use them from Browser. For Microsoft teams when you launch it, it asks whether you want to use the installed application or continue with the browser. So if you do not have an app installed you can join the team by having your browser up and running.  

For some reason if you cannot install Python in your machine, which I highly recommend then you can also use it from your browser. I say, install it. This will not take a lot of space in your machine and will give you some peace of mind.  

Here are the instructions given for the setup in both Windows operating systems and Linux based operating systems like Ubuntu.

## How you can install Python

{% youtube hrzKDORwvxs %}

### Windows

**Microsoft Teams** can be downloaded from [https://www.microsoft.com/en-in/microsoft-365/microsoft-teams/download-app](https://www.microsoft.com/en-in/microsoft-365/microsoft-teams/download-app)

For **Python** please download the **Windows** version from [https://www.python.org/ftp/python/3.8.5/python-3.8.5-amd64.exe](https://www.python.org/ftp/python/3.8.5/python-3.8.5-amd64.exe)

### Ubuntu

**Microsoft Teams** can be downloaded from [https://www.microsoft.com/en-in/microsoft-365/microsoft-teams/](https://www.microsoft.com/en-in/microsoft-365/microsoft-teams/)

For **Python** please download the **Ubuntu** version from
[Python.org](http://python.org)

After Python is installed open **Command Prompt** in **Windows** or **Terminal** in **Ubuntu** type

```python
python --version
```

if this don't work then use

```python
python3 --version
```

---
[Next: Day 1]("")

[Back to Index]("")
Excel tips - lock column and row in formula
Tags: excel
Published: 2020-10-04 06:23:01

Suppose I would like to do something like this.

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/8k4p6s9qur9zb8dfijb3.png)

Instead of calculating interest by hand, of course we should use formula to do that.

We can put `=A2*B2/100`, `=A2*B3/100` and `=A2*B4/100` to `C2`, `C3` and `C4` respectively. But it is troublesome to prepare different formulas for each row.

Instead, we can use `$` to lock both column index and row index for `A2`, so when we "paste" the formula, Excel will update the row index of `B` for us.

We put `=$A$2*B2/100` to `C2` and copy `C2`.

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/ul1bgjr3dstsqvmk9zaz.png)

When we paste the copied `C2` to `C3`, we will get `=$A$2*B3/100` without additional modification.

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/ojyds1di5tr1j2zl4vd2.png)

But still, we need to keep pasting the formula to other cells. We can simply drag the small dot at the right bottom corner of the cell to the cells you want it to copy to.

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/hey68pdejja69ler1k6n.png)
What is MERN stack & what it stands for?
Published: 2020-10-04 06:21:43

MERN stands for MongoDB, ExpressJS, ReactJS, and NodeJS, which is a web development framework. Here are basic components in developing a web application when using MERN:

MongoDB: A document-oriented, No-SQL database used to store the application data.

NodeJS: The JavaScript runtime environment. It is used to run JavaScript on a machine rather than in a browser.

ExpressJS: A framework layered on top of NodeJS, used to build the backend of a site using NodeJS functions and structures. Since NodeJS was not developed to make websites but rather run JavaScript on a machine, ExpressJS was developed.

ReactJS: Facebook created this library. It is used to build UI components that create the user interface of the single page web application.
Hash pada Webpack
Tags: webpack, hash, optimize, caching
Published: 2020-10-04 06:17:14

## Hash

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

TLDR; Hash adalah suatu kode dari hasil enkripsi yang umumnya terdiri dari huruf maupun angka yang acak. Fungsi / pengunaan Hash sendiri dalam webpack yang digunakan umumnya untuk menghindari duplikasi ketika terjadinya update pada JS / saat melakukan update. Lalu bagaimana penggunaan hash yang tepat ketika kita melakukan konfigurasi pada webpack? 

## Perbedaan dan jenis hash pada webpack
Hashing dapat digunakan dengan menggunakan kurung siku pada script webpack dan Hash sendiri memilik jenis / tipe yang sering digunakan ketika membuat script webpack.

**1. [hash]**
Ketika kita menggunakan hash maka ketika setiap build terjadi perubahan maka chunk sendiri akan membuat hash baru. 

contoh :
```javascript
module.exports = {
  //...
  output: {
    filename: '[name].[hash].bundle.js'
  }
};
```

**2. [Chunkhash]**
Ketika menggunakan chunkchash maka ketika setiap build terjadi 
perubahan pada chunk hanya chunk tertentu saja atau chunk yang entry pointnya terjadi perubahan. Maka dalam perubahan ini dalam kasus webpack ini sangat cocok digunakan untuk menghash file javascript.

contoh:
```javascript
module.exports = {
  //...
  output: {
    filename: '[chunkhash].bundle.js'
  }
};
```

**3. [Contenthash]**
Contenthash sering digunakan untuk menghash file css karena jika menggunakan hash yang sama dengan hash pada javascript maka ketika terjadi update pada entry css tersebut maka chunk file css hashnya tidak akan terganti untuk menghindari case seperti ini maka lebih baik menggunakan contenthash.

contoh:
```javascript
module.exports = {
  //...
  output: {
    filename: '[contenthash].bundle.css'
  }
};
```

### NOTES
#### Slicing hash
Jika hash dirasa terlalu panjang kita dapat menggunakan `[hash:8]` maka hash yang dihasilkan akan menjadi seperti `8c4cbfdb`

Referensi untuk dipelajari :
https://medium.com/@sahilkkrazy/hash-vs-chunkhash-vs-contenthash-e94d38a32208
https://webpack.js.org/guides/caching/
https://webpack.js.org/configuration/output/
https://codeburst.io/long-term-caching-of-static-assets-with-webpack-1ecb139adb95
Azure CLI Query JSON Output using JMESPath
Tags: azure, cli, json, jmespath
Published: 2020-10-04 05:48:23

Azure CLI retuns JSON output bydefault. To find the right information we use JMESPath to query the JSON string. Azure CLI Allows you to pass the value in `--query` parameter. 

Before we jump to the Azure CLI we can dive into the basics of JMESPath to find a bit more details.

Let's assume that we have the below sample JSON
```json
{
    "employees":
    [
        {
            "name": "Wriju", 
            "email": "wriju@contoso.com",
            "city": "Bangalore"        
        },
        {
            "name": "Wrishika", 
            "sal":
            {
                "jan":"100",
                "feb":"200"
            }
        },
        {
            "name": "Wrishika", 
            "email": "wrishika@contoso.com",
            "city": "Mysore",
            "sal":
            {
                "jan":"100",
                "feb":"200"
            }
        },
        {
            "name": "Writam", 
            "email": "writam@contoso.com",
            "city": "Siliguri"
        }
    ]
}
```

To get all the values we can write 
`employees` then it will return all the values. If you want to view the values only from field `name` then you can use 

```json
employee[*].name
```

This would result in as 

```json
[
  "Wriju",
  "Wrishika",
  "Wrishika",
  "Writam"
]
```

Now imagine you want to read the **jan** value from **sal** property then you would write

```json
employee[1].sal.jan
```
so on and so forth. 

In **Azure CLI** we can also use it filter the output result. If I want to get the **admin user name** of a VM that information is stored in 

```json
"osProfile": {
      "adminPassword": null,
      "adminUsername": "wriju",
      "allowExtensionOperations": true,
      "computerName": "wm-Ubuntu18",
      ...
```

So we can use `osProfile.adminUsername`

The final **Azure CLI** would look like,

```bash
az vm show -g rg-vm -n wm-Ubuntu18 --query "osProfile.adminUsername"
```