teleren/devto huggingface dataset:
Use Pull Request Number as Serverless Deployment Stage
Tags: aws, serverless, github, productivity
Published: 2022-04-21 10:14:26

The Serverless Framework allows to deploy one service to multiple stages, for example dev, qual, and prod. The stage can be set on the `provider` property:

```yml
# serverless.yml
service: myservice

provider:
  name: aws
  stage: dev
  region: us-east-1
```

The stage is appended to the CloudFormation stack name and added to all Lambda functions and most other resources in the service. It can also be overridden during deployment with the command line flag `--stage` or `-s`:

```sh
serverless deploy --stage prod --region eu-central-1

> Deploying myservice to stage prod (eu-central-1)

> ✔ Service deployed to stack myservice-prod (130s)

> functions:
>  hello: myservice-prod-hello (14 kB)
```

Now, you may have a CI/CD environment such as GitHub Workflows where you continuously deploy changes based on a commit or pull request. These changes need to be tested separately from the development or production state. One way is to deploy them in a separate stage (e.g. qual or the name of the branch/commit/pull request) and then run your test scripts.

Instead of appending `--stage` to each of my deployment scripts, I like to use environment variables to set the stage dynamically. At the beginning of my GitHub workflow, I set the environment variables based on the pull request that triggered the workflow run:

```yml
# .github/workflows/ci.yml
name: GitHub CI/Testing

on:
  pull_request

env:
  PR_NUMBER: ${{ github.event.number }} # e.g. 65
  BRANCH: ${{ github.head_ref }}        # e.g bugfix/issue-42
  STAGE: pr${{ github.event.number }}   # => pr65

...
```

In order for the Serverless Framework to fetch the correct stage from the environment, we need to overwrite the stage with a variable resolution:

```yml
# serverless.yml

provider:
  stage: ${opt:stage, env:STAGE, "dev"} 
```

This variable defines the order in which the stage is being resolved during deployment. First, the `--stage` flag is checked. If it is not available, the environment variable `STAGE` is checked. If it is not available either, the default value `dev` is used. 

In this example, the Serverless Framework would provide the service as `myservice-pr65` and the Lambda function as `myservice-pr65-hello`. If you need to access the stage within the serverless.yml file, for example to name other resources and exports, you can use the buil-in variable `${sls:stage}` which resolves against the `provider.stage` variable from above.

#### Links
- [Serverless Variables](https://www.serverless.com/framework/docs/providers/aws/guide/variables)
- [GitHub Actions Environment Variables](https://docs.github.com/en/actions/learn-github-actions/environment-variables)
- [GitHub Actions Context](https://docs.github.com/en/actions/learn-github-actions/contexts#github-context)
Watching videos on 720p instead of 1080p cuts the energy consumption of your phone in half!
Tags: performance, mobile, energy, streaming
Published: 2022-04-21 10:03:26

---
title: Watching videos on 720p instead of 1080p cuts the energy consumption of your phone in half!
published: true
description: 
tags: #performance #mobile #energy #streaming
//cover_image: https://direct_url_to_image.jpg
---

I just stumbled upon this ["The impact of video quality on energy efficiency and network usage for video streaming applications on Android"](https://s2group.cs.vu.nl/2022-01-05-green-lab-experiment/) 

According to their research the energy savings are significant!

![A graph that shows the estimates of the power consumption during video plays on Youtube with 360p, 480p, 720p and 1080p.](https://s2group.cs.vu.nl/files/posts/images_energy_android_experiment/Y_con.png)

Makes me wonder if I can somehow fix it to 720p on all me devices (especially since my phone's display does not support 1080p natively and would have to downsize the image anyway).

Also last week I stumbled upon a paper which said that [only ~20% of GitHub Actions use Caching](https://dev.to/_vsaw/do-you-use-caching-in-your-cicd-pipelines-m7o), which makes me wonder how much low hanging fruit is out there that we can use the make SW more energy efficient and performant!
Difference between Abstract Class and Interface
Tags: codequality, csharp, beginners, webdev
Published: 2022-04-21 09:45:11

                      **Abstract Class**

 
1.It contains both declaration and definition part
2.Multiple inheritance is not achieved by abstract class
3.It can contain static members and It contain constructor
4.It can contain different types of access modifiers like 
 public, private, protected
5.A class can only use one abstract class.
6.If many implementations are of the same kind and use common behavior, then it is superior to use abstract class.
7.It can be fully, partially or not implemented.


                       **Interface**


1.It contains only a declaration part
2.Multiple inheritance is achieved by interface.
3.It does not contain static members.
4.It does not contain constructor.
5.It only contains public access modifier because everything in the interface is public.
6.A class can use multiple interface.
7.Interface can only contains methods, properties, indexers, events.
Recover your Dropped Table from the Recyclebin ⛅😎
Tags: database, sql, productivity
Published: 2022-04-21 09:44:17




![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/5pm3z6genb9qw7cmoqld.gif)

👉Recyclebin: helpful for developers in case a DROP command occured mistakenly; tables can be recovered as if nothing happened 💪

- 📖 [Documentation](https://docs.oracle.com/en/database/oracle/oracle-database/19/sqlrf/PURGE.html)
- 💻 [Gist](https://gist.github.com/loiclefevre/a371f6c5f83badd2860c644bfd15897b)
Abstract Class
Tags: csharp, programming, tutorial, advancedcsharp
Published: 2022-04-21 09:44:11

Abstraksiya kodning ma'lum qismini yashirishga va kerakli ma'lumotlarni berishga yordam beradigan protsess hisoblanadi. Va bu protsess abstrakt klass yoki interface orqali amalga oshiriladi.

Abstrakt modifier klasslar, metodlar, propertylar, eventlar va intexerlar uchun ishlatilinadi. Abstrakt klasslarni boshqa klasslarga ota (base) sifatida ishlatinglar, shunchaki emas. Chunki u ABSTRAAAKT klass. Abstrakt sifatida belgilangan memberlar abstrakt klassdan kelib chiqadigan, lekin abstrakt bo'lmagan klasslar tomonidan amalga oshirilishi kerak.

abstrakt klass bu object orqali chaqirish mumkin bo'lmagan klass. Chaqirish uchun uni boshqa klassdan turib inherit qilish kerak

abstrakt method faqatgina abstrakt klass ichida foydalana olishimiz mumkin bo'lgan method, va unda body bo'lmaydi. Uning bodysini derived klassda (inherit qilingan klass) yozishimiz kerak bo'ladi.
Misol:
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/sk5qtmzl99dwn4ndxk0a.png)

Abstraktning fichalari:

1. Abstrakt sinfini yasab bo'lmaydi, ya'ni ichidagilarning hammasini boshqa klasslarda implementatsiya qilinadi
2. Abstrakt klass abstrakt method va accessorlarni talab qilishi mumkin.
3. Abstrakt klassni sealed modifier bilan o'zgartirib bo'lmaydi, chunki bu ikkalasi bir biriga qarama qarshi meaningi bor. Sealed modifier klassni inherit qilishdan saqlasa, abstrakt modifier uni majbur qiladi.
4. Abstrakt klassdan derive qilingan (inherit qilingan) klass abstrakt klassning barcha abstrakt methodlar va accessorlarni implement qilishi shart.

Implementation -> (method) tanani boshqa klassdan turib yozish
Training models automatically on tabular data with Hugging Face AutoTrain
Tags: automation, datascience, automl, machinelearning
Published: 2022-05-24 16:02:43

---
title: Training models automatically on tabular data with Hugging Face AutoTrain
published: true
date: 2022-04-21 09:32:35 UTC
tags: automation,datascience,automl,machinelearning
canonical_url: https://julsimon.medium.com/training-models-automatically-on-tabular-data-with-hugging-face-autotrain-d5a80d53d89e
---

In this video, I use [AutoTrain](https://huggingface.co/autotrain), an AutoML product designed by [Hugging Face](https://huggingface.co), to train a multi-class classification model on tabular data (the PetFinder dataset from Kaggle).

{% youtube OH_e0wOkpZc %}

Original dataset: [https://www.kaggle.com/competitions/petfinder-adoption-prediction/](https://www.kaggle.com/competitions/petfinder-adoption-prediction/)

Dataset on the hub: [https://huggingface.co/datasets/juliensimon/autotrain-data-petfinder-demo](https://huggingface.co/datasets/juliensimon/autotrain-data-petfinder-demo)

Model on the hub: [https://huggingface.co/juliensimon/autotrain-tabular-demo-762523398](https://huggingface.co/juliensimon/autotrain-tabular-demo-762523398)

Notebook: [https://gitlab.com/juliensimon/huggingface-demos/-/tree/main/autotrain-petfinder](https://gitlab.com/juliensimon/huggingface-demos/-/tree/main/autotrain-petfinder)

New to Transformers? Check out the [Hugging Face](https://huggingface.co/course) course!
705. Design HashSet
Tags: cpp, algorithms, 100daysofcode, programming
Published: 2022-04-21 09:20:52

# **705. Design HashSet**

# Description

Design a HashSet without using any built-in hash table libraries.

Implement `MyHashSet` class:

- `void add(key)` Inserts the value `key` into the HashSet.
- `bool contains(key)` Returns whether the value `key` exists in the HashSet or not.
- `void remove(key)` Removes the value `key` in the HashSet. If `key` does not exist in the HashSet, do nothing.

## Example 1:

```
Input
["MyHashSet", "add", "add", "contains", "contains", "add", "contains", "remove", "contains"]
[[], [1], [2], [1], [3], [2], [2], [2], [2]]
Output
[null, null, null, true, false, null, true, null, false]

Explanation
MyHashSet myHashSet = new MyHashSet();
myHashSet.add(1);      // set = [1]
myHashSet.add(2);      // set = [1, 2]
myHashSet.contains(1); // return True
myHashSet.contains(3); // return False, (not found)
myHashSet.add(2);      // set = [1, 2]
myHashSet.contains(2); // return True
myHashSet.remove(2);   // set = [1]
myHashSet.contains(2); // return False, (already removed)
```

## Constraints:

- `0 <= key <= 106`
- At most `104` calls will be made to `add`, `remove`, and `contains`.

---

# Solutions

## Solution 1

### Intuition

### Code

```cpp
const int N = 113;
class MyHashSet {
private:
    vector<int> mySet[N];
    int find(int linkIndex, int target) {
        vector<int> &link = mySet[linkIndex];
        for (int i = 0; i < link.size(); i++) {
            if (link[i] == target) return i;
        }
        return -1;
    }

public:
    MyHashSet() {
    }

    void add(int key) {
        int linkIndex = key % N;
        int index = find(linkIndex, key);
        if (index == -1) mySet[linkIndex].push_back(key);
    }

    void remove(int key) {
        int linkIndex = key % N;
        int index = find(linkIndex, key);
        if (index != -1) mySet[linkIndex].erase(mySet[linkIndex].begin() + index);
    }

    bool contains(int key) {
        int linkIndex = key % N;
        int index = find(linkIndex, key);
        return index != -1;
    }
};

/**
 * Your MyHashSet object will be instantiated and called as such:
 * MyHashSet* obj = new MyHashSet();
 * obj->add(key);
 * obj->remove(key);
 * bool param_3 = obj->contains(key);
 */
```

### Complexity

- Time: O(n)
- Space: O(n)

---
Security Schemes for OpenAPI Provider Rest API Descriptor in Integration Server
Tags: webmethods, integrationserveresb, api, rest
Published: 2022-04-26 10:04:10

---
title: Security Schemes for OpenAPI Provider Rest API Descriptor in Integration Server
published: true
date: 2022-04-21 09:20:27 UTC
tags: webMethods, IntegrationServerESB, API, REST
canonical_url: https://tech.forums.softwareag.com/t/security-schemes-for-openapi-provider-rest-api-descriptor-in-integration-server/256885
---

 
Author - @PriyaGupta
## Overview

The OpenAPI Specification 3.0.x provides a security object that defines the security schemes for operations. Following are the supported security schemes for OpenAPI 3.0.x:

- HTTP authentication
- API key
- OAuth2 (implicit, password, client credentials, and authorization code)
- OpenID Connect Discovery

Integration Server supports the following authentication mechanisms from the OpenAPI Specification version 3.0.x:

- HTTP authentications: Basic, Bearer, and Digest
- OAuth 2.0 flows: Authorization Code, Implicit, Resource Owner Password Credentials or Password, and Client Credentials

The API key and the OpenID Connect Discovery security schemes are not supported by the provider REST API Descriptor (RAD).

This tutorial explains how the provider RAD that uses the OpenAPI document 3.0.x displays the security schemes.

### Prerequisites

Ensure that the following are available:

- Integration Server that processes the REST API request.
- An integration developer implementing the business logic in the service.

## Use Cases

Visit the [Original post](https://tech.forums.softwareag.com/t/security-schemes-for-openapi-provider-rest-api-descriptor-in-integration-server/256885) in the Software AG Tech Community to find 5 Use Cases on how the provider RAD displays different security schemes.
Linked List in TS
Tags: datastructures, typescript
Published: 2022-04-21 09:11:26

## What are Linked Lists

1. Linear dynamic Data Structure
2. Expensive to maintain in comparison to arrays in terms of insertion and deletion
3. comprises nodes
4. last element points to null
5. can grow and shrink on demand
6. made of 2 items of data and reference to the next node 

**_MAJOR DISADVANTAGE OF LINKED LIST_** - O(n) for access to an element in the worst case.



Basic Operations
1. traverse linked list
2. push
3. pop
4. insertAtFirst
5. deleteByIndex

{% embed https://stackblitz.com/edit/typescript-tmtmgm?devToolsHeight=33&embed=1&file=linked-list/linked-list.class.ts&view=editor %}
Getting Started with the Blazor File Upload Component
Tags: blazor, webdev, dotnet
Published: 2022-04-21 08:57:22

This video will get you started with the Syncfusion [File Upload component in a Blazor](https://www.syncfusion.com/blazor-components/blazor-file-upload) Server application. You will learn about the basic functionalities like uploading multiple files or a single file at a time and validation during file upload. You will also see how to save and remove files with or without using Server APIs. 

**Product Overview**: https://www.syncfusion.com/blazor-components/blazor-file-upload

**Download an example from GitHub**: https://github.com/SyncfusionExamples/getting-started-with-blazor-file-upload-component

**Refer to the following documentation to learn about the Blazor File Upload component**: https://blazor.syncfusion.com/documentation/file-upload/getting-started

Check out this online example of the Blazor File Upload component: https://blazor.syncfusion.com/demos/file-upload/default-functionalities

{% youtube MxyrifDwud4 %}
Swift — 11 Useful Combine Operators You Need to Know
Tags: swift, operators, combine, ios
Published: 2022-04-21 08:52:58

**What is an Operator in Combine?**

Combine declares publishers to expose values that can change over time, and subscribers to receive those values from the publishers. And the methods that operate on values coming from a publisher are called operators.

Each operator returns a publisher that, receives the values, manipulates them, and then sends them to its subscribers.

11 very important Combine operators with examples and graphical representation.

1. Prepend
2. ReplaceNil
3. switchToLatest
4. merge(with:)
5. CombineLatest
6. zip
7. map
8. collect
9. Reduce
10. Debounce
11. Throttle

To read more about each operator, visit our website [blog.canopas.com](https://blog.canopas.com/swift-11-useful-combine-operators-you-need-to-know-499cfdce0cd5)
Checking port visibility without net tools
Tags: linux, bash
Published: 2022-04-21 08:30:19

> Note: these are my self-help notes. Please let me know if they're wrong :)

The only thing you have is pure bash - no net tools. How to check the port visibility on a remote machine?

*1. Opening stream for the TCP connection*

`exec [stream number]<>/dev/tcp/[host]/[port]`

e.g.:
`exec 5<>/dev/tcp/10.21.24.41/22`

*2. Sending something to that port*

`echo "hello" >&5`

*3. Reading the answer*

`cat <&5`

In case the port 22 is open, we'll get something like:

```bash
SSH-2.0-OpenSSH_7.4
Protocol mismatch.
```

*4. Closing the stream descriptor*

`exec 5<&-`
Launching system from GRUB2 console
Tags: linux, grub
Published: 2022-04-21 08:21:07

> Note: these are my self-help notes. Please let me know if they're wrong :)

A Linux system that isn't visible in Grub2 can be launched using Grub2 console.

**0. Entering the console**

To enter the grub2 console you need to press `c` key.

**1. Choosing the device**

The `ls` command prints out all the disk devices formatted as `(hd0), (hd0,msdos1), (hd0,msdos2)` which translates to `/dev/sda, /dev/sda1, /dev/sda2`.

You choose the disk using `set root=(hd0,1)`.

**2. Choosing the kernel and system image**

Now you can view the disk content using `ls`. You should be looking for `vmlinuz*` and `initrd*` files in `/boot` subdirectory.

After finding them you need to set them:

`linux /boot/vmlinuz-3.13.0-29-generic root=/dev/sda1`

`initrd /boot/initrd.img-3.13.0-29-generic`

The `root` argument isn't required but omitting it may result in errors when grub2 runs from another device like a pendrive or live cd.

It's crucial to point to the same version in both commands. In case the system became unbootable after kernel upgrade you obviously need to specify the older version.

**3. Booting**

The final touch is the `boot` command.
ReactJS's components written in Typescript
Published: 2022-04-21 08:13:13

Actually you can use ReactJS's components in Typescript as in facebook's example. Just replace 'jsx' file's extension to 'tsx':

```
//helloMessage.tsx:
var HelloMessage = React.createClass({
 render: function() {
 return <div>Hello {this.props.name}</div>;
 }
});
ReactDOM.render(<HelloMessage name="John" />, mountNode);
```
But in order to make full use of Typescript's main feature (static type checking) should be done couple things:

1) convert React.createClass example to ES6 Class:

```
//helloMessage.tsx:
class HelloMessage extends React.Component {
 render() {
 return <div>Hello {this.props.name}</div>;
 }
}
ReactDOM.render(<HelloMessage name="John" />, mountNode);
```
2) next add Props and State interfaces:

```
interface IHelloMessageProps {
name:string;
}
interface IHelloMessageState { //empty in our case } class HelloMessage extends React.Component {
constructor(){
super();
}
render() {
return
<div>Hello {this.props.name}</div>;
}
}
ReactDOM.render(, mountNode);
```
Now Typescript will display an error if the programmer forgets to pass props. Or if they added props that are not defined in the interface.

**References:**
_ReactJSNotesForProfessionals Book_
PowerShell(pwsh) Tutorial for Perl
Tags: perl, pwsh, powershell, windows
Published: 2022-04-21 08:09:49

PowerShell(pwsh) is a [CLI](https://en.wikipedia.org/wiki/Command-line_interface) tool to run programs on Windows. 

This article is originally <a href="https://en.perlzemi.com/blog/20220420170117.html">PowerShell(pwsh) Tutorial for Perl | Perl ABC</a>


* UTF-8
* Linux/UNIX-like Shell
* ls, echo commands, etc
* A string is quoted "" and ''

### Installation of PowerShell(pwsh)

PowerShell(pwsh) can be downloaded from the following page.

[Installing PowerShell on Windows](https://docs.microsoft.com/en-us/powershell/scripting/install/installing-powershell-on-windows?view=powershell-7#installing-the-msi-package)

Click the following link to download PowerShell(pwsh).

[PowerShell-7.2.2-win-x64.msi](https://github.com/PowerShell/PowerShell/releases/download/v7.2.2/PowerShell-7.2.2-win-x64.msi)

And double-click the downloaded file. The installer is executed.

"Next" | "Next" | "Next" | "Install" | "Finish"

### Execution of PowerShell/pwsh

Let's execute PowerShell/pwsh.

"Start Menu" | "Apps" | "PowerShell" | "PowerShell 7 (x64)"

![](https://en.perlzemi.com/images/installation/pwsh.png)

Your home directory is shown on PowerShell/pwsh.

<pre>
PS C:\Users\kimot
</pre>

### Showing File Extensions

The extension of Perl program is "**.pl**". It is useful if extensions of files are displayed.

The way to show file extensions is described in the following page.

[How to Make Windows Show File Extensions](https://www.howtogeek.com/205086/beginner-how-to-make-windows-show-file-extensions/)

### Execution of Notepad

Perl programs are text files. You can create your Perl programs using Notepad.

The way to use Notepad is described in the following page.

[11 ways to start Notepad in Windows](https://www.digitalcitizen.life/start-notepad-windows/)

### Creating Perl Programs

Let's create a Perl program.

Create a file named "start.pl" at your home directory.

<pre>
C:\Users\kimot\start.pl
</pre>

And write the following text.

<pre>
print "Hello World";
</pre>

And save it.

### Running Perl Programs

You can run your Perl program using **perl** command.

<pre>
perl start.pl
</pre>

The output is:

<pre>
Hello World
</pre>

### Commands of PowerShell/pwsh

Introduce often used commands of PowerShell/pwsh.

#### ls

The "ls" command displays the list of files.

<pre>
ls
</pre>

#### cd

The "cd" command changes the working directory.

<pre>
cd DirectoryName
</pre>

".." is the file name that means the folder one level higher.

<pre>
cd ..
</pre>

#### Changing Drives

You can change drives using "c:" or "d:".

<pre>
Set-Location -Path c:
Set-Location -Path d:
</pre>

#### Seeing Command Histories

You can see command histories using "↑" and "↓" keys.

<pre>
↑
↓
</pre>

### Show Environment Variables

Show environment variables.

<pre>
ls env:
</pre>

#### Getting Environment Variables

You can get and show an environment variable as the following.

<pre>
echo $env:PATH
</pre>

$env:MYENV = "This is my env."

#### Setting Environment Variable

You can set an environment variable as the following.

<pre>
$env:DATE=20080604
</pre>
A Quick 10-Second Programming Joke For Today
Tags: jokes, dailydeveloperjokes
Published: 2022-04-21 08:00:12

---
title: "A Quick 10-Second Programming Joke For Today"
description: "Check out today's daily developer joke! (a project by Fred Adams at xtrp.io)"
series: "Daily Developer Jokes"
published: true
tags: #jokes, #dailydeveloperjokes
---

Hi there! Here's today's Daily Developer Joke. We hope you enjoy it; it's a good one.

![Joke Image](https://private.xtrp.io/projects/DailyDeveloperJokes/public_image_server/images/5e125896e0846.png)

---

For more jokes, and to submit your own joke to get featured, check out the [Daily Developer Jokes Website](https://dailydeveloperjokes.github.io/). We're also open sourced, so feel free to view [our GitHub Profile](https://github.com/dailydeveloperjokes).

### Leave this post a ❤️ if you liked today's joke, and stay tuned for tomorrow's joke too!

_This joke comes from [Dad-Jokes GitHub Repo by Wes Bos](https://github.com/wesbos/dad-jokes) (thank you!), whose owner has given me permission to use this joke with credit._

<!--
Joke text:
___Q:___ Why was the developer unhappy at their job?

___A:___ They wanted arrays.
 -->