openssl rand -hex 32
sudo hdparm -tT /dev/mmcblk0
This file contains 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 asyncFn = () => Promise.reject(new Error("async fn error", { | |
cause: { | |
type: 'FirstErrorCause' | |
} | |
})); | |
const asyncManipulateResponse = (response) => Promise.resolve("manipulated response"); | |
const tryCatchFn = async () => { | |
try { | |
const response = await asyncFn(); |
This file contains 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 functionA = async () => { | |
try { | |
// request something that resolves in a promise | |
} catch (error) { | |
throw new Error("Function A failed"); | |
} | |
} | |
const functionB = async () => { | |
try { |
This file contains 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
sudo addgroup --system docker | |
sudo adduser $USER docker | |
newgrp docker | |
# And something needs to be done so $USER always runs in group `docker` on the `Ubuntu` WSL | |
sudo chown root:docker /var/run/docker.sock | |
sudo chmod g+w /var/run/docker.sock |
This file contains 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
// url => https://regex101.com/r/jhw0wy/1 | |
const regex = /https:\/\/([a-z\.]{4})?([0-9]+.hs-sites|hubspot).com[\/]?/gm; | |
// Alternative syntax using RegExp constructor | |
// const regex = new RegExp('https:\/\/([a-z\.]{4})?([0-9]+.hs-sites|hubspot).com[\/]?', 'gm') | |
const str = `https://hubspot.com/ | |
https://123456.hs-sites.com/ | |
https://google.com`; |
This file contains 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
/** | |
* search for: | |
* const x = require('x'); | |
* const { a } = require('a'); | |
*/ | |
const ([\w\s\n,{}:]+) = require\('([.\/@\w-]+)'\) | |
/** | |
* replace with: |
If you get stuck with the login loop, press ctrl
+ alt
+ F3
to access to the shell.
Login with your account, then run these commands:
sudo apt purge gdm3
sudo apt install gdm3
Restart and you should be able to login now.
This file contains 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
/** | |
* @description Transform a kebab case string into a Camel Case | |
* @param {string} string Source string | |
* | |
* @example | |
* // returns thisIsMyString | |
* kebabToCamelCase('this-is-my-string'); | |
* @returns {string} | |
*/ | |
export function kebabToCamelCase(string) { |
This file contains 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
function format(string, keyValues) { | |
const regex = /{{([a-zA-Z]+)}}/g; | |
return string.replace(regex, (match, key) => { | |
return keyValues[key]; | |
}); | |
} | |
console.log(format('Hello {{name}}', {name: 'Alessio'})); // Hello Alessio | |
console.log(format('The price is {{currency}} {{price}}', {price: '10.5', currency: 'EUR'})); // The price is EUR 10.5 | |
console.log(format('Il prezzo è {{price}}{{currency}}', {price: '10.5', currency: 'EUR'})); // Il prezzo è 10.5EUR |
NewerOlder