Skip to content

Instantly share code, notes, and snippets.

View LeanSeverino1022's full-sized avatar

Leandro Severino LeanSeverino1022

View GitHub Profile
@LeanSeverino1022
LeanSeverino1022 / debounce.js
Last active January 16, 2021 03:39
debounce snippet #vanillajs
const debounce = (callback, wait) => {
let timeoutId = null;
return (...args) => {
window.clearTimeout(timeoutId);
timeoutId = window.setTimeout(() => {
callback.apply(null, args);
}, wait);
};
}
@LeanSeverino1022
LeanSeverino1022 / readme.md
Last active November 9, 2020 08:03
Daily log

11/08

you can tell React to only execute the side effect once (at mount time), by passing an empty array: - react

useEffect(() => {
  console.log(`Component mounted`)
}, [])
import * as say from './say.js';

say.sayHi('John');
say.sayBye('John');
  1. Modern build tools (webpack and others) bundle modules together and optimize them to speedup loading and remove unused stuff.

Let’s say, we added a 3rd-party library say.js to our project with many functions:

@LeanSeverino1022
LeanSeverino1022 / readme.md
Last active July 6, 2020 04:16
HTTP #concepts
  • Hyper Text Transfer Protocol - responsible for the communication between web server and the client. You are using HTTP when you open a new page, submit a form, ajax calls, etc.

HTTP is stateless

  • Every request is completely independent
  • Similar to transactions
  • Programming, Local Storage, Cookies, Sessions are used to create enhanced user exp.

What is HTTPS?

@LeanSeverino1022
LeanSeverino1022 / insertAfter.js
Created June 11, 2020 10:32
Insert an element after or before another #DOM #cheatsheet
//The following helper function insertAfter() lets you insert a new element after an existing one in the DOM tree:
function insertAfter(newNode, referenceNode) {
referenceNode.parentNode.insertBefore(newNode, referenceNode.nextSibling);
}
// example
var newEl = document.createElement('div');
newEl.innerHTML = '<p>Hello World!</p>';
@LeanSeverino1022
LeanSeverino1022 / plugin.php
Last active April 19, 2020 12:17
[wpBeter create a custom gutenberg container block and create reusable group of blocks] #wordpress
<?php
/**
* Plugin Name: WP Blocks
* Version: 1.0.0
*/
function loadMyBlockFiles() {
wp_enqueue_script(
@LeanSeverino1022
LeanSeverino1022 / readme.md
Last active June 25, 2020 05:56
Developer Job #career
@LeanSeverino1022
LeanSeverino1022 / gulpfile.js
Created April 14, 2020 04:05
wpBeter automation with gulp
//init modules
const gulp = require('gulp');
const browserSync = require('browser-sync').create();
//settings (where paths are defined)
const settings = require('./settings');
//TASKS
//puyih: put on hold SASS, minifiers, etc. features in wpbeter, if you need it later on check your gist