teleren/devto huggingface dataset:
Lexicographical Rank of String-Naive Approach
Tags: javascript, lexicographical
Published: 2022-08-15 03:42:00

```
let a = "DCBA";
let actualStrInArray = a.split("");
let sortedStrInArray = a.split("").sort();
let rank = 0;

for (let i = 0; i < actualStrInArray?.length; i++) {
  let elem = actualStrInArray[i];
  let indexOfElementInSorted = sortedStrInArray.indexOf(elem);
  if (indexOfElementInSorted > 0) {
    let getCount =
      indexOfElementInSorted * factorial(sortedStrInArray.length - 1);
    rank = rank + getCount;
    sortedStrInArray.splice(indexOfElementInSorted, 1);
  } else {
    rank = rank + 1;
  }
}
console.log(rank);
```

```
function factorial(n) {
  let answer = 1;
  if (n == 0 || n == 1) {
    return answer;
  } else {
    for (var i = n; i >= 1; i--) {
      answer = answer * i;
    }
    return answer;
  }
}
```
Project: Simple Todo App with React and Ruby (Sinatra)
Tags: beginners
Published: 2022-08-15 03:33:00

_This post will be updated as I make corrections to this project._

[Backend](https://github.com/mwarrn/phase-3-sinatra-react-project) | [Frontend](https://github.com/mwarrn/phase-3-project) 

**Project Goals**
1. Use Active Record to interact with a database.
2. Have a minimum of two models with a one-to-many relationship.
3. Create API routes in Sinatra that handles at least three different CRUD actions for at least one Active Record model.
4. Build a separate React frontend application that interacts with the API to perform CRUD actions.
5. Use good OO design patterns with separate classes for each model and instances and class methods as necessary.

Active Record has two models: `Category` (which has many `todos`) and `Todo` (belongs to `category`), and each table has a `name` column.

The `ApplicationController` has `post`, `get`, `path`, and `delete` routes set up for the frontend to interact with.

At the time of submission, I am currently in the middle of finishing building all of the CRUD React components for the frontend to interact with the API created in Sinatra.

**Additional advanced features for future versions**
- Site membership with secure sign-in (using the [bcrypt gem](https://rubygems.org/gems/bcrypt/)?)
- Option to add deadline for each task
- Points system for completing a task (productivity gamification)
- Animation with [Motion](https://www.framer.com/motion/)
Learn Redis In 15 Minutes with Real life example
Tags: redishackathon, webdev, javascript, beginners
Published: 2022-08-15 03:31:00


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/h0ejti7snmqoz0ckq6y0.png)
Video link:https://youtu.be/4zeBXN59TP8

In this video we have explained, what is redis! How redis caching works,


However, we are gonna be using redis latest version with node project , if you follow this video you will get a clear idea, in order to use your first project..
Coz redis is pretty much popular almost every single project you have to use ...
EAT THAT FROG! FOR STUDENTS
Tags: productivity, books, braintracy, eatthatfrog
Published: 2022-08-15 03:13:59

 1 What is this book about ?
 - This book about improving productivity and time managemnet.

 2 Book for whom?
 - For the Students.

 Few points from this book are  helping me everyday.

- Make a todo list every day
- Prioritize the tasks
- Complete the most important and hard tasks first.
- Follow 80/20 rule. (_ there are 10 tasks on your to-do list but all are not having the same importance. 2  tasks are having same importance combined as the remaining 8 tasks. so find out the 2 important tasks and complete them first_)

- Make a deadline for your task.
13. Leetcode solution in JavaScript
Tags: javascript
Published: 2022-08-15 03:07:43

```
const roman = {'I':1,'V':5,'X':10,'L':50,'C':100,'D':500,'M':1000}

var romanToInt = function(S) {
    let ans = 0
    for (let i = S.length-1; ~i; i--) {
        let num = roman[S.charAt(i)]
        if (4 * num < ans) ans -= num
        else ans += num
    }
    return ans
};
```

#leetcode
#challenge
here is the link for the problem: 
https://leetcode.com/problems/roman-to-integer/
[Desafio] - Validações 01/02
Published: 2022-08-15 02:22:30

> Conteúdo original em https://twitter.com/zanfranceschi/status/1559000660506341376

---

Ei dev,

É normal não termos a validação que esperamos dos outros. Mas pelo menos NÓS podemos s̶e̶r̶ fazer a validação de que precisamos, certo?! Claro que sim! Então pega a parte 01/02 desse desafio. 🤭

cc @sseraphini

↓

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

---

Essa parte do desafio vai te ajudar a não te xingarem quando estiverem usando as APIs que desenvolveu!

Tirando a brincadeira, a ideia é super simples e tem muito a ver com a experiência que você quer oferecer para quem consome suas APIs.

---

Vamos lá. Desenvolva uma API para cadastro de propostas de abertura de conta num banco digital hipotético.

A API pode ser algo como nessa imagem (é apenas uma sugestão ─ faça do jeito que tiver vontade).

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

---

Agora vem o desafio em si.

Na validação, retorne tudo que estiver errado usando mensagens bem informativas. Algo mais ou menos como nessa imagem.

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

---

A ideia central aqui é não retornar a resposta na primeira inconsistência. Concatene todos os erros que puder e retorne tudo duma vez. Dessa forma, quem estiver usando a API será capaz de entender de primeira tudo que estiver errado. A experiência será muito melhor ─ te garanto!

---

Minha sugestão de prática é você fazer essas validações na mão mesmo. Numa API produtiva, possivelmente você irá querer usar alguma lib/framework que faça isso para você ─ existem muitas opções para isso.

---

Como disse no começo, a ideia central desse desafio é pensar na experiência de quem vai consumir suas APIs. Esse tipo de preocupação demonstra cuidado e capricho e é sempre super bem vista.

Obrigado demais por ter lido até aqui! 💕

Logo menos, vem a segunda parte desse desafio!

---

Parte 02/final do desafio ↓

https://twitter.com/zanfranceschi/status/1559000993127247872
Generate a txt file with unique name in python
Published: 2022-08-15 02:53:00

In this tutorial, you will learn how to Generate a txt file with unique name in python.

## Generating a random number
To generate [random number](https://devsuggest.com/question/generate-random-number-in-python), randint() function is used.
The randint() method returns an integer number selected element from the specified range.

To create a file in python, open() function is used.
The open() function opens a file, and returns it as a file object.

## Code Example

```
import random

ran_num = random.randint(0,5)
file_name = "random"+str(ran_num);

try:
    with open(file_name+'.txt', 'w') as f:
      f.write('Create a new text sfile!')
except FileNotFoundError:
    print("There is an unknown error!!")
```

Thanks for reading.
For more question and answer visit [DevSuggest](https://devsuggest.com)
cara mengganti pemisah ribuan dari koma ke titik
Published: 2022-08-15 02:44:44

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

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

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/bco81dosax4zrn76ok24.png)
 
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/e3r1cuhujk7rgdde4axd.png)
Lightweight key value storage for Python
Tags: python
Published: 2022-08-15 02:32:00

Working with massive JSON data in Python is indeed frustrating. Let say you have around thousand of data stored on a JSON file and you wanted to search on a specific data. I know, thinking about it is kinda... Normally, you'll just end up doing a for loop.
```py
for i in data.items():
    if i["name"] == "John Doe":
        print("Finally, found you!")
```
But there's an easy way in doing that. Thanks to [LemonDB](https://github.com/riyuzenn/lemondb). Just initialize a lemon database object and do built in operation.
```py
from lemondb import LemonDB
db = LemonDB('test.json')

# You can use dict queries
db.find_one({'name': 'John Doe'})

# Or just built-in search queries
from lemondb import Query; query = Query()
db.find_one(query.name == 'John Doe')

# Lambda function is also supported
db.find_one(lambda x: x['name'] == 'John Doe')
```
But that's it- No, there's more. In the previous release, LemonDB now support different type objects such as `datetime`, and more that the normal JSON could'nt properly serialize. Don't believe me? heres an example:

```py
from lemondb import LemonDB
from datetime import datetime

db = LemonDB('test.json')
db.insert({'name': 'John Doe', 'created-at': datetime.now()})

# Filtering the item
print(db.find_one({'name': 'John Doe'})['created-at'])
# ...
```
Frankly speaking, LemonDB is a document-oriented database, -- *similar to mongodb or any key-value based database. In fact, lemondb was inspired by mongodb but more lightweight with around <= 1000 lines of code in total.* -- a type of NoSQL database in which data is stored in binary document files. This type of database associates each document with a unique key that takes the form of a string, path or URI. Keys are used to locate and pull individual documents from the database. 

More information can be found @ [Github](https://github.com/riyuzenn/lemondb)
I Created A Simple Tinder Like Clone
Tags: rails, showdev, beginners, programming
Published: 2022-08-15 02:07:26

## Introduction

Hello! Recently I've been learning Rails and have created a simple Tinder like clone so I thought I'd show it. 😀

---

## Home Page

The Home Page is pretty simple containing just a fullscreen background image, with the options to Login and to create a new account.

![Landing Page](https://i.ibb.co/3f3Tm1S/home.png)

---

## Creating A New Account

The create account page form takes an email address, name, password and gender. (Yes I know I should implement password confirmation). The tutorial I used was Japanese hence the Japanese text. 🎌

![Signup Page](https://i.ibb.co/0rXR4Qc/create-account.png)

---

## Login Page

The login page form is the same as your average login page it takes an email address and the user's password.

![Login Page](https://i.ibb.co/X4sb030/account-login.png)

---

## Users Page

Once the user has logged in they are greeted with a page that displays other users display pictures, the user can then drag the card right to "like" the user or left to "dislike" the user.
This process continues until there is no more cards left.

![Users Page](https://i.ibb.co/t26KnxL/users.png)

---

## Edit Profile Page

The edit profile page allows the user to change their profile information and or image. 

![Edit Profile Page](https://i.ibb.co/tbzmCn6/profile-edit.png)

---

## Matched Page

The matched page displays a list of users that have each "liked" each other. Clicking on a matched user navigates the page to the chat page.

![Matched Page](https://i.ibb.co/sFKhtNs/matched-users.png)

---

## Chat Page

The chat page is pretty much like your standard chat message application, received chats are displayed on the right and sent chats are displayed on the left.

![Chat Page](https://i.ibb.co/L6PLYmJ/chat.png)

---

## Conclusion

Thanks for reading my article! 😆

I know the application may be simple but I managed to learn the following things:

* Devise - Used for signup/login, highly recommended if you use rails and want authorization out of the box.
* Channels - Used for the chatroom, very easy to implement websocket. I'm thinking of using it again for other applications.

I'm thinking of making another Rails tutorial, so let me know what you think. 
Also I haven't forgot about my WebRTC series, it's just that I need to learn Rails for my new job, and I'm having a lot of fun learning it. 😎
Episode 23 Turbo Powered Chat Application in Rails 7
Tags: rails, ruby, webdev, tutorial
Published: 2022-08-15 02:05:48

Turbo Streams deliver page changes as fragments of HTML wrapped in self-executing "turbo-stream"elements. Each stream element specifies an action together with a target ID to declare what should happen to the HTML inside it. We will leverage the power of turbo streams to create a chat application.
{% youtube r8vmtooFNKc %} 
Github: https://github.com/railsdrill/episode-23-turbo-chat
How to enable syntax highlighting and auto-completion for NS-3 in Doom Emacs?
Published: 2022-08-22 21:52:09

---
title: How to enable syntax highlighting and auto-completion for NS-3 in Doom Emacs?
published: true
date: 2022-08-15 01:41:03 UTC
tags: 
canonical_url: 
---

If doom is your favorite editor and you want to work on ns-3 with doom then follow these steps:

- Have doom emacs and ns-3 installed.

- Make sure your `init.el` file has cc with lsp enabled:

```
(cc +lsp)

```

- You will need to generate a file called `compile_commands.json`.

- Depending on your version of ns-3 you might use waf or cmake for that.

- on cmake, add the following to your cmake compilation command:

```
cmake -DCMAKE_EXPORT_COMPILE_COMMANDS=ON ...

```

- on waf, the document is automatically generated inside the `build` folder.

- Move the `compile_commands.json` file to the root of your `ns3` folder.

- Enjoy your autocompletion:

![2022-08-14-18:33:27.png](https://cdn.hashnode.com/res/hashnode/image/upload/v1660527250695/Tcd-TeaFQ.png)

- You can use `g d` to jump to the definition of an identifier.
Web Server Kill Process on Ports
Tags: ruby, programming, beginners, database
Published: 2022-08-15 01:35:27

Here are a few things you can do when a locally-run web server port is in use and your server won't start back up.

This issue presented itself to me during Phase 3 of [Flatiron School](https://flatironschool.com/courses/coding-bootcamp): Four weeks of learning [Ruby](https://www.ruby-lang.org/en/), [SQL](https://en.wikipedia.org/wiki/SQL), [Active Record](https://guides.rubyonrails.org/active_record_basics.html), and [Sinatra](https://github.com/sinatra/sinatra#readme).

[Live or hot reloading](https://stackoverflow.com/a/41429055/7931329) all possible things makes me happy, so I was glad to implement [rerun](https://github.com/alexch/rerun) on my server immediately after learning about it. 

It's great fun to not manually restart a local server on every change in your program, except for this very occasional issue I've come across. This happened when I would tab out of my VS Code window (configured to autosave my app as I leave), which triggers a rerun-fueled refresh in my browser.

I'd often `Command + R` my webpage anyway to restart my user path, and with the right timing, I would get an error along the lines of `port is in use`.

My first stop on Google was [this Stack Overflow page](https://stackoverflow.com/a/32592965/7931329) which gave me a two-step solution: See if any processes were listening to the port my server was on by running:
```
lsof -i:9292
```
(ruby was indeed listening to that port, which meant it was blocking my server from restarting on that port), and then run:
```
kill $(lsof -t -i:9292)
```
 to clear the way for a server restart.

Soon after running into this myself, the same issue came up in class and [another solution](https://www.npmjs.com/package/kill-port) was shown:
```
npx kill-port 9292
```
Angelos Project™
Tags: blog, opensource, development, devjournal
Published: 2022-08-15 00:53:00

The Angelos Project is purposed to be a platform and technology stack for crypto-anarchistic free speech. Of course NOT based on anonymity, but instead based on privacy and verifiability. The idea behind the concept is to hide from regimes what could be said in public in a normal democracy with sufficient free speech rights.

I have recently the last four (4) years developed a [prototype](https://github.com/kristoffer-paulsson/angelos) for the technology stack in python on Github for testing, learning and making achievements.

Right now I am developing the sharp version that is and will be published at [Maven Central](https://search.maven.org/artifact/org.angproj.io.buf/angelos-project-buffer).
How To Use Activity Result API To Parse Information Between 3 Activities - In JAVA_Beginners.
Published: 2022-08-15 00:46:00

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

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

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

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

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

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

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

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

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

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

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

**_Source code here: https://github.com/kemicky/How-To-Use-ActivityResult-API-To-Parse-Information-Between-3-Activities-In-Java-Beginners-Tutorial.git_**
**_Watch the video tutorial here: https://youtu.be/y639CS0ILsk_**
Adding data to array list
Tags: react, reactnative, javascript, html
Published: 2022-08-15 00:44:42

hello, 
I am trying to add a name to the list of already created array names on the click of the button **add user** when I type the name in the same _input_ that I use to filter names. I seem to be having difficulty accomplishing this, I would be happy to receive help.

Below is React code.

`import React, { useState } from "react";
import classes from "./Users.module.css";

const DUMMY_USERS = [
  { id: "u1", name: "Ama" },
  { id: "u2", name: "Abena" },
  { id: "u3", name: "Kwame" },
  { id: "u4", name: "Michael" },
];

const Users = () => {
  const [showUsers, setShowUsers] = useState(true);
  const [filterUsers, setFilterUsers] = useState("");
  const [newUser, setNewUser] = useState("");

  // console.log(addUser);

  const filterHandler = (event) => {
    setFilterUsers(event.target.value);
  };

  const addUser = () => {
    let newName = { name: "" };

    setNewUser([...newUser, newName]);
  };

  const search = !filterUsers
    ? DUMMY_USERS
    : DUMMY_USERS.filter((user) =>
        user.name.toLowerCase().includes(filterUsers.toLowerCase())
      );

  const toggleHandler = () => {
    setShowUsers((curState) => !curState);
  };

  const userList = (
    <ul>
      {search.map((user) => (
        <li key={user.id}>{user.name}</li>
      ))}
      ;
    </ul>
  );

  return (
    <div className={classes["User-List"]}>
      <div>
        <input
          name="name"
          type="text"
          value={filterUsers}
          onChange={filterHandler}
        />
      </div>
      <div>
        <button className={classes.btn} onClick={toggleHandler}>
          {showUsers ? "Hide" : "show"} Users
        </button>
      </div>
      <div>
        <button onClick={addUser}>Add Person</button>
      </div>

      {showUsers && userList}
      <div>
        <ul>
          {addUser.map((input) => (
            <li key={input.id}>{input.name}</li>
          ))}
        </ul>
      </div>
    </div>
  );
};

export default Users;
`
Javascript Tagalog - Equality & Strict Equality
Tags: javascript, tagalog, pinoy, equality
Published: 2022-08-15 00:16:00

**Ano ngaba ang Equality and Strict Equality operator sa Javascript?**
Basically yung equality operator i kukumpara niya lang yung dalawang values tapos mag rereturn siya ng true or false (boolean types). "Strict Equality" basahin niyo nalang sa baba

**Syntax**
```Equality :  value1 == value2
Strict Equality : value1 === value2```

**Examples**

![Javascript Tagalog Pinoy Strict Equality Equality](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/f6mfmcmpg8z6n1xla35z.png)

---
**Normal vs Strict Equality**
Sa Normal Equality sign i a-attempt niya i convert and compare mga values na different ang type, in this case String Type yung "1" but equal padin siya sa Number Type na 1
![Javascript Tagalog Pinoy Strict Equality Equality](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/frs22eu32udif22uur0e.png)
Pero sa **Strict Equality** hindi gagana yan, kase nga strict tulad ng parents niya.

---

yung mga **Falsy** values equals sila false
![Javascript Tagalog Pinoy Strict Equality Equality](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/dktknv8iq2b0lig998ze.png)
Pero sa **Strict Equality** False yarrn

![Javascript Tagalog Pinoy Strict Equality Equality](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/6olfey46hnlu98lff5qv.png)

---

maraming pang iba't-ibang values ang iba behavior sa equality operator, kunwari sa mga Objects,Arrays magkamukha sila pero false parin ang result kasi reference types sila.

![Javascript Tagalog Pinoy Strict Equality Equality](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/pgyifzm8s66oehrq6qm6.png)

I know medyo weird pero if magegets niyo on how javascript works under the hood, this totally makes sense. When you encounter mga problems sa mga equalities saglit lang silang i google in my opinion.

---

**More tagalog Javascript Learning Resources:**
https://javascript-methods-in-tagalog.vercel.app/