teleren/devto huggingface dataset:
Essential Linux commands Every Dev should know !!
Tags: linux, firstpost, codenewbie, beginners
Published: 2021-01-19 02:57:19

There are tons of commands in every Linux distro.some of the basic commands every developer should know.
 
##### 1. Check current path of the directory
  ```
  pwd
  ```
##### 2. Change to a directory 

```
cd <directory name>
``` 
> `cd data` , to enter/change to folder _data_.

##### 3. List contents of a directory

```
ls 
```
> `ls data` , will list files of _data_ folder.
> `ls -a data` , will also list hidden files in the _data_ folder
> `ls -l data` , will list files/folders in _data_ folder with permission.
> combining above two commands `ls -la data` will give you all files including hidden files with permission.


##### 4. create a directory
```
mkdir 
```
> `mkdir data` will create _data_ directory in current location.
> `mkdir -p data/video` will create _data_ directory and a video folder inside.
> `mkdir -p data/{video,music}` will create _data_ directory and  video,music folder inside.

##### 5. view content of a file
```
cat 
```
> `cat hulk.txt` , can view content of hulk.txt

##### 6. edit a file
There are several ways we can edit file in Linux , most of the Linux distro will have vim editor. so we are looking into vim today.

```
vim <filename>
```

> type `i` for insert mode , make changes to current file.
> press ESC button then type `:wq` to save the file.


##### 7. search

```
grep "pattern" file
```
> `grep "hulk" avangers.txt` , will search for the 
avangers.txt for the pattern "hulk".
> `grep -i "hulk" avangers.txt marvel.txt` for case-insensitive search in multiple files.
> `grep -nr "hulk" data` if you want to search a pattern in folder _data_.

##### 8. find the difference between two files

diff command is used to find the difference between two files.

```
diff file1 file2
```
> here we can understand difference between file1 and file2.

##### 9. find files in the system
```
find -name hulk.txt
```
> this command will find all the files named hulk.txt in the folder and sub-folder.
 
##### 10. Changing permission of a file.

- 4 - read permission
- 2 - write permission
- 1 - execute permission
- 0 - no permission

```
chmod 755 hulk.txt
```
> This gives all permission to file hulk.txt.
> In 755
 `7` is user permission
 `5` is group permission
 `5` is others permission

> for example if you want change permission/restrict permission to only for you
```
chmod 700 hulk.txt 
```

**This is my first post , let me know how can i improve in upcoming posts**
# Week 4/14 : 100 Days of Code
Tags: devjournal, 100daysofcode
Published: 2021-01-19 02:17:40

---
series: 100 Days Of Code
---
# Day 22

I've noticed that my productivity curve is diminishing recently. I get distracted more easily and start scrolling through Dev or Twitter or read cool blogs. Anyways, I set time limits for social media apps and I plan to allot time slots and get work done.

I did some problems related to modulo arithmetic. 
```
Make it fit in int range using %(10^9+7)
```
# Day 23

I revised basics of Dynamic Programming and did the Alphacode question. Next week's going to be a tough one - there's lots of events crashing.

We have placement training series for starters - everyday 2 hours for next 1 week. I scheduled my MLH technical interview for Monday. It's with Kunal Kushwaha - one of the founders of Code for Cause. I never thought I'd get to actually meet him. I'm a bit nervous and very excited. I really appreciate the work put in by Code for Cause for democratising Computer Science Education. Final Lab project due in 1 day - we have loadssssss left to doooo. Better get on with it.

# Day 24

Spent the entire day coding a social media web app using Nodejs + React + PostgresSQL ..... literally the whole day!

It was kind of fun. I still have loads left to do though. Comment module, populate in sequelize (if it's even possible) and hopefully there will be time to deploy it.

I'm feeling really bad - I should have allotted time for everything and not focus 1 dimensionally on something...

# Day 25

I attended RTC's Motivating Career Session. It opened my eyes to a lot of new things about the Tech industry and finding a workplace that resonates with you. I 'blogged' it out [here](https://dev.to/stratospher/reflections-on-rtc-s-career-sessions-5299) to leave a lasting impression. Spent the rest of the day working on the web app. It's almost done except I'm unable to render comments on the screen - when I make changes in code and run it comments get displayed, other times no changes. Why??

# Day 26

Got my next assignment for the internship. I have to demonstrate 2 reports in both power BI and tableau in 3 days. Next week's gonna be tight.

I had my social media web app demonstration today. It went well for a 3 days project. But so many more features could have been added. Did today's Leetcode challenge - it was about priority queues.

# Day 27

Sunday was a very relaxing day. I just did a few unfinished Leetcode challenges related to array maximums and pentatope numbers. Tomorrow is my big interview day. So I'm going through the code which I submitted.

# Day 28

Had my MLH interview. Idk. I prepared too much and it did't go as well as I had expected. I really really need to improve my communication skills and be able to talk freely to a person.

I did today's Leetcode challenge - it was about finding how many pairs of numbers sum to k. Tomorrow I have my Database lab exam. I just went through my notes quickly. I've seem to have forgotten most of it.😅



Hoping that the next week turns out more productive,
Bye!
@stratospher
User Management in Linux
Tags: tutorial, linux, beginners
Published: 2021-01-19 01:57:24

## User Management in Linux

User management in linux can be done by using many commands that already provided. User management in linux includes the management of user and group of users.

> User management operation is recommended using root user. To login as root user, use `sudo -i` command then enter the username and password.

## Create new user

To create a new user, use `adduser` command.

```
adduser fox
```

Then, insert related data to the new user.

```
Enter new UNIX password:
Retype new UNIX password:
passwd: password updated successfully
Changing the user information for fox
Enter the new value, or press ENTER for the default
        Full Name []: fox mccloud
        Room Number []: 64
        Work Phone []: 123123
        Home Phone []: 123123
        Other []:
Is the information correct? [Y/n] Y
```

The `useradd` command is also available for creating new user. With this command, the additional information about the new user isn't needed.

```
useradd nathan
```

## Change an user's password

To change certain user's password, use `passwd` command.

```
passwd nathan
```

To change password for group, use `gpasswd` command.

```
gpasswd mygroup
```

## View list of users

All available users can be seen with `more /etc/passwd`. This is the output example.

```
fox:x:1001:1001:fox mccloud,64,123123,123123:/home/fox:/bin/bash
```

This output includes many information such as username for login, password, user ID, group ID, additional informations, home directory and login shell.

## Remove an user

To remove an user, use `userdel` command followed with user's name.

```
userdel nathan
```

To remove an user include it's home directory, use `userdel -r` command.

```
userdel -r test
```

## Create a group

To create a new group, use `groupadd` command followed with group name.

```
groupadd ravenwest
```

To add a new member into a group, use this command. In this command, the user with username `nathan` is added into `ravenwest` group.

```
usermod -a -G ravenwest nathan
```

## View a list of groups

To view a list of groups, use `more /etc/group` command. This is the output example from the command.

```
ravenwest:x:1003:nathan,harrison
```

This output includes many information such as group's name, encrypted password, GID number, group's members.

## Remove a group

To remove a group, use `delgroup` command followed with group name.

```
delgroup ravenwest
```

To remove an user from certain group, use `deluser` command. In this example, the user with username `fox` is removed from group called `ravenwest`.

```
deluser fox ravenwest
```

I hope this article is helpful for learning user management in linux, if you have any thoughts or feedbacks. You can write in the discussion section below.
IonicVue Live Stream One: Enhancing Ionic Framework CLI List Template App
Tags: ionic, vue, javascript, tutorial
Published: 2021-01-19 01:35:26

>Related Links
- [See My Upcoming Book On Ionic & Vue JS](http://bit.ly/ionicvuebook)
- [See More Ionic VueJS Video Tutorials](https://www.youtube.com/playlist?list=PL2PY2-9rsgl2bgNTX9omlDisiWh1NYInz)

{% youtube JC60ZB9UJm0 %}
Quick Video Overview of App Built In IonicVue Livestream 1
<hr/>

Wanted to quickly get out some more interesting content in a live setting so people could watch and ask questions as I use [Ionic Framework with VueJS](https://ionicframework.com/docs/vue/overview). It is hard to get feedback and see where people are struggling when you just post a video. 

So far there are over 42 videos posted to get you started with Ionic Framework and VueJS; [See Ionic Vue JS Video Playlist](http://bit.ly/ionic-vue-playlist)

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

In the four plus hours of content we covered the following
- Walkthrough of the Ionic CLI List template
- Using refs with Ionic Component
- Creating Alerts, Loading Indicators & Toast In Ionic
- Deploying your application using Ionic Capacitor
- Working with Firebase
And much more...

All of the videos are listed below with links to full source code included in the video descriptions.

{% youtube JjwLwwX8ON4 %}
**More VueJS Content Working With Modal, Toast & Emitting Events** 
<hr/>

{% youtube jEVgY6Y_ls0 %}
**Using IonAlert, Components, Refs, Emitting Events and Deploying w/Capacitor**
<hr/>

{% youtube WRU3lHgBZXU %}
**More VueJS Content Working With Firebase Adding CRUD To App**
<hr/>
What advice would I give to new Junior Developers.
Tags: beginners, career, devpool
Published: 2021-01-19 01:34:46

**1. You don't need to know everything when you starting out:**
   One of the things that I remember when I was a Junior Developer. I thought I had to know everything. But in reality, the expectation was how fast can I learn and can I work together with a team. Because when you are starting out, your seniors or supervisor will know that you are no expert and they would be giving you easy tasks that they know you can handle and learn from bit by bit. So don't forget, when you are starting out, focus on sharpening your skills and be a team member.

**2. Learn how to break code apart:**
   One of the major things in writing code is to learn how can you make it reusable. It sounds easy, but it's a bit tricky in practice. One of the books that I would recommend (I read it as a junior and it helped me to jump-start my career) and is to read clean code written by Robert Cecil Martin.

**3. Last but not least, try to reference the docs:**
   A lot of developers (who aren't even juniors) would search Stack Overflow for the answer instead of going directly to the source. Copying and pasting the answer is not how you will get to the answer. Most of the time Stack Overflow would have answers that are not best in practice. So when you write a new piece of code lest say using JavaScript, refer to the JavaScript document on how the specific function is working.


These are my top 3 pieces of advice to Juniors that helped me to progress in the tech world much faster and I hope that this will help you to advance your technical skills much faster as well.

Subscribe to my youtube channel DevPool as my goal is to help beginners and juniors to succeed in the tech industry.

[YouTube - DevPool](youtube.com/channel/UC03vw5F2isFkbJhyEZU5bvg?sub_confirmation=1 "DevPool")
What advice would I give for beginners in software development? 
Tags: beginners, productivity, devpool
Published: 2021-01-19 01:24:10

**1. Learn by repeating it:**
   From the very beginning, I kept on redoing the work over and over again. Till I could explain it to others in a way they could understand. The reason why, it's because, by the time I get to the very end of a book, I would forget how functions or simple how loops work. That did happen to me at first, I was not able to recall the knowledge. So I had to go back and reread the topic again. Use your time wisely and don't rush yourself. Keep covering the same topic multiple times till you get sick of it and reuse it in your next topic.

**2. Successful developers learned their fundamentals:**
   I have worked with a number of professionals and to this day, I still encounter developers that make mistakes because of not having a good understanding of fundamentals. I strongly encourage beginners from the very beginning, try to spend as much time as you need to understand the foundation as it will help you in the long term of your career. 

**3. Practice by doing walkthroughs:**
   The idea behind walkthroughs is for you to read some piece of code and identify the exacted output. Repeating this process weekly will help you to speed up your learning curve plus it will pinpoint what you still need to work on. For this part, I would recommend printing walkthroughs on a piece of paper and write the new value for each variable. If you get the same result as it was expected, that means you have mastered the material and you should proceed to the next material. 

These are my top 3 advice for new beginners in software development. This is something I was doing it and it helped me to become a software developer much faster with much fewer knowledge gaps. I hope this can help you to speed up your learning process or it gives you an idea of what you could do instead.

Subscribe to my youtube channel DevPool as my goal is to help beginners and juniors to succeed in the tech industry.

[YouTube - DevPool](youtube.com/channel/UC03vw5F2isFkbJhyEZU5bvg?sub_confirmation=1 "DevPool")
Installing nodejs on macOS Apple Silicon (M1)
Tags: node, applesilicon, macos, javascript
Published: 2021-01-19 01:23:48

---
title: Installing nodejs on macOS Apple Silicon (M1)
published: true
date: 2021-01-19 01:23:00 UTC
tags: NodeJS,AppleSilicon,macOS,javascript
canonical_url: https://michael.codes/posts/nodejs_apple_silicon/
---

I recently bought a new MacBook Pro with the M1 Apple Silicon CPU. While most things seem to be working great, some developer tools are not yet distributed as native aarch64 binaries. Currently, nodejs is one of those tools. The developers are working on [official support](https://github.com/nodejs/build/issues/2474), but it isn’t available yet. Fortunately thanks to the [nvm](https://github.com/nvm-sh/nvm) project it is still easy to get up and running.

First, if you do not already have the xcode command line tools installed you should install them. This will download the needed C++ compiler and other development tools. Do this by running:

```bash
sudo xcode-select --install
```

Once that completes, install nvm per their instructions. The command will look something like the following (to ensure you get the latest version of nvm use the command from [Github](https://github.com/nvm-sh/nvm#install--update-script)).

Note that if you do not already have a profile file (~/.bash\_profile, ~/.zshrc, ~/.profile, or ~/.bashrc) for your shell it won’t be able to install correctly. You should create the appropriate file(s) first before running the command below.

```bash
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.37.2/install.sh | bash
```

Now that you have nvm installed you can run the following command to install node. Version 15 is the one that currently (Jan 2021) works on aarch64 for Mac.

```bash
nvm install v15
```

If everything works correctly this step will take a while to compile everything and copy the newly buily node to the correct install location inside the `~/.nvm` directory. After the build and install completes test the install by running:

```bash
node --version
```

You will probably need to close and re-open your terminal for the command to be found.

Finally, you will want to clear the nvm cache to reduce clutter. After the build mine was consuming about 11GB, vs about 100MB once the cache was cleared. This can be done using:

```bash
nvm cache clear
```

Hopefully, this helps someone else that is also on the bleeding edge of Apple hardware!
Tudo tem um começo
Tags: webdev, discuss, codenewbie, showdev
Published: 2021-01-19 00:38:31

Eu vejo que a maior parte dos posts aqui publicados nessa plataforma são na língua inglesa. Vou de português mesmo mas quero fazer o compromisso comigo mesmo de estar migrando para posts em Inglês. Isso é uma forma também de melhorar meu Inglês já que este mundo da tecnologia, a maior parte das coisas que encontramos como tutoriais, está nessa língua.

Vou começar publicar uma série de posts aqui para um referência para as pessoas como eu, querem ter um rumo na vida, ou na carreira de programação. Eu estou nessa, apesar de ter um emprego estável queria navegar nesse oceano que é o desenvolvimento de produtos digitais quer quer seja uma intranet, um site, um aplicativo comercial e por vai.

Fui muito feliz em conseguir em estar num grupo de mentoria com o Daniel Wildt e acredito que seja a pontapé para conseguir as coisas que almejo, pegar um pouco da experiência de que tem muito.

Como será isso... eu não sei... mas quero descobrir e vou contar aqui e quem sabe, com essas experiências que terei não te inspirem a correr atrás dos seus sonhos, do que você quer fazer, do que te completa...

Então, creio que vem muita coisa boa por aí... Me acompanhe nesse caminhada...
You may not need ngOnChanges
Tags: angular, rxjs, typescript, decorator
Published: 2021-01-19 00:29:52

"ngOnChanges" is a lifecycle hook for an Angular component to know when the @Input props are changed. The main drawback of using ngOnChanges is that you have to write much more code to watch a single prop.

Angular team also provides another way to [intercept the property changes by setter](https://angular.io/guide/component-interaction#intercept-input-property-changes-with-a-setter). If you use the setter technique naively you would find it tediously to write the getter/setter pair and the redundant private variable.

In this article, I would like to share how I improve the setter technique into an npm module - [subjectize](https://www.npmjs.com/package/subjectize).

#### Usage
Say we are building a counter component and would like to do something whenever the count changes. We could have 3 versions of implementation like below(excerpt):

1) By ngOnChanges
```js
class CounterComponent implements OnChanges {
  @Input()
  count: number;

  ngOnChanges(changes: SimpleChanges) {
    if (changes.count) {
      // do something
    }
  }
}
```

2) By naive setter
```js
class CounterComponent {
  @Input()
  get count(): number {
    return this._count;
  }

  set count(value) {
    this._count = value;
    // do something
  }

  private _count: number;
}
```

3) By Subjectize
```js
class CounterComponent implements OnInit {
  @Input()
  count: number;

  @Subjectize("count")
  count$ = new ReplaySubject(1);

  ngOnInit() {
    this.count$.subscribe(() => {
      // do something
    });
  }
}
```
They may look fair in such a simple scenario, but things go differently when you have a few Input props to watch. For ngOnChanges, you got lots if logics. For naive setter, you got many boring private variables.

The Subjectize is also a mentally-direct approach: declare a RxJS Subject and subscribe to the Subject for changes, that's it.

#### The magics
The Subjectize is a TypeScript property decorator. Under the hood, it creates an internal getter/setter for the specified Input prop, just like the naive setter implementation. The Subjectize itself only depends on RxJS, hence you can use it on any ES6 class without Angular. You could also use it for simple state management.

Without saying, there are more things to do to keep the reliabilities. If you are interested, see the [source code](https://github.com/hankchiutw/monorepo/tree/main/libs/subjectize).

#### Conclusion
JavaScript getter/setter can be used to watch Input props and [subjectize](https://www.npmjs.com/package/subjectize) helps you to do that. If you just got fed up with ngOnChanges, give [subjectize](https://www.npmjs.com/package/subjectize) a try!
ความ magic ของ Ecto.Query
Tags: elixir, ecto, programming
Published: 2021-01-19 00:26:19

[Ecto.Query](https://hexdocs.pm/ecto/Ecto.Query.html) เนี่ยเป็น module ที่ช่วยให้เราเขียน SQL Query ด้วย syntax ของ Elixir ความ magic ของมันคือหน้าตามันเหมือนจะเรียก Elixir function โดยตรงเนี่ยแหละ แต่มันไม่ใช้ สิ่งที่เขียนไปมันจะโดน macro แปลงไปอยู่ในรูปของ SQL Query ให้

ตัวอย่างเช่น โค้ดที่เขียน Query แบบนี้

```elixir
from p in Post, select: sum(p.wrapped_visits)
```

ซึ่งมันยังคงถูก syntax Elixir นะ อธิบายทีละส่วนคือมันเรียก macro ชื่อ `from`

ทีนี้เวลาเรียก macro สิ่งที่เราส่งให้มันจะยังไม่ถูก evaluate ใดๆ ดังนั้น `p in Post` และ `sum(p.wrapped_visits)` ก็จะยังไม่เกิดอะไรขึ้น `sum(p.wrapped_visits)` ที่เราเห็นว่าเหมือนเรียกฟังก์ชัน จริงๆแล้วไม่มีโค้ด function หรือ macro ชื่อ sum ใน Ecto.Query ด้วยซ้ำ

ทั้งสองส่วนนี้จะถูกแปลงเป็นรูปแบบ AST (Abstract Syntax Tree) หลังจากนั้นตัว from macro จะค่อยแปลง AST เป็น SQL Query อีกที

ถ้าเราไปลองอ่านๆโค้ดของ Ecto ที่ https://github.com/elixir-ecto/ecto/blob/v3.5.5/lib/ecto/query/builder.ex จะเจอจุดที่คิดว่าเป็น logic ในการแปลงตรง `sum(p.wrapped_visits)` เป็น SQL คือ

```elixir
  @static_aggregates [
    count: {0, :integer},
    count: {1, :integer},
    count: {2, :integer},
    avg: {1, :any},
    sum: {1, :any},
    row_number: {0, :integer},
    rank: {0, :integer},
    dense_rank: {0, :integer},
    percent_rank: {0, :any},
    cume_dist: {0, :any},
    ntile: {1, :integer}
  ]
```

และ

```elixir
  for {agg, {arity, return}} <- @static_aggregates do
    defp call_type(unquote(agg), unquote(arity)), do: {:any, unquote(return)}
  end
```

นั้นคือเวลาเรียก `sum(p.wrapped_visits)` มันจะถูกแปลงเป็น AST แล้วเอาข้อมูลใน AST มา matching กับ `call_type` ที่มีจนได้ข้อมูลเพียงพอที่จะแปลงเป็น SQL ต่อไปนั่นเอง

<a href="https://www.buymeacoffee.com/weerasak" target="_blank"><img src="https://cdn.buymeacoffee.com/buttons/v2/default-yellow.png" alt="Buy Me A Coffee" style="height: 60px !important;width: 217px !important;" ></a>