Skip to content

Instantly share code, notes, and snippets.

View vicainelli's full-sized avatar
🤓
Focusing

Vinicius Cainelli vicainelli

🤓
Focusing
View GitHub Profile
@vicainelli
vicainelli / README.md
Last active September 30, 2024 08:45
Most Imporant Javascript commands

Most Imporant Javascript commands

Variables declarations

let x;          // Declare a block-scope variable
const y = 2;    // Declare a block-scope, read-only constant

Functions

CSS Snippets

Highlight an element on page

Blur the rest of the page and highligh some element, good to show new features/changes

css-highlight

@vicainelli
vicainelli / settings.json
Last active February 14, 2024 14:43
VS Code
{
"editor.stickyScroll.enabled": true,
"editor.scrollbar.horizontal": "hidden",
"editor.scrollbar.vertical": "hidden",
"security.workspace.trust.untrustedFiles": "open",
"workbench.settings.editor": "json",
// * Editor
"editor.cursorSmoothCaretAnimation": "on",
"editor.accessibilitySupport": "off",
"editor.renderWhitespace": "boundary",
@vicainelli
vicainelli / Toast.cy.js
Last active August 27, 2021 10:44
Toast Component
import { mount } from '@cypress/vue';
import Toast from '@/components/toast';
import '@/assets/css/style.css';
const toastTemplate = {
template: `
<div class="w-screen h-screen bg-grey-200">
<div class="text-center pt-8">
<button @click="$refs.toast.success({ title: 'New action, pushing the previous one', description: 'Description for the action, containing links' })">Success</button>
<button @click="$refs.toast.error({ title: 'Action failed', description: 'Sorry, your action didn’t come through' })">Error</button>

Sign Up Form React Typescript

Error message

TypeScript error in FormSignUp.tsx(43,19):
Argument of type '{ [x: string]: string; }' is not assignable to parameter of type 'MyState | ((prevState: Readonly<MyState>, props: Readonly<{}>) => MyState | Pick<MyState, keyof MyState> | null) | Pick<...> | null'.
  Type '{ [x: string]: string; }' is missing the following properties from type 'Pick<MyState, keyof MyState>': name, email, confirm_email  TS2345
@vicainelli
vicainelli / initials.js
Created May 20, 2021 10:12
Extract two initials from name string
const makeInitial = (name) => {
const rgx = new RegExp(/(\p{L}{1})\p{L}+/, 'gu');
let initials = [...name.matchAll(rgx)] || [];
return (
(initials.shift()?.[1] || '') + (initials.pop()?.[1] || '')
).toUpperCase();
}
@vicainelli
vicainelli / nestedLoop.js
Created April 13, 2021 11:49
loop through nested json object javascript recursive
function nestedLoop(obj) {
const res = {};
function recurse(obj, current) {
for (const key in obj) {
let value = obj[key];
if(value != undefined) {
if (value && typeof value === 'object') {
recurse(value, key);
} else {
// Do your stuff here to var value
@vicainelli
vicainelli / README.md
Last active January 7, 2021 10:36
Instagram high resolution image
document.querySelector('img[srcset*="fbcdn"]')
    .srcset.split(',').pop()
    .match(/\bhttps?:\/\/\S+/gi)[0]
@vicainelli
vicainelli / README.md
Last active July 13, 2020 10:58
CSS Overview, new experimental feature on Chrome DevTools

Hey Developer, have you heard about the new experimental feature of Chrome DevTools?

It's called CSS Overview, and it shows you the colors, font info, unused declarations, and media queries.

chrome-css-overview

To enable it in your Chrome or Brave browser