teleren/devto huggingface dataset:
Data Structures & Algorithms using Rust: Remove Duplicates from Sorted Array
Tags: rust
Published: 2020-10-28 07:34:28

As part of Data Structures and Algorithms implementation using Rust, today we will explore `Remove Duplicates from Sorted Array` problem.

Leetcode problem link: https://leetcode.com/problems/remove-duplicates-from-sorted-array/

###### Problem Statement

```rust
Given a sorted array nums, remove the duplicates in-place such that each element appears only once and returns the new length.

Do not allocate extra space for another array, you must do this by modifying the input array in-place with O(1) extra memory.
```

###### Instructions

```rust
Example 1:

Input: nums = [1,1,2]
Output: 2, nums = [1,2]
Explanation: Your function should return length = 2, with the first two elements of nums being 1 and 2 respectively. It doesn't matter what you leave beyond the returned length.
Example 2:

Input: nums = [0,0,1,1,1,2,2,3,3,4]
Output: 5, nums = [0,1,2,3,4]
Explanation: Your function should return length = 5, with the first five elements of nums being modified to 0, 1, 2, 3, and 4 respectively. It doesn't matter what values are set beyond the returned length.
 

Constraints:

0 <= nums.length <= 3 * 104
-104 <= nums[i] <= 104
nums is sorted in ascending order.
```

###### Solution

Please find below the solution implemented using Rust

```rust
impl Solution {
    pub fn remove_duplicates(nums: &mut Vec<i32>) -> i32 {
        nums.dedup();
        nums.len() as i32
    }
}
```

Please feel free to share your feedback.

Happy reading!!!
Create Github-Pages in create-react-app project
Published: 2020-10-28 06:55:10

Today I tried to create a gh-page for my [minesweeper project](https://github.com/chenchengxing/minesweeper). Nothing fancy but I just want to publish it somewhere. It turns out to be pretty easy to do that and it was a success. Result is [here](https://chenchengxing.github.io/minesweeper/).

## Search around
I thought it's only possible to host only one github page under one account name, like jackchen.github.io. But I was wrong, according to https://pages.github.com/. 

In fact any github user can have unlimited project sites.
![GitHub_Pages___Websites_for_you_and_your_projects__hosted_directly_from_your_GitHub_repository__Just_edit__push__and_your_changes_are_live_](https://dev-to-uploads.s3.amazonaws.com/i/on1xzzj1pme4v8rwxivi.png)

## npm package gh-pages

The next step will be creating a new branch that contains all the static files.

But it doesn't sound right to do it manually. 

Then I found this https://www.npmjs.com/package/gh-pages .

Basically, `gh-pages` will help you push files under some certain folder only to 'gh-pages' branch(configurable).


## Just do it
So it seemed pretty straightforward until I hit something..

BTW, I'm using create-react-app for my project.
I went `yarn run build`, then run the `gh-pages` script. So all my build folder went to the correct branch.

But the site didn't work.
I found that the index.html was loading correctly but not other resources. So I can tell something is wrong in PUBLIC_URL.

By running, according to creact-react-app [documentation](https://create-react-app.dev/docs/advanced-configuration/), to `PUBLIC_URL=. react-scripts build` did work!

## can it be better?
Yes.. I found this https://create-react-app.dev/docs/deployment/#github-pages

It turns out create-react-app has already got it covered. Amazing!
Django React Deployment to Heroku
Tags: django, react, beginners
Published: 2020-10-28 06:54:14

I want to develop web app using Django + React. But I don't know how to use it together.

I want to deploy my web app later on Heroku, and I don't how to make it in one plan. One deployment only.

Is there any alternatives instead using React for front end with Django?
Is it worth it just by using Vanilla JS and jQuery for DJango front end?

Will in the future DJango upgrade the templating system like React?

Please advise. Thanks
Data Structures & Algorithms using Rust: Remove Element
Tags: rust
Published: 2020-10-28 06:49:10

As part of Data Structures and Algorithms implementation using Rust, today we will explore `Remove Element` problem.

Leetcode problem link: https://leetcode.com/problems/remove-element/

###### Problem Statement

```rust
Given an array nums and a value val, remove all instances of that value in-place and return the new length.

Do not allocate extra space for another array, you must do this by modifying the input array in-place with O(1) extra memory.
```

###### Instructions

```rust
The order of elements can be changed. It doesn't matter what you leave beyond the new length.

Example 1:

Input: nums = [3,2,2,3], val = 3
Output: 2, nums = [2,2]
Explanation: Your function should return length = 2, with the first two elements of nums being 2.
It doesn't matter what you leave beyond the returned length. For example if you return 2 with nums = [2,2,3,3] or nums = [2,3,0,0], your answer will be accepted.
Example 2:

Input: nums = [0,1,2,2,3,0,4,2], val = 2
Output: 5, nums = [0,1,4,0,3]
Explanation: Your function should return length = 5, with the first five elements of nums containing 0, 1, 3, 0, and 4. Note that the order of those five elements can be arbitrary. It doesn't matter what values are set beyond the returned length.
 

Constraints:

0 <= nums.length <= 100
0 <= nums[i] <= 50
0 <= val <= 100
```

###### Solution

Find below the implementation using Rust

```rust
impl Solution {
    pub fn remove_element(nums: &mut Vec<i32>, val: i32) -> i32 {
        nums.retain(|&x| x != val);
        nums.len() as i32
    }
}
```

Please feel free to share your feedback.

Happy reading!!!
Log4j2 파일 기록 방식 차이점
Tags: java, log4j, korean
Published: 2020-10-28 05:05:05

## `RollingFile`

### 장점

- 최소한의 간단한 세팅
- OS(주로 `*nix`)의 파일 가공 용이 (외부 롤링 및 압축, 잠금 등)

### 단점

- 오버헤드 (크지는 않지만 후술할 기술의 비해 상대적으로)

## `RollingRandomAccessFile`

상술한 `RollingFileAppender` 기술은 `BufferedOutputStream` 클래스를 사용하지만, 이 기술은 `ByteBuffer` + `RandomAccessFile` 클래스 조합을 사용

### 장점

- 뛰어난 파일 기록 성능 (공식 문서 상으로 20%에서 최대 200%까지)

### 단점

- `TriggeringPolicy` 와 `RolloverStrategy` 요소 필요 (보통 기본적으로 깔고 들어가기 때문에 단점같지는 않으나 `RollingFileAppender` 기술은 이 둘이 선택사항임)
- OS(주로 `*nix`)와의 파일 상호작용 불가 (외부 롤링 및 압축, 잠금 등)

## 마치며

참고로 사용 방법은 둘이 똑같다. 요구사항에서 약간의 차이가 있고, 성능을 희생하는 대신 유연한 대응이 필요하냐, 아니면 성능 믿고 log4j2에 모두 위임할거냐 차이점에 대한 당신의 선택만 있으면 된다.
보통 log4j(및 여타 logging)에서 파일을 기록하려면 `RollingFileAppender` 사용법만 알려져 있으나, log4j2 사용 시 더 강력한 `RollingRandomAccessFileAppender` 기술이 있기에 이 기술을 한글로 소개하고자 기록하였다.

끗.
How To Get Client IP with Javascript / React
Tags: javascript, react, webdev
Published: 2020-10-28 06:16:17

With VPN and Tor, IP may not be a reliable data anymore. Still there are times when we want to log that info. To my surprise, there is no built-in ReactJS (please correct me if I'm wrong about this) method that displays the client IP address. Definitely, you can retrieve that info from the request object "manually".

After trying a few popular packages, the simplest one that does the job is [public-ip](https://www.npmjs.com/package/public-ip), super simple, and it provides support for fallback URLs when the IP is not found in the request.

```Javascript
import publicIp from "public-ip";

export const getClientIp = async () => await publicIp.v4({
  fallbackUrls: [ "https://ifconfig.co/ip" ]
});
```
My First React Template
Tags: react, typescript, redux
Published: 2020-10-28 06:09:24

Hi there,
I created template React with Typescript, some customize.
You can get it with command:
``` npx create-react-app name --template react-rematch-ts```

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

I also have init some example file in project when you create. 

Link: [npm](https://www.npmjs.com/package/cra-template-react-rematch-ts)
Hope you enjoy it!
Did it 
Tags: hacktoberfest, digitalocean
Published: 2020-10-28 05:16:57

Hello I am Sagar Maheshwari, currently studying at The LNM Institute of Information Technology, Jaipur, I am new to this community and would like to grow with others. I got to know about hacktoberfest from a friend of mine and thought to give it a try.

I am new to open source, and got to know about about it from my seniors and friends, in general I am a beginner at coding with basics of c, java, python, DSA.

Completed my first Hacktoberfest challenge, feeling very nice for it.

My contributions consisted of challenge codes on hackerrank and other platforms for different languages i.e. c, java, python. I made a total of 9 pull requests out of which 8 got accepted.

Learned a lot doing this, had to scroll through certain notes and webpages to learn about the languages and it really helped me. Looking forward to the next hacktoberfest for some more open sourcing.

GitHub account: https://github.com/sagarmaheshwari

Stay home, stay safe.
custom profile readme
Tags: csharp, webdev
Published: 2020-10-28 05:13:44

So I wanted to make one of those fancy custom profile readmes,
Initially I was just going to have a few links there and some description - but since I saw someone using svg I thought I'd try using foreignObject to actually have some custom CSS and markup.

So I spend around an hour designing a silly readme layout, only to realize GitHub renders a static version of it, so none of my custom animations will work :(

I ended up completing it anyway, and it seems clicking on the rendered svg on my profile opens up a version of it (cached by github) in which the animations actually work!

![profile](https://dev-to-uploads.s3.amazonaws.com/i/axnb3armf5j1ka17hxws.png)

The above image is the final result. The code for the backend which populates the svg template can be seen at [avail/readme-backend](https://github.com/avail/readme-backend)
Rails 6.1 supports order DESC for find_each, find_in_batches, and in_batches
Tags: rails, sql
Published: 2020-10-28 05:09:44

Rails 6.1 now supports *ORDER BY* id for ActiveRecord batch processing methods like *find_each*, *find_in_batches*, and *in_batches*. This would allow us to retrieve the records in ascending or descending order of ID.

**Points to remember:**

- The *ORDER BY* clause only works with the primary key column.
- Valid values for the *ORDER BY* clause are *[:asc,:desc]* and it’s case sensitive. 
- If we use caps or title case (like DESC or Asc) then we’ll get an *ArgumentError*.

[Read more](https://blog.bigbinary.com/2020/10/22/rails-6-1-supports-order-desc-for-find_each-find_in_batches-and-in_batches.html)
Apple ARM announcement and what it means
Tags: discuss
Published: 2020-10-28 05:09:19

---
title: Apple ARM announcement and what it means
published: true
description: 
tags: #discuss
//cover_image: https://direct_url_to_image.jpg
---

So, Apple recently announced that their Macs will be transitioning from Intel based CPUs to ARM chips:

https://www.inputmag.com/tech/apple-arm-chip-cpu-hardware-details

I didn't see this one coming and it came to me as a pretty big shock!

What to make out of this?

Macs are quite popular among devs as workstations - will it stay that way, will this change put people off and have them looking for alternatives, or doesn't it really matter?

Is there a risk that this might lead to fragmentation - making things harder in terms of supporting, maintaining and installing open source or third party software/packages? (in terms of having to support more CPU architectures)

Or will other platforms (PCs, Windows, Linux) simply follow suit and also jump ship to embrace ARM? (so that this just becomes the new norm)

Is the move from Intel to ARM even a thing server-side (I have no idea if a move to ARM would even make any sense in the cloud or the data center, I'm pretty clueless TBH).

Curious about your thoughts!
How to set the permission to an executable versionnized on git
Tags: howto, tipsandtricks, git, programming
Published: 2020-10-28 08:13:24

---
title: How to set the permission to an executable versionnized on git
published: true
date: 2020-10-28 05:00:00 UTC
tags: Howto,TipsAndTricks,git,Programming
canonical_url: https://10xlearner.com/2020/10/28/how-to-set-the-permission-to-an-executable-versionnized-on-git/
---

Hello ! I’m Xavier Jouvenot and in this small post, we are going to see how to set the permission to an executable file versionnized on git.

_Self promotion_: You can find other articles on my [website](www.10xlearner.com) 😉

## Problematic

If you encountered this article, you may already be familiar with the problem, but I am going to explain it anyway 😛

When you want to commit an executable (a binary) into a git repository, you may encounter a problem when you check it out on another machine. Indeed, an error can occur, more or less explicit about the real problem, forbidding you to run your versionnized program.

In fact, this problem comes from the permission rights on the binary that are being modified when committing and checking out the file.

## Solution

To solve this problem, you want to specify to git that you want to have the permission to execute the files that you want to commit. By doing so, when you are going to check them out, you will be able to run the executable you want right away.

The command to achieve such a behavior is the following one:

```
git add --chmod=+x -- 
git commit -m "An explicit commit message"
```

The first command stages the file or the folder that you want to add, with the right permission, to be able to run either the executable passed in, or the executables contained in the folder passed to the command. The second command is a classic git command to create a commit.

With those two, your problem won’t be one anymore 😉

* * *

Thank you all for reading this article, And until my next article, have a splendid day 😉

## Interesting links

- [Stack overflow reference](https://stackoverflow.com/questions/21691202/how-to-create-file-execute-mode-permissions-in-git-on-windows)
How to write .gitignore correctly
Tags: git
Published: 2020-10-28 04:49:12

I've been frustrating when I cannot successfully make git ignore huge files such as 'node_modules' or 'mysql' etc.


Today I totally figured out why sometimes it doesn't work as I wish.


The biggest reason is that I have no idea if I want to ignore certain file, I DO NOT need to write the relative path to it, JUST have to write the name of the file or the folder, without any slash.


As long as you don't have one file with the same name in the same project folder and futhermore you don't want to ignore that one. 

The reason why is because only writing the name of the file or the folder would make git ignore all the files with that name.

> Example

```
#1
work

#2 
/work

#3
work/

#4
/work/
```

**#1**
every work folder would be ignored

**#2**
the work folder which is on the same directory with .gitignore would be ignored

**#3**
same with #1

**#4**
same with #2


I recommend only having one .gitignore and put it on the root directory.

(you can have two, and if so the one on the deeper layer would be executed first)

Personally I feel it's confusing.


One last thing, 
once you added/committed something, you have to delete its cache so you can let git ignore it.
The command following.

```
$ git rm --cached <file or directory>
```


Thank you for reading, happy coding:)
SAP Là Gì- Ứng Dụng Của Hệ Thống SAP Trong Cuộc Sống
Published: 2020-10-28 04:13:14

SAP là gì- Đây là một trong những công ty phần mềm có trụ sở chính nằm tại Đức. SAP có hơn 40 năm phát triển bền vững và được hàng ngàn tập đoàn đa quốc gia. Xem chi tiết tại: https://blog.itnavi.com.vn/sap-la-gi-he-thong-sap-hoat-dong-nhu-the-nao/
Deep Learning Là Gì- Khái Quát Kiến Thức Về Deep Learning
Published: 2020-10-28 04:06:19

Trong những năm qua, thế giới đã và đang chứng kiến sự phát triển vượt bậc của Deep Learning vào các sản phẩm công nghệ quen thuộc trong cuộc sống. . Xem chi tiết tại: https://blog.itnavi.com.vn/deep-learning-la-gi/
Hacktober 'Done n Dusted'!
Tags: hacktoberfest, opensource, github
Published: 2020-10-28 03:53:21

## What I Learned From Hacktoberfest

Well this has been my first participation in any open source contribution and I'm very happy that I had been to complete it successfully (completed 4 PRs on 16 Oct).
I did my contribution in the field of **blockchain** which I had been learning for sometime. I also contributed to **web development** in the same context, i.e., integration of blockchain with the frontend.

It was quite some experience being my first and looking forward to more such experiences ahead.
My first step 👣 towards open-source
Tags: opensource, hacktoberfest, git, github
Published: 2020-10-28 03:37:31

Hey all!! Hope you all are doing well.. This blog is all about my first open source contribution. It all started with HACKTOBERFEST 2020..I got to know about Hacktoberfest through LinkedIn.. Many people were posting about their open source contribution in Hacktoberfest.. I found it very interesting and wanted to give it a try. Hacktoberfest is a month long celebration 🎉 of contributing to open source which happens in the month of October.

Things to be done to complete Hacktoberfest:
 
👉 You need to make four valid Pull Requests in this October month. 
👉 Git and Github:
 First and foremost you need to know git and github. 
Ps😉: Even I don't know.. I learnt about git and contributed. 


👉 Registration for Hacktoberfest:

You need to register in Hacktoberfest's website to participate. 

👉 Get onto work 👀:

We can start contributing to any repository labelled "Hacktoberfest".

Checkout my github profile☺:

https://github.com/Raghavi94

That's it about my first open source contribution.. Thanks for reading😇
Designers Take: Free Vector Resources for Devs
Tags: webdev, beginners, design, tips
Published: 2020-10-28 03:16:27

As a designer turned developer, some tools are relevant to both and need to stay sharp in the toolbox. One of those tools I have found are the use of vector graphics. There are several types of vector graphics used frequently within web design and development including illustrations, icons, and even animations. I have collected this list by category of some of my favorite (and generally free) resources for vectors. Hopefully this list provides you with some additional tools for your own toolbox to keep your designs and skillset sharp.

## Free Vector Graphic Sites (by Category)
--- 
### Illustrations
These platforms have a wide variety of fun and customizable set of illustrations you may find useful for your project. They can be used for things such as splash page images, hero images, or even on your 404 page!.
###### [unDraw](https://undraw.co/)
###### [FreePik: Stories](https://stories.freepik.com/)
###### [Blush](https://blush.design/)
###### [icons8: illustrations](https://icons8.com/illustrations)
###### [The Pattern Library](http://thepatternlibrary.com/)

### Icons
Icons can be used for a variety of things across a web application and its nice to keep your project's icon set fresh. This list provides you a TON of free and easily customizable icons to use throughout your project. 
###### [The Noun Project (Also has a great photo selection)](https://thenounproject.com/)
###### [Flaticon](https://www.flaticon.com/)
###### [Heroicons](https://heroicons.com/)
###### [icons8](https://icons8.com/)
###### [Font Awesome: Cheatsheet](https://fontawesome.com/cheatsheet)
###### *Honorable Mention (because of it's free option!): [Shape.so](https://shape.so/)


### Animations
The use of animations on the web is very popular already, and can be used for stylistic and attention grabbing purposes. I will leave the specific learning of javascript animation frameworks for another day, but instead provide a list of free resources that allow for the free downloading and insertion of pre-made animations (Lottie), animation prototyping tools, and principals for when and how to use animations across your projects.
###### [Lottie by AirBnb](https://airbnb.io/lottie/#/)
###### [LottieFiles: Searchable lottie animations](https://lottiefiles.com/)
###### [Framer: Free animation prototyping tool](https://www.framer.com/)
###### [Origami: Free animation prototyping tool](https://origami.design/)
###### [Material Design: Understanding Motion](https://material.io/design/motion/understanding-motion.html#principles)


--- 
## Conclusion
With the right box of sharpened tools, we all can produce more beautiful, more powerful, and more effective work. One of the tools you should include in your dev toolbox is the resources for finding beautiful and customizable vector graphics. I hope you find some value in the above resources, and are able to pick and choose a few of your own favorites to sharpen this fun and important tool in your box.
Entendendo os arquivos .bashrc e .profile
Tags: linux, portugues, terminal, freebsd
Published: 2020-10-28 01:53:10

# TL:DR

Os arquivos .bashrc e .profile são usados para definir variáveis de ambiente e executar comandos para usuários do sistema(.profile) ou seu usuário (.bashrc).

# Entendendo

Para entendermos a diferença e qual a melhor forma de configurarmos nosso sistema recomendo a leitura do post sobre [a diferença entre shell, terminal e console.](https://dev.to/alexandreliberato/diferenca-entre-shell-terminal-console-e-cli-command-line-131h)

Esses são dois dos mais famosos arquivos de configuração do sistema que utilizamos e vemos por tutoriais, artigos e posts em toda internet, mas existem outros também.

Quando um login shell é invocado ele roda o /etc/profile para o ambiente atual então checa por outros três arquivos:

```
se o /etc/profile existe ele é executado(source)
se ~/.bash_profile existe ele é executado(source)
se ~/.bash_login existe ele é executado(source)
se ~/.profile existe ele é executado(source)
```

Quando um deles é encontrado ele deixa de buscar pelos outros.

Já o .bashrc é executado toda vez que executamos um shell interativo. Normalmente colocamos variáveis, aliases e funções aqui.

Muitas pessoas colocam uma instrução no .profile para ler o .bashrc.

### Por hoje é isso pessoal!

Obrigado pela visita, deixe seu like e siga para novos artigos sobre Desenvolvimento de Sistemas.

> @feiler no Twitter

# Saiba Mais

https://stackoverflow.com/questions/415403/whats-the-difference-between-bashrc-bash-profile-and-environment

https://leimao.github.io/blog/bashrc-VS-profile-VS-bash_profile/