Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
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
- Host: GitHub
- URL: https://github.com/qobulovasror/commonly_used_algorithms
- Owner: qobulovasror
- Created: 2023-07-24T11:58:31.000Z (over 1 year ago)
- Default Branch: master
- Last Pushed: 2023-07-24T12:39:04.000Z (over 1 year ago)
- Last Synced: 2023-07-24T14:03:44.208Z (over 1 year ago)
- Language: JavaScript
- Size: 6.84 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
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!');
});
```