Skip to content

Instantly share code, notes, and snippets.

View ir3ne's full-sized avatar
🏠
Working from home

irene (Irene Tomaini) ir3ne

🏠
Working from home
View GitHub Profile
@ir3ne
ir3ne / periodic-table.json
Created November 26, 2023 16:22
periodic-table.json
[
{
"name": "Hydrogen",
"number": 1,
"symbol": "H"
},
{
"name": "Helium",
"number": 2,
"symbol": "He"
function checkUrl(url) {
const urlPattern = new RegExp('^(https?:\\/\\/)?'+ // protocol
'((([a-z\\d]([a-z\\d-]*[a-z\\d])*)\\.)+[a-z]{2,}|'+ // domain name
'((\\d{1,3}\\.){3}\\d{1,3}))'+ // OR ip (v4) address
'(\\:\\d+)?(\\/[-a-z\\d%_.~+]*)*'+ // port and path
'(\\?[;&a-z\\d%_.~+=-]*)?'+ // query string
'(\\#[-a-z\\d_]*)?$','i')
return urlPattern.test(url);
}
function checkEmail(email) {
const emailPattern = /^[^@]+@\w+(\.\w+)+\w$/;
return emailPattern.test(email);
}
input {
&::placeholder {
color: $color;
}
&::-webkit-input-placeholder {
color: $color;
}
&::-moz-placeholder {
const delay = () => {
setTimeout(() => {
console.log('me the last one!');
}, 4000);
}
async function fire() {
try {
const runDelay = await delay();
return runDelay();
// Like a === b
function strictEquals(a, b) {
if (Object.is(a, b)) {
// We know a and b are equal so we check only a
if (Object.is(a, NaN)) {
// Special case #1.
return false;
} else {
return true;
}
@ir3ne
ir3ne / 01-directory-structure.md
Created August 7, 2020 17:39 — forked from tracker1/01-directory-structure.md
Anatomy of a JavaScript/Node project.

Directory structure for JavaScript/Node Projects

While the following structure is not an absolute requirement or enforced by the tools, it is a recommendation based on what the JavaScript and in particular Node community at large have been following by convention.

Beyond a suggested structure, no tooling recommendations, or sub-module structure is outlined here.

Directories

  • lib/ is intended for code that can run as-is
  • src/ is intended for code that needs to be manipulated before it can be used
{
"panifici": {
"icon": "🥖",
"data": [
{
"name": "Panificio Dalle Mule",
"tel": "0422230885",
"note": "Chiuso Mercoledì E Domenica"
}
]
@ir3ne
ir3ne / change-bg-color.js
Last active December 29, 2017 18:57
JS Change body background color
const body = document.body;
const colors = ["#820263", "#D90368", "#86CB92", "#2E294E", "#FFD400", "#F46036"];
let i = 0;
function change() {
body.style.backgroundColor = colors[i];
i++;
if(i > colors.length - 1) {
i = 0;
}