teleren/devto huggingface dataset:
I want to put extra text into R.array."extratext"
Published: 2022-09-19 18:15:25

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main2);

    int **value** = getIntent().getIntExtra("key",0);

I want to use this extra text value into this line R.array."this extra text".

String[] loveshayari=getResources().getStringArray(R.array.value);
    RecyclerView recyclerView=findViewById(R.id.recyclerview);
    recyclerView.setLayoutManager(new LinearLayoutManager(getApplicationContext()));
    recyclerView.setAdapter(new MyAdapter(loveshayari,getApplicationContext()));

}

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/13qvhhz6qmr6bcgk4o1s.png)
How totp works in authenticator app ?
Tags: security, webdev, beginners
Published: 2022-09-19 18:13:08

In simple

**Shared secret key + Time = token (which we see in the authenticator app)**

1. Shared secret key will be created in server and shared to client i.e (authenticator apps).
2. Authenticator app will create a token from time and shared secret key.
3. Also shared secret will be stored in database.
4. While checking server will create a token from time and shared secret key (server will get it from DB) and it will check the result with the token which server received as a part of request.


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/21xtledn4nncxcvgmsta.png)
While in React I can't resolve with webpack custom module that was forked
Published: 2022-09-19 18:09:44


I"m trying to use a custom library but I can't see to be able to use when the webpack runs. I already added it to the fallback assign and a new resolve extensions, but couldn't make it work:

`config.resolve.extensions = ['.ts','.tsx','.js','.jsx'],`

This is the component I'm adding it:

```
import {AvatarComponent} from '@rainbow-me/rainbowkit';
import makeGradient from 'ethereum-gradient-base64';
 
export const CustomAvatar: AvatarComponent = ({ address, ensImage, size }) => {
    const image = makeGradient(address);
    return ensImage ? (
      <img
        src={ensImage}
        width={size}
        height={size}
        style={{ borderRadius: 999 }}
      />
    ) : (
      <div>
        <img
            src={image}
            width={size}
            height={size}
            style={{ borderRadius: 999 }}
        />
      </div>
    );
};
```

Error it shows me at terminal:

```
Failed to compile.
Module not found: Error: Can't resolve 'ethereum-gradient-base64' in '/home/afa/Documents/code/others/PROJECTS/wagrk/src/Components/Web3'

ERROR in ./src/Components/Web3/CustomAvatar.tsx 4:0-52
Module not found: Error: Can't resolve 'ethereum-gradient-base64' in '/home/afa/Documents/code/others/PROJECTS/wagrk/src/Components/Web3'

webpack compiled with 1 error
No issues found.
```

this is my tsconfig:
```
{
    "include": [
        "./src/**/*"
    ],
    "compilerOptions": {
        "moduleResolution": "node",
        "strict": true,
        "esModuleInterop": true,
        "isolatedModules": true,
        "lib": [
            "dom",
            "es2015"
        ],
        "jsx": "react-jsx",
    },
    "exclude": ["node_modules"]
}
```

and this is my config:

```
const webpack = require('webpack');

module.exports = function override(config) {
    const fallback = config.resolve.fallback || {};
    Object.assign(fallback, {
        "crypto": require.resolve("crypto-browserify"),
        "stream": require.resolve("stream-browserify"),
        "assert": require.resolve("assert"),
        "http": require.resolve("stream-http"),
        "https": require.resolve("https-browserify"),
        "os": require.resolve("os-browserify"),
        "url": require.resolve("url")
    })
    config.ignoreWarnings = [/Failed to parse source map/];
    config.resolve.fallback = fallback;
    config.resolve.extensions = ['.ts','.tsx','.js','.jsx'],
    config.plugins = (config.plugins || []).concat([
        new webpack.ProvidePlugin({
            process: 'process/browser',
            Buffer: ['buffer', 'Buffer']
        })
    ])
    return config;
}
```

Links: Repo That I'm making the error demo: https://github.com/afa7789/wagrk https://github.com/afa7789/ethereum-gradient-base64/
How to enable TLS on Postgres managed by Helm.
Tags: kubernetes, helm, postgres, tls
Published: 2022-09-19 17:49:19

Hello, here is a simple way to enable TLS in your Postgres DB managed by Helm.


> See the Screenshot Bellow

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

```

# As a starting point use this awesome cli-tool to create a selfsign certificate (testing only).
Ref: step certificate create (smallstep.com)

step certificate create self-signed-leaf.local leaf.crt leaf.key --profile self-signed --subtle

# Remove the password from the leaf.key
openssl -ec -in leaf.key -out leaf-decr.key

# Create Kubernetes Secrets
 kubectl create secret generic test-tls-secret --from-file=./leaf.crt --from-file=./leaf-decr.key

# Specify the necessary values to enable TLS and finally run
helm upgrade --install test-postgres bitnami/postgresql --values ./values.yaml
```

I hope you like the tutorial, if you do give a thumps up! and follow me in [Twitter](https://twitter.com/TVelmachos), also you can subscribe to my [Newsletter ](https://dashboard.mailerlite.com/forms/167581/67759331736553243/share) in order to avoid missing any of the upcoming tutorials.

Thank you, Cheers!!!
Lottery Scheduling Example
Tags: lottery, lotteryscheduling, scheduling, operatingsystem
Published: 2022-09-19 17:30:18

Lottery Scheduling Example: Process scheduling of the lottery variety is slightly unique from normal scheduling. Random scheduling is used for scheduling processes. Preemptive or non-preemptive lottery scheduling are both options. Additionally, it addresses the issue of famine. Each method will have a non-zero probability of getting chosen at each scheduling operation if at least one lottery ticket is given to it. GeeksForGeeks has written a good post on Lottery Scheduling Example.

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

Lottery Scheduling Example
Lottery Scheduling Example
Every process in this scheduling has a number of tickets, and the scheduler chooses one at random. The process holding that ticket is the winner. It is run for a time slice before the scheduler chooses another ticket. These tickets stand in for the processes’ share. More tickets is directly proportional to being selected for execution.

Lottery Scheduling Example
If out of a total of 100 tickets, two processes, A and B, each have 60 and 40 tickets, respectively. A has a 60% CPU share, while B has a 40% CPU share. The calculation of these shares is probabilistic rather than deterministic.

Lotter Scheduling Explanation
A and B are the two methods we use. A has 60 tickets (numbered 1 through 60), while B has 40 tickets (ticket no. 61 to 100).
The scheduler chooses a random number between 1 and 100. A is executed if the selected number is between 1 and 60; else, B is executed.
An illustration of 10 tickets chosen by Scheduler would resemble this:
Ticket number – 73 82 23 45 32 87 49 39 12 09.
Resulting Schedule – B B A A A B A A A A.
B executes just once.A executes seven times. As you can see, A uses 70% of the CPU while B uses 30%, which is not what we require as A needs to use 60% of the CPU while B needs to use 40%. This occurs as a result of the probabilistic calculation of shares, but over the long term (i.e., when more than 100 or 1000 tickets are chosen), we may attain a share percentage of around 60 and 40 for A and B, respectively.

Lottery Scheduling Implementation
Let’s say we have 3 Processes A, B, C. Job A has 100 Tickets, Job B has 50 and Job C has 250

// counter: used to track if we’ve found the winner yet
 int counter = 0;
 
 // winner: use some call to a random number generator to
 // get a value, between 0 and the total # of tickets
 int winner = getrandom(0, totaltickets);
 
 // current: use this to walk through the list of jobs
 node_t *current = head;
 
 // loop until the sum of ticket values is > the winner
 while (current) {
 counter = counter + current->tickets;
 if (counter > winner)
 break; // found the winner
 current = current->next;
 }
 // ’current’ is the winner: schedule it...


READ MORE
at : https://hecodesit.com/lottery-scheduling-example
Elves Look, Elves Say
Tags: adventofcode, algorithms, programming, javascript
Published: 2022-09-19 17:22:47

## [Advent of Code 2015 Day 10](https://adventofcode.com/2015/day/10)

## Part 1
1. What's the best way to count?
2. My first use of `Map()`?
3. New approach: Walking the line

### What's the best way to count?
- I'm well-trained by now to tally the number of times any given character appears in a string
- Often, however, order hasn't mattered
- When it did, I could rely on alphabetical order
- But here, there's no alphabet...and order is very important

Could I still use an object to tally each number?

### My first use of `Map()`?
Per MDN's page:
> The Map object holds key-value pairs and remembers the original insertion order of the keys

That's what I want, right?

Using one of the examples:
```
1211
```

With `Map()`, I could build this object:
```
{ '1': 1 }
{ '1': 1, '2': 1 }
{ '1': 2, '2': 1 }
{ '1': 3, '2': 1 }
```

And in order, generate a new sequence:
```
1321
```

Uh, oh. That's not what I wanted.

I wanted:
```
1 1 1 2 2 1
```

Hmm, seems like I need another approach.

### New approach: Walking the line
Back to this example:
```
1211
```

My algorithm as pseudocode:
```
Do 40 times
  Set next as an empty string
  Set i as 0
  Do as long as i is less than the length of the sequence
    Set count to 1
    Set j to one more than i
    Do as long as j is less than the length of the sequence and the character at j is the same as the character at i
      Increment count by 1
      Increment j by 1
    Concatenate next with count and the character at i
    Set i to j
  Set sequence to next

Return the length of sequence
```

My algorithm, animated:
![Animation of my algorithm](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/c5is44exy5aev5zo4whj.gif)

Running my algorithm 40 times generated the correct answer almost instantly!

## Part 2
1. Getting the correct answer...eventually
2. Getting the correct answer much faster

### Getting the correct answer...eventually
- I updated `40` to `50`
- Re-ran my program
- Waiting several seconds
- Then generated the correct answer!

### Getting the correct answer much faster
- I updated my algorithm to use arrays instead of strings
- Re-ran my program
- Waited a second
- Then generated the same correct answer!

My optimized algorithm in JavaScript:
```js
function lookAndSay(digits, times) {
  let sequence = digits.split('')
  for (let times = 0; times < 50; times++) {
    let next = [], i = 0
    while (i < sequence.length) {
      let count = 1, j = i + 1
      while (j < sequence.length && sequence[j] == sequence[i]) {
        count++
        j++
      }
      next.push(count, sequence[i])
      i = j
    }
    sequence = next
  }
  return sequence.length
}
// Part 1
lookAndSay(input, 40)
// Part 2
lookAndSay(input, 50)
```

## I did it!!
- I solved both parts!
- By writing an algorithm...for the first time in a few Days!
- Then writing a faster algorithm that uses arrays instead of strings!
- I learned how mathematically interesting this puzzle's subject matter really is, thanks to the linked video in Part 2!

2015 is turning out to be a really fun year of puzzles so far!
Code Smell challenge! 👃
Tags: beginners, tutorial, codenewbie, showdev
Published: 2022-09-19 17:16:16

Hello everyone!

I'm working on an article (with a video version as usual!) about **Code Smell**. I'm planning to have it ready this or next week.

What is a Code Smell?
I'll try to keep it short for now, let's say it's _something in the code that doesn't seem quite right_. It can be a simple and little thing, at first harmless, but that can generate problems at a later point. Even big problems!

Being able to spot code smells at a first glance is a skill every good developer should have, as it might help saving a loooot of time for the future.

---

While writing the script I though it would have been fun to play around with YouTube shorts, creating short vertical clips with an example of code smell and a possible solution.

I'm collecting all of them under [this playlist](https://www.youtube.com/playlist?list=PLOQjd5dsGSxKcEVtnt1EIAPj6Z0PvPv-f). There are 4 now but I'm planning to add more in the coming days (I've got a few more ideas ready to go).

{% embed https://www.youtube.com/playlist?list=PLOQjd5dsGSxKcEVtnt1EIAPj6Z0PvPv-f %}

Is there any particular code smell that you find often and bothers you particularly?
Or one that you'd like to see covered on the playlist? Let me know in a comment :)

---

If you like my content, feel free to follow me to get notified when new articles are out ;)
{% embed https://dev.to/balastrong %}
Functions in Memory (Stack)
Tags: programming, beginners, algorithms, dsa
Published: 2022-09-19 17:11:54

Checkout my twitter thread explaining how functions work in memory (stack).

{% embed https://twitter.com/CeleronCoder/status/1571901815616344065?s=20&t=E-hfi73IIAME8elLkWJ_iw %}

Things to keep in mind to understand functions behavior
- When a function is called, it gets in the stack, and stays there until its execution.
- When the function completes executions, it gets off the stack and returns to the program flow.

Here's a program with a main function that call some other functions and that function call some other function. As they get called, they are loaded into the memory stack.
![initial stack](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/l91knfnd7uj2fa9zot6o.png)

When the function, completes execution the functions gets off the stack and the program returns to the previous program flow, aka to the previous function that called that function.
![function getting off the stack](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/igkjw5q0pnvdx6ufau2r.png)
![program flow](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/inmv051pedqrxma3ya28.png)

When there is nothing left in the stack, even the main function that is loaded by default, gets off the stack, the program finishes execution.
![empty stack](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/6pfgrppvfrqj4e522quu.png)

### **Takeaways**
- When the function is called, it is loaded on the stack with its arguments.
- When it completes execution, it gets off the stack and the program returns to its previous program flow.

> If "A" function calls "B" function, "A" function will remain in the stack (and in scope also) until the "B" function returns. It means that not only the currently executing function remains in the function but also all the parent function that called it.
Fluent UI Insights EP3: Griffel
Tags: javascript, webdev, fluentui, react
Published: 2022-09-19 17:08:43

Fluent UI Insights is a series that describes the design and decisions behind the Fluent UI design system. 

In the third episode, Oleksandr from the Fluent UI team explains the implementation details and complexities behind [Griffel](https://js.griffle.org). Griffel is a CSS-in-JS used in Fluent UI React v9 and features ahead-of-time compilation.

In this video he covers:
- Requirements for styling solution
- Important concepts of Atomic CSS-in-JS
- Creating Griffel CSS-in-JS
- Did it all magically go smoothly? Find out more!

{% embed https://youtu.be/edyW7t-rIUU %}

Checkout the CodesandBox from the video that demonstrates LVFHA order importance:

{% embed https://codesandbox.io/embed/lvfha-puzzle-ihbict?fontsize=14&hidenavigation=1&theme=dark %}

As always let us know what kind of content you want see from Fluent UI React by visiting us on:

- GitHub: https://github.com/microsoft/fluentui
- Docs: https://react.fluentui.dev
- Twitter: https://twitter.com/fluentui
C++ da operatorlar
Published: 2022-09-19 16:49:24

- **Increment/Decrement operatorlar**
"++" va "--" operatorlari o'zgaruvchidagi qiymatni bittaga oshiradi yoki kamaytiradi.

```cpp
#include <iostream>
#include <iomanip>

using namespace std;
int main() {
  int n = 5;
  ++n;

  cout << n;

  return 0;
}
```

```
6
```
qiymatni bittaga oshiradi yoki kamaytiradi.

```cpp
#include <iostream>
#include <iomanip>

using namespace std;
int main() {
  int n = 5;
  --n;

  cout << n;

  return 0;
}
```

```
4
```
Agar kadimizda **_Increment/decrement_** o'zgaruvchidan oldin kelsa birinchi bo'lib  **_Increment/decrement_** hisoblanib keyin boshqa buyruqlar bajariladi:

```cpp
#include <iostream>
#include <iomanip>

using namespace std;
int main() {
  int n = 5;

  cout << ++n << endl;
  cout << n;

  return 0;
}
```
 

```
6
6
```
Lekin kadimizda **_Increment/decrement_** o'zgaruvchidan keyin kelsa birinchi bo'lib boshqa buyruqlar bajarilib keyin **_Increment/decrement_**  hisoblaniladi:

```cpp
#include <iostream>
#include <iomanip>

using namespace std;
int main() {
  int n = 5;

  cout << n++ << endl;
  cout << n;

  return 0;
}
```
```
5
6
```
Hola como
Tags: webdev, beginners, programming
Published: 2022-09-19 16:46:44

# “Mi Primer Empleo, Mi Primer Salario” promueve el desarrollo de tus competencias profesionales”


> Alcanzar el éxito profesional implica mucho más que manejar los conocimientos necesarios para una determinada tarea, también exige desarrollar competencias acordes con los requerimientos del cargo por desempeñar y desarrollar habilidades interpersonales.

> Para ello, es preciso utilizar eficazmente los recursos con los que se dispone, abarcando los conocimientos (saber), las actitudes (saber ser) y las habilidades (saber hacer). Estas competencias pueden ser: trabajar en equipo, resolución de problemas, proactividad, planificación y organización, liderazgo.

>  Mi Primer Empleo te prepara a través del taller **“Desarrollo de Competencias Profesionales”**,  con el objetivo de que conozcas las principales competencias que el mercado laboral actual requiere, de esta forma  podrás rendir de manera mucho más eficiente en tu trabajo, ser capaz de aceptar nuevos desafíos laborales, crecer profesionalmente y ser altamente valorado donde sea que te desempeñes como profesional. Recuerda que además de ser un excelente profesional en determinada área, es muy valorado ser una persona íntegra en el diario vivir. 


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

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/byivrx0opgkkpswqfip3.PNG)
Adding the medusa admin dashboard
Tags: javascript, webdev, beginners
Published: 2022-09-19 16:18:51

Now that we have the [medusa server up and running](https://daily-dev-tips.com/posts/setting-up-the-medusa-server/) let's go on and add the first visual system.

We'll connect the medusa admin dashboard to our server for this article.
The admin dashboard can perform all kinds of actions on your system data.
It provides a way to see/create/edit and delete your products, view orders, and so on.

## Medusa installing the admin dashboard

To get started, we can use the basic admin template provided by medusa.

```bash
git clone https://github.com/medusajs/admin medusa-admin
```

This will clone the admin panel into the `medusa-admin` directory.

Now navigate into the folder in your terminal and install all dependencies.

```bash
cd medusa-admin && npm install
```

Once installed, make sure to run our medusa server first.

```bash
// Navigate to medusa server
cd medusa-server

// Start server
medusa develop
```

Then you can run your dashboard project.

```bash
npm run start
```

You should be able to visit `localhost:7000` now and be able to see the login panel.

![Medusa admin login](https://cdn.hashnode.com/res/hashnode/image/upload/v1662706167927/ARnlnLQD8.png)

If you used the seed option on installation, you could log in with the base user: `admin@medusa-test.com` and password: `supersecret`.

And you'll now be able to explore the admin panel.

![Medusa dashboard product overview](https://cdn.hashnode.com/res/hashnode/image/upload/v1662706298471/6v1hYWrgZ.png)

And that's it. Super easy to add a separate dashboard to our already existing medusa server.

### Thank you for reading, and let's connect!

Thank you for reading my blog. Feel free to subscribe to my email newsletter and connect on [Facebook](https://www.facebook.com/DailyDevTipsBlog) or [Twitter](https://twitter.com/DailyDevTips1)
Null/Undefined Check
Tags: typescript, webdev, javascript
Published: 2022-09-19 16:10:58

In react, if we declare and do not initialise a variable, it would be undefined
```typescript
var a; //undefined
```
If we would want to assign a variable and initialise a variable later, we could first assign it as null. (Not recommended) 

``` typescript
var a = null;
```
As undefined and null is [different](https://flexiple.com/javascript/undefined-vs-null-javascript/), we should perform validation whenever we think that the code would break if the variable is null or undefined. 

```typescript
typeof null          // "object" (not "null" for legacy reasons)
typeof undefined     // "undefined"
```
 To make the code reusable, we could define a utility function to perform the validation. The function could be as simple as a function that takes in any type of input, or a function that utilise Generics.

```typescript
function nonNullish(value: unknown): boolean {
    return value !== (null || undefined) ? true : false;  
}


function assertNonNullish<TValue>(value: TValue): boolean {
    return value !== (null || undefined) ? true : false;  
}
```