teleren/devto huggingface dataset:
Go library in gitlab private repo
Tags: go
Published: 2022-10-18 11:32:05

ความยากลำบากในการเขียน Go lib เอาไว้ใช้ในองค์กรมันระดับไหน เรามาลองทำด้วยตัวเองกัน โดยมีขั้นตอนดังนี้

1. สร้าง library ขึ้นมาง่ายๆสักตัว โดยมีเงื่อนไขคือ จะต้องตั้งชื่อ module ตาม url ที่มันอยู่จริงเช่น ถ้า url ของมันจะอยู่ที่ gitlab.myhost.com/mygroup/mysubgroup/mylib
ก็จะต้องตั้งชื่อ module ให้ตรงกันด้วยคำส่ง

```go
go mod init gitlab.myhost.com/mygroup/mysubgroup/mylib
```

โดย repo นี้จะเป็น private repo นะครับ

2. เขียน project ขึ้นมาเรียกใช้ mylib จากข้อ 1 ซึ่งมันจะ go get มาไม่ได้ถ้าเรายังไม่ทำขั้นตอนต่อไปให้จบก่อน

3. เอา url ของ lib เต็มๆมาใส่เป็นค่าหนึ่งใน Go env เช่น
ซึ่งถ้า GOPRIVATE มีค่าเดิมของมันอยู่ ก็ให้เอามาต่อกันและใช้ `,` คั่น

```sh
export GOPRIVATE=gitlab.myhost.com/mygroup/mysubgroup/mylib
```

4. โดยปกติเมื่อเราตั้งค่านี้ลงไป มันจะเอาค่านี้ไปใส่ไว้ในอีก 2 env ให้เองนั่นคือ
  - GONOPROXY
  - GONOSUBDB
ให้ตรวจสอบดูว่า ถ้ามันยังไม่เอามาใส่ให้ ก็ช่วยมันนิดนึง ตัวอย่างเช่น

```sh
export GONOPROXY=gitlab.myhost.com/mygroup/mysubgroup/mylib
export GONOSUBDB=gitlab.myhost.com/mygroup/mysubgroup/mylib
```

5. ขึ้นตอนพิเศษเพื่อให้มันได้สิทธิ์เข้าไปถึง repo นั้นคือ ให้ไปสร้าง Access Tokens โดยให้สิทธิ์ api,read_api

6. แก้ไขไฟล์ ~/.netrc โดยเพิ่มข้อมูลแบบนี้เข้าไป

```txt
machine gitlab.myhost.com
login your_account
password your_access_token
```

ก็คือนำเอา Access Token ที่เพิ่งสร้างจากข้อ 5 มาใช้เป็น password

เพียงเท่านี้เราก็สามารถใช้คำสั่ง go get ได้แล้ว

```sh
go get gitlab.myhost.com/mygroup/mysubgroup/mylib
```

หลังจากทำทั้งหมดนี้แล้ว อย่าเพิ่งดีใจไป เพราะเราก็เห็นแล้วว่าขั้นตอนมันเยอะ และให้ลองคิดสถาพตอน push ขึ้นไปวิ่งใน CI/CD ดูว่ามันจะเกิดอะไรขึ้นบ้าง

เอาเป็นว่า ถ้าอยากจะทำแบบนี้จริงๆ ก็คงต้องคุยกันหลายๆคน เพื่อหาข้อสรุปกันดูก่อนว่าเป็นอย่างไร ต้องออกแรงตรงไหนอีก และคุ้มหรือไม่

ผมขออธิบายไว้เพียงแค่นี้นะครับ
Advanced React Context with Typescript
Tags: javascript, programming, beginners, webdev
Published: 2022-10-18 11:28:48

---
title: Advanced React Context with Typescript
published: true
description: Learn how to use React Context with Typescript
tags: #javascript #programming #beginners #webdev
---

Time to talk about context again! This time it's more advanced and I'll talk about using React Context with Typescript. I'll also show how to create a custom hook and a component to use the context. Finally I'll show how to memoize the context.

{% youtube nTQ-PfUqDvM %}
Useful Python Modules
Tags: python, datascience, gamedev, webdev
Published: 2022-10-18 11:04:34


Python is a language used vastly across many domains or technical fields like data science, web development, automation etc. Being used on such a large scale we discover many new modules present and used in python. In this article, you will come across various modules in python used in different fields be it research or software building.

Fields which require python modules :

- Data Science
- GUI Development
- Game Development
- Web Development
- Automation
- Network automation/programming

First of all what are python modules ?

A python module is collection of different runnable codes, python statements and definitions. Grouping related code into a module makes the code easier to understand and use. It also makes the code logically organized, in short it reduces the amount of work to be done and also the complexity and lines of code.


Following are different types of Fields using different python modules along with their respective pip installation statement.

Most used modules in DATA SCIENCE

1. Numpy -  

```
pip install numpy
```
  -> NumPy aims to use of array object to save and use the data which faster than traditional python lists.
2. Pandas - 

```
pip install pandas
```
 -> Pandas module aims to data manipulation and importing the data into the respective workspace.
3. Scipy - 

```
pip install scipy
```
4. Matplotlib - 

```
pip install matplotlib
```
 -> Matplotlib aims to visualization of the data imported in the form of line graphs, scatter plots, histograms etc.
5. Sci-kit Learn - 

```
pip install scikit-learn
```
6. Seaborn - 

```
pip install seaborn
```

Most used modules in GUI development

1. PyQt5 - 

```
pip install PyQt5
```
2. Tkinter - The Tkinter library is built-in with every Python installation.
3. Kivy - 

```
pip install Kivy
```
4. Dear PyGui - 

```
pip install dearpygui
```
5. PySide2 - 

```
pip install PySide2
```

Most used modules in Game Development
1. Pygame - 

```
pip install pygame
```
2. Pyglet - 

```
pip install pyglet
```
3. Panda 3D - 

```
pip install Panda3D
```
4. pykyra - 

```
pip install pykira
```
5. Ursina - 

```
pip install ursina
```

Python is used to build backend in web development where you can deploy your machine learning models and make amazingly interactive and useful.
Most used modules in Web Development

1. Django - 

```
pip install django
```
2. Cherry Py - 

```
pip install CherryPy
```
3. Flask - 

```
pip install Flask
```
4. Battle
5. Web2py - 

```
pip install web2py
```

Most used modules in Network Automation

1. Netmiko - 

```
pip install netmiko
```
2. NAPALM - 

```
pip install napalm
```
3. Genie - 

```
pip install genie
```
4. NCClient - 

```
pip install ncclient
```
5. Paramiko - 

```
pip install paramiko
```

Most used modules in Automation

1. Py auto GUI - 

```
pip install PyAutoGUI
```
2. pywinauto - 

```
pip install pywinauto
```
3. Selenium - 

```
pip install selenium
```
4. Requests - 

```
pip install requests
```
5. Beautifulsoup - 

```
pip install beautifulsoup4
```
How do you deal with test record leaks?
Tags: rails, rspec, tests, leaks
Published: 2022-10-18 10:59:30

---
title: How do you deal with test record leaks?
published: true
description: 
tags: Rails, RSpec, tests, leaks
---

I've [written about test leaks](https://dev.to/epigene/minimising-spec-fragility-26a1) before, they are a pernicious, hard to debug thing that must be avoided at all costs.

Today I got a weird failure on CI and while investigating, it became apparent that some other spec is leaving records in the test DB, working outside DB transaction.

I know of two common ways to sidestep transactionality:
1. Creating records in a `before(:all)` block. Sometimes this may be necessary to save on repeat setup time, but look into [TestProf](https://test-prof.evilmartians.io/#/recipes/before_all)'s `before_all` helper for a safer approach. 
2. Creating records in inline code outside example context:
```rb
describe "#some_method" do
  # the two users fabricated in this hash will leak.
  {
    regular: FactoryBot.create(:user), 
    elevated: FactoryBot.create(:super_user),
  }.each_pair do |permission_level, record| 
    it "works for '#{#{permission_level}}'" do
      # some asserts ...
    end
  end
end
```

To avoid cases like this in the future, I recommend setting up a simple hook that checks the test DB has no records of popular models used in your app.
Place in a file location that gets loaded by spec helper, usually `spec/support/hooks/`:

```rb
class RecordsLeftInTestDBError < StandardError; end

RSpec.configure do |config|
  config.after(:suite) do
    counts = {
      some_records: SomeModel.count,      
    }

    counts.values.sum.positive? &&
      # I'd prefer `abort` to `raise`, but for some reason
      # it  does not fail the RSpec run when called from an
      # after-suite hook like this.
      raise(
        RecordsLeftInTestDBError.new(
          "Leak detected!\n" \
          "Records in the test DB after running the suite:\n" \
          "#{counts}",
        ),
      )
  end
end
```
Beginner guide to Hacktoberfest with step by step guide to your first contribution.
Tags: hacktoberfest, opensource, beginners, github
Published: 2022-10-18 10:56:43

## Hacktoberfest

Hacktoberfest is a month-long celebration of open-source software by DigitalOcean that encourages participation in giving back to the open-source community. Developers get involved by completing pull requests, participating in events, and donating to open source projects. During this event, anyone can support open source by contributing changes and earn limited-edition swag.

## Version Control
A version control system, or VCS, tracks the history of changes as people and teams collaborate on projects together. As developers make changes to the project, any earlier version of the project can be recovered at any time.

Here is the list of popular source code versioning and management tools:

1. GitHub.
2. Git.
3. GitLab.

> During hacktoberfest mostly contributions are done on GitHub and GitLab

## HERE’S WHAT YOU NEED TO KNOW TO PARTICIPATE AND COMPLETE HACKTOBERFEST:

1. Register anytime between September 26 and October 31
2. Pull requests can be made in any GITHUB or GITLAB hosted project that’s participating in Hacktoberfest (look for the “hacktoberfest” topic)
3. Project maintainers must accept your pull/merge requests for them to count toward your total
4. Have 4 pull/merge requests accepted between October 1 and October 31 to complete Hacktoberfest
5. The first 40,000 participants (maintainers and contributors) who complete Hacktoberfest can elect to receive one of two prizes: a tree planted in their name, or the Hacktoberfest 2022 t-shirt.

## Repositories for contribution on GitHub
All repository can be found [here ](https://github.com/topics/hacktoberfest)

## Step by step guide to your first contribution.

The repository I found most helpful for newbie is [here](https://github.com/hackclub/dinosaurs)

You can follow the step by step instructions at [this](https://draw-dino.hackclub.com/)

## HackClub
The goal of Hack Club is to help you become a hacker. We want a space at every school where people are making interesting things with code, every week. Schools don’t provide that, so we’re creating it in every school to make building things accessible to everyone.

## Thanks and Regards,
## Muhammad Ahsan
Vamos Fazer o Computador Pensar em um Número com Python
Tags: python, beginners, tutorial, braziliandevs
Published: 2022-10-18 10:56:38

Uma maneira prática de fazer isso é usando a biblioteca `random`. Vamos importá-la:
```py
import random
```
Dentre os métodos da `random`, existe o método `randint`, cujo objetivo é retornar um valor inteiro dentro de uma faixa especificada.
```py
random.randint(0,10)
```
Basta usar uma variável para armazenar o valor que a função irá retornar e pronto, podemos exibir o valor em que o computador pensou.

```py
x = random.randint(0,10)
print(x)
```
How to Choose Which Digital Marketing Agency is Right for You..?
Tags: webdev, programming
Published: 2022-10-18 10:52:16



![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/dc3sj6imyllaz8aw8emk.png)
You may be wondering what to anticipate from a digital marketing Company if you're thinking about employing one. To get the most out of your time with an agency, prepare by reviewing your existing marketing strategy and outlining your long-term objectives.

In order to create effective marketing campaigns, digital marketing agencies will collaborate with you to gain a thorough understanding of your company's identity, including its branding image, voice, and values.

A digital marketing company should also provide the following services: 

Full-stack digital marketing campaigns require specialized designs and strategies, and the best digital marketing services can provide just that. These campaigns will be tailored to your brand's unique image and voice.


When dealing with a digital marketing agency, you can anticipate clear and consistent communication. They might give updates on a regular basis, talk about any issues that have arisen or methods that have proven useful, and report on their progress.


Also, a top digital marketing agency should function as an extension of your in-house marketing department. As a result, they can assist free up resources and give your marketing staff more time to focus on other initiatives.


Digital marketing services  that truly care about their clients will always keep their clients' long-term goals and visions at the forefront of their minds when they craft campaigns. 

Get Digital marketing services from pixel studios : https://www.pixel-studios.com/
How to create triangles in TailwindCSS
Tags: html, css, webdev, tailwindcss
Published: 2022-10-18 10:46:16

In this post, we are going to see four examples to draw a triangle in TailwindCSS using borders.

## Triangle Down

Triangle is one of the simplest shapes in geometry. It can be drawn with just three straight lines and a couple of angles.

1. Set a width and height of 0 by: `w-0` and `h-0`
2. Set the top border to have the full height and color by: `border-t-[75px] border-t-red-500`
3. Set the side borders to half the width with the color transparent by: `border-l-[50px] border-l-transparent` and `border-r-[50px] border-r-transparent`
```html
<div class="w-0 h-0 
  border-l-[50px] border-l-transparent
  border-t-[75px] border-t-red-500
  border-r-[50px] border-r-transparent">
</div>
```
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/lty9myydv862xrzdplm8.png)

## Triangle Left
```html
<div class="w-0 h-0 
  border-t-[50px] border-t-transparent
  border-r-[75px] border-r-blue-500
  border-b-[50px] border-b-transparent">
</div>
```
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/5wkf825qmrkth0swawxe.png)

## Triangle Up
```html
<div class="w-0 h-0 
  border-l-[50px] border-l-transparent
  border-b-[75px] border-b-yellow-500
  border-r-[50px] border-r-transparent">
</div>
```
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/hvchko8w2mi3nnvx9l4r.png)

## Triangle Right
```html
<div class="w-0 h-0 
  border-t-[50px] border-t-transparent
  border-l-[75px] border-l-green-500
  border-b-[50px] border-b-transparent">
</div>
```
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/9x7x2twgrj9a2hsqjh9k.png)

In this post, we showed examples of a simple equilateral triangle. If you need a triangle with different sides, you can play with the width of the border `[*px]`.
Bun.js - Faster than Node.js
Tags: webdev, programming, javascript
Published: 2022-10-18 10:26:04

We have this new Javascript runtime that claims to be faster than Node.js.

Node.js is widely used in backend, machine learning, and data science services although it's quite a fast runtime we have a bun.js which is 3x sometimes even 6x times faster than Node.js.

The main reason behind bun being so blazingly fast is because Node runs using a chrome v8 engine whereas Bun.js handles the memory features on its own by developing its custom javascriptCore engine which tend to become or run faster than node. 

More about it on this page - https://bun.sh/

Here is the introduction to Bun.js #shorts
https://t.co/qGPkB5lYO9

Keep developing
Shrey
ihatereading.in
Comparison between binary search and logarithmic
Published: 2022-10-18 10:14:31

The number of times binary search runs increases logarithmically with the number of elements it has to search. This is the opposite of an exponential increase. For example, the algorithm must run a maximum of 2 times to search 4 items, 3 times to search 8 items, and only 5 times to search 32 items

BINERY SEARCH

Binary search compares the target value to the middle element of the array. If they are not equal, the half in which the target cannot lie is eliminated and the search continues on the remaining half, again taking the middle element to compare to the target value, and repeating this until the target value is found.

logarithmic
We will shortly encounter algorithms that run in time proportional to log N for some suitable defined N. The base-10 logarithm of a value is the exponent to which 10 must be raised to produce the value. It is written as 'log10', and usually abbreviated as just 'log'. Thus

log10 1000 is 3
log10 90 is slightly less than 2
log10 1 is 0
In algorithms, we commonly deal with the base-2 logarithm, defined similarly, written ‘log2’, and abbreviated as ‘lg’.

lg 1024 is 10
lg 9 is slightly more than 3
lg 1 is 0
Algorithms for which the running time is logarithmic are those where processing discards a large quantity of values in each iterations. The binary search algorithm you encountered a few weeks back (in the “guess a number” game) is an example. In each iteration, the algorithm discards half the possible values for the searched-for number. We will see further applications of logarithmic behavior when we work with trees in subsequent activities.
---------------------------------
Tags: csharp
Published: 2022-10-18 10:10:50

Implement the following problem using genetic algorithms in any programming language 
(e.g. C++/python/java):


<u>**Problem**</u>
Suppose your “individuals” are 32-bit computer words. You want a string in which all the bits are ones.

**Here’s how you can do it:**

- Create 100 randomly generated computer word
- Repeatedly do the following:
- Count the 1 bits in each word
- Exit if any of the words have all 32 bits set to 1
- Keep the ten words that have the most 1s (discard the rest)
- From each word, generate 9 new words as follows:
- Pick a random bit in the word and toggle (change) it
- Note that this procedure does not guarantee that the next “generation” will have more 1 bits, but it’s likely.

> THANKS ALOT!
My first OSS contribution
Tags: json
Published: 2022-10-18 09:58:25

> Date: 11/2020, Repository: [TroyTae/game-of-life](https://github.com/TroyTae/game-of-life)


Find issue at [Github Help Wanted](http://github-help-wanted.com/) and just write json!

{% embed https://github.com/TroyTae/game-of-life/pull/1355 %}


![https://troytae.github.io/game-of-life/](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ec92pkb9cx8xbtpskvid.gif)
LinkDB: A comprehensive dataset of public LinkedIn members and companies
Tags: linkdb, productivity, database, programming
Published: 2022-10-18 09:48:13

![Illustration image](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/55a33zvdklut30fr5pbq.png)
Are you aware of how easy it is to automate sales/marketing prospecting and investment analysis on LinkedIn? What if you realized that LinkDB even makes it easier?

LinkDB is an exhaustive dataset of publicly accessible LinkedIn members and companies. The database contains the profiles of 17+M companies worldwide and people's profiles separated by regions. The regions include countries like the United States, Canada, the United Kingdom, Israel, Singapore, Australia, New Zealand, and Ireland. It also has snapshots of other countries too. You can reach out to them to get a breakdown of our people profiles by country.

To access the database you need a basic knowledge of SQL, JSON query functions and operators, and SQL/JSON path expressions. Here is a basic example of how to search users by name.

```
SELECT
  id,
  parsed_data->>'first_name' AS first_name, 
  parsed_data->>'last_name' AS last_name
  FROM profile
  LIMIT 10;
```

Visit their documentation if you are interested in finding out more about their search queries, e.g. finding all Apple employees or finding Software Engineers in San Francisco.

Find out more about [LinkDB](https://medium.com/r/?url=https%3A%2F%2Fnubela.co%2Fblog%2Flinkdb-an-exhaustive-dataset-of-linkedin-members-and-companies%2F) in this post..
IndexNow Protocol with .Net
Tags: dotnet, seo
Published: 2022-10-18 09:47:03

IndexNow is an open-source protocol, created by Microsoft, to get your website get indexed faster.   The protocol is supported by Bing and Yandex and Google is testing it.

With the IndexNow protocol, search engine bots don't need to perform crawls on your website to determine whether a page has been updated. 

This reduces unnecessary site load, reducing energy consumption and enabling servers to work more efficiently.

## Steps to implement IndexNow  
1. **Generate API Key**
   API key is needed to match the ownership of the domain along with submitted URLs; should be of minimum 8 characters.
 [Generate your Key](https://www.bing.com/indexnow)

2. **Host API key**
   Host your API key on the root directory in txt format. This will help in verifying the ownership of the submitted URLs.
  Ex. https://www.yourdomain.com/6e63101cf92a4766a5880804bb9ac578.txt.txt  with _6e63101cf92a4766a5880804bb9ac578_ in the content of the txt file

3. **Submit URLs with parameters**
   Webmasters can submit individual or bulk URLs. Just submit your key location as URL parameter.
Ex. https://www.bing.com/indexnow?url=http://www.example.com/product.html&key=6e63101cf92a4766a5880804bb9ac578

## .Net Nuget Package
You can use the .Net NuGet Package [CodeHelper.API.IndexNow](https://www.nuget.org/packages/CodeHelper.API.IndexNow)

## The Code
```
using CodeHelper.API.IndexNow;

IndexNowHelper _helper = new("your-key");
await _helper.Submit("your ur");
```
   
## Submit in Bulk
```
using CodeHelper.API.IndexNow;

IndexNowHelper _helper = new("your-key", "your domain");

List<string> urlList = new();
urlList.Add("url 1");
urlList.Add("url 2");
urlList.Add("url 3");
urlList.Add("url 4");

string _response = await _h.SubmitBulk(urlList);
```
What are streams?
Published: 2022-10-18 09:44:06

Streams are one of the fundamental concepts that power Node.js applications. They are data-handling method and are used to read or write input into output sequentially.

Streams are a way to handle reading/writing files, network communications, or any kind of end-to-end information exchange in an efficient way.

What makes streams unique, is that instead of a program reading a file into memory all at once like in the traditional way, streams read chunks of data piece by piece, processing its content without keeping it all in memory.

This makes streams really powerful when working with large amounts of data, for example, a file size can be larger than your free memory space, making it impossible to read the whole file into the memory in order to process it. That’s where streams come to the rescue!

Using streams to process smaller chunks of data, makes it possible to read larger files.

Let’s take a “streaming” services such as YouTube or Netflix for example: these services don’t make you download the video and audio feed all at once. Instead, your browser receives the video as a continuous flow of chunks, allowing the recipients to start watching and/or listening almost immediately.

However, streams are not only about working with media or big data. They also give us the power of ‘composability’ in our code. Designing with composability in mind means several components can be combined in a certain way to produce the same type of result. In Node.js it’s possible to compose powerful pieces of code by piping data to and from other smaller pieces of code, using streams.

Why streams
Streams basically provide two major advantages compared to other data handling methods:

Memory efficiency: you don’t need to load large amounts of data in memory before you are able to process it
Time efficiency: it takes significantly less time to start processing data as soon as you have it, rather than having to wait with processing until the entire payload has been transmitted
There are 4 types of streams in Node.js:
Writable: streams to which we can write data. For example, fs.createWriteStream() lets us write data to a file using streams.
Readable: streams from which data can be read. For example: fs.createReadStream() lets us read the contents of a file.
Duplex: streams that are both Readable and Writable. For example, net.Socket
Transform: streams that can modify or transform the data as it is written and read. For example, in the instance of file-compression, you can write compressed data and read decompressed data to and from a file.
If you have already worked with Node.js, you may have come across streams. For example, in a Node.js based HTTP server, request is a readable stream and response is a writable stream. You might have used the fs module, which lets you work with both readable and writable file streams. Whenever you’re using Express you are using streams to interact with the client, also, streams are being used in every database connection driver that you can work with, because of TCP sockets, TLS stack and other connections are all based on Node.js streams.