This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ALTER TABLE employee ADD COLUMN hired_year SMALLINT; | |
ALTER TABLE employee ADD COLUMN department ENUM('Marketing', 'HR', 'Software', 'Hardware'); | |
UPDATE employee SET hired_year = FLOOR(RAND()*(2019-2014+1)+2014); | |
UPDATE employee SET department = CASE | |
WHEN RAND() < 0.25 THEN 'Marketing' | |
WHEN RAND() < 0.33 THEN 'HR' | |
WHEN RAND() < 0.5 THEN 'Software' | |
ELSE 'Hardware' | |
END; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const express = require('express'); | |
const app = express(); | |
const port = 3000; | |
const connection = require('./conf'); | |
app.listen(port, (err) => { | |
if (err) { | |
throw new Error('Something bad happened...'); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const express = require('express'); | |
const app = express(); | |
const port = 3000; | |
const connection = require('./conf'); | |
app.listen(port, (err) => { | |
if (err) { | |
throw new Error('Something bad happened...'); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const express = require('express'); | |
const app = express(); | |
const port = 3000; | |
const connection = require('./conf'); | |
app.listen(port, (err) => { | |
if (err) { | |
throw new Error('Something bad happened...'); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const express = require('express'); | |
const app = express(); | |
const port = 3000; | |
const connection = require('./conf'); | |
app.listen(port, (err) => { | |
if (err) { | |
throw new Error('Something bad happened...'); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const express = require('express'); | |
const app = express(); | |
const port = 3000; | |
app.get('/api/movies', (req, res) => { | |
res.send('Récupération de tous les films'); | |
}); | |
app.get(`/api/movies/:id`, (req, res) => { | |
const id = req.params.id; // récupère John |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const url = require('url'); | |
const http = require('http'); | |
const port = 8000; | |
const requestHandler = (request, response) => { | |
const parsedUrl = url.parse(request.url, true); | |
const params = parsedUrl.query; | |
if (params.name && params.city) { | |
response.end(`Hello ${params.name} from ${params.city}!`); | |
} else { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
### get all wilders | |
GET https://http-practice.herokuapp.com/wilders | |
### get wilder for JavaScript, page 10 | |
GET https://http-practice.herokuapp.com/wilders?language=JavaScript&page=10 | |
### create wilder from url-encoded | |
POST https://http-practice.herokuapp.com/wilders | |
Content-Type: application/x-www-form-urlencoded |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var cowsay = require("cowsay"); | |
console.log(cowsay.say({ | |
text : "hello boy", | |
e : "^^", | |
T : "U " | |
})); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
process.stdin.resume() | |
process.stdin.setEncoding('utf8') | |
console.log('What\'s your age ? ') | |
process.stdin.on('data', (value) => { | |
const age = parseInt(value, 10); | |
if (isNaN(age)) { | |
console.error("Value is not a number") | |
} else if (age < 0 || age > 99) { | |
console.error("Illegal value") |