teleren/devto huggingface dataset:
Advent of Code 2021: Day 06 with Python, and numpy.roll()
Tags: python, adventofcode
Published: 2021-12-06 12:34:19

[Link to challenge on Advent of Code 2021 website](https://adventofcode.com/2021/day/6)

## Loading the data
The data is a comma-separated list, so we can load this using numpy's `np.loadtext()` again. We set dtype to `uint32` as we'll be using these numbers for indexes later and they'll need to be whole numbers.

```py
lines = np.loadtxt("day_6.txt", delimiter=",", dtype="uint32")
```

## Part 1
Part 1 asks us to track the number of exponentially reproducing fish. While it's possible at this stage to keep an array of every fish, since every fish of the same age behaves the same, we can just keep track of groups of them.

The demo data gives these fish ages: `3,4,3,1,2`, this can be reduced to an array of fish, where the index is the age, and the value are their count: `[0, 1, 1, 2, 1, 0, 0, 0]`

The benefit of this approach is that when fish age, we can simply roll the array around:

```
Initial: [0, 1, 1, 2, 1, 0, 0, 0]
  Day 1: [1, 1, 2, 1, 0, 0, 0, 0]
  Day 2: [1, 2, 1, 0, 0, 0, 1, 1]
  Day 3: [2, 1, 0, 0, 0, 1, 2, 1]
                            ^  ^
  old fish get added here --^  ^
     new fish get added here --^
```

To assemble the fish, we can use numpy's `np.unique()` to return a frequency count of the fish:

```py
fish = np.zeros(9)
age, count = np.unique(lines, return_counts=True)
fish[age] = count
```

And to implement the roll, we can use `np.roll()`:

```py
gen = np.copy(fish)
for _ in range(80):
    gen[7] += gen[0]
    gen = np.roll(gen, -1)
result = sum(gen)
```
Taking the sum of the array gives us the total fish.

## Part 2
Exactly the same as Part 1, but simulated to 256 generations. I assume the reason for part 2 like this is to trip up anyone who implemented Part 1 inefficiently, since it would take a lot of RAM to keep track of individual fish without grouping them.

```py
gen = np.copy(fish)
for _ in range(256):
    gen[7] += gen[0]
    gen = np.roll(gen, -1)
result = sum(gen)
```

## Full Code
```py
import numpy as np

lines = np.loadtxt("day_6.txt", delimiter=",", dtype="uint32")
fish = np.zeros(9)
age, count = np.unique(lines, return_counts=True)
fish[age] = count

gen = np.copy(fish)
for _ in range(80):
    gen[7] += gen[0]
    gen = np.roll(gen, -1)
result = sum(gen)
print("Part 1 result:", result)

gen = np.copy(fish)
for _ in range(256):
    gen[7] += gen[0]
    gen = np.roll(gen, -1)
result = sum(gen)
print("Part 2 result:", result)
```
Manage issues with hundreds of comments
Tags: actionshackathon21
Published: 2021-12-06 11:00:22

[Instructions]: # (To submit to the GitHub Actions x DEV Hackathon 2021, please fill out all sections.)


### My Workflow
[Note]: # (Please make sure the project links to the appropriate GitHub Actions repository, and includes [an open source license](https://choosealicense.com/) and README.)

Issues are a wonderful way to see where your project needs to improve, but what do you do when an issue has more than **20** comments? Or maybe **a hundred**?

They are daunting to read for newcomers. Even if you are an active participant, it may be hard to remember what it is all about. Heaven forbid that you come back to this issue after a vacation.

Do long-winded issues like that have overstayed their usefulness? What do you do with them?
- Split into smaller issues and close this humongous banter? But are you sure you are not missing any important points raised in the comments?
- Convert it into a discussion? But how does this make things more manageable?

This action will check for the most reacted comments in the issue and add them to the issue's original body with corresponding issues.

You can specify the maximum number of reacted comments to display.

Say goodbye to trawling through walls of text to get the gist of a issue. Happy coding.

### Submission Category: 

[Note]: # (Maintainer Must-Haves, DIY Deployments, Interesting IoT, Phone Friendly, or Wacky Wildcards)

Maintainer Must-Haves

### Yaml File or Link to Code

[Note]: # (Our markdown editor supports pretty embeds. Try this syntax: `{% github link_to_your_repo %}` to share a GitHub repository)

{% github https://github.com/bytrangle/most-reacted-comments %}

### Additional Resources / Info
This action is looking forward to be used by thoughtful open-source projects. If you are a maintainer of such projects, what are you waiting for?

[Note:] # (Be sure to link to any open source projects that are using your workflow!)

[Note]: # (Be sure to include the DEV usernames of your collaborators, if any. )

[Reminder]: # (Submissions are due on December 8th, 2021 (11:59 PM PT or 2 AM ET/6 AM UTC on December 9th).
In pursuit of an even playing field
Tags: womenintech
Published: 2021-12-06 12:22:42

This post is overdue, and for that I apologise. The fact that I have been putting this off and not prioritising it, is perhaps in some small way indicative of the problem.

Because there is a problem. Whether we want to admit it or discuss it is another matter.

The problem is that women are not yet treated the same as men in tech. In fact, in many cases they are treated down right despicably and it is up to everyone, (especially men) to acknowledge this and address it.

This post is in part dedicated to the work by Salma and [unbreak.tech](unbreak.tech) whose aim is to highlight and bring about change.

{% twitter 1450370452363296768 %}

There are a number of things that we can do.. so I thought I would just list a few that I think are important (in no particular order).

- Equal pay for women
- Gender bias awareness and training (especially in recruitment)
- Improve female speaker ratios at conferences
- Increase female attendance at tech conferences
- Don't assume women are less technical than male colleagues around them
- Don't assume women at tech conferences are non technical
- Don't explain things to women that they may already know
- Reduce female drop out of STEM subjects at early ages
- Support groups encouraging women in tech
- Support women in tech
- Speak up when we see something wrong
- Consider what we say and how we act can be interpreted i.e. "hi guys"
- Help women feel safe

(I may update this list)

But I'd really like to take the opportunity to highlight that the many female colleagues that I have had the honour of working with, have been/are absolutely amazing (you know who you are), and I dare say better (on average) than their male colleagues.

I'd also like to challenge anyone of my male peers who's initial thoughts are "yeah but..". You need to get yourself to a place where you acknowledge that there is a problem.

In my opinion, it is similar to white people having a problem with the "black lives matter" message and insisting on using a "black lives matter too" or "all lives matter" instead.. of course they do! but the original phrase is to help raise awareness of the particular problem and I can completely understand why variations on it detract from the original message/problem. [Source](https://theconversation.com/why-is-it-so-offensive-to-say-all-lives-matter-153188)

For me the most important thing that men can do is admit there is a problem and after that, as I've listed, there are various ways to help to get towards a place where women are treated equally in tech. (I don't have all the answers before someone asks me how we get there).

Slightly selfishly as I write this I realise that I am thinking about the world I want my 8yo daughter to live in and my 5yo son to be aware of and help towards creating. 

What kind of future do you want future generations to live in?

-- Lee

(Photo by Elena Mozhvilo, from Unsplash)
Upgrade to Angular13 and Spring boot 2.6.1
Tags: angular, typescript, java, springboot
Published: 2021-12-06 12:13:40

In the last few weeks, we have been busy migrating our product to #angular 13 and #springboot 2.6.1.

I can't share with you our product code, so we also upgrade our [TODO](https://github.com/alchemycloud/todo) and [PetClinic](https://github.com/alchemycloud/petclinic) apps.

Check it out!
Kicad Helper Workflow
Tags: actionshackathon21, github, git, kicad
Published: 2021-12-06 12:08:35

[Instructions]: # (To submit to the GitHub Actions x DEV Hackathon 2021, please fill out all sections.)


### My Workflow
A workflow for KiCAD that adds images of the back and front, as well as a bill of materials, of the design for easier viewing and collaboration.
## How to use:
1. Copy the workflow to your repository.
2. Replace the environment variables at the top.
   * `PUSH_NAME` - name of the user that pushes the additions
   * `PUSH_USER` - username of the user that pushes the additions
   * `PUSH_MESSAGE` - the commit message
3. Profit

Ran action:

Image:
![View of the diff](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/tsbvhg5tc9se9dqh7s6z.png)

### Submission Category: 
Wacky Wildcards


### Yaml File or Link to Code
{% github https://github.com/boredom101/kicad-test %}


### Additional Resources / Info
This mainly uses the KiBot action ([https://github.com/INTI-CMNB/KiBot](https://github.com/INTI-CMNB/KiBot))
Learn Python. Stay tuned for the next posts🥳
Tags: python, programming, tutorial
Published: 2021-12-06 11:48:20

## **session one**


## What is Python?
Python is a popular programming language developed in 1991 by Guido van Rossum.

## This language is used in the following cases:

Web development (server side)
software development
Mathematics
And …
 

## Use of Python programming language
Python can be used to build web applications on the server
Python can be used alongside software to build workflows
Python can connect to database systems and read and modify files
Python can be used in programming and managing big data and performing complex mathematical calculations.
And…
 

## Why should we learn Python?
Python runs on various platforms (Windows, Mac, Linux, Raspberry Pi,…)
Python has a simple syntax
The grammatical structure of this language is such that it allows developers to write less code than other languages
Python runs on an interpreter, meaning it does not need to be compiled and runs immediately
Python supports a variety of programming methods such as procedural, object-oriented, and functional
 

Comparing the grammatical structure of Python with other programming languages
The purpose of Python's design is to make it more readable and similar in English syntax to the effect of mathematics
Each Python command is defined in one line, while in most programming languages ​​the commands are; They end
Python uses indentation and tabs to define blocks of code, such as blocks of functions and classes, while brackets use brackets to do this in other languages.
 

 

The **Python programming language** introduction session is also over.

In the next session, we will teach you how to start working with Python. Stay with us

Do not forget to like!
Bye until the next post
New portfolio using Next.js
Tags: portfolio, nextjs, webdev, javascript
Published: 2021-12-06 11:46:46

Created a brand new portfolio!
Using plain Next.js with svg files.

visit at : [https://kdssoftware.com](https://kdssoftware.com)

You can view the repository at:[https://github.com/snakehead007/kdssoftware](https://github.com/snakehead007/kdssoftware)
How to store passwords in db?
Tags: webdev, beginners, security, database
Published: 2021-12-06 09:37:29

Hello All,

Hope all are doing good in this pandemic time.

This article is about hashing passwords before writing in storage.

Now a days every one are adding authentication for their apps and i heard some of the apps are storing password with out hashing.

### Why we need to hash the passwords
#### Reason 1
You are using a mobile / web app called *Abc* assume if the Abc app's database got compromised your username and password will be in the hackers hand. If abc app has any sensitive or confidential information of yours then hacker able to access that because hacker has your credentials.

#### Reason 2
Almost 50% of the people will use same password for all their logins. So if attacker got your password he/she can try that over other apps.

### Solution!!!
For the above 2 problems user cannot do anything from his/her side. But developer can do it i.e hashing a password.

We can use irreversible hashing technique and we can hash user password and we can store that hashed password in the database.

#### How can we validate user if we don't have a plain password?

Simple when ever user try to login. Hash the password which was entered by user and compare that hash with the password which we saved during the time of registration or signup.

So no one don't know what is the actual password except the user.Even if database compromised it is impossible to generate actual one because we are using one-way hash function which cannot be reversed.


#### Adding Salt 
For more security we can hash user's password with unique random string i.e salt. So if multiple users are using same password then it looks different in database because salts are unique and we can store that salts in db. We can use those salts at the time of login to validate user.

You can now extend your support by buying me a Coffee.

<a href="https://www.buymeacoffee.com/sakethk" target="_blank"><img src="https://cdn.buymeacoffee.com/buttons/v2/default-blue.png" alt="Buy Me A Coffee" style="height: 30px !important;width: 60px !important;" ></a>
What is Python Programming Language?🤔😜🤭
Tags: python, programming, opensource
Published: 2021-12-06 11:26:17

**

## Python
:**
Python is a general-purpose, high-level, object-oriented, scripting, interpretive, and open source programming language developed by Khodo van Rassam himself in 1991 in the Netherlands.
The philosophy of creating this language is to emphasize the principle of high readability and brevity and the relative efficiency of programs written in this language.
Unlike other programming languages ​​where code blocks were defined in parentheses, this language uses spaces and tabs to specify blocks.
Python supports a variety of programming styles such as object-oriented and function-oriented.

**

### History:
**
Python was created in the late 1980s by Khodo van Rossum of the National Institute for Mathematical and Computer Research (CWI) in the Netherlands.
The goal was to create an alternative to ABC that could handle exceptions.
In 1991, Fan Codi released the version 0.9.0 tag. In this version there were improvements to classes with inheritance, exception processing, functions and data types list, dict and str.
Also in 1994, version 1.0 of this language was released. The main features of this version included functional programming tools such as lambda, map and reduce.


Do not forget to like!😘
Bye until the next post👋
How to use the cash app boost?
Published: 2021-12-06 11:07:39

A [cash app boost](https://www.contact-customerservice.co/blog/how-do-boosts-work-on-cash-app/) feature has been created for the management of monetary aspects. Cash app users mostly tend to save their money and hence they can start by clicking on the boost option available on the cash app screen. Further, they need to add a boost to begin saving with no hassles. However, they can also speak to the cash app service team for guidance.
Week 6 Task Force 4.0
Published: 2021-12-06 11:03:23

---
title: Week 6 Task Force 4.0
published: true
cover_image: https://drive.google.com/thumbnail?id=1qI4ADaG-FYMBztGA8qQNsharbRZ8T5ph
description: 
---
> When you have a dream, you've got to grab it and never let go.

The amazing news is I've graduated; after six weeks of learning tech and soft skills, moreover working intensively, i would say that i am proud of what I've achieved.

I would like to start by thanking, codeofafrica in partnership with awesomity, for the opportunity they brought to us, to enhance our skills and work with their talented team.

Last week, as the final week of the bootcamp, our task was regarding to complete and demo the project, we've been working on. The task were as follow:
* We had dockerize our ongoing project; In fact, i had no clue about dockerizing, but now i am surely confidence in it.
* We also had to deploy the project on remote server(digitalocean), despite that was my first time to deploy the app, i finally deployed. Now i can deploy.

After preparation, finally we had to present the project we've been working, grateful that our project was ready.

Lastly, i would say though the journey might be challenging, but keep pushing because the future is in your hand. Many thanks to facilitators, teammates and others who was part of my journey; Kudos.
Hide Your Source Code from Developer Tools while using React
Tags: react, sourcemap, hide, sourcecode
Published: 2021-12-06 10:30:47

If you are building a Product using React & using create-react-app boilerplate to get started.

I have seen this mistake doing by many of the  Startups i got offer for different roles and by some great products.

Here's One Thing you need to change. That, Source Code that is written by you or the developer team should not be visible to the client.

And, To Hide Your Source Code in Developer Tools, just update this one line in your `package.json` file.

```json

"build": "GENERATE_SOURCEMAP=false react-scripts build"

```

[_Demo On GitHub_](https://github.com/Siddhant-K-code/dont-use-default-boilerplate/blob/main/package.json#L16)


Before Adding that Line: 


![React Source Code Visible in Developer Tool](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/8var8jtb8z5w4yzmpew3.png)

After Adding that Line: 


![Hide Source Code in React](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/14zf4sfg6mmm7mhumsow.png)

Some More Modern Frameworks Like next.js have fixed this issue in their boilerplates.

Live Demo: https://dont-use-default-boilerplate.vercel.app/

Source Code on GitHub: https://github.com/Siddhant-K-code/dont-use-default-boilerplate
Sort two Object properties with Array.sort()
Tags: javascript, beginners, codenewbie, programming
Published: 2021-12-06 10:19:03

Bit of a long one, but I had an array of objects that contained movie titles, movie release dates, reviews, directors etc.

The task was to sort them by release date in ascending order. In my head that was fine, just find the property by while running the Array.sort() method.

However if two movies had the same release date, these 2 or 3 movies would need to be further sorted by title in alphabetical order.

This stumped me for a while as I've never had to sort something twice in the same method call.

It was a little difficult to find a solution online as the question seemed to be a little difficult to come up with to get the right answer.

## Array.sort()
This method checks two elements and if the result of this check is a positive number, it places the second element before the first.

If the result of the check is negative, it keeps the first element in its place and puts the second after it.

> 0 returned? sort b before a
< 0 returned? sort a before b
=== 0 returned? keep original order of a and b

If the result is 0, this means they are eaqual. This is where our problem comes in. We have two movies with identical date values.

We now want to sort those alphabetically. The solutions turns out to be simple but took me a while staring at it to realise I never understood what sort was doing in the first place.

We want sort to do it’s job normally if the dates are NOT identical. So we check if a minus b is a positive or negative number and if it is, carry on as sort() normally does.

What I didn’t understand initially here is that the result doesn’t have to be 0, 1 or -1. It can be any positive and negative number…silly me.

```js
let sortedAsc = myArrayOfObjects.sort((a, b) => {
  let result = a.year - b.year;
  // 1995 - 1987 = 8
  // a - b will sort in ascending just like a is before b
  // b - a would be backwards "think z -> a" a being last.

  if (result !== 0) return result;
  // if 8 is not equal to 0 we short circuit
  // and return "positive" ie: sort b before a

  // If we get to here, it means they're the same
  // and we need another sorting check.

  // String length and alphabet order seems to be hit by > or <.
  // Aalvin is less than Calvin, which means Aalvin comes first.

  if (a.title < b.title) {
    return -1;
  } else if (a.title > b.title) {
    return 1;
  } else {
    return 0;
  }
});
```
Sorting by letter’s is a slightly different check. It looks like we can’t use minus symbol but instead we’re looking at Greater or Less than symbols.

Javascript has its own way of evaluating the result of this. I believe it stops checking the moment it finds a difference in values within the string, this may mean the **ENTIRE** string is not checked. Just the first few characters until a difference is found.

We’re trying to return a positive, negative or 0 after checking the string order. So we use dot notation to get the value, compare them to each other and return a number to finish to original Array.sort() method.
Best Virtual Reality Movies to Watch
Published: 2021-12-06 10:11:17

[Best Virtual Reality Movies to Watch
](https://externlabs.com/blogs/most-popular-virtual-reality-movies-to-watch/)

What is Virtual Reality

Virtual Reality or VR can be described as a simulated visual experience that can be similar or different from your surrounding environment. VR is being used in various industries, including entertainment, event, business, and education. Further development in virtual Reality technologies leads to extended versions of VR like mixed Reality and more advanced extended Reality or XR. Virtual reality can be described in two types- immerse VR and text-based VR.

Here's the top 5 Virtual reality movies to watch

- Dunkirk: Save Every Breath – The Dunkirk VR Experience
- The Conjuring 2 – Enfield 360 Experience
- Fairness Works: Refugee Crisis
- The Invisible Man
- IT: Float

Also check: [Top Virtual reality stocks to buy](https://qfinancialadvisors.com/virtual-reality-stocks-to-buy/)
Week 6 and Overall experience in the Task force
Tags: awesomitylab, codeofafrica, taskforce
Published: 2021-12-06 10:07:25

Sooo TF 4.0 has come to an end and much of the technical and soft skills learned can be found in previous weeks' journals so this one will mostly focus on the overall experience given that it is the last one.

"Many fine things can be done in a day if you don't always make that day tomorrow" -Somebody

the quote above was sooo relatable throughout the bootcamp. When we were expected to come up with fully working APIs in a week & using a new language at first you think "it will most likely take longer than that". It is incredible how you go from that to "uhmm maybe we can do it" to "OK let me finish ahead of time so I can go back and refactor the code I wrote before fully understanding what I was doing" all in a matter of a week or so.

That steep learning curve was also possible thanks to brilliant TF4 fellow members, our hard work and team spirit throughout the bootcamp was something to be admired, so much Kudos to them "WE DID IT,JOE"

I can not finish without thanking CoA, AL teams and everyone that was working behind the scenes to make the bootcamp a pleasant experience for all of us, personally I d say I am a much much better developer than I was 6 weeks ago thanks to all of you and your work.

last but not least cheers to new connections, friends, knowledge acquired for the last 6 weeks 🍻🍻