Skip to content

Instantly share code, notes, and snippets.

mysql> use wild_db_quest_2
Database changed
mysql> SELECT lastname, firstname, role, name AS teamname
-> FROM wizard
-> JOIN player ON player.wizard_id = wizard.id
-> JOIN team ON player.team_id = team.id
-> ORDER BY teamname, role, lastname, firstname;
+-----------------+-------------+--------+------------+
| lastname | firstname | role | teamname |
+-----------------+-------------+--------+------------+
@teasmade
teasmade / index.js
Created May 2, 2021 08:16
Express quest 5
const connection = require('./db-config');
connection.connect(function (err) {
if (err) {
console.error('error connecting: ' + err.stack);
return;
}
console.log('connected as id ' + connection.threadId);
});
@teasmade
teasmade / index.js
Created May 2, 2021 08:01
Express quest 4
const connection = require('./db-config');
connection.connect(function (err) {
if (err) {
console.error('error connecting: ' + err.stack);
return;
}
console.log('connected as id ' + connection.threadId);
});
@teasmade
teasmade / index.js
Created May 2, 2021 07:05
Express Quest 3
const connection = require('./db-config');
connection.connect(function (err) {
if (err) {
console.error('error connecting: ' + err.stack);
return;
}
console.log('connected as id ' + connection.threadId);
});
@teasmade
teasmade / index.js
Last active May 2, 2021 06:21
Express Quest 2
// https://imgur.com/a/hXtrYLB
const connection = require('./db-config');
connection.connect(function (err) {
if (err) {
console.error('error connecting: ' + err.stack);
return;
}
console.log('connected as id ' + connection.threadId);
@teasmade
teasmade / requests.http
Created April 18, 2021 06:24
WCS HTTP Quest
### GET status of custom API for this quest
GET https://http-practice.herokuapp.com/status
### GET application status is JSON format
GET https://http-practice.herokuapp.com/status
Accept: application/json
### GET Wilders API
GET https://http-practice.herokuapp.com/wilders
Accept: application/json
@teasmade
teasmade / codewars_railcipher.js
Created April 15, 2021 18:06
Codewars Rail Cipher solution
function encodeRailFenceCipher(string, numberRails) {
// initialise empty rails arrays
const rails = [];
while (rails.length < numberRails) {rails.push([])};
// loop over rails subarrays, "bouncing" to add string chars in the fence pattern
let counter = 0;
let increment = 1;
for (let i = 0; i < string.length; i++) {
counter += increment;
@teasmade
teasmade / getDistance.js
Created April 13, 2021 19:57
Distance between 2 points test
const quaiFM = [47.2076056402, -1.55753246791];
const testMarker = [47.21, -1.552];
const rdgReze = [47.19316, -1.549212];
const plWalRou = [47.2277747611, -1.55214798607];
// function to calculate distance - expects array of lat / long for each param
// this is no good due to the difference in conversion offset degrees / metres between lat and long!
calcDistance = function (origin, dest) {
const xOffset = origin[1] - dest[1];
const yOffset = origin[0] - dest[0];
const http = require('http');
const url = require('url');
const port = 8000;
const requestHandler = (request, response) => {
const parsedUrl = url.parse(request.url, true);
if (parsedUrl.query.name && parsedUrl.query.city) {
response.end(`Hello, ${parsedUrl.query.name} from ${parsedUrl.query.city}!`);
} else {
response.end('Please provide name AND city parameters');
@teasmade
teasmade / Linux2.txt
Created March 2, 2021 14:28
Linux Terminal 2 - fichiers et dossiers
tom@LAPTOP-BGP53NKI:~/quests/shell$ curl -L -o planets.zip https://github.com/WildCodeSchool/quests-resources/blob/master/terminal/planets.zip?raw=true
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 148 100 148 0 0 393 0 --:--:-- --:--:-- --:--:-- 393
100 159 100 159 0 0 358 0 --:--:-- --:--:-- --:--:-- 358
100 293k 100 293k 0 0 302k 0 --:--:-- --:--:-- --:--:-- 302k
tom@LAPTOP-BGP53NKI:~/quests/shell$ ls
fruits planets.zip vegetables
tom@LAPTOP-BGP53NKI:~/quests/shell$ unzip planets.zip
Archive: planets.zip