Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/qobulovasror/commonly_used_algorithms

This is repository for commonly used algorithms
https://github.com/qobulovasror/commonly_used_algorithms

Last synced: 7 days ago
JSON representation

This is repository for commonly used algorithms

Awesome Lists containing this project

README

        

# commonly used algorithms
- - - - - -
## algorithms
1. [filter items](#1-filter-items)
2. [read, translate and write sql db](#2-read-and-write-sql)

## algorithm codes
### 1. filter items for react apps
```js
const rows = [];
this.props.products.forEach((product) => {
if (product.name.toLowerCase().indexOf(filterText.toLowerCase()) === -1) {
return;
}
if (inStockOnly && !product.stocked) {
return;
}
rows.push( );
});
```
### 2. read and write sql db with nodejs
```js
const mysql = require('mysql');
// Ma'lumotlar bazasiga ulanish uchun konfiguratsiya
const connection = mysql.createConnection({
host: 'localhost',
user: 'your_database_user',
password: 'your_database_password',
database: 'your_database_name',
});

// Ma'lumotlar bazasiga ulanish
connection.connect((err) => {
if (err) {
console.error('Xatolik yuz berdi: ', err);
return;
}
console.log('Ma\'lumotlar bazasiga muvaffaqiyatli ulanildi!');
});

// Ma'lumotlar bazasidan so'rov yuborish
const sqlQuery = 'SELECT * FROM your_table_name';
connection.query(sqlQuery, (err, result) => {
if (err) {
console.error('So\'rov yakunlanishida xatolik: ', err);
return;
}
console.log('Javob: ', result);
});

// Ulanishni yopish
connection.end((err) => {
if (err) {
console.error('Ulanishni yopishda xatolik: ', err);
return;
}
console.log('Ma\'lumotlar bazasi bilan muvaffaqiyatli ravishda aloqa yopildi!');
});
```