This file contains hidden or 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 text = ` | |
<p>This is some test with <a href=\"/piesync.html\">a relative link</a> and one with an <a href=\"http://piesync.com\">absolute link</a></p> | |
<p>This is some test with <a href=\"/piesync.html\" title="test">a relative link</a> and one with an <a href=\"http://www.piesync.com\">absolute link</a></p> | |
<p>This is some test with <a href=\"/piesync/hello/path\">a relative link</a> and one with an <a href=\"http://piesync.com\">absolute link</a></p> | |
<p>This is some test with <a href=\"/\">a relative link</a> and one with an <a href=\"http://piesync.com\">absolute link</a></p> | |
<p>This is some test with <a href=\"/?_ga=2.12323232.131232131.423413123-1231231.123123123\">a relative link</a> and one with an <a href=\"http://piesync.com\">absolute link</a></p> | |
`; | |
let replaced = text.replace(/<a href="(\/([\w.\/?=-]+)|\/)/gm, `<a href="https://www.domain.com$1`); |
This file contains hidden or 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
code --list-extensions | xargs -L 1 echo code --install-extension |
This file contains hidden or 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 |
This file contains hidden or 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) { |
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 hidden or 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: |
This file contains hidden or 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 hidden or 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 hidden or 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 { |