Skip to content

Instantly share code, notes, and snippets.

View Elius94's full-sized avatar
🏔️

Elia Lazzari Elius94

🏔️
View GitHub Profile
@Elius94
Elius94 / node-js-create-gui-on-console.md
Created April 6, 2022 14:48
How to draw GUI on Node.js console

To draw Popups and more inside a Node.js program I've built this example (a TCP server)

example-node-js-console-gui

image

So, in this program if I press "s" I can choose the sending speed of the TCP message:

image

@Elius94
Elius94 / seo-injector.md
Created March 10, 2022 15:04
How to programmatically update the HTML headers of a static site generated with create-react-app (CRA)

If you want to find an elegant way to dynamically insert HTML elements inside the block, such as all those needed for a good SEO (meta, open graph, twitter cards, icons etc...), you might have tried to use a React method that acts on the DOM of the application.

In the past I tried with the react-helmet library, which allows to insert free elements inside the headers. The problem is that when search engines or social networks try to generate the site preview, they don't see anything of the inserted meta. This issues is that the javascript method is only good if the site is then interpreted after react has rendered it. Search engine crawlers, but also social, use the bare index.html file as is. That way, react-helmet hasn't inserted the tags yet, and therefore doesn't see them.

To solve this problem, I made this library: Seo Injector

@Elius94
Elius94 / Coverage Badges
Created November 26, 2021 20:52
Coverage Badges
Coverage Badges
@Elius94
Elius94 / msconvert.js
Created March 10, 2016 14:21 — forked from remino/msconvert.js
JavaScript: Convert milliseconds to object with days, hours, minutes, and seconds
function convertMS(ms) {
var d, h, m, s;
s = Math.floor(ms / 1000);
m = Math.floor(s / 60);
s = s % 60;
h = Math.floor(m / 60);
m = m % 60;
d = Math.floor(h / 24);
h = h % 24;
return { d: d, h: h, m: m, s: s };