teleren/devto huggingface dataset:
2D Array DS Hackerrank solution in Python
Tags: hackerrank, python, algorithms, datastructures
Published: 2022-01-23 14:33:41

Question
Given a 6×6 2D Array, arr:

1 1 1 0 0 0
0 1 0 0 0 0
1 1 1 0 0 0
0 0 0 0 0 0
0 0 0 0 0 0
0 0 0 0 0 0

An hourglass in A is a subset of values with indices falling in this pattern in arr’s graphical representation:

a b c
 d
e f g

There are 16 hourglasses in arr. An hourglass sum is the sum of an hourglass’ values. Calculate the hourglass sum for every hourglass in arr, then print the maximum hourglass sum. The array will always be 6×6.

Example

arr =

-9 -9 -9  1 1 1
0 -9  0  4 3 2
-9 -9 -9  1 2 3
0  0  8  6 6 0
0  0  0 -2 0 0
0  0  1  2 4 0

The 16 hourglass sums are:

-63, -34, -9, 12,
-10,   0, 28, 23,
-27, -11, -2, 10,
 9,  17, 25, 18

The highest hourglass sum is 28 from the hourglass beginning at row 1, column 2:

0 4 3
 1
8 6 6

Function Description

Complete the function hourglassSum in the editor below.

hourglassSum has the following parameter(s):

int arr[6][6]: an array of integers
Returns

int: the maximum hourglass sum
Input Format

Each of the 6 lines of inputs arr[i] contains 6 space-separated integers arr[i][j].

Constraints

-9 <= arr[i][j] <= 9
0 <= i,j <= 5
Output Format

Print the largest (maximum) hourglass sum found in arr.

Solution

The solution is here https://hecodesit.com/2d-array-ds-hackerrank-solution-in-python/
watch anime from the command line
Tags: linux, tutorial, bash, beginners
Published: 2022-01-23 14:23:58

do you watch anime? if yes Highfive! me too.
Today I will show you how can you watch anime from the command line!
not only watch but search & download
Even in android & mac? heck yeah!
Dependencies::

**Essential**
`grep
sed
curl
openssl
jq`

**Optional**

`mpv - The default video player (recommended)
aria2 - For downloading (recommended)
iina - An alternative video player for the Mac
vlc - An alternative video player
diff - Update checking
patch - Update checking`

**Install**

_Linux / Mac_
`git clone https://github.com/pystardust/ani-cli.git
cd ani-cli
sudo make`

**Android (Termux)**
`apt update
apt install git make ncurses-utils openssl-tool jq -y
git clone -b android-termux https://github.com/pystardust/ani-cli.git
cd ani-cli
make`

**Windows**
`Download and install gitbash
Download and install vlc (mpv needs further testing)
Add vlc to Windows Env PATH like so: C:\Program Files\VideoLAN\VLC.
Open git bash by right-clicking and choosing "Run as administrator"
Run the following commands
git clone -b windows-vlc https://github.com/pystardust/ani-cli.git
cd ani-cli
chmod +x ani-cli-win
./install`

[Buy me a coffee](https://www.buymeacoffee.com/tawhid)
SQL Beginner Friendly Cheatsheet
Tags: sql, database, programming, computerscience
Published: 2022-01-23 14:18:29

## 1. Retrieving/Selecting Data -
The `SELECT` statement is used to select data from a database.

```
SELECT column_name FROM table_name;
```
for eg - 
```
SELECT StudentName FROM Student;
```
<br/><hr><br/>

## 2. Selecting All Records/Columns of Data -
The Asterisk(`*`) is used to select all records.
```
SELECT * FROM table_name;
```
for eg - 
```
SELECT * FROM Student;
```
<br/><hr><br/>

## 3. Selecting Distinct Data -
The `SELECT DISTINCT` statement is used to return only distinct (different) values.
```
SELECT DISTINCT column_name FROM table_name;
```
for eg - 
```
SELECT DISTINCT StudentName FROM Student;
```
<br/><hr><br/>

## 4. Filtering the Records -
The `WHERE` clause is used to filter records.
It is used to extract only those records that fulfill a specified condition.
```
SELECT column_name FROM table_name WHERE condition;
```
for eg - 
```
SELECT * FROM Student WHERE Marks>=450;
```
<br/><hr><br/>

## 5. Filtering the Records by two or more conditions -
The `WHERE` clause can be combined with `AND`, `OR`, and `NOT` operators.
The `AND` and `OR` operators are used to filter records based on more than one condition.
The `NOT` operator displays a record if the condition(s) is NOT TRUE.
```
SELECT column_name FROM table_name WHERE condition1 AND condition2 OR condition3;
```
```
SELECT column_name FROM table_name WHERE NOT condition;
```
for eg - 
```
SELECT * FROM Student WHERE Marks>=450 AND Div="A";
```
```
SELECT * FROM Student WHERE NOT Marks=500;
```
<br/><hr><br/>

## 6. Sorting the Data of Records -
The `ORDER BY` keyword is used to sort the result-set in ascending or descending order.
The `ORDER BY` keyword sorts the records in ascending order by default. To sort the records in descending order, use the `DESC` keyword.
```
SELECT column_name FROM table_name ORDER BY column_name;
```
for eg -
```
SELECT * FROM Student ORDER BY Marks DESC;
```
<br/><hr><br/>

## 7. Inserting Data -
The `INSERT INTO` statement is used to insert new records in a table.
```
INSERT INTO table_name (column1, column2, column3, ...) VALUES (value1, value2, value3, ...);
```
If you are adding values for all the columns of the table, you do not need to specify the column names in the SQL query. However, make sure the order of the values is in the same order as the columns in the table.

for eg -
```
INSERT INTO Student (StudentName, Class, Div, Marks)
VALUES ("Durgesh", "Second Year", "B", 450);
```
<br/><hr><br/>

## 8. Updating Data -
The `UPDATE` statement is used to modify the existing records in a table.
If you omit the `WHERE` clause, ALL records will be updated!

```
UPDATE table_name SET column=value WHERE condition;
```
for eg - 
```
UPDATE Student SET Marks=440 WHERE StudentName="Durgesh";
```
<br/><hr><br/>

## Follow for more :-)
[Linkedin](https://www.linkedin.com/in/durgesh-mahajan-99bab0212/)
[Github](https://github.com/durgeshm01722)
[Instagram](https://www.instagram.com/durgeshm01722/)
Paracetamol.js💊| #26: Explica este código JavaScript
Tags: javascript, webdev, beginners, spanish
Published: 2022-01-23 14:01:37

## **¿Qué imprime este código JavaScript?**

```js
let person = { name: "Lydia" };
const members = [person];
person = null;

console.log(members);
```
-     A: `null`
-     B: `[null]`
-     C: `[{}]`
-     D: `[{ name: "Lydia" }]`


Respuesta en el primer comentario.

---
Paracetamol.js💊| #25: Explica este código JavaScript
Tags: javascript, webdev, spanish, beginners
Published: 2022-01-23 14:01:03

## **¿Qué imprime este código JavaScript?**

```js
console.log([..."Oscar"])
```

-     A: `["O", "s", "c", "a", "r"]`
-     B: `["Oscar"]`
-     C: `[[], "Oscar"]`
-     D: `[["O", "s", "c", "a", "r"]]`

Respuesta en el primer comentario.

---
how to watch spongebob from terminal!
Tags: beginners, codenewbie, bash, linux
Published: 2022-01-23 14:00:57

today I was storming in reddit and found a guy in linux subreddit made a bash tool to watch spongebob from terminal!
heres how you can use that too:
download the repo:
link: [spongebob-cli](https://github.com/trakBan/spongebob-cli)

then:
`cd spongebob-cli`
`sudo chmod +x spongebob-cli; sudo python setup.py install`

Troubleshooting
If setup.py fails try this:

`pip3 install termcolor beautifulsoup4`

run it by `spongebob-cli`

[Buy me a coffee](https://www.buymeacoffee.com/tawhid)
Paracetamol.js💊| #24: Explica este código JavaScript
Tags: javascript, beginners, spanish, webdev
Published: 2022-01-23 14:00:15

## **¿Qué imprime este código JavaScript?**

```js
setInterval(() => console.log("Hi"), 1000);
```

-     A: `1000`
-     B: `Hi` 1000 veces.
-     C: `Hi` cada segundo.
-     D: undefined

Respuesta en el primer comentario.

---
Instalando o Composer no Linux e habilitando de forma global em apenas 2 passos
Tags: php, webdev, composer, softwareengineer
Published: 2022-01-23 13:48:58


![Composer](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/y9y6xd0bbbgvvbza1zrm.png)
 
Olá! Nesse curto artigo eu vou te ensinar a instalar o Composer, o gerenciador de dependências do PHP, em dois passos simples.
Para dar início no primeiro passo, copie o script de download do Composer no site oficial clicando aqui. Será algo semelhante a isso:

![Página de Download do Composer](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/y5vte5iq5ntmct85eymz.png) 

Agora vamos ao primeiro passo!
Abra o seu terminal (Ctrl + Alt + t, ou busque por “terminal” no menu) e cole o código que você copiou no site oficial. Teremos algo parecido com isso:

![Imagem do terminal Linux](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/dqg1cihcokc38g5xf127.png)
 

Agora que o Composer foi instalado o que precisamos fazer é mover o arquivo baixado (composer.phar) para um diretório global. Vamos fazer isso rodando o comando sudo mv composer.phar /usr/bin/composer

![Imagem do terminal Linux](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/m3kkhur9f7n2ymkhb93h.png)
 

Pronto! Agora temos o composer instalado de maneira global e você poderá chamá-lo de qualquer diretório.
Para um teste rápido de verificação, vamos ver qual versão foi instalada rodando o comando composer — version e o retorno será algo parecido com isso:

![Imagem do terminal Linux](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/iuh5bxtut48b0natccr1.png)
 

Agora o Composer está instalado de maneira global na sua distro Linux. Faça bom uso!
Allied Technologies – Best Digital Marketing Agency USA
Published: 2022-01-23 13:41:12

[With the experience of 7 years and based in Tennesse USA, Allied Technologies is more than just a digital marketing agency. It is being known to have secured its place in the list of best digital marketing agencies in the USA and is considered one of the most popular app development companies too. With a team of experts in each field, Allied Technologies has numerous services to offer to its clients.]
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/b8ny48sxxhll9t4x9uod.png)
Allied Technologies
Website- https://www.alliedtechnologies.io/
Email - info@alliedtechnologies.io
Add- 205 Powell Pl, Brentwood, TN 37027, United States
Contact no.- (800) 936-0755(https://alliedtechnologies.io/)
I messed up my git history: retrieving your lost commits
Tags: git, github, productivity, tooling
Published: 2022-01-23 13:39:45

> Photo by [Elisa Ventur](https://unsplash.com/@elisa_ventur).

When using git commands that rewrite a branch's history, like `rebase` or `reset`, you might end up losing some commits by mistake. 

But don't worry, as long as you committed your changes once, you should be able to get them back!

Indeed, a magical git command can help us: [git reflog](https://git-scm.com/docs/git-reflog). 

Git keeps a trace of all your commit in reference logs: this is, for instance, what allows you to use commands like `git checkout my-branch@{two.week.ago}` to checkout on your branch as it was two weeks ago.

So if you just messed up with your branch, you can do something like `git checkout my-branch@{ten.minute.ago}`, otherwise, it can be more accurate to look directly at the reference logs entries with the `git reflog` command.

## Reading the reference logs

The format of the reference logs is as follows:

`commit hash` (`branch name`) `handle`: `action`: `action description`.

Here is an example of a git reflog output:
can be
```bash
0e60901 (HEAD -> feature-branch, main) HEAD@{0}: reset: moving to main
2b38384 HEAD@{1}: commit: feat: new feature
0e60901 (HEAD -> feature-branch, main) HEAD@{2}: checkout: moving from main to feature-branch
```

Here for instance we have:

- HEAD@{2} - creation of a new branch named `feature-branch`
- HEAD@{1} - add a commit with the message `feat: new feature`
- HEAD@{0} - reset on branch `main`

When I have reset my branch on `main`, I used the `--hard` option, so currently the changes from my commit `feat: new feature` are lost.

But thanks to the `reflog,` I can checkout on them or directly reset my head on it with the following command:

```bash
git reset --hard HEAD@{1} # or with the commit hash: git reset --hard 2b38384
```

Here we go, I got back my lost commit!
What Evaluation Metrics Should I use?
Published: 2022-01-23 13:37:01

When working with imbalanced data, judging your model's performance using accuracy is like pouring diesel on a burning flame, if not careful you too might burn. Avoid accuracy! Please use F1-score, However, depending on your problem definition you call settle for high precision or recall.

Note: You can't have high recall and precision at same time. You can only have either of both.

I’d like to know what your answer is as well? 😉

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/on71ah5p8zg9stww5q17.jpg)
Best Programming Languages for Game Development.
Tags: gamedev, devops, unity3d, gui
Published: 2022-01-23 13:21:01

Choosing the right programming language for game development make your work more easier. But it is handy to know which one is the most suitable. The choice of programming languages depend on the device , game type, rate of interactivity and etc... 

1.**C#**
 C# is pronounced as c sharp. It encompasses static typing, strong typing, lexically scoped, imperative, declarative, functional, generic, object-oriented, and component-oriented programming disciplines. Some examples of C#-based games include Pokemon Go, Hearthstone, Temple Run, and Assassin’s Creed Identity. C# was designed by Anders Hejlsberg from Microsoft in 2000.

2.**C++**
  C++ is an object-oriented programming language. Its speed, ease of use, and widespread adoption make it stand out as a highly desirable language. Some titles made with a C++-based engines include the Assassin’s Creed, Doom, and the Bioshock series. C# was designed by Bjarne Stroustrup at 1985.

3.**Java**
  Java is a high-level, class-based, object-oriented programming language that is designed to have as few implementation dependencies as possible.Java game programming is nearly universally compatible, making it incredibly versatile and one of the most popular languages used today. Video games made with Java include Minecraft, RuneScape, and Star Wars Galaxies.Java was originally developed by James Gosling at Sun Microsystems and released in May 1995.

<u>You Can Support Me here 👇</u>
BUY ME A COFFEE - https://bit.ly/3FN8thW
Custom Service Worker in any app with esbuild
Tags: webdev, javascript, codenewbie
Published: 2022-01-23 13:18:52

Lately I’ve been exploring use of Service Workers in web apps. Use cases include [prefetching content at scale](https://docs.layer0.co/guides/prefetching), [speeding up your website](https://www.builder.io/blog/how-we-cut-99-percent-js-with-qwik-and-partytown), [handling failovers](https://dexecure.com/blog/beyond-offline-other-interesting-use-cases-for-service-workers-2/#automated-failover) and possibly many more. One of the problems that I continuously face is the need to adjust my service worker according to the framework, well no more. Let’s see what gold I dig up last week below 👇🏻

## Where it started?
I was trying to set up a custom service worker with Angular 11, and the guide [https://angular.io/guide/service-worker-getting-started](https://angular.io/guide/service-worker-getting-started) asked me to install angular/pwa module, read [https://angular.io/guide/service-worker-communications](https://angular.io/guide/service-worker-communications) and then adapt to the angular’s way of creating service worker. Well, seemed like a lot of work to me, so I set out to create a framework-agnostic process for adding a custom service worker. Reflecting back, I think it was [fairly easier with Vue 2 and 3](https://rishi.app/blog/enabling-service-worker-with-vue-2-and-vue-3), yet felt like a hacky way.

## Show me the solution!

Step 0. Install [esbuild](https://esbuild.github.io/getting-started/#install-esbuild)

Step 1. Create workbox-config.js:
Learn more about what’s there in workbox config here:
```js
module.exports = {
  globDirectory: "dist/",
  globPatterns: [
    "**/*.{css,eot,html,ico,jpg,js,json,png,svg,ttf,txt,webmanifest,woff,woff2,webm,xml}",
  ],
  globFollow: true,
  globStrict: true,
  globIgnores: [
    "**/*-es5.*.js",
    "3rdpartylicenses.txt",
    "assets/images/icons/icon-*.png",
  ],
  dontCacheBustURLsMatching: new RegExp(".+.[a-f0-9]{20}..+"),
  maximumFileSizeToCacheInBytes: 5000000,
  swSrc: "dist/service-worker.js",
  swDest: "dist/service-worker.js",
};
```

Step 2. Create compile_sw.js:
```js
const { build } = require("esbuild")

build({
  entryPoints: ["./path/to/service-worker.js"],
  outfile: "./dist/service-worker.js",
  minify: true,
  bundle: true,
  define: {
    'process.env.NODE_ENV': '"production"',
    'process.env.SOME_VARIABLE': '"SOME_VALUE"'
  },
}).catch(() => process.exit(1))
```

Step 3. Compile and inject:
```bash
npx workbox-cli injectManifest && node compile_sw.js
```

Step 4. Register the Service Worker ✨
```html
<script>
// Check that service workers are supported
if ('serviceWorker' in navigator) {
  // Use the window load event to keep the page load performant
  window.addEventListener('load', () => {
    navigator.serviceWorker.register('/service-worker.js');
  });
}
</script>
```

That’s all, enjoy! I hope this helps!
Simple HTTP Server Using Python
Tags: python, beginners
Published: 2022-01-23 15:07:43

---
title: Simple HTTP Server Using Python
published: true
date: 2022-01-23 13:07:24 UTC
tags: python,beginners
series: "Sunday Snippet"
canonical_url: https://clavinjune.dev/en/blogs/simple-http-server-using-python/
---

![Sunday Snippet #1 simple HTTP server using python](https://clavinjune.dev/img/sunday-snippet/image.png "Sunday Snippet #1 simple HTTP server using python")

Opening simple HTTP server using python

```bash
# python3 -m http.server <port>
$ python3 -m http.server 8080
Serving HTTP on :: port 8080 (http://[::]:8080/) ...
```
Testing pyramid in software development
Tags: software, testing, beginners
Published: 2022-01-23 10:17:49

We have all been hearing about the importance of writing tests and test-driven development.

✅ Here's how you can write better tests by implementing the testing pyramid strategy.

### A testing pyramid is made up of 3 layers

1. Unit Tests
2. Integration Tests
3. End to End Tests

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/7sh80sa4oru07efiro21.jpeg)
 

Testing pyramid tells you what type of tests you should be more focussed on.

### Unit tests
A unit test verifies that an individual piece of code functions as expected. They don't have any external dependencies.

Unit tests form the base of the pyramid. Ideally they should constitute bulk of your tests.


They are quite fast to execute, hence devs are encouraged to run it as often as required.


### Integration

Next layer on the pyramid are the integration tests.

Integration tests validate how a piece of code functions when it interacts with other code. These tests communicate with external dependencies like database's & external API's.


They are slow compared to unit tests. They also need the external services to be running.


### End to End (E2E)

At the top of the pyramid, we have End 2 End tests.

These tests interact with pages just like a user would, for example by clicking buttons and typing into text boxes, and they check that pages respond appropriately from the user's perspective.


They test the functioning of an app in its entirety. They are the slowest to run and given its dependency over multiple things, they are non-deterministic in nature. Ideally, you should be having only a few of these.


They are non-deterministic, the automation software must wait for the browser to complete the page load and for the particular element to appear.


For example, suppose that you write a test that clicks a button to open a modal and then clicks a button inside the modal to close it. Sometimes, the modal will open before the test tries to click the close button, so the test will pass.


### Summary

We've looked at the types of tests above. 

At a broad level, there are 2 aspects of a test type.

- Speed
- Test surface

You can see that speed is inversely proportional to the test area. Unit tests cover a short area, hence they are fast to run. But they cannot guarantee the functioning of a feature from the perspective of a user.


On the other hand E2E tests, validate the functioning of an entire feature as an end user would use it, but they are very slow to run and have lot of dependencies.


A good test suite will have a mix of the 3 types of tests outlined above. Unit tests are more reliable and fast, on the other hand E2E tests verify the functioning of an entire app, but are slow and non-deterministic.
Starting a new journey with the DEV.to community!
Published: 2022-01-23 12:46:03

**Hey folks!** I just joined DEV.to and read a lot of blogs from these amazing people on this platform and I am excited to start a new journey with all of you in this community.

Myself Elwin, and I am a self-learned full-stack web developer. I write UI's and apps with React and mostly with Django and REST Framework. I have been actively working and researching on Frontend technologies and servers for the past 4 years and I can't wait to share my experience and knowledge with all you guys!

Thank you for stopping by. 🤗
Have a great day!!! ✌️‍
Qr Code Maker Made With PhP
Tags: php, webdev, programming, tutorial
Published: 2022-01-23 12:41:45

![Qr Code](https://www.qrcode-monkey.com/img/modal/logo-modal.png)

## We Will Make A Qr Code Maker 

You Can Get The Code On GitHub - [https://github.com/cyberstain/qrcode_maker](https://github.com/cyberstain/qrcode_maker)
 
{% github cyberstain/qrcode_maker %}
What I learnt last week #1
Tags: javascript, beginners, weeklyretro
Published: 2022-01-23 12:32:13

Hi there ! 

This week I learnt how to get a node js project up and running. 
using the awesome tutorial from MDN webdocs. 

Last month I was doing a bit of basic html. 
so I wondered how to go about bringing one my sample html project onto the node js server. 

All it took was to upload those files into the right directory. (inside the public directory).

Here's a screen share where I go over things. 

https://youtu.be/S9vuQaaYwYY


citation
here's the link to the tutorial I'm referring. 
https://developer.mozilla.org/en-US/docs/Learn/Server-side/Express_Nodejs/skeleton_website