teleren/devto huggingface dataset:
Let's know about Process, thread, and Synchronicity
Tags: javascript, codenewbie, webdev
Published: 2021-01-05 04:25:12

# Process and Thread
**Process and thread:** It's a program in execution. Generally, the creation of a process is resource-consuming. That's why we split our process into multiple unit's which is called a thread. It's of two types:
*Single thread:* If there is one thread in a process
*Multithread:* if more than one thread in a process

Every thread is assigned to do a specific task. The single thread executes the full process without being interrupted by a thread but in multithread it allows other threads to executed independently but shares their resources. Also, in a single thread, one thing is done at a time. But the multithread process allows multiple parts of a program to be executed at the same time.

Although most of the programming languages are single-threaded, they support libraries and other functionality that enable us to use multithreading. JavaScript is a single-threaded language. Go and Rust is the multithreaded language.

#What is Synchronous and asynchronous

In Programming, two operations are very significant is Synchronous and Asynchronous.

Synchronous operation is also called blocking operation because it blocks instruction until the task is completed. you can execute only one task at a time, after finishing the current task then the next task starts.

Asynchronous operation is called non-blocking operation because you can execute multiple things at a time and it's not necessary to finish execution of the current program in order to execute the next one. It can execute multiple programs at a time. Every program does its job independently without blocking others and they share resources among them.
Laravel Sanctum API Token Tutorial
Tags: laravel
Published: 2021-01-05 04:06:53

Here, i will show you laravel sanctum spa authentication. This article will give you simple example of laravel sanctum api authentication. you can understand a concept of laravel sanctum api auth. i would like to share with you laravel sanctum api tutorial. Here, Creating a basic example of laravel sanctum mobile authentication.

you can easily create api using sanctum in laravel 6, laravel 7 and laravel 8 version.

Laravel Sanctum provides a simple authentication system for SPAs (single page applications), mobile applications, and simple, token based APIs. Sanctum also allows each user of your application to generate multiple API tokens for their account.

So you also want to create api for your mobile application than you can follow this tutorial for how to create rest api step by step with laravel and sanctum. If you are new than don't worry about that i written tutorial step by step.

Read: https://www.itsolutionstuff.com/post/laravel-sanctum-spa-api-authentication-exampleexample.html
Ubuntu Server Hardening
Tags: ubuntu, devops, linux
Published: 2021-01-05 04:03:42

Hardening pada sistem operasi berbasis Linux merupakan kegiatan yang bertujuan untuk memperkuat keamanan dengan mengatur akses-akses yang diizinkan, seperti pengaturan akses user, menutup akses dari luar untuk layanan terbatas, dll.

Kali ini kita akan praktik hardening dengan menggunakan Ubuntu Server. Karena tulisan ini bertujuan untuk berbagi kepada temen-temen semua, sekaligus mendokumentasikan setup server saya yang baru saja terinstalasi.

# Menambah User
Hardening pertama yang akan kita lakukan adalah membuat user baru. Hal ini diperlukan karena beberapa alasan, yaitu:
* Saat pertama kali Ubuntu Server terinstalasi, kita hanya mendapatkan user root yang bila jatuh ke tangan orang lain, maka kita tidak dapat mencegah hal-hal di luar keinginan kita. Maka dari itu, kita perlu mengurangi penggunaan user root sehingga mengurangi kemungkinan orang lain melihat kita melakukan akses, terutama saat memasukkan password.
* Dengan menggunakan user selain root, kita juga mengurangi kemungkinan kesalahan dalam melakukan aksi.

Menambah user di Ubuntu Server dapat dilakukan dengan menggunakan perintah berikut:
```bash
# adduser <username>
```
Contoh:
```bash
# adduser hammurabi
```
Setelah itu, isikan password, nama lengkap, dan informasi lainnya. Setelah selesai, maka user baru tersebut sudah bisa digunakan.

Agar lebih pasti, bisa kita coba untuk masuk ke Ubuntu Server dengan menggunakan user yang baru saja kita buat. Hal ini dapat dilakukan dengan menjalankan perintah berikut:
```bash
# login
```
Kemudian masukkan username dan password user baru. Bila berhasil, maka kita akan masuk sebagai user tersebut.

# Mendaftarkan User Sebagai `sudo`
Karena kita tidak akan menggunakan user root lagi, sekarang kita perlu mengatur agar user memiliki izin untuk mengakses hal-hal terkait sistem, seperti menginstalasi aplikasi, membaca file di sistem, dll.

Mendaftarkan user sebagai `sudo` dapat dilakukan dengan menggunakan perintah:
```bash
# usermod -aG sudo <username>
```
Contoh:
```bash
# usermod -aG sudo hammurabi
```

Agar lebih pasti, kita dapat mengecek apakah user kita sudah terdaftar sebagai sudo dengan menggunakan perintah:
```bash
# groups <username>
```
Contoh:
```bash
# groups hammurabi
```
Bila tertulis `sudo` berarti user kita sudah termasuk user dengan akses sudo.

Sekarang, hardening untuk tahap user akses, sudah selesai, kalau temen-temen mau nambah lagi, bisa coba untuk mematikan akses root supaya aman. Kalau saya, cukup dengan jarang menggunakannya saja.
DAY 1 of building the Higher Order Functions in javascript. the map Higher Order Function.
Published: 2021-01-05 03:52:20

Hello community,

its been a while but i assure you this year contents gonna be lit 👨🏿‍💻🍺☕️.

So today we will be implementing the map HOF.

    //map function
    /**********
    * @prototype _map method
    * @prototype _map takes in a callback function as an   argumanet
    * @callbal function of _map prototype takes in the Array   function
    * @author: Emmanuel Onah
    **********/
    Array.prototype._map = function(callback){
        const newArray = []
        for ( let i = 0; i < this.length;i ++){
             newArray.push(this[i]);
             callback(this[i],i,this);
       }
     }
     const names = ["Jerry","Joe","Jack","sashaBlanca"];
     const newMappedArray =     names._map((eachArrayVal,index,array)=>{
     console.log(eachArrayVal,index,array)
     });
     newMappedArray;

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

[Day 2: The filter array prototype](https://dev.to/emmanuelonah/day-2-of-building-the-higher-order-functions-in-javascript-the-filter-higher-order-function-56ld)
[Day 3: The find array prototype](https://dev.to/emmanuelonah/day-3-of-building-the-higher-order-functions-in-javascript-the-find-higher-order-function-24l4)
[Day 4: The reduce prototype](https://dev.to/emmanuelonah/day-4-of-building-the-higher-order-functions-in-javascript-the-reduce-higher-order-function-643)
Working with double-byte regex expressions and Python3
Tags: regex, python, doublebyte
Published: 2021-01-05 03:09:46

As part of my project [Self Hosted Zapier Alternative](https://bas-man.github.io/post/self-hosted-zapier-alternative/); I am having to deal with doing regex searches against the three Japanese written forms, Kanji, Hiragana and Katakana.

Fortunately this is a common problem. So I have found some references for this.
Also one of my favourite tools for developing regex expressions, [Regex101](https://regex101.com),  also offers support in this area.

I found this useful [Github](https://github.com) Gist.  
**note:**
You should also check the gist directly as there are some follow up comments and additions. See [here](https://gist.github.com/terrancesnyder/1345094)

    
{% gist https://gist.github.com/terrancesnyder/1345094 %}

Using Regex101 I was able to come up with the following expression.

```Python3
r"
^「(?P<busname>[一-龯]\d{1,2})\s
(?P<destination>[一-龯]+)行き・
(?P<boardedat>[一-龯]+)」
"
```

This will successfully match a string such as:  
`「渋11 渋谷駅行き・駒沢大学駅前」でタッチしました。`
&nbsp;  
Resulting in the following three groups.  
*busname* = 渋11  
*destination* = 渋谷駅  
*boardedat* =  駒沢大学駅  


If you are working in PHP you can also use the following:  
`\p{Han}` (Using Chinese to match Kanji)  
`\p{Hiragana}`  
`\p{Katakana}`  

You can also checkout my Regex Experiments:  
[v1](https://regex101.com/r/YkltWH/1) PHP  
[v2](https://regex101.com/r/YkltWH/2) Python3
DB best practice question
Published: 2021-01-05 03:48:36

I am building an app on Strapi and am deciding on the best practice to organise the database.

I have a Table (‘Job’) that has roughly 60 rich text form fields. Additionally, each of the form fields needs to have a ‘visibility’ boolean value, which toggles whether the field is viewable by certain users.

Regarding the database structure, do you think it is better practice to have two separate fields, or to combine them into a single JSON field that contains 'value' and 'visibility' as keys within the field?

The upside of having them separate is that can store them text and boolean, but the downside is that it will double the number of fields needed for each Table.
Making my own code documentation
Published: 2021-01-05 03:48:03

<i>(This was originally posted [on my blog] (https://codingwithaaron.wordpress.com/2021/01/04/making-my-own-code-documentation/) on 1/4/2021)<i>

A simple project I started was creating my own JavaScript documentation page with functions I have learned from freeCodeCamp with my own personal definitions. I did this for a few reasons. 1) As a beginner, I find the Mozilla documentation to be hard to understand sometimes, and 2) it is an easy project that requires HTML, CSS, and some JavaScript.

Project Link: [HERE](https://codepen.io/aaronmac/full/abmYZqP)

For the freeCodeCamp HTML/CSS course, I had created a documentation page project already, however it was static. After learning about how to use JavaScript to add/change the information in a <code>div</code>, I was able to make a basic documentation page while using less page space.

For the dark colors, I used the same color hex shades of grey that Spotify uses, which I picked up from this fantastic article (which also includes other color hex combinations used by other applications and companies. I used CSS flex boxes to create a two-column layout for the buttons on the left, and the explanations on the right. The buttons were used for version 1.0 since I already knew how to attached a JS function to a button using the <code>onclick</code> attribute inside the <code>button</code> tag. One upgrade I want to use soon is making it a link on a page that lights up instead of a physical button you click, since animated links seem to be currently the popular theme (like the left-hand options on the Twitter web browser app).

In the JavaScript portion, each function is essentially the same function, except each has a different name and each outputs different information in the DOM. Below is a picture of one of the functions:

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

Here, myPop is a variable that contains the function itself. I created a <code>div</code> with the class “definition” and saved the access in the function inside the variable “place.” Each function initially resets the <code>div</code> to an empty string to make sure the <code>div</code> is cleared of any information. Then it adds the title of the function using a <code>h3</code> tag, then below is the definition wrapped in a <code>p</code> tag, and lastly I use the newly learned <code>code</code> tag to wrap an example of using the function. In short, this function accesses the “definition” <code>div</code> and places in the correct information on the function. Each version of this function clears out old information and puts in new information.

Lastly, for a bit of fun, I added the JavaScript logo in the upper right-hand side of the page to balance out the header and added soft corners (a personal favorite when it comes to borders).
Code Smell 53 - Explicit Iteration
Tags: codenewbie, webdev, cleancode, tutorial
Published: 2021-01-05 03:23:56

*We learned loops back in school. But enumerators and iterators are the next generation.*

> TL;DR: Don't use indices while iterating. Prefer Higher level collections.

# Problems

- Encapsulation

- Declarativeness

# Solutions

1. Favor *foreach()* or high order iterators

2. You will be able to use yield(), caches, proxies, lazy loading and much more when you hide your implementation details.

# Sample Code

## Wrong

[Gist Url]: # (https://gist.github.com/mcsee/9277f66f0a09b0e01ab217a65f80fe61)
```javascript
for (i = 0; i < colors.count(), i++) {
  print(colors[i]);
}
```

## Right

[Gist Url]: # (https://gist.github.com/mcsee/c5640773e3691e2aa6ac6db27b5596bf)
```javascript
foreach (color of colors) {
  print(color);
}

//Closures and arrow functions
colors.foreach(color => print(color));
```

# Detection

Linters can find this smell using regex.

There might be false positives. See exceptions below.

# Exceptions

If the problem domain needs the elements to be bijected to natural numbers like indices, the first solution is adequate.

Remember all time to find real world analogies.

{% post https://dev.to/mcsee/the-one-and-only-software-design-principle-3086 %}

# Tags

- Declarative

# Conclusion

This kind of smell do not ring the bell to many developers because they think this is a subtlety. 

Clean code is full of this few declarative things that can make a difference.

# Relations

{% post https://dev.to/mcsee/code-smell-33-abbreviations-356o %}

# More info

{% post https://dev.to/mcsee/what-is-wrong-with-software-5pa %}

# Credits

<span>Photo by <a href="https://unsplash.com/@miracleday">Elena Mozhvilo</a> on <a href="https://unsplash.com/s/photos/jack-in-the--box">Unsplash</a></span>

* * *

> If you get tired of writing for loops, take a break and continue later.

_David Walker_
 
* * *
 
{% post https://dev.to/mcsee/software-engineering-great-quotes-26ci %}

* * *

Original twitter thread by @[Matt Moll](@MattCodeJourney)

{% twitter 1346193744178110465 %}

* * * 

This article is part of the CodeSmell Series.

{% post https://dev.to/mcsee/how-to-find-the-stinky-parts-of-your-code-1dbc %}

*Last update: 2021/06/13*
Free C++ Course for Complete Beginners!
Tags: beginners
Published: 2021-01-05 03:01:37

Hello! this is about a free course that I came across in educative platform.It is about learning c++ for beginners.It is a free course and not a video based one(text based).i found that the average video tutorial is spoken at 150 words per minute, while you can read at 250. 

https://www.educative.io/courses/learn-cpp-from-scratch?affiliate_id=5073518643380224

This is my first post.. hope this helps.👍
[HOW TO]: New Year Resolutions
Tags: productivity, programming, career, discuss
Published: 2021-01-05 02:53:45

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

---

🧘‍♂️ Why do people do new year resolutions?

Probably, because you want to cultivate a new habit that would improve your life?



This year don't just start a new year resolution...

make sure you finish it too!

###HOW? 👇



###STEP 1:

Choose an area you want to improve upon the most

- Health

- Career

- Work

- Relationships


###STEP 2:

Write down an action plan

Don't just say I want to improve my health

Instead, write down, I will go for a run 5x per week


###STEP 3:

Aim for 21 days first

Do it every day - whatever it takes, don't skip it

Step up and hustle!


###STEP 4: 

Track your progress

With some app or simple pen and paper

Find a buddy to keep yourself accountable


###STEP 5:

Don't stop until you have reached your goal!


####What is your goal in 2021?
Creating a database from scratch with Node.js - Day 10
Tags: javascript, node, database
Published: 2021-01-05 02:52:20

Hey folks

This will be a quick update, I really have to sleep

Today I've added the UPDATE and DELETE statements in the database (both in LQL and LuisDB)

this is how they work 

### Update 

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

### Delete 

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

pretty much like SQL 

tomorrow I will write some proper documentation and probably start working on a global CLI for LuisDB 

These are the repos for the projects 

{% github ciochetta/learndb no-readme %}

{% github ciochetta/lql-parser no-readme %}
Multi python versions on Mac using pyenv
Tags: python
Published: 2021-01-05 02:50:04

## install using Homebrew

```
brew update
```

```
brew install pyenv
```

## Configure your Mac's environment

Depends on your shell (mine was zsh)
```
echo 'eval "$(pyenv init -)"' >> ~/.zshrc
```
Activate the change
```
source ~/.zshrc
```

## Install a version of Python
```
pyenv install python3.4.10
```

## Set your environment python
```
pyenv local python3.4.10
```
Help me !!
Tags: opensource, contributorswanted, github, webdev
Published: 2021-01-05 02:40:05

Hey folks 😊 👋

I am new to web development..
I have created my website for my project showcase..
Here is the link 🔗👇

http://uniquebond.live/

But i see this is not looking Good..☹️
I mean my website is <strong>NOT RESPONSIVE</strong>

and i think some css-padding issue in my code..
I hear that many people will help me out here!!😘

Anyone want to contribute to my Repository and can make my website look professional..
Here is the link 🔗 of my Repo. 
https://github.com/wasimparsani/ledcube.github.io


That will be great help for me !!

Thankyou so much!!😊
How to Use Elixir Pipes
Tags: elixir, tutorial, programming
Published: 2021-01-05 02:30:55

A while ago I was introduced to an awesome functional language called Elixir. It's a young ecosystem but has plenty of useful libraries and frameworks, like [Phoenix Web Framework](https://phoenixframework.org) which we use on my team here at IBM.

When I was learning Elixir there were completely new concepts I hadn't seen in previous languages. The pipe operator is one of those and it's well worth learning.

## The Pipe Operator

Is used to *pipe* output from one function to another via the 1st argument.

```elixir
# traditional
myFunction(arg1, arg2, arg3)
# with a pipe
arg1 |> myFunction(arg2, arg3)
```

All it does is feed the left side into the right side -- riveting!

## Example

It's best to teach something like this through examples. Let's say we want to write a function which filters an array and then sorts it.

In JavaScript, we may write something like this:
```javascript
function filterSort(l) {
  l = l.filter(n => n < 3);
  l = l.sort();
  return l;
}
```

In Elixir, we can simplify using pipes
```elixir
def filterSort(l) do
  l
  |> Enum.filter(fn n -> n < 3 end)
  |> Enum.sort()
  # return is not required in Elixir!
end
```

Here we needed 2 pipes. One to pass the original list into the filter function, and the second to pass our filtered list into sort. We can chain pipes as much as we like. It makes for some really clear and maintainable code when done right.

## Debugging with pipes

We can debug effortlessly by adding `IO.inspect()` (Elixir's equivalent to `console.log` or `print`) to our chain of pipes. Continuing from our example, let's inspect the state of our list between each manipulation.

```elixir
def filterSort(l) do
  l
  |> IO.inspect()
  |> Enum.filter(fn n -> n < 3 end)
  |> IO.inspect()
  |> Enum.sort()
  |> IO.inspect()
  # return is not required in Elixir!
end
```

This works because `IO.inspect()` will return whatever value you originally gave it; allowing the pipe to carry on your list to the next function in your chain.

Having a hard time understanding pipes? Feel free to ask questions in the comments!
New eBook On Ionic Framework VueJS and Capacitor
Tags: ionic, javascript, vue, mobile
Published: 2021-01-05 01:57:19

Starting 2021 off with some new content, an eBook, and then following up with the video series as part of a bundle.

The book is currently titled

["Build a VueJS App with Ionic Framework, SQLite, And Capacitor"](https://leanpub.com/ionic-vue-sqlite-crud/) 

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

It is an ebook that I am self-publishing on [Leanpub](https://leanpub.com/). The book is written using vuejs without typescript and walks you through the process of building a CRUD application using SQLite as the data storage mechanism. We also step through the process of running the app on IOS and Android since the SQLite Plugin only works on the device.

You can get more specifics about the contents of the book by checking out the [landing page](https://leanpub.com/ionic-vue-sqlite-crud/).

{% youtube kHopRsPfYv0 %}

Thanks and Happy New Year
New Year 2021, New Blog, First Post, New Goals!
Tags: firstpost, newyear, 2021, helloworld
Published: 2021-01-05 01:45:15

By the end of 2020, I felt really stagnant. I lost my first full time after just a year due to Covid, after working so hard to make my career switch. I don't plan to stay feeling this way forever though! I am starting off my 2021 with a bunch of new goals to try. I don't know which one I will want to stick with eventually - there are so many things I want to do - but I will never know without taking the first step.

One of them, obviously, is to start blogging again. My previous blog in WordPress wasn't that consistent. I kind of just did it whenever I felt like it. This time, I am going to blog at least once a week.

As for what to post... well, I did said I had a bunch of goals, so this blog will probably be what I will learn. My current schedule:
* Monday - Tuesday: Anything VR. Unity for now - in fact, my cover image for this is from the Unity tutorial I am doing, taken while the Lego figure is dancing!
* Wednesday - Thursday: Laravel. As a CMS developer, I have to keep growing my PHP skills!
* Friday - Saturday: Python, my first programming language love. I also need to refresh my knowledge with data structure and algorithm.
* Sunday: Cybersecurity, because MIT is providing the course "Cybersecurity for Critical Urban Infrastructure" on edX. Considering I work mostly with gov websites & my interest in urban planning, I am definitely going to do it.

I also plan to do daily Yoga, and I have been knitting a shawl while watching programming videos. 

Yes, this is a very pack schedule, but I don't plan to keep all of them. This is all about explorations. This is the fun of New Year Goal! Let's do this!!!

And now, as mandatory for any new programming project...

Hello World!