teleren/devto huggingface dataset:
string int
Published: 2023-01-21 06:26:37

#ornatilgam ma'lumotlar turlari 
#dasturlashda ma'lumot turlari muhim tushunchadir.
#ozgaruvchilar har hil turdagi ma'lumotlarni saqlashi munkin va har xil bajarish munkin.
#pyton dasturlash tilida quydagi malumot mavjud 

#text type - String 
#umeric tiypes - integer, float, complex
#sequnce types - list, tipe, range 
#mapping type - dict
#boolen tupe - booL 
#binary types - butes, butearriy, memoryview
#none type - Nonetype

#Misol uchun 
#x = "hello world" #-- #String 
#x = 20 -- int
#x = 20.5 -- float
#x = 1j -- complex
#x = ["aplle" "banan" "cherry"] -- list
#x = ("aplle" "banan" "cherry") -- tuple
#x = range(6) -- range
#x = {"Name", : "John","Age" : 36} -- dict
#x = {"Apple", " banana", "cherry"} -- set 
#x = frozenset({"apple", "banna", "cherry",})
#x = true 
# = b"hello" -- bytes 
#x = bytearray(5) -- bytearray 
#x = memoryview(bytes(5)) -- memoryview
#x = None -- nonetype 

# string mashq!
#x = "hello world"
#display x:
#print(x)

#display the data type of x:

#int ga mashq:
#print(type(x))

#int ga mashq!
#x = 20 
# = 25 
#c = x + y 
#z = c + x  
#e = z + c 


#display x: 
#print(e)

#display the data type of x: 
#print(type(e))

#float ga mash!
#x = 20.5 


#display x:
#print (x)


#display the type of x: 
#print 

#complex ga mashq!
#x = 1j

#dsplay x:
#print(x)

#display the of x:
#print(type(x))

#x = 9 + 8j 
#y = 10 + 4.5j
#print(type(x))
#print(type(y))
#print(type(z))

#print(type(x)
#print(type(y)
#print(type(z)


#list ga mashq!
#x = ["apple","banana","cherry"]

#display x:
#print(x[2])

#display the data of x: 
#print(type(x))

#my_list = ["jessa", "kelly", 20,35.75]
#print(my_list)
#print(type(my_list))




#type ga mashq!
#x = ("apple", "banana", "cherry")

#displaay x:
#print(x)

#displayga the data type of x: 
#print(type(x))

# my_tuple = (11, 24, 56, 88, 78)
# print(my_tuple[2:5])

# range ga mashq!
# x = range(6)

# display x: 
# print(x)

# display the data type of x:
#print(type(x))


#
ma'lumot turlari va int string.
Tags: beginners, tutorial, programming, github
Published: 2023-01-21 06:11:44

                    Ma'lumot turlari 

dasturlashda ma'lumotlar turi muhim tushunchadir
O'zgarubchilar har xil turdagi ma'lumotlarni saqlashi mumkin va har xil ishlarni bafarishi mumkin . 

Payton dasturlsh tilida quyidagi ma'lumot turlari mavjud . 
Ttext type -string 
umeric types - integer 
sequense types -list , tuple 
Mapping type -dict
set types -set frozenest
boolean type -bool 
binary types -bytes ,bytearray , memoryview 
none type -none type .

#Hozir men sizlarga bular haqida ma'lumot beraman . 
string - "hello world" #string tipi ma'lumotlar uchun ishlatiladi.
integer(int)-100 #int tipi butun sonlar uchun ishlatiladi .
float-100.5 # float kasr sonlar uchun ishlatiladi . 
komplex- 3j #kabi sonlar bular murakkab sonlar deb yoki sonlar va harflardan iborat bo'lgan tip deyish mumkin. 

list-["apple" , "banan", "cherry"] # mana shunday ko'rinishda bo'ladi . 
tuple-("apple "," banan"," cherry") # mana shunday ko'rinishda bo'ladi . 
dict-{"name",:"john",:"age":36} # mana shunday ko'rinishda bo'ladi so'zlar va sonlardan iborat va har biri orasida ikki nuqta bor.
set-{"name","john","age"36} # bu dictga o'xshash bo'lib faqat ikki nuqtasi yo'q tipdir . 
frozenest -({"apple","banan", "cherry"}) #bular mana shunday korinishda bo'ladi . faqat ({}) shunday qavuslari bor holos. 
                tunshuntirish - list , tuple 
bular faqat qavuslari bilan farq qiladi . 
listda [] shunday qovus .
tuple da esa () mana shunday .

#stringga mashq :
x="Hello world"
print(x)
print(type(x))

#intga mashq :
x=30
print(x)
print(type(x))

#floatga mashq :
x=30.5
print(x)
print(type(x))

#complexga mashq :
x=3j
print(x)
print(type(x))

#listga mashq :
x=["apple" , "banan", "cherry"]
print(x)# agar aynan bittasini chiqarmoqchbo'lsangiz print(x[1])mana shunday ko'rinishda yozasiz . Raqamlash 0 dan boshlanadi . 
pirnt(type(x))

#tuple ga mashq :
x=("apple", "banan", "cherry")
print(x) # bu yerda ham aynan bittasini chiqarmoqchi bo'lsangiz tepada aytganimday qilishingiz kerak bo'ladi. 
print(type(x))

#range ga mashq :
 x=range(6) #sonlarni tartiblab beradi . 
print(x)
print(type(x))
Exploring the Power of useRef hook.✨
Tags: webdev, javascript, react, programming
Published: 2023-01-21 06:04:14

The useRef hook is a built-in React hook that is used to create a reference to a DOM node so that you can interact with it directly. The useRef hook is a function that accepts a maximum of one argument as the initial value and returns an object. The returned object has a special property called current.

Here’s an example of how you might use the useRef hook to create a simple form that takes input from the user:

```
import { useRef } from 'react';

function MyForm() {
  const inputRef = useRef(null);

  const handleSubmit = (event) => {
    event.preventDefault();
    console.log(inputRef.current.value);
  };

  return (
    <form onSubmit={handleSubmit}>
      <label>
        Name:
        <input type="text" ref={inputRef} />
      </label>
      <button type="submit">Submit</button>
    </form>
  );
}
```
In this example, we are using the useRef hook to create a reference to an input element in our form. We then pass this reference to the input element using the ref prop. This allows us to access the input element's value property in our handleSubmit function, which is triggered when the form is submitted.

We are also using the _<u>preventDefault()</u>_ method to prevent the form from refreshing the page when the user submits it.

The example above is just a simple one, you can add more inputs and logic to it, also you can use useState to handle the form inputs and submit them to a server or any other logic that you want to apply.

> _We use the useRef hook to store the values without triggering the re-render of the component. We can't do this with the useState hook. Updating a state value with the useState hook causes the component to be re-rendered. If we want to keep our component in sync with the state, we use the useState hook. Sometimes we just don’t want the component re-render when the value is updated, there we useuseRef hook._

I hope that this article helped you understand what the useRef hook is and how to use it.

> If you like such stories and want to support me, please share my content as much as you can. 👇 Your support is very important for me to write the next story — thank you.

Follow me on [Twitter](https://twitter.com/Sidddabdullah),  [LinkedIn](https://www.linkedin.com/in/abdullah-siddiqui-b05552262/)
Expanding Search Bar
Tags: codepen
Published: 2023-01-21 06:01:58

<p>This was a learning exercise based on Udemy lesson "50 projects in 50 days" by Brad Travesty</p>

<p><a href="https://www.udemy.com/course/50-projects-50-days/?src=sac&amp;kw=50" target="_blank">https://www.udemy.com/course/50-projects-50-days/?src=sac&amp;kw=50</a></p>

<p>initially the search bar is hidden behind the search button by absolute and relative positioning</p>

<p>When clicked the search button translated to the right and the search bar increased in size to reveal</p>

{% codepen https://codepen.io/frankintech00/pen/dyjJZpX %}
Restore IP Address
Tags: javascript, leetcode
Published: 2023-01-21 05:17:25

[Restore IP Address](https://leetcode.com/problems/restore-ip-addresses/description/)

```js
/**
 * @param {string} s
 * @return {string[]}
 */

var restoreIpAddresses = function(s) {
    let ans = [];
  // if length is greater than 12 that means str cannot be divided in 4 part
  // if length is less than 4 means not able to generate 4 parts
  if (s.length > 12 || s.length < 4) return [];

  function backtrack(start, substrings) {
    // we have 4 parts of string
    if (substrings.length == 4) {
      let strAddress = [...substrings].join(".");
      // strAddress is of length s + 3(dot) & comparing it with s.length + 3 dots
// also means that we have reached the end of string & considered all numbers from string s 
      if (strAddress.length == s.length + 3) {
        ans.push(strAddress);
        return;
      }
    }
// i = start becoz we have to move to nect index every time 
    for (let i = start; i < s.length; i++) {
      let temp = s.substring(start, i + 1);
// temp should be less than 255
      if (Number(temp) <= 255) {
// temp[0] ==0 means that any part of ip cannot have leading zero
// & if so we will not consider that as valid part & move to next index
        if (temp[0] == 0 && temp.length >= 2) continue;
        backtrack(i + 1, [...substrings, temp]);
      }
    }
  }

  backtrack(0, []);
  return ans;
};

```
Selenium Java Interview Questions and Answers || That Every QA should Know - Part 2
Tags: webdev, beginners, programming, tutorial
Published: 2023-01-21 05:09:55

In this video , We are going to learn about the TOP 51+ Selenium Selenium Java Interview Questions and Answers. These are exact questions asked for the beginners and experience people. 

{% embed https://youtu.be/YuNmn2PmdI4 %}

Question #1 : How will you find an element using Selenium?
Question #2 : What is the difference between verify and assert commands?
Question #3 : Explain what are the JUnits annotation linked with Selenium?
Question #4 :  Explain what is DataDriven framework and Keyword driven?
Question #5 :  How you can switch between frames?
Question #6 :  How you can perform double click ?
Question #7 :  How to read a JavaScript variable in Selenium WebDriver?

Question #8 :  How to wait for Element to visible by a AJAX call?
Question #9 :   What is Page Object Model (POM) ?
Question #10 :   What is Page Factory?
Question #11 : What is the difference between Page Object Model and Page Factory?
Question #12 :  How to upload a file in Selenium WebDriver?

Download Slides : http://bit.ly/seleniumInterview

-----------------------------------------------------
👪 Join our Community - http://bit.ly/learntesting2019

✅ Automation Community - https://thetestingacademy.com

🐦Follow us on Twitter  - https://twitter.com/itstechmode

📖 Like us on Facebook - https://www.facebook.com/scrolltest

🎤  Listen to our Podcast - https://anchor.fm/thetestingacademy

------------------------------------------------------
#automationtesting #manualtesting #testautomation #thetestingacademy #scrolltest
🚀 Tools and services I recommend:
Some of the courses that I recommend to become better Automation Tester 🙌🙌

✅Selenium Training and Certification -
https://scrolltest.com/go/edureka


✅Learn Jenkins for QA -
https://bit.ly/learnjenkins-p1


✅Programming Java -
https://bit.ly/learnjava2020-p1


✅Test Automation - 
https://bit.ly/learnautomation2020


✅API Testing - 
https://www.learnapitesting.com


✅Cypress Tutorial with LIVE Projects -
http://cypresstutorial.com
Starchart: Picking a project area
Published: 2023-01-21 05:02:10

As we continue to work on developing [starchart](https://github.com/Seneca-CDOT/starchart), which is a project that aims to make it easier to Seneca developers to create SSL certificates (without worrying about the costs or the need to provide personally identifiable information), a list of task groups has been created to make it easier to visualize the different parts of the project. These include Web, Testing, Server, DNS, etc. (full list [here](https://github.com/Seneca-CDOT/starchart/wiki/Initial-Task-List-and-Scope)).

I have spent the last week thinking about where I can contribute. An obvious choice was `Testing` as I spent the previous week researching [Playwright](https://playwright.dev/), which is a framework for end-to-end testing. As I looked into some of its features, I found that it has [auto-wait functionality](https://playwright.dev/docs/actionability) for its tests by default. Basically, before an action is performed on an element(e.g. click), it will wait for it to be in a specific state (e.g. attached to the DOM) based on the action. This reduces flaky tests which fail if a statement executes before the element is ready.

Further, through [Codegen](https://playwright.dev/docs/codegen#running-codegen), tests can be automatically generated based on actions performed in the browser. This should reduce the time required for writing tests quite a bit. So, in addition to working on testing, I also decided to contribute to the `Web` component, which involves building the pages for the app. This will be done using [Chakra UI](https://chakra-ui.com/) and [Remix](https://remix.run/). Chakra UI provides a bunch of components  for different needs such as tooltips, cards, popups, and [many more](https://chakra-ui.com/docs/components). I have worked on building webpages a lot in the past five months, and even though I have never used Chakra UI, I think I would still be able to utilize some of that experience here.

Finally, this is meant as a guideline, and not restrictions, for which parts of the project I would like to contribute to.
Running Debugger in Rails 7 of containerized app
Tags: rails, docker, debug
Published: 2023-01-21 05:00:00

I use rails 7 these days with ruby 3.0 in a containerized app using docker-compose. The problem buzzing me a lot was debugging the app in localhost. Yes, you can debug RSpec when you run the RSpec in the `docker run` command, but what about direct debugging on the local server?

Rails 7 has a built-in [debug](https://rubygems.org/gems/debug) gem, and my target was to use this gem, not the old ones like debase, pry, etc.

The problem with docker-compose is that we can log or do console or even do RSpec give input option and system stops while doing RSpec, but rails server starts when we call `up` on compose, and then we can see logs not control it.

## Solution:

In docker-compose, in rails service, write:

```yaml
web:
  ...
  stdin_open: true
  tty: true
```

**`stdin_open: true`** in a **`docker-compose.yml`** file means that the container will have an open **`STDIN`** stream when it is run. This allows you to send input to the container over its **`STDIN`** stream, which can be useful in certain situations.

For example, you might use **`stdin_open: true`** when running an interactive command-line application in a container to type commands into the container and see the output.

**`tty: true`** in a **`docker-compose.yml`** file means that the container will have a "pseudo-tty" when it is run. This allows you to interact with the container in a way that is similar to a terminal session.

When a container is run with a pseudo-tty, you can send input to the container using your keyboard, and the container’s output will be displayed in your terminal. This can be useful when running interactive command-line applications in a container.

---- 
Now, after running `docker-compose up`, you write in the new terminal session `docker container ls` to find the name of the rails container and then write `docker attach container_name` and now add `debugger` to your process and when that process run in docker then `rdbg` will stop at that point and now you can debug the application. Use `c` to continue to the next breakpoint.

```bash
docker container ls
docker attach container_name
```

To get out of the attached container session, press `Ctrl+P` and then `Ctrl+Q`.

---- 
Happy Coding!
REST API Implementation in Rust
Tags: rust, api
Published: 2023-01-21 04:44:18

In this blog post, let us see how to build a simple REST API in Rust. 

##### Pre-requisites

- Cargo
- PostgreSQL
- Environment variable `DATABASE_URL` configured with postgres database URL

##### Crates used in this example project

Following crates are used in this project

- *actix_rt:* Tokio-based single threaded async runtime for the Actix ecosystem
- *actix_web:* Actix Web is a powerful, pragmatic, and extremely fast web framework for Rust
- *serde:* A generic serialization/deserialization framework
- *serde_json:* A JSON serialization file format
- *chrono:* Data and time library
- *uuid:* A library to generate and parse UUID
- *env_logger:* A logging implementation for ==log== which is configured via an environment variable
- *diesel:* A safe, extensible ORM framework and Query builder
- *r2d2:* A generic connection pool
- *r2d2-diesel:* r2d2 support for Diesel ORM

##### Setup

###### PostgreSQL Table schema

I am creating below tables in **test** schema in PostgreSQL DB. In case if you intend to use different schema, please use that as well. Make sure to specify correct schema in DATABASE_URL environment variable as well.

Ex: 

```
set DATABASE_URL=postgres://postgres:postgres@localhost:5432/testdb?options=-c%20search_path%3Dtest
```

I am going to create 2 tables. One for storing Tweets and another one is to keep tracking the likes for each Tweet. Create table scripts for the 2 tables as below:

```
create table test.tweets (
id uuid not null primary key, 
created_at timestamp not null, 
message varchar(500)
);

create table test.likes (
id uuid not null primary key, 
created_at timestamp not null, 
tweet_id uuid not null references test.tweets(id));
```

###### Checkout the sample project

You can do git clone this project to your local machine

```
git clone https://github.com/sivakumar-sivaprakasam/simple_twitter_rest_api.git
```

###### Launch the application

Once the pre-requisites are well configured, please run `cargo run` to launch the application. You can use below CURL commands to test the application

*Post a tweet*

```
curl -X POST -d "{\"message\": \"This is a tweet\"}" -H "Content-type: application/json" http://localhost:9090/tweets
```

*Retrieve all tweets*

```
curl http://localhost:9090/tweets
```

*Get a specific tweet*

```
curl http://localhost:9090/tweets/{id}
```

*Like a tweet*

```
curl -X POST http://localhost:9090/tweets/{id}/likes
```

*Unlike a tweet*

```
curl -X DELETE http://localhost:9090/tweets/{id}/likes
```

*Delete a tweet*

```
curl -X DELETE http://localhost:9090/tweets/{id}
```

Please feel free to share your comments.

Happy exploring rust !!!
Data type
Tags: programming, python
Published: 2023-01-21 04:37:13

dasturlashda ma'lumotlar turi muhim tushunchadir.o'zgaruvchilar har xil turdagi ma'lumotlarni saqlashi mumkin va har xil ishlari bajarishi mumkkin.Python tilida quyidagi ma'lumotlar bor:

Text type - String
umeric types - intejer , float , complex
Sequence types - list, tuple, range 
Mapping type - dict 
Set types - set frozenset 
Boolean type - bool
Binary types - bytes, bytearray, memoryview 
None type - NoneType

_Misol uchun_
x = "Hello world" #-- #String
x = 20 -- int
x = 20.5 -- float
x = 9j -- complex
x = ["Cabage","Potato", "tomato"] -- list 
x = ("Apple", "Banana", "cherry") -- tuple
x = range(6) -- range
x = {"Name",: "Lora", "Age",: 25} -- dict
x = {"banana","apple", "cherry"} -- set
x = frozenset({"aplle", "banana","cherry"})
x = True 
x = b"hi" -- bytes 
x = bytearray(5) -- bytearray
x = memoryview(bytes(5)) -- memoryview
x = None -- Nonetype
Day 16 #100DaysofCode
Published: 2023-01-21 04:22:42

I was going to skip today's entry because I have been busy with my job obligations but I told myself I will not neglect the small daily disciplines; so here I am.

## Here is what I did today
I signed up for [Exercism](https://exercism.org/) which is a free open source platform that helps you learn how to program through exercises. So far, I love this platform! I have tried others like Codewars and I feel like this one is the best option for me! The UI is amazing and it has a community section. I also love that they have learning tracks and you can see your progress. So far, I have completed 2 JavaScript learning tracks.
FastAPI Day 1: Type Hints
Tags: fastapi, python, typehints, variables
Published: 2023-01-21 04:14:44

Hey there 👋! Today I am starting my day one with FastAPI programming. I have very little knowledge about Python and Django so, I think this is the good time for me to start.

Today I learnt about Type Hints,
Type Hints are nothing but defining the data types of the variables during the declaration. So that we will have required suggestions (Ctrl+Space) from the IDE like VS Code, Sublime text, etc. 

suggestions when declaring variable without types hints:
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/52w34shhl44yokfeps5o.png)

suggestions when declaring variable with types hints:
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/n27qajrxkeiwai27th45.png)

Type Hints can be used for standard data types like int, str, float, bool, byte. In order to use the generic data types like dict, list, tuple, set we have to import **typing** module in our code.

```
from typing import List, Set, Tuple, Dict
```
Using SQLite in the Browser
Tags: beginners, javascript, webdev, tutorial
Published: 2023-01-21 04:11:45

Easy peasy instructions to get sqlite working in the browser and not

First step download the following 3 files, the wasm binary and the wrappers:

```
wget https://nivethan.dev/js/sqlite/sql-httpvfs.js
wget https://nivethan.dev/js/sqlite/sql-wasm.wasm
wget https://nivethan.dev/js/sqlite/worker.js
```
If you feel uncomfortable downloading random binaries from random people, then you can use the instructions below to build it yourself. The building is relatively straightforward and doesn’t take long.

https://nivethan.dev/devlog/building-sql.js-httpvfs-for-the-browser.html

Now that we have the library, we can then include the sql-httpvfs.js as a module and use it with our sqlite database.

```
<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1" />
    <title>title</title>
  </head>
  <body>
    <script type="module">
      import { load } from "/js/sqlite/sql-httpvfs.js";

      const worker = await load("/db/example.sqlite3");

      const result = await worker.db.query(`select * from mytable`);

      console.log(result);
    </script>
  </body>
</html>
```
Rust Traits
Tags: rust, traits
Published: 2023-01-21 03:52:12

In this blog post, let us see how to work with `Traits` in Rust

#### Traits

Traits is equivalent to Interfaces in Java. Traits can be made up of three varieties of associated items such as:

- Functions and Methods
- Constants
- Types

When a type implements a trait it can be treated abstractly as that trait using generics or trait objects.

###### Create Traits

Traits can be created by using trait keyword. 

```rust
trait TypeUtils {
    fn is_in_range(&self) -> bool;
}
```

###### Implement Traits for a type

It is possible to implement traits for a specific type (primitive or custom types)

In this below example, we can see how to implement TypeUtils trait for some of standard library types

```rust
impl TypeUtils for String {
    fn is_in_range(&self) -> bool {
        false
    }
}

impl TypeUtils for i32 {
    fn is_in_range(&self) -> bool {
        true
    }
}

impl TypeUtils for str {
    fn is_in_range(&self) -> bool {
        true
    }
}
```

It is also possible to implement Trait for custom types such as Structs. In this below example, we're creating an Employee Struct and implementing TypeUtils trait

```rust
struct Employee {
    name: String,
    age: i32,
}

impl TypeUtils for Employee {
    fn is_in_range(&self) -> bool {
        true
    }
}
```

###### Call traits methods implemented for a type

After declaring Traits and implementing them for type, let us see how to call the trait methods

```rust
fn main() {
    let s: String = String::from("Rust");
    let i: i32 = 100;
    let s1: &str = "Rust is awesome";
    let e: Employee = Employee::new(String::from("John"), 30);
    println!("Is '{s}' within range?: {}", s.is_in_range());
    println!("Is '{i}' within range?: {}", i.is_in_range());
    println!("Is '{s1}' within range?: {}", s1.is_in_range());
    println!("Is {e:#?} within range?: {}", e.is_in_range());
}
```

I hope this blog post gives you a brief overview about Traits. 

All the code examples can be found in this [link](https://github.com/sivakumar-sivaprakasam/rust-examples/tree/main/traits). 

Please feel free to share your feedback.

Happy reading!!!