List of helpful shortcuts for faster coding
If you have any other helpful shortcuts, feel free to add in the comments of this gist :)
async function addImageToDOM() { | |
const imageDiv = document.createElement('div'); | |
imageDiv.className = 'one-fourth'; | |
const imgElement = document.createElement('img'); | |
imgElement.src = generateImageLinks(); | |
imageDiv.append(imgElement); | |
document.querySelector('.container').append(imageDiv); | |
} |
Revert a Git repository to a previous commit
git reset --hard [previous Commit SHA id here]
git push origin [branch Name] -f
It will remove your previous Git commit. If you want to keep your changes, you can also use:
git reset --soft [previous Commit SHA id here]
const toggleElements = document.querySelectorAll("#table tr"); | |
toggleElements.forEach(el => { | |
el.addEventListener("click", function () { | |
this.classList.toggle("is-selected"); | |
// siblings | |
Array.prototype.filter.call(el.parentNode.children, function (child) { | |
return child !== el && child.classList.remove("is-selected"); | |
}); |
lsof -ti:5901 | xargs kill -9 |
function dividePastedValuesByCommas(e) { | |
/* bind on paste event */ | |
e.preventDefault(); | |
const target = e.target, | |
val = target.value, | |
start = target.selectionStart, | |
arr = e.originalEvent.clipboardData | |
.getData('text') | |
.replace(/\r\n\t|\n|\r\t|\s|,|;/gm, ' ') |
Create table
CREATE TABLE Users (
id MEDIUMINT AUTO_INCREMENT,
email VARCHAR(50),
password VARCHAR(50),
PRIMARY KEY(id)
)
const providerConfig = { | |
domain: config.domain, | |
clientId: config.clientId, | |
...(config.audience ? { audience: config.audience } : null), | |
redirectUri: window.location.origin, | |
onRedirectCallback, | |
}; |
// Expo SDK41 | |
// expo-blur: ~9.0.3 | |
import React, { useRef } from 'react'; | |
import { | |
Animated, | |
Image, | |
ImageBackground, | |
ScrollView, | |
StatusBar, |
const RADIUS = 100; | |
const NUM_SLICES = 8; | |
const renderPath = () => { | |
const sliceAngle = (2 * Math.PI) / NUM_SLICES; | |
const paths = []; | |
const colors = [ | |
"#FF5733", | |
"#FFC300", | |
"#36A2EB", |