Skip to content

Instantly share code, notes, and snippets.

@LevPewPew
LevPewPew / dash-list.scss
Created August 11, 2020 21:28
how to get a dash style ul unordered list symbol icon
ul {
list-style-type: none;
li:before {
content: "- ";
}
}
// arrow binds to window this, don't use it here to work with other properties of the object
const calculate = {
array: [1, 2, 3],
sum: () => {
console.log(this === window); // => true
return this.array.reduce((result, item) => result + item);
}
};
console.log(this === window); // => true
// Throws "TypeError: Cannot read property 'reduce' of undefined"
@LevPewPew
LevPewPew / dumbdepsreact.jsx
Created August 11, 2020 01:26
how to ignore that missing dependencies linting error in react
/* eslint-disable react-hooks/exhaustive-deps */
@LevPewPew
LevPewPew / multirule.json
Created August 11, 2020 01:06
multiple character length rulers with different colors in vs code settings
"editor.rulers": [
{
"column": 80,
"color": "#ffffff07"
},
{
"column": 120,
"color": "#ffffff59"
},
],
@LevPewPew
LevPewPew / always-visible-scroll.css
Created July 14, 2020 11:24
how to get an always visible scrollbar in css
.children-container {
height: 100%;
padding: 2.5rem 0;
overflow-y: scroll;
&::-webkit-scrollbar {
-webkit-appearance: none;
}
&::-webkit-scrollbar:vertical {
@LevPewPew
LevPewPew / settings.json
Created July 3, 2020 04:40
revert the new coloring for constants in VS code
"editor.tokenColorCustomizations": {
"[Default Dark+]": {
"textMateRules": [
{
"scope": ["variable.other.constant", "variable.other.enummember"],
"settings": {
"foreground": "#9CDCFE"
}
}
]
@LevPewPew
LevPewPew / .graphqlconfig
Created July 3, 2020 01:26
basic graphql config for use with prisma graphql vs code extension
{
"extensions": {
"endpoints": {
"whatever you wanna label/name this endpoint": {
"url": "https://somewebsite.com/graphql"
}
}
}
}
@LevPewPew
LevPewPew / sleep.js
Created May 29, 2020 05:18
how to make a sleep/wait timer to be used inside an async function (instead of a setTimeout which is buggy inside an async function).
async function wait(ms) {
return new Promise(resolve => {
setTimeout(resolve, ms);
});
}
@LevPewPew
LevPewPew / composition.js
Last active May 26, 2020 04:32
a short demonstration of using composition instead of inheritance
const barker = (state) => ({
bark: () => console.log(`My name is ${state.name}`)
});
const walker = () => ({
walk: (distance) => console.log(`I just walked ${distance} km`)
});
const dog = (name) => {
let state = {
@LevPewPew
LevPewPew / midnight.js
Last active May 26, 2020 06:29
get the time for midnight tonight local time in epoch milliseconds
let d = new Date();
d.setHours(24, 0, 0, 0);
let date = d;
let dateInEpochMilliseconds = Date.parse(d);
console.log(date);
console.log(dateInEpochMilliseconds);
// or
dateInEpochMilliseconds = new Date().setHours(24, 0, 0, 0);