curl -L https://raw.githubusercontent.com/creationix/nvm/v0.30.2/install.sh > /tmp/nvm-install.sh && bash /tmp/nvm-install.sh
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
# Step 1 | |
# create main branch locally, taking the history from master | |
git branch -m master main | |
# Step 2 | |
# push the new local main branch to the remote repo (GitHub) | |
git push -u origin main | |
# Step 3 | |
# switch the current HEAD to the main branch |
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
// if user accepts, this will give `persistent` (true/false, 1/0) back to the promise itself | |
if (navigator.storage && navigator.storage.persist) { | |
navigator.storage.persist().then((persistent) => { | |
if (persistent) { | |
// let the user know about what will happen | |
"Great! You will never loose your data even after clearing the cache of your browser." | |
} else { | |
"Ups, you need to activate storage within your browser to get notified." | |
} |
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
// the function which enables us to send notification to the user in every 30 seconds | |
function randomNotification() { | |
const notifTitle = 'Title here'; | |
const notifBody = `Body here...`; | |
const notifImg = 'http://image-url-here/static/image.png'; | |
const options = { | |
body: notifBody, | |
icon: notifImg, | |
}; | |
new Notification(notifTitle, options); |
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 request = indexedDB.open("FlightApp", 1); | |
request.onerror = function (event) { | |
console.error("An error occurred with IndexedDB"); | |
console.error(event); | |
}; | |
request.onupgradeneeded = function () { | |
const db = request.result; | |
const store = db.createObjectStore("flights", { keyPath: "id", autoIncrement:true }); |
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
// ... | |
export const getStaticProps = async () => { | |
const ECONNRESET_ERROR_SKIP_PAYLOAD = { | |
props: { hede: true } | |
} | |
try { | |
process.on('uncaughtException', (err) => console.log('message here...', err)); | |
return ECONNRESET_ERROR_SKIP_PAYLOAD |
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
parse_git_branch() { | |
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ (\1)/' | |
} | |
export PS1="\u@\h \W\[\033[32m\]\$(parse_git_branch)\[\033[00m\] $ " |
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
ssh-keygen -t rsa -b 4096 -C "your_email@example.com" | |
Enter a file in which to save the key (/Users/you/.ssh/id_rsa): [Press enter] | |
Enter passphrase (empty for no passphrase): [Type a passphrase] | |
Enter same passphrase again: [Type passphrase again] | |
pbcopy < ~/.ssh/id_rsa.pub | |
Go to the Github profile and update the RSA key there by adding a new name for it |
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 fs = require('fs'); | |
const { exec } = require('child_process'); | |
const readline = require('readline'); | |
const {google} = require('googleapis'); | |
const envs = [ | |
'testing', | |
'production' | |
] |
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 currentUrl = https://blacklane.com/?maintenance_mode=on&foo=baz | |
function removeQueryString(currentUrl, removeThis) { | |
const url = new URL(currentUrl); | |
const query_string = url.search; | |
const search_params = new URLSearchParams(query_string); | |
search_params.delete(maintenance_mode); | |
url.search = search_params.toString(); |
NewerOlder