Skip to content

Instantly share code, notes, and snippets.

View Ovicakov's full-sized avatar

Clément Here Ovicakov

View GitHub Profile
@Ovicakov
Ovicakov / index.js
Last active May 3, 2021 17:41
Freecodecamp JavaScript algorithms and data structures certification
/*** intermediate algorithm challenge n° 4 :
https://www.freecodecamp.org/learn/javascript-algorithms-and-data-structures/intermediate-algorithm-scripting/wherefore-art-thou
***/
function whatIsInAName(collection, source) {
const srcKeys = Object.keys(source)
return collection.filter((obj) => {
return srcKeys.every((key) => {
return obj.hasOwnProperty(key) && obj[key] === source[key]
@Ovicakov
Ovicakov / index.js
Last active September 12, 2024 12:13
algorithms
// Bubble sort
const bubbleSort = (numbersArray) => {
const arrayLenght = numbersArray.length;
for (let i = 0; i < arrayLenght; i++) {
for (let j = 0; j < arrayLenght; j++) {
if (numbersArray[j] > numbersArray[j +1]) {
const currentNumber = numbersArray[j]
numbersArray[j] = numbersArray[j +1]
@Ovicakov
Ovicakov / index.js
Last active January 31, 2021 19:39
intermediate algorithm challenge - FreeCodeCamp
/*** intermediate algorithm challenge n° 4 :
https://www.freecodecamp.org/learn/javascript-algorithms-and-data-structures/intermediate-algorithm-scripting/wherefore-art-thou
***/
function whatIsInAName(collection, source) {
const srcKeys = Object.keys(source)
return collection.filter((obj) => {
@Ovicakov
Ovicakov / .env
Created January 13, 2020 12:51
QuestNodeEnv
MY_NAME=Bob
MY_CITY=Laillé
MY_LANGUAGE=React
@Ovicakov
Ovicakov / node.js
Created December 17, 2019 22:04
nodeAsync
const request = require('request');
request('https://swapi.co/api/people/1/', function (error, response, body) {
const obj = JSON.parse(body);
console.log(obj);
request(obj.films[0], function (err, res, bod) {
const movie = JSON.parse(bod);
console.log(movie.title); // result => "The Empire Strick Back"
})
@Ovicakov
Ovicakov / db.sql
Created December 9, 2019 09:38
sql quest 6
mysql> select name, count(*) AS nb_student
-> from player
-> JOIN wizard ON wizard.id=player.wizard_id
-> JOIN team ON team.id=player.team_id
-> GROUP BY team_id
-> ORDER BY nb_student DESC;
+------------+------------+
| name | nb_student |
+------------+------------+
| Gryffindor | 36 |
@Ovicakov
Ovicakov / db5.sql
Last active December 6, 2019 13:02
mysql> select firstname, lastname, role, name
-> from player
-> JOIN wizard ON wizard.id=player.wizard_id
-> JOIN team ON team.id=player.team_id
-> ORDER BY name ASC, role ASC, lastname ASC, firstname ASC;
+-------------+-----------------+--------+------------+
| firstname | lastname | role | name |
+-------------+-----------------+--------+------------+
| Sirius | Black | beater | Gryffindor |
| Lavender | Brown | beater | Gryffindor |
@Ovicakov
Ovicakov / Express5.js
Created November 27, 2019 10:50
Express5
const express = require('express');
const app = express();
const port = 3000;
const connection = require('./conf');
// ------- QUETE EXPRESS 3 ----------
const bodyParser = require('body-parser');
// Support JSON-encoded bodies
app.use(bodyParser.json());
@Ovicakov
Ovicakov / index.js
Created November 27, 2019 10:43
Express4
const express = require('express');
const app = express();
const port = 3000;
const connection = require('./conf');
const bodyParser = require('body-parser');
// Support JSON-encoded bodies
app.use(bodyParser.json());
// Support URL-encoded bodies
app.use(bodyParser.urlencoded({
@Ovicakov
Ovicakov / index.js
Created November 26, 2019 09:30
Quête express3
const express = require('express');
const app = express();
const port = 3000;
const connection = require('./conf');
connection.connect(function (err) {
if (err) {
return console.error('error: ' + err.message);
}