teleren/devto huggingface dataset:
Beneath the Rug, Computer Processing
Tags: machinelearning, systemarchitecture, computerscience, computing
Published: 2022-07-12 04:18:50

You have probably heard that the CPU processing is done in 0s and 1s. Have you ever wondered how this is possible?

Consider the number 11. This number is represented as eleven in the decimal numbering system. The decimal system is a representation of numbers using digits 0 – 9. The number 11 simply means the second number after the roundtrip from 0 – 9. The same number represented in the binary system is 1011. Note that the number of digits used for representing the same number is reduced (11 vs 1011), this is an attribute known as compactness. Since computers are better at handling numbers, using the binary system ensures accuracy and precision at the expense of compactness. These binary numbers are usually represented in 8-digit bit strings called bytes. For example, the representation of the number 1011 would be 00001011, with extra zeros used for padding.

At this point, you are probably wondering, what about the text on my screen? The CPU uses a text conversion process called character encoding to translate text to numbers. Think of it as a dictionary. Every character is a key, tied to a numeric value. Assuming A has a value of 1 in the dictionary, B would have the value of 2. This dictionary is case sensitive; hence the alphabet A has a different value from the alphabet a. Initially, computers used ASCII, a character encoding scheme modeled for only English characters, today computers use Unicode which encompasses 100, 000 characters (including your favorite emoji 😀).

Images follow a similar but slightly more complex pattern. At the smallest level, every image is made up of a pixel. On a color screen, every pixel is represented using three colors Red, Green, and Blue (RGB). Each color uses an 8-bit number to represent the color intensity. For example, 255 255 255 means all three colors are at the highest intensity for the particular pixel, and 000 000 000 means all colors are set to the lowest intensity. Interestingly, since images can be described in terms of numbers, mathematical calculations can be done on images. This is the basis of facial and character recognition systems using machine learning.

If you learned something new from this article, please like and share
How to Setup and run Cypress Test cases In Azure DevOps Pipeline
Tags: javascript, azure, testing, beginners
Published: 2022-07-12 04:50:49

How to Setup and run Cypress Test cases In Azure DevOps Pipeline

This Blog covers 

- How to Setup Pipeline

- Run Cypress Test cases In Azure DevOps 

https://qaautomationlabs.com/how-to-setup-and-run-cypress-test-cases-in-azure-devops-pipeline/
Webhook: Part IV
Published: 2022-07-12 04:46:53

So, we know how to create Webhook Provider application and Webhook Consumer application. So, what's next?

Here am sharing part of my experience developing both kind of application.

### Webhook Provider

**Provide an interface to store webhook consumers information**

This is useful when your consumer are getting bigger. You need a way, to maintain it easily.

**Provide options to consumer to choose what kind of Webhook events** 

I did not explain well on this, but basically what kind of event you want to listen to from Webhook provider - such as on user creation/update, new subscription, etc. 

So, you Webhook Provider application don't have to send all webhook consumers. Only send to those subscribe to the particular events.

### Webhook Consumer

**Provide An Interface to Generate the Secret Key**

You don't have to think of what secret key to use, let the codes do the work. Random string, 32 characters will be good.

## Conclusion

So far it's a challenge for me to understand and manage what's needed for my team, to develop applications that can communicate well. I don't want to use API calls, as it's require maintaining the API token / key, plus there's other new applications want to use the same information. Hence, using webhook is much easier approach, just a little bit of learning curve.

Source Code can be found here:

- [Webhook Provider](https://github.com/nasrulhazim/learn-webhook-provider)
- [Webhook Consumer](https://github.com/nasrulhazim/learn-webhook-consumer)

p/s: I might come up with a small package to handle Webhook Consumers and Secret Key.
Webhook - Part I
Tags: webhook, integration
Published: 2022-07-12 04:45:59

## The Definition of Webhook

A webhook in web development is a method of augmenting or altering the behavior of a web page or web application with custom callbacks. 

These callbacks may be maintained, modified, and managed by third-party users and developers who may not necessarily be affiliated with the originating website or application. The term "webhook" was coined by Jeff Lindsay in 2007 from the computer programming term hook.

The format is usually JSON. The request is done as a HTTP POST request. Reference as in [Wikipedia](https://en.wikipedia.org/wiki/Webhook)

## TLDR;

In this post, I will share how you can create your own Webhook and use it in your other application. 

Assuming now, you have multiple application, each of it has responsibilities to share their own data via Webhook.

I will use the term Webhook Provider - as the application that provide data to other application and Webhook Consumer, which application that receive data from Webhook Provider.

### Webhook Provider

The provider usually require to send data to an endpoint. But in webhook context, we need to make it data in consistent format and secure when sending them to an endpoint.

Following are some of the Webhook provider:

1. [Github](https://docs.github.com/en/developers/webhooks-and-events/webhooks/about-webhooks)
2. [Stripe](https://stripe.com/docs/webhooks)
3. [ClickUp](https://clickup.com/integrations/webhooks)
4. [Facebook](https://developers.facebook.com/docs/graph-api/webhooks/)

Keywords:

- data in consistent format: JSON
- secure: HTTPS endpoint + Signature

### Webhook Consumer

The consumer usually will provide an endpoint which the Webhook Provider will call the endpoint, using POST method.

Upon receiving the data, which usually called payload, the consumer require to validate the signature sent by the Webhook Provider. 

The payload usually in JSON format.

This to ensure that only a valid payload received on the consumer side. To validate, usually the provider will send together in the header, the signature of the webhook. 

Keywords:

- data aka payload, in JSON format
- validate the incoming Payload based on given signature.

On the next post, we will setup a simple Webhook Provider.
Cara install anaconda pada linux mint 20 Ulyana
Tags: python, anaconda, datascience, linux
Published: 2022-07-12 04:38:57

Anaconda adalah distributor bahasa pemrograman python dan R untuk komputasi ilmiah seperti data science, machine learning, pemrosesan data dengan skala besar, analisis deskriptif, dan lain sebagainya yang bertujuan untuk menyederhanakan manajemen dan penerapan paket. Platform ini dapat digunakan pada windows, linux, maupun macOS [[1](https://dqlab.id/tutorial-install-python-tanpa-download-dengan-anaconda-navigator)]

1. Download installer anaconda via situs [resmi](https://www.anaconda.com/products/distribution#Downloads)

2. Masuk directori anaconda yg kita download

3. Via terminal ketikan chmod 777 namainstalleranacondanya.sh atau  bisa juga chmod +x nama namainstalleranacondanya.sh

4. Via terminal ketikan bash namainstalleranacondanya.sh Atau jika kita pakai langkah chmod+x ketikan ./namainstalleranacondanya.sh

5. Ketikan enter,enter terus sampai readme nya selesai, lalu konfirmasi penginstallan Anaconda nya

6. Tunggu sampe proses selesai

7. Akses via terminal ketikan source ~/.bashrc

8. Masuk mode Base lalu ketikan conda list untuk mengetahui apa saja yang terinstall di sana

9. Ketikan anaconda-navigator untuk mengakses nya 

Demikian tutorial singkat ini
Semoga sukses
Implement Binary Search Using JavaScript
Tags: javascript, algorithms, programming, beginners
Published: 2022-07-12 04:36:59

Binary search technique is used to search for any element in a sorted array using divide and conquer approach.

```
/**
 * Binary Search
 * Note - It works only for the sorted array. start and end are left and right of the array.
 *
 * Recursive Approach
 * - If starting index is greater than the ending index return false
 * - Compute the middle index.
 * - Compare the middle element with the number x. If equal return true.
 * - If greater, call the same function with ending index = middle-1 and repeat step 1.
 * - If smaller, call the same function with starting index = middle+1 and repeat step 1.
 * 
 * Time Complexity: O(logN)
 * Auxiliary Space: O(1)
 */

const arr = [1, 3, 5, 7, 8, 9];

const binarySearchRecursive = (arr, val, start, end) => {
    if (start > end) return false;

    const mid = Math.floor((start + end) / 2);

    if (arr[mid] === val) return mid;

    const left = arr[mid] > val ? start : mid + 1;
    const right = arr[mid] > val ? mid - 1 : end;

    return binarySearchRecursive(arr, val, left, right);
}

console.log(binarySearchRecursive(arr, 5, 0, arr.length - 1)); // -> 2
```
473. Leetcode solution in CPP
Tags: leetcode, challenge, cpp
Published: 2022-07-12 04:30:04

```
class Solution {
 public:
  bool makesquare(vector<int>& matchsticks) {
    if (matchsticks.size() < 4)
      return false;

    const int perimeter = accumulate(begin(matchsticks), end(matchsticks), 0);
    if (perimeter % 4 != 0)
      return false;

    sort(begin(matchsticks), end(matchsticks), greater<int>());
    return dfs(matchsticks, 0, vector<int>(4, perimeter / 4));
  }

 private:
  bool dfs(const vector<int>& matchsticks, int selected, vector<int>&& edges) {
    if (selected == matchsticks.size())
      return all_of(begin(edges), end(edges),
                    [](int edge) { return edge == 0; });

    for (int i = 0; i < 4; ++i) {
      if (matchsticks[selected] > edges[i])
        continue;
      edges[i] -= matchsticks[selected];
      if (dfs(matchsticks, selected + 1, move(edges)))
        return true;
      edges[i] += matchsticks[selected];
    }

    return false;
  }
};

```


#leetcode
#challenge
here is the link for the problem: 
https://leetcode.com/problems/matchsticks-to-square/submissions/
Buffer Overflow
Tags: exploit, bufferoverflow, programming, cpp
Published: 2022-07-12 04:25:00

Buffer overflow or buffer overrun is a term used to describe a condition where a program writes to a buffer beyond its capacity. With an overflowing buffer, a malicious attacker can gain access to memory not originally allocated to a process, for the purpose of injecting and executing arbitrary code.

Dependency Execution Prevention (DEP) is a solution to combat buffer overflow by enforcing memory access policies. The basic idea behind DEP is this, even if a buffer overflow occurs and the control flow integrity is compromised, the newly injected code should not be able to execute. Any attempt to execute code at non-executable location results in a STATUS_ACCESS_VIOLATION exception.

As an optimization, Microsoft provides other memory protection attributes to further limit buffer flows. For example, Copy-on-Write Protection allows processes to share a physical memory space so far as it has not been written to. Though effective, DEP offers no protection against other types of attacks, particularly those involving code reuse and Return Oriented Programming.

If you learned something new from this article, please like and share
Migrating Core-Banking Workloads to the Cloud
Tags: microservices, architecture, finance, cloud
Published: 2022-07-12 04:23:13

Core banking is a backend system that provides all mission-critical functionalities – backbone functionalities that are key to the running of a bank – which includes account management, transaction processing, deposit, general ledger, loan, and credit processing

For half a century, mainframes have proven to be a tested and trusted solution in handling core banking workloads. This is largely due to the fact that mainframes are a beast when it comes to raw processing power with the latest z16 being able to process 25 billion secure transactions per day!

Traditional banks have been unable to keep up with the fast pace of fintech digitalization because most core banking solutions target mainframes that use primitive languages such as COBOL and complex monolithic architecture. Changes also require planned downtimes to load even the smallest updates.

There is a severe scarcity of technology domain expertise required for business continuity in most traditional banks. Rather than work with “boring” programming languages, students and recent college graduates have opted for more “exciting” programming languages poised to take create cutting-edge solutions. Older ones with in-depth knowledge of how complex mainframes work and have been around supporting the core banking system are now retiring or are increasingly expensive to retain. This presents a risk that cannot be ignored as the safety reputation of any bank hinges on its risk culture.

A shift to the cloud offers a greatly reduced Total Cost of Ownership. Whereas the annual cost of maintaining a mainframe is estimated to be around $5 million, a similar workload running on a public cloud provider could be 10 times lower at around $550,000.

The Migration of core banking workloads is best done in phases to avoid disruption. Portions of mission-critical functionalities are broken down into microservices and shifted to the cloud in a “Lift and Shift” process starting from the least essential to the most essential functionalities.

Typically, a large organization like a traditional
bank will need more than 5000 million instructions per second (MIPS) capacity. For such a workload, twenty 1 TB solid-state drives can be used as primary storage while twenty 1TB hard disk drives provide a virtual tape.

Azure Active Directory can be leveraged when using Microsoft Azure to provide consistent and organizational-level security. This is in addition to the inherent defense system available on the cloud against distributed attacks. Azure Backup will provide a secure backup environment that ensures data in transit and at rest is protected even against ransomware attacks.

If you learned something new from this article, please like and share
MariaDb Quick-tip #4 - Random int for each row
Tags: sql, mysql, mariadb
Published: 2022-07-12 03:55:19

## MariaDB tips and tricks

This is part of a series of quick tips and tricks I have accumulated over the years, that I think can be useful for others.
If you have similar short tips and tricks please leave a comment.

### Random int for each row

The trick to generate a random number for each row is to use the RAND() function, multiply it by the maximum number you need and then cast the number as INT.

The code below show how to create a number between 0 and 24 and another example of how to create a number between 15 and 25.

The calculation of the random int for each row is not very efficient, so you should consider using a more efficient method for generating the random numbers if you need it in production code.

You have to do something slightly different to generate a range of int on the [SQL Server](https://dev.to/coderallan/sql-quick-tip-4-random-int-for-each-row-3d71)

```sql
CREATE OR REPLACE TEMPORARY TABLE names (Name VARCHAR(50));

INSERT INTO names (Name) 
VALUES ('Joe'), ('Bob'), ('Anne'), ('Jane');

-- Generate random ints between 0 and 24
SELECT Name, CAST(MOD(RAND() * 100000, 25) AS INT) AS `Random Int`
  FROM names;

-- Generate random ints between 15 and 25
SELECT Name, CAST(MOD(RAND() * 100000, (25-15)) AS INT) + 15 AS `Random Int`
  FROM names;
```

![DBeaver screenshot 1](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/u5f9yr92nkuqxsuuedil.png)

![DBeaver screenshot 2](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ppxa359jaar0toi7x8lb.png)

![DBeaver screenshot 3](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/jq502i6ui63ugs9o96ak.png)
Let's Talk Python Sets
Tags: python, beginners, programming, webdev
Published: 2022-07-12 03:55:10

Let's talk about #SETS in python

A Set is an unordered collection data type that is iterable, mutable and has no duplicate elements. Python’s set class represents the mathematical notion of a set.

OR

Sets are used to store multiple items in a single variable. Set is one of 4 built-in data types in Python used to store collections of data, the other 3 are List, Tuple, and Dictionary, all with different qualities and usage. A set is a collection which is unordered, unchangeable*, and unindexed.


. Below are 5 different example on sets 



![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/dlzt7ajuzx6vvmoidiz2.jpg)


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/dngre9w39144frovi3a6.jpg)

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/q912ldt3wgolfwd1o1g5.jpg)

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/kj086gfpeyvdu3an4cgw.jpg)

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/0dshs3jpt274hvpn1wwb.jpg)t
Cross-account S3 Origin Setup
Published: 2022-07-12 03:45:58

It is possible to setup cross account S3 Bucket for CloudFront

Let's take a look of the solution first. 

Master account - This is where you created your CDN

Sub-account - This is where you have the S3 



## Sub-account
You will need to setup s3 bucket policy to allow OAI access from the Master account

S3 bucket policy looks like below

```
{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Effect": "Allow",
            "Principal": {
                "AWS": "arn:aws:iam::cloudfront:user/CloudFront Origin Access Identity <OAI ID>"
            },
            "Action": "s3:GetObject",
            "Resource": "arn:aws:s3:::<bucket-name-of-the-sub-account>/*"
        }
    ]
}
```

## Master Account
Create a S3 Origin using the S3 endpoint 

Format:

```
<bucket-name-from-the-sub-account>.s3.<aws-region>.amazonaws.com
```

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/jay1lp39168r0omosqnj.png)
 
abc is the bucket name from the sub-account

Select the Origin access identity from the Master account. 

Last but not least, Create a path pattern that suit your s3 origin behaviour if you have multiple origins
How to connect php-fpm(WAS server) to apache(Web server)?
Tags: php
Published: 2022-07-12 03:36:26

Hi, everyone!
My team members and I are doing a team project.
We have each web server, WAS server, and db server and they are all separated.

At this point, we try to connect php-fpm(WAS server) to apache(Web server), but there are little information how to do that.

Most people talk about the connection of apache and php-fpm in the same one server, not separated environments like ours.... :(

We already installed apache 2.4.6 version and rpm-fpm in each server.

If one of you guys know how to connect, please please please help me how to do that.
Thank you.
Implement a antivirus clamav scanner with rest api in dokku
Tags: dokku, docker, clamav, api
Published: 2022-07-12 03:26:48

At work, I had the need of implement a virus scanner for all files uploaded to the server. 

Well lets give a chance the clamav a deamon virus scanner opensource.

I found a project what implement a rest api very easy!

https://github.com/benzino77/clamav-rest-api/ 

I run the [docker compose of the proyect](https://github.com/benzino77/clamav-rest-api/ ) and works like charm!

It use clamav in a docker container, an a api rest application to scan the file, using a network connector.

I'm not a big fan of docker, for run the docker project by hand, but dokku handle very well and can manage (deploy, maintain, etc) very well without effort.

With the good advice of the core developer from dokku. I can implement very fast the solution in dokku.

Then let's jump in....

```
                                                                        ┌──────┐
                                                                        │      │
     ┌───────────────────┐                 ┌────────────────────┐       │  N   │
     │                   │   clamav-net    │                    │  proxy│  G   │
     │ Clamav (clamd)    ◄─────────────────┤   Rest API  :3000  │◄──────┤  I   │
     │                   │                 │                    │       │  N   │
     └───────────────────┘                 └────────────────────┘       │  X   │
                                                                        │      │
                                                                        │  :443│
                                                                        │      │
                                                                        └──────┘



```
Basically this is implemented by dokku..

first the nginx proxy the http request to the  `rest api application` which is listen at :3000 in the container, to do that needs to communicate with clamd the deamon which scan the file and return the result to the apirest.

Easy right ?

My first approach to solve this is creating a plugin doing that but @savant Jose Gonzales from dokku suggest better create two dokku apps using https://dokkupose.netlify.app

The I paste the docker-compose file to the dokkupose and for my surprise it give exactly all the commands needed to deploy in dokku. Feeling like this:

![black magic was generated](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/mhkux8quje5wbn45k9sq.png)

Then the only missing here is the network link between clamd and the rest-api. I handle it by hand.

I left you the script i made to create the solution with comments:

{% gist https://gist.github.com/zodman/9c32a034e6dc49e9426b70252e75afa2 %}


Question?

**What about the signature updates ?**
[In container handle it by automatically and update daily](https://github.com/Cisco-Talos/clamav/blob/main/README.Docker.md#controlling-the-container)

you don't know about dokku ?

{% github https://github.com/dokku/dokku %}

It's like heroku but selfhosted.
Open Source projects that I’ve been contributing
Tags: opensource, devjournal, programming, webdev
Published: 2022-07-12 03:10:13

On the last two weeks I’ve learned a lot about contributing in open source projects.
Two of the projects that I’ve been contributing is the largest UI library and Fig an autocomplete extension used for terminal. 

### Material UI Library (MUI)

As an open source project Material UI, recently developed their new version Material UI 5, they include a lot of new features but also currently have a lot of bugs specially related to Typescript. One of the bugs I’ve tried to solve is related to customize FormHelperTextProps component, on this issue I’ve been learning a lot of how Customization works on Material UI components and Typescript, still haven’t found the solution but I think is related to a type. After reading a lot of similar issues and documentation I have  a better idea of what’s going on, hope I’ll fix it soon.

### Fig MacOS terminal extension

Fig is an open source extension developed to autocomplete cli commands, currently it supports Git, Npm, Yarn, Brew, Docker, etc. I’ve been working with this extensions for 4 months and it helps me a lot. The last project I’ve worked on used Java and while I was using Fig I noticed that it doesn’t support Spring, so I decided to start working on the Spring CLI autocomplete.

It’s hard to contribute on open source projects, specially when you don’t take your time to understand the issue.