teleren/devto huggingface dataset:
Practical example for Ranking with Window Functions
Tags: sql, postgres, database
Published: 2021-04-08 20:57:24

---
title: Practical example for Ranking with Window Functions
published: true
description: 
tags: sql, postgres, database
---

In this article, [Mysql 5.7 Window Functions Workaround](https://dev.to/maxborysov/mysql-5-7-window-function-workaround-1h76), I put some examples of how we can solve problems if we need window functions in MySQL 5.7(which lacks such functionality).

In this post, we can achieve the same result, but with less code, and it looks more readable.

What we want to do: given we have a list of tweets, we want to **find `SUM` of the latest comments**(only 3 latest items) for each user.

```sql
SELECT
  user_id,
  SUM(likes)
  FROM (
    SELECT
      *,
      ROW_NUMBER() OVER( PARTITION BY user_id ORDER BY published_at DESC ) AS rank
      FROM twitter_comments
     ORDER BY user_id ASC, published_at DESC
  ) AS data
 WHERE rank <= 3
 GROUP BY user_id;
```

For each user's tweet, we generate a **unique row number**, which is later used to limit rows with aggregation functions(like `SUM` or `AVG`)

The intermediate result(with `rank` for each tweet per user) looks like this:

```sql
 id | user_id | likes |    published_at     | rank
----+---------+-------+---------------------+------
  6 |       1 |   200 | 2021-04-05 14:01:00 |    1
  5 |       1 |   100 | 2021-04-05 13:01:00 |    2
  4 |       1 |   200 | 2021-04-05 12:01:00 |    3
  3 |       1 |   300 | 2021-04-05 11:01:00 |    4
  2 |       1 |   200 | 2021-04-05 10:01:00 |    5
  1 |       1 |   100 | 2021-04-05 09:01:00 |    6
 12 |       2 |   100 | 2021-05-05 14:01:00 |    1
 11 |       2 |   200 | 2021-05-05 13:01:00 |    2
 10 |       2 |   300 | 2021-05-05 12:01:00 |    3
  9 |       2 |   100 | 2021-05-05 11:01:00 |    4
  8 |       2 |   300 | 2021-05-05 10:01:00 |    5
  7 |       2 |   200 | 2021-05-05 09:01:00 |    6
(12 rows)
```

[SQL Fiddle example](https://www.db-fiddle.com/f/vyeeWoJ9dEYbyuT9uJsBTs/1)

---

Helpful links:
- [PostgreSQL ROW_NUMBER Function]
(https://www.postgresqltutorial.com/postgresql-row_number/)
- [PostgreSQL 9.6.21 Documentation]
(https://www.postgresql.org/docs/9.6/functions-window.html)
Design, Coding, Testing and Maintenance.
Tags: design, testing, codequality
Published: 2021-04-08 20:39:35

#Never code until the specifications are precise and complete.
I'm going to survey a great deal of ground, but mainly from a bird’s-eye view, going to expand some of the principles in software engineering

##what is software engineering?
It is the study and practice of methods helpful for the construction and maintenance of large software systems. Although small by realistic standards,  we are going to illustrate necessary aspects of software engineering.

**phases of life cycle**
1. **Analyze** the problem precisely and completely. Be sure to specify all necessary user interface with care.

2. **Build** a prototype and experiment with it until all specifications can be finalized.

3. **Design** the algorithm, using the tools of data structures and of other algorithms whose function is already known.

4. **Verify** that the algorithm is correct, or make it so simple that its correctness is self-evident.

5. **Analyze** the algorithm to determine its requirements and make sure that it meets the specifications.

6. **Code** the algorithm into the appropriate programming language.

7. **Test** and evaluate the program on carefully chosen test data.

8. **Refine** and repeat the foregoing steps as needed for additional classes and functions until the software is complete and fully functional.

9. **Optimize** the code to improve performance, but only if necessary.

10. **Maintain** the program so that it will meet the changing needs of its users.

we will handle the primary way in which the user and the software engineer attempt to understand each other and establishes the standard by which the final project will be judged. Among the contents of this specification will be the following:

1. **Functional requirements** for the system: what it will do and what commands will be available to the user.

2. **Assumptions and limitations** on the system: what hardware will be used for the system, what form must the input take, what is the maximum size of input,what is the largest number of users, and so on.

3. **Maintenance requirements** : anticipated extensions of the system, changes in hardware, changes in user interface.

4. **Documentation requirements** : what kind of explanatory material is required for what kinds of users.

The requirements specifications state what the software will do, not how it will be done. These specifications should be understandable both to the user and to the programmer. If carefully prepared, they will form the basis for the subsequent phases of design, coding, testing, and maintenance.

**conclusion**
I want to give a small advice **Be sure you understand your problem before you decide how to solve it.**
and we will be continuing what we have start with forming the basis of software life cycle and go throw SDLC Models & Methodologies.
One-liner to install peerDependencies
Tags: webdev, javascript, programming, productivity
Published: 2021-04-08 20:39:05

---
title: One-liner to install peerDependencies
published: true
description: 
tags: webdev, javascript, programming, productivity
//cover_image: https://direct_url_to_image.jpg
---

Here it is:

```sh
node -e "console.log(Object.keys(require('./package.json').peerDependencies).join(' '))" | xargs yarn add
```

## How it works

Let's say we have `peerDependencies` in our `package.json` like this:

```json
    ...
  },
  "peerDependencies": {
    "react": "^17.0.2",
    "react-dom": "^17.0.2"
  }
}
```

We'll see one by one:

1. Load the `package.json` and get the peerDependencies.

    ```sh
    Welcome to Node.js v15.14.0.
    > require('./package.json').peerDependencies
    { react: '^17.0.2', 'react-dom': '^17.0.2' }
    ```

1. `Object.keys` function collects the keys of the object and put them together in the array.

    ```sh
    Welcome to Node.js v15.14.0.
    > Object.keys({ react: '^17.0.2', 'react-dom': '^17.0.2' })
    [ 'react', 'react-dom' ]
    ```

1. `join` method joins the elements with the given string.

    ```sh
    > [ 'react', 'react-dom' ].join(' ')
    'react react-dom'
    ```

1. `node -e` evaluates the given script.

    ```sh
    $ node -e "console.log('react react-dom')"
    'react react-dom'
    ```

1. Pass it to the `yarn add` with `xargs`.

    ```sh
    $ node -e "console.log('react react-dom')" | xargs yarn add
    yarn add v1.22.5
    [1/4] Resolving packages...
    [2/4] Fetching packages...
    [########------------------
    ```

Done 🥳
Vue.js CRUD example - a simple Note App
Tags: vue, crud, note
Published: 2021-04-08 17:29:43

https://grokonez.com/frontend/vue-js/vue-js-crud-example-a-simple-note-app

Vue.js CRUD example - a simple Note App

In this tutorial, we're gonna create a simple Note App that represents Vue.js CRUD example with Vue CLI 3 for building project.

More Practice:
- <a href="https://grokonez.com/firebase/vue-js-firebase-database-example-crud-operations">Vue.js Firebase Database example – CRUD Operations</a>
- <a href="https://grokonez.com/firebase/vue-js-firestore-example-vue-js-crud-serverless-with-firebase-cloud-firestore">Vue.js Firestore example – Vue.js CRUD serverless with Firebase Cloud Firestore</a>

<!--more-->
<h2>Vue.js CRUD example Overview</h2>
<h3>Goal</h3>
Our Vue App can help us write new Notes, then it displays a list of Notes and each Note page (containing title and content) can be modified easily:

<img src="https://grokonez.com/wp-content/uploads/2018/09/vuejs-crud-example-note-app-overview.png" alt="vuejs-crud-example-note-app-overview" width="687" height="361" class="alignnone size-full wp-image-14522" />
<h3>Project Structure</h3>
<img src="https://grokonez.com/wp-content/uploads/2018/09/vuejs-crud-example-note-app-project-structure.png" alt="vuejs-crud-example-note-app-project-structure" width="178" height="359" class="alignnone size-full wp-image-14523" />

We have 3 components:
- <code>App.vue</code> holds all of the other components.
- <code>NotesList.vue</code> contains all of notes in a List with <strong>+ Note</strong> button.
- <code>Note.vue</code> display a single Note in the List that allows us to create new Note or edit current Note.
<h3>Technologies</h3>
- Vue CLI 3.0.1
- Vue 2.5.17
<h2>Practice</h2>

More:
https://grokonez.com/frontend/vue-js/vue-js-crud-example-a-simple-note-app
Arch Linux (April 2021) - A NEW guided installer is included
Tags: linux, productivity, opensource, beginners
Published: 2021-04-08 20:17:21

---
title: Arch Linux (April 2021) - A NEW guided installer is included
published: true
description: In the latest release of Arch Linux, a new guided installer is included. Today, we'll review the installer and see how well it works. 
tags: linux, productivity, opensource, beginners
cover_image: https://dev-to-uploads.s3.amazonaws.com/uploads/articles/6vaqrz9j3p67w8rbtwxj.png
---

Hello everyone, 

I wanted to share a new video that I recently created geared towards beginners that are looking to learn how to install Arch Linux from scratch without all the messy configuration in previous builds though a guide installer (which now ships with the April 2021 release). 

What is Arch Linux?

Arch Linux is a Linux distribution for computers with x86-64 processors. Arch Linux is focused on simplicity, modernity, pragmatism, user centrality, and versatility. In practice, this means the project attempts to have minimal distribution-specific changes, and therefore minimal breakage with updates, and be pragmatic over ideological design choices and focus on customizability rather than user-friendliness.

With the April 2021 release, the new installer streamlines some of the most common aspects associated with the installation of a new operating system, including:

* Selecting a disk to install to, optionally adding encryption
* Format disk and mount it for you
* Installs some standard packages, but gives you the ability to add more
* Includes the option to install several different windows managers such as (awesome window manager, GNOME, XFCE, etc.)

Since this is such a big release, I have created a video to show you how to install it step-by-step by using the new guided installer. 

Video (14 mins)

{% youtube 3ks2hwE7k14 %}

Conclusion

Stay tuned for [future Twitch streams](https://twitch.tv/mbcrump) as we learn about security and app development or you can watch the condensed version of all of my streams by subscribing to my [YouTube](https://youtube.com/mbcrump). 

Stay connected with me on social platforms for daily software development news.

-[Twitter](https://twitter.com/intent/follow?screen_name=mbcrump) | [Twitch](https://twitch.tv/mbcrump) | [Instagram](https://instagram.com/mbcrump) | [YouTube](https://youtube.com/mbcrump) | [GitHub](https://github.com/mbcrump) | [Website](https://www.michaelcrump.net)
Building a Foundation for Data Engineering
Published: 2021-04-08 20:13:51

My overall career goal is to transition into data engineering There are some overall areas that I can improve on that will make me a more confident engineer. This blog post would be super long if I explained how I plan to improve every single area. So for this first article, I’ll be talking about how I’ll improve my overall programming skills by learning data structures and algorithms, design patterns, and Java programming.

##Data Structures & Algorithms 

Data structures and algorithms are the building blocks of creating good software, so it’s important to truly understand them. As an Information Technology student, there’s not that much emphasis on data structures or algorithms, understandably. Also, when I was interviewing for jobs, I only memorized some algorithms and data structures to pass the technical interview (don’t be like me). That being said, it’s time I revisit this topic. 

I am mainly following the 2014 version of UC Berkeley's CS61b course on data structures. Completing the labs, homework assignments, and projects that come with the course will keep me busy actually building things. 

I’ve created a github repository to track my progress: https://github.com/kriscodez/CS61B-2014

##Design Principles & Design Patterns  

Whenever I work on a project, the thought that is always in the back of my mind is: how should this be structured & organized? After spending enough time on data structures and algorithms, I plan on learning more about SOLID principles and commonly used design patterns. After that, I’ll choose a book to follow for more in-depth information. 

There are quite a few projects that I’ve written before that can be refactored with design patterns and principled in mind, so that’s how I plan on applying what I’ve learned. I want my code to be reusable, maintainable, and done with intent.

##Intermediate Level Java 

There are a few different languages you can choose from when learning about data engineering, python being the most popular right now. Java is also a good choice, and that’s what I’m starting with. 

![alt text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/u2lpuu64h2o6skmmi0v0.png)

I’m using a book called “Core Java for the Impatient” by Cay Hortsman to get caught up on Java Syntax and features. After that I’ll learn about the spring boot framework and then multi-threading. Once I’ve built a few personal projects with Java, I’ll be ready to move on to learning Python.

##Good Programming Skills Are Important 

Some describe data engineers as software engineers that specialize in data. I’ve spent some time looking at what knowledge is required for both fields and there’s significant overlap. Data engineers are responsible for building and maintaining data pipelines, making data usable for analysts and scientists, improving database efficiency, and other related tasks. Being a good programmer is at the root of all of those things, so it’s worth investing time in improving that specific skill set.
Hottest Security Startup with Open-Source Spirit
Tags: security, privacy, gdpr, compliance
Published: 2021-04-08 20:08:11

Hi guys

I run the hottest security startup, and I am going to prove it in a second.

But before that, imagine that you are going to get a blue pill. Imagine that this one is a blue one:  💊.

A blue pill that is going to save you from the problems of personal information disclosure and that you will never be a victim of the computer crime.

Yesterday our product was winning Bitcoin for popularity on the GitHub list of trending repositories.

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/a2ze83jcjf2ae7pf42mc.jpg)


That's right. the project is called **Databunker**.

That day, Databunker won over Bitcoin for popularity!
Databunker (161 ⭐) vs Bitcoin (132 ⭐) 

## So, what is Databunker?

**Databunker** is that blue pill - 💊 - remember this one is blue.

**Databunker** is an open-source, network-based, self-hosted, GDPR compliant, secure storage for personal data.

You can check out the project website for additional information: https://databunker.org/

PS. If you like this project, show your love with a ⭐ on the project GitHub page: https://github.com/securitybunker/databunker

🤫 Shhhh, investors love GitHub ⭐.

Happy hacking!
how to determine a field to get in deep with if you a cs student?
Tags: discuss
Published: 2021-04-08 19:49:27

the more i know the tech world the more i get confused to choose what I'm really want to do.

i have been studying python for over a six months.

doing some cool stuff with it like web development, data visualization, building games, discovering the software world in detailed with it,  beside solving problems for over three months.
and i really don't know where i should focus most of my effort to, if you can help me please don't think twice and share you knowledge with me.
Recursive Thinking approach (python)
Tags: programming, python, recursive, firstyearincode
Published: 2021-04-08 19:40:07

Here's the code snippet with improved markdown formatting and readability:

---

A recursive definition is one which uses the word or concept being defined in the definition itself. Before applying recursion to programming, it is best to practice thinking recursively. Here I'm gonna to show you a good example for clarifying the purpose in detail.

### Problem Statement:

The problem is finding the complement number of a binary format.

#### Example 1:

**Input:** 
```
num = 5
```
**Output:** 
```
2
```
**Explanation:** 
The binary representation of 5 is 101 (no leading zero bits), and its complement is 010. So you need to output 2.

#### Example 2:

**Input:** 
```
num = 1
```
**Output:** 
```
0
```
**Explanation:** 
The binary representation of 1 is 1 (no leading zero bits), and its complement is 0. So you need to output 0.

#### Constraints:

- The given integer num is guaranteed to fit within the range of a 32-bit signed integer.
- num >= 1
- You could assume no leading zero bit in the integer’s binary representation.

Python Solution:

```python
class Solution:
    def findComplement(self, num: int) -> int:
        # Convert num to binary format
        binary_num = bin(num)[2:]  # '101'

        # Get complement by replacing every '0' with '1'
        new_binary_num = binary_num.replace('0', '1')  # '111'

        # Convert binary complement to integer
        int_num = int(new_binary_num, 2)  # 7

        # Calculate the difference to get the complement
        difference = int_num - num  # 7 - 5 = 2

        return difference
```

Explanation:
- Formatting the integer input to a proper binary to get processed, slicing it with `[2:]` to avoid the `0b` prefix as the output.
- To get the complement, we replace every '0' with '1'.
- We then turn it into the integer format again using the additional `int()` argument `base=2`.
- Finally, we calculate the difference, which represents the complement of the binary sequence.

Additional resources:
[For curious readers](https://www.igi-global.com/dictionary/recursive-thinking/46967)

---
Data structures and algorithms importance
Tags: help
Published: 2021-04-08 19:31:51

Hey, dev community. I am a kind of newbie computer science student. I spent much of time in here reading dev articles. Besides all of this, I am learning front end technologies html etc and react js. My question is how much is important to learn data structures and algorithms to grow in the software industry as a developer. You know a website geeksforgeeks.com is providing tons of tutorials on data structures and algorithms. Whenever I try to learn something new, my mind forces me to learn data structures and algorithms first. Please help me with a strong answer. Thank you, waiting for every super duper software engineer answer.🙃
My Current Project(s)
Tags: hashnodebootcamp, nextjs, paypal
Published: 2023-04-23 11:23:24

---
title: My Current Project(s)
published: true
date: 2021-04-08 19:26:07 UTC
tags: hashnodebootcamp,Nextjs,PayPal
canonical_url: https://chrisdevcode.hashnode.dev/my-current-projects
---

TL;DR

I started focusing on projects that would land me my first ever software development job this week. So I have been dealing with creating applications with functionalities that introduce me to the most commonly used features throughout the industry.

So I have been working on payment integrations and re-designing my portfolio.

I love following the 'Build as I Learn' technique, so I started two projects, one called ' [Fundraiser](https://github.com/ChrisAchinga/fundraiser) ' and the other one ' [Community Space](https://github.com/ChrisAchinga/community-space) '.

## [Fundraiser](https://github.com/ChrisAchinga/fundraiser) :

This is a donations application, I will be creating a campaign to help me get a MacBook (LOL). The front end is built using [NextJS](https://nextjs.org/) and [Tailwind CSS](https://tailwindcss.com/).

For the payments, I will be using [Stripe](https://stripe.com/), to make it easier for card payments.

## [Community Space](https://github.com/ChrisAchinga/community-space)

I spend most of my time in a [community workspace](https://swahilipothub.co.ke/), for the strong internet and of course the calm environment (It's just next to the ocean). So I am building this application that will enable community space booking, including the hall for corporate events.

For the frontend, I am using [NextJS](https://nextjs.org/) and [Bootstrap](https://getbootstrap.com/). I will add the booking/saving a spot feature and sending a confirmation receipt via email/phone number (I have never done that before, So help me Code - LOL)

## The Tech Stack

I am using React/Next for all the projects because I want to perfect the skills professionally and also build scalable applications that are up to [WCAG](https://www.w3.org/TR/WCAG21/) standards.

I love challenging myself, so working with all projects that have to deal with payment integration will keep me up to pace with my timings and skills.

I also started working the "Professional Way". Yes, I use [Trello](https://trello.com/) to plan the project timeline and workflow. I feel like I worth more and need to use better tools for this.

### The End/

Written by [Chris](https://www.linkedin.com/in/chris-achinga-001/)
Episode 3: To Boldly Debug
Tags: debugging, python, devops, sre
Published: 2021-04-08 19:15:35

What is DevOps anyway? How about SRE? What's so awesome about Jupyter Notebook? And what do you do when that rogue process is more of a Nazgul than a zombie?

Moshe Zadka joins hosts Bojan Miletic and Jason C. McDonald on this episode of The Bug Hunters Café to answer those questions and more.

{% podcast https://dev.to/bughunters/episode-3-to-boldly-debug %}

---

Moshe Zadka (Website): https://cobordism.com/

Moshe Zadka, Glyph Creating And Consuming Modern Web Services with Twisted PyCon 2017: https://www.youtube.com/watch?v=ztkBG4qLR_4

Music by: https://audionautix.com

Sponsored by Softerrific: https://www.softerrific.com/
Help I need to choose a UI Automation tool!
Tags: python, testing, selenium, javascript
Published: 2021-04-08 19:09:07

Our team has the opportunity to choose a new UI Automation tool for a new web front end. We're considering Python/Selenium, WebdriverIO, Test Café or Cypress. Here's what we need to support for technology:

1. The user interface is developed on Node.js with React.
2. Need some support for iframes automation as some legacy apps will be plugged in.
3. Need the ability to pass in test script parameters including **Host Header support** for K8S and so we can run tests in CI/CD pipelines.
4. An open source tool with an active user community would be nice! We might be able to convince the company to pay for a tool that is totally awesome :)

We've done some basic automation POCs (Proof of Concepts) with Python/Selenium and WebdriverIO. Our automation people have some good coding skills in Java/C# but more limited skills in Python/Javascript. 

What do you think? Thanks!