teleren/devto huggingface dataset:
C ++
Published: 2022-12-14 11:58:03

```cpp
/*  
      data tip non=qiymat;
---------O'zgaruvchilar turlari---------
int=>integer ya'ni faqat butun son saqlaydi;4 byte
string=>faqat tekislar saqlash uchun;4 byte
char=>faqat bitta belgi saqlash uchun;1 byte
float=>faqat kasr son saqlash uchun;4 byte
*/

int yosh=16;
string ism= "Etibor";

cout<<"salom "<< ism <<endl;
 cout<<"man "<< yosh<< "yoshman";


return 0;
  }  

```

Biz bu kodda butun sonlarni ekaranga chiqarishmi organamiz.

```cpp
#include <iostream>
using namespace std;

int main1() {
  cout<<"salom ikkichilar\n";
  cout<<"mani yoshim" <<" 16 da"<< endl;
  cout<<"25+5"<< endl;
  cout<<25*5;
  cout<<"ota"<<" ona\n";
  cout<<25+5;
  return 0;
}

```
Bu kodda siz cin "siaut"ni ishlatishni organasiz.

```cpp
int son;
  cout<<"sanni kiriting:";
  cin>>son;
  cout<<"siz kiritgan son:"<< son;
return 0;
  }

```
BU kodda sonlarni bir qatorga chiqarishni o'rganamiz.SHu bilan birgalikda matinlarni ham.

```cpp
int son,son1,son2;
son1=10;
son2=son1+20;
son=son1+son2;
  cout<<son<< endl;
  son=son*3;
  cout<<son<<endl;
  string ism,a,b,c;
  ism="Etibor";
  a="salom ";
  b=" nima gap";
  cout<<a<<ism<<b<<endl;
  b="qolaysan";
  cout<<b;
return 0;
  }

```
Bu kodda esa masalalar ishlashmiz mumkin.`cin`yordamida.

```cpp
int m;
  cin>> m;

  cout<<m<<m<<m<<m<<m<<m<<endl;
  cout<<m<<"    "<<m<< endl;
  cout<<m<<"    "<<m<< endl;
  cout<<m<<m<<m<<m<<m<<m;

  return 0;
 }
```
Bu kodda esa karajadval ishlashni organamiz.

```cpp
  int son;
  cin >> son;

  cout << son << "*" << 1 << "=" << son*1 <<endl;
  cout<< son <<"*"  << 2 << "=" << son*2 <<endl;
  cout<< son <<"*" << 3 << "=" << son*3 <<endl;
  cout<< son <<"*" << 4 << "="<< son*4 <<endl;
  cout<<son <<"*"  << 5 <<"=" <<son*5 <<endl;
  cout<<son <<"*" << 6 <<"=" <<son*6 <<endl;
  cout<<son <<"*" << 7 <<"=" <<son*7 <<endl;
  cout<<son <<"*" << 8 <<"=" <<son*8 <<endl;
  cout<<son <<"*" << 9 <<"=" <<son*9 ;
  return 0;
}
```
@dawroun
Use emojis in your commit messages 🥳
Tags: cli, git, tutorial, productivity
Published: 2022-12-14 11:46:55

Most of the time, it's difficult to understand the impact of a commit just from the commit message. You can, of course, create your own commit conventions or follow one of the existing conventions. You probably already saw a commit message like _chore: implementing xyz feature_. It's boring, isn't it?

How about using emojis in our commit messages to make them fun? 🤩

Yes, you read that right. In this article, I will present [Gitmoji](https://gitmoji.dev/). I have been using it for two years, and I must admit that it is a game changer and really easy to use. 

---

## Getting Started

###Installation

Check out their [README file](https://github.com/carloscuesta/gitmoji-cli). The installation is also pretty simple. You can either install the [npm package](https://www.npmjs.com/package/gitmoji-cli) or the [homebrew formulae](https://formulae.brew.sh/formula/gitmoji). 

```bash
# Installing via npm
npm i -g gitmoji-cli

# Installing via Homebrew
brew install gitmoji
```

### Usage

After installing the CLI, you are ready to use. As usual add your files that you want to commit via `git add <file_path_to_add>` and just run the command `gitmoji -c`. 

```bash
$ gitmoji -c
? Choose a gitmoji: (Use arrow keys or type to search)
❯ 🎨  - Improve structure / format of the code. 
  ⚡️  - Improve performance. 
  🔥  - Remove code or files. 
  🐛  - Fix a bug. 
  🚑  - Critical hotfix. 
  ✨  - Introduce new features. 
  📝  - Add or update documentation. 
(Move up and down to reveal more choices)
```

CLI provides some prompts and allows you to select the most appropriate emoji for your commit message from a list.

```bash
$ gitmoji -c
? Choose a gitmoji: add
❯ ➕  - Add a dependency. 
  📝  - Add or update documentation. 
  ✅  - Add or update tests. 
  📄  - Add or update license. 
  🍱  - Add or update assets. 
  🔊  - Add or update logs. 
  👥  - Add or update contributor(s). 
(Move up and down to reveal more choices)
```

### But wait – there’s more 

How does this look in a GitHub repo? 

![Gitmoji commit messages in GitHub](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/2dr9ue2cdroroyj0owzl.png)
Isn't it awesome and fun? 


## Yay or Nay? 

### Cons

As in every convention, the reader should follow the convention in order to understand entirely.

Emojis are not ASCII characters, most of them are Unicode characters. Some tools may not support emojis at all or some of them may support only Unicode emojis. 

### Pros 

I love emojis. Emojis are fun, and the GitHub repository looks better with them. It is fun to use, and it encourages writing commits.

## Conclusion 
It is easy to install and use and take your commits into an other level. I definitely recommend!

Happy coding!👩🏻‍💻
I need help!!!
Published: 2022-12-14 11:26:39

My name is Maurício, I'm Brazilian, I'm 51 and I've been living in London for 2 years. I'm a Java developer and I'm asking for help to get my first job in UK. Today my biggest problem is the difficulty with the language. I'm studying at a College but I still don't speak fluent English. I am married, I have a couple of children, I pay rent and I urgently need a job. It can be Junior or Middle level, no problem. I also need help studying Information Technology here in the UK, every contribution is very welcome.
Yours sincerely.
mauricioaraujodelrei@gmail.com 
+44 07868207604
Solving day 14 of Advent of Code 2022 in JavaScript
Tags: challenge, adventofcode, javascript, video
Published: 2022-12-14 11:08:01

---
title: Solving day 14 of Advent of Code 2022 in JavaScript
published: true
description: JavaScript walkthrough of Advent of Code 2022 (day 14)
tags: challenge, AdventOfCode, javascript, video
series: Advent of Code 2022 in Javascript
---

{% youtube -gglpfUvP2g %}
BASH - What is Shell ____(1)
Tags: linux, shellscript
Published: 2022-12-14 10:54:13

```
                       ______________
                       |  ╲╭━━━━╮╲╲ |
                       |  ╲┃╭╮╭╮┃╲╲ | 
                       |  ┗┫┏━━┓┣┛╲ |
                       |  ╲┃╰━━╯┃   |
                       |  ╲╰┳━━┳╯╲╲ |
                       [####USER####]
                     [####SHELL####]
                   [###KERNEL####]
                [###HARDWARE###]
```

The ``shell`` is the interface that the user uses to communicate with the system.

### Shell Types

- Bourne Shell (sh): Original and standard Unix shell.
- Bourne Again Shell (bash): Standard shell on linux, compatible with ``sh`` but with improvements. It also incorporates features from ``csh`` and ``ksh``.
- Korn Shell (ksh): Also an enhancement to the bourne shell
- C Shell (csh): Brings in itself improvements to the features of the ``C`` language.

To find out which shell is being used on the system, just type ``echo $0`` or `ècho $SHELL`` or ``tail /etc/passwd``:

``machine@machine:~$ echo $0``
output: bash

In case you want to install another shell, before installing it let's check:

``sudo dpkg -l | grep ksh``

If it doesn't return anything, it means that ``ksh`` is not installed, so do:

``sudo apt-get install ksh``

Typing again will see that it will return this time:

``sudo dpkg -l | grep ksh``

Now to use ``ksh``, just type ``ksh`` in the terminal. To exit ksh just type ``exit``.

<br />

________________________[next page >>](https://dev.to/israellopes/bash-main-commands2-5ghg)_______________________

[![Texto alternativo da imagem](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ds4alkts3uxq0dsco0nv.png)](https://www.linkedin.com/in/israel-lopes-419a32189)
Create a JavaScript Promise with timeout
Tags: javascript, programming, promises
Published: 2022-12-14 10:40:27

I found a few examples on the web that let Promises run with a timeout:

- https://italonascimento.github.io/applying-a-timeout-to-your-promises/
- https://advancedweb.hu/how-to-add-timeout-to-a-promise-in-javascript/

Both were already good ideas but I wanted some more control of their behaviour and therefore I want to share my modified version.

## Code

```js
const defaultMessage = 'promise.timedOut'

/**
 * Lets a promise race against a timeout. If the promise settles before the timeout then it will
 * be the one to use (no matter, whether it has been resolved or rejected).
 *
 * Otherwise the timeout promise will be used to either resolve to a message
 * or reject an error, depending on the used options.
 *
 * @param promise {Promise} the promise to race against the timeout
 * @param timeout {number=}  optional number of milliseconds until timeout, defaults to 1000ms / 1 sec
 * @param throwIfTimedOut {boolean=} optional flag to either reject (if true) or resolve (if false), defaults to false
 * @param message {string=} optional message to be resolved/rejected on timeout, defaults to 'promise.timedOut'
 * @return {Promise<Awaited<unknown>>}
 */
export const createTimedPromise = (promise, { timeout = 1000, throwIfTimedOut = false, message, details } = {}) => {
  let timeOut = undefined

  const race = Promise.race([
    promise,
    new Promise((resolve, reject) => {
      timeOut = setTimeout(() => {
        if (throwIfTimedOut) {
          const error = new Error(message || defaultMessage)
          // I often like to attach contextual information to errors.
          // This is up to you, whether to do this or not
          error.details = details
          return reject(error)
        }
        else {
          return resolve(message || defaultMessage)
        }
      }, timeout)
    })
  ])

  // always clear timeout to prevent weird behaviour
  race.finally(() => clearTimeout(timeOut))

  return race
}
```

## Usage

```js
// all default
await createTimedPromise(new Promise((resolve, reject) => { ... }))

// custom timeout
await createTimedPromise(new Promise((resolve, reject) => { ... }), { timeout: 500 })

// reject if timedout
await createTimedPromise(new Promise((resolve, reject) => { ... }), { throwIfTimedOut: true })

// additional context
await createTimedPromise(new Promise((resolve, reject) => { ... }), { message: 'you lost', details: { foo: 'bar' } })
```
Quickly customize and anime a Bootstrap button (1)
Tags: modcss, css, beginners, tutorial
Published: 2022-12-14 10:39:47

One of the things that bootstrap is often criticized for is the fact that websites based on its components all look very similar. When you want to go fast or avoid writing CSS/SASS, it's mission impossible.

_MOD-CSS_ is a lightweight framework that allows you to quickly customize your Bootstrap components.

**For example**, We'll quickly apply a custom background-color and a rounding effect of the edges on hover.
![Rounding edge on hover](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/nk3bf6curj1bu7klfh1o.gif)
```
<button class="btn btn-danger" 
  :box="bg[#BE123C] && hover:bg[#F43F5E] br[2rem]">Hover-me
</button>

```

Preview on codepen [here](https://codepen.io/dev-geos/pen/abKgQzb)


##  
## What is MOD-CSS ?
It a utility-first designed to be a lightweight alternative to Bootstrap and Tailwind.

[Mod-css.com](mod-css.com)
[Github](https://github.com/modsLabs/mod-css/)
Learning Notes of ADO.NET
Tags: learning, ado, dotnet
Published: 2022-11-26 11:24:25

# Primary Objects
*(Ref: https://docs.microsoft.com/en-us/dotnet/framework/data/adonet/data-providers)*
1. Connection - *Provides connectivity to a data source.*
2. Command - *Enables access to database commands to return data, modify data, run stored procedures, and send or retrieve parameter information.*
3. DataReader - *Provides a high-performance stream of data from the data source.*
4. DataAdapter - *Provides the bridge between the DataSet object and the data source. The DataAdapter uses Command objects to execute SQL commands at the data source to both load the DataSet with data and reconcile changes that were made to the data in the DataSet back to the data source.*
5. DataSet - *Contains a collection of one or more DataTable objects consisting of rows and columns of data, and also primary key, foreign key, constraint, and relation information about the data in the DataTable objects.*
*(DataTable, DataView, DataRow)*

# DataReader or DataSet
Use a DataSet to do the following:
- Cache data locally in your application so that you can manipulate it. If you only need to read the results of a query, the DataReader is the better choice.
- Remote data between tiers or from an XML Web service.
- Interact with data dynamically such as binding to a Windows Forms control or combining and relating data from multiple sources.
- Perform extensive processing on data without requiring an open connection to the data source, which frees the connection to be used by other clients.
Is Java "pass-by-reference" or "pass-by-value" ?
Tags: java, beginners, programming, tutorial
Published: 2022-12-14 10:30:00

Java is a "pass-by-value" language, which means that when an argument is passed to a method, the value of the argument is copied and passed to the method, rather than a reference to the original object. This means that any changes made to the argument within the method have no effect on the original object outside of the method.

In contrast, a "pass-by-reference" language would pass a reference to the original object, rather than a copy of the value, so any changes made to the object within the method would be reflected in the original object outside of the method.

{% embed https://youtu.be/5gGXEbAJ50E %}

The "pass-by-value" behavior of Java can be counterintuitive at times, especially for programmers who are accustomed to languages that use "pass-by-reference." However, it is a fundamental aspect of the language and is important to understand in order to write correct and effective Java code.
The 5 best resources to learn Rust !
Tags: beginners, programming, rust
Published: 2022-12-14 10:22:17

Rust is a popular programming language known for its performance and reliability. It is a systems programming language that runs blazingly fast, prevents segfaults, and guarantees thread safety. If you're looking to learn Rust, there are many great resources available to help you get started.

One of the best places to start learning Rust is the official Rust website, which offers comprehensive documentation, tutorials, and other resources to help you get up and running quickly. The website also features an active community forum where you can ask questions and get help from experienced Rust developers.

Another great resource for learning Rust is the Rust Book, which is available for free online. This book provides a thorough introduction to Rust and covers everything from the basics of the language to advanced concepts and features. It also includes numerous examples and exercises to help you practice and solidify your knowledge.

In the case where you want to quick approach to rust, I suggest you two places:

- https://learnxinyminutes.com/docs/rust/
- https://fasterthanli.me/articles/a-half-hour-to-learn-rust

In addition  there are many other online resources available to help you learn Rust. For example, the Rustonomicon is a more advanced resource that covers advanced topics such as unsafe code, concurrency, and more.
If you are interested in building website check this [repo](https://github.com/steadylearner/Rust-Full-Stack).

If you prefer to learn by watching videos, there are also many great Rust tutorials and courses available on platforms such as YouTube and Udemy. Some popular ones to check out include "Lets get rusty" by [Bogdan](https://www.youtube.com/@letsgetrusty).


## Hands-on Ressources

**Are you searching for more hands-on approach? Here is the top five resources.**

1. [Rustlings](https://github.com/rust-lang/rustlings)

2. [Exercism](https://exercism.org/tracks/rust)

3. [Codewars](https://codewars.com)

4. [Coding Game](https://www.codingame.com/ide/puzzle/onboarding) 

5. [codecrafter]
(https://app.codecrafters.io/join?via=DeliciousBounty)

Finally, if you want to dive deeper into Rust and learn from experienced developers, there are many online communities and forums where you can connect with other Rust developers and learn from them. Some popular ones to check out include the Rust subreddit, the Rust users forum, and the Rust programming language Discord server.


In summary, if you want to learn Rust, there are many great resources available to help you get started. Whether you prefer books, videos, or online forums, there is something out there for everyone. With the right resources and a bit of practice, you'll be writing high-performance, reliable Rust code in no time.

Star our [Github repo! ](https://bit.ly/3QFgAUf)
Check us at [BLST ]
(https://www.blstsecurity.com/?promo=blst&domain=nathan/The_4_best_resources_to_learn_Rust_programming!)
Magic Triplets
Published: 2022-11-22 17:12:08

## Problem Statement
Given an array of size n, a triplet (a[i], a[j], a[k]) is called a Magic Triplet if a[i] < a[j] < a[k] and i < j < k.  Count the number of magic triplets in a given array.
 
> Problem statement: https://practice.geeksforgeeks.org/problems/magic-triplets4003/1


Example 1:
```
Input: arr = [3, 2, 1]
Output: 0
Explanation: There is no magic triplet.
```

Example 2:
```
Input: arr = [1, 2, 3, 4]
Output: 4
Explanation: Fours magic triplets are 
(1, 2, 3), (1, 2, 4), (1, 3, 4) and 
(2, 3, 4).
```

## Approach

Example
```
[1, 2, 3] -> 1
  1,2,3
```
```
[1, 2, 3, 4] -> 4
  1,2,3
  1,2,4
  1,3,4
  2,3,4
```

So Naive Solution can be via approaching all 3 variables independently.

Like,
```
  for i in [0, n]:
    first_number = a[i]          # first number
    for j in [i+1, n]:
      if a[j] > first_number:
        second_number = a[j]     # second number
        for k in [j+1, n]:
          if a[k] > second_number:
            third_number = a[k]
            overall_count += 1   # as we got all three numbers
```

This as we could see costs us O(N<sup>3</sup>) time complexity

Could we avoid it,
Yes, we could.

We do not need to display all three numbers, we just wanted to count such triplets. Let's think this way, if we got `first_number` and then `second_number` we just wanted to know how many numbers are next to `second_number` which are greater than `second_number`.
For this, we need to have a pre-iteration of the list to know how many numbers next to the current are greater in value, let's call this array as `lookupTable`.

[Know how](https://dev.to/obrutus/count-next-greater-element-1ppb) to generate the lookup table.

Once we got `lookupTable` we just need to find the first two numbers and for the second number need to look into the lookup table.

```
class Solution {
    private int[] generateLookupTable(int[] a) {
        int[] res = new int[a.length]; // result array

        // for every element
        for (int i = 0; i < a.length; i++) {
            int count = 0;
            for (int j = i+1; j < a.length; j++) {
                // previous value is lesser than new value
                if (a[i] < a[j]) 
                    count++;
            }
            res[i] = count;
        }

        return res;
    }
    
    public int countTriplets(int[] a) {
        final int[] lookupTable = generateLookupTable(a);
        int res = 0;
        
        for (int i = 0; i < a.length; i++) {
            for (int j = i+1; j < a.length; j++) {
                if (a[i] < a[j])
                    res += lookupTable[j];
            }
        }
        
        return res;
    }
}
```
#### Time Complexity: O(N<sup>2</sup>) 
#### Space Complexity: O(N)
Advent of Code 2022 - Day 14
Published: 2022-12-14 09:46:43

---
title: Advent of Code 2022 - Day 14
published: true
description: I'm trying to solve all the Advent of Code puzzles in this video series.
tags:
cover_image: https://i.ytimg.com/vi/uJiPlik3mfY/maxresdefault.jpg
---

{% youtube uJiPlik3mfY %}

I'm trying to solve all the Advent of Code puzzles in this video series.
Angular production Build with proxy conf
Published: 2022-12-14 09:41:22

Hi everyone,
I just wanted to know if there is a way in Angular-v.14 to build my project for production (ng build --configuration production) with the proxy config that I set in the proxy.conf.json ?

Basically is there a way to build for different environment using different proxy.conf.json configs ?

ng build --dev using proxy.conf-dev.json
ng build --prod using proxy.conf.json
etc...

thanks for your answers.
Cheers
Marc
Sessões (Sessions)
Tags: http, session, webdev, php
Published: 2022-12-14 09:34:57



Sessões são pequenos ficheiros de texto guardados num directório específico do servidor. 
O protocolo HTTP é conhecido por não guardar o estado (Stateless). Durante as requisições o navegador não consegue identificar os usuários e o que fazem. 

A sessão é usada para armazenar e passar informações de uma página para outra temporariamente.  Por padrão, as variáveis de sessão duram até que o usuário feche o navegador.

## Principais aplicações de Sessions
- Criação de carrinhos de compra;
- Autenticação de Usuários;
- Personalização no site (imagem, cor de fundo, mensagens) de acordo ao Usuário;
- Tratamento de Ataques CSRF;
- Contagem de visitas num site;
- Atribuição de tempo de actividade de um usuário (session timeout);
- Outras aplicações que necessitam de identificar mudanças por usuários;


## Bibliotecas para tratamento de Sessões
- Python: requests, Flask-Session
- PHP: $_SESSION (nativo);
- Elixir: Plug.Session
- C#: Microsoft.AspNetCore.Http
- Java: javax.servlet.http.HttpSession.


## Vantagens
- Facilidade de implementação;
- Ajuda o HTTP no armazenamento de estado;
- Armazena configurações que podem ser alteradas pelo usuário.


## Desvantagens
- Necessitam de mais memória do que variáveis locais;
- Valores colocados em na Session precisam ser serializáveis;
- Se tratados da forma incorrecta, pode revelar falhas de segurança;
- Quando mal implementadas pode causar o sequestro de sessões.

## Exemplos
Usando a Linguagem PHP, vamos apresentar 2 casos de uso da sessão:
- Implementação da Autenticação de usuário, (login, reconhecimento de usuário e logout).
- Tratamento de ataques CSRF.

**Código Fonte**
https://github.com/ortizdavid/sessions-app



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


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


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


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



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


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


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/0eyk0z3jisnkon04ckq4.png)


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/1uongkqfsd65bx67r435.png)

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


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/60ksegnmzvrjy186bhmz.png)


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