Skip to content

Instantly share code, notes, and snippets.

View Deuchnord's full-sized avatar
🐛
Implementing bugs of a new kind

Deuchnord Deuchnord

🐛
Implementing bugs of a new kind
View GitHub Profile
@Deuchnord
Deuchnord / server.js
Last active July 15, 2017 15:49
Using a session variable to show a message once in Node.JS/Express
app.get('/', (req, res) => {
var msg = req.session.message;
req.session.message = undefined; // you must do it before rendering, instead it will just not work
res.render('views/index.ejs', {
message: msg
});
})
.post('/connect', (req, res) => {
@Deuchnord
Deuchnord / romanNumber.php
Last active August 16, 2017 11:46
Number to Roman digits and vice-versa converter
<?php
/**
* Converts $n from Arabic digits to Roman digits.
* This is accurate from 1 to 4999 and only for integers, since the
* extensions to write the numbers greater than 4999 and the fractions are
* not implemented.
* Note that there is no way to write negative number ans zero, as they were
* not used by Roman. Plus, numbers are truncated to integers, so that 4.2
* will be converted to IV.
*