Skip to content

Instantly share code, notes, and snippets.

View zaguiini's full-sized avatar
🏠
Working from home

Luis Felipe Zaguini zaguiini

🏠
Working from home
View GitHub Profile
@zaguiini
zaguiini / README.md
Last active November 2, 2019 22:45
Travis CI NPM workflow

Travis CI - NPM workflow

This workflow does, in the following order:

  • install your packages
  • run the lint command
  • run the test command
  • publishes the package with the version defined in the release tag
  • publishes the new version code on github (updates the package.json to match the latest tag)

It will only trigger the deploy phase on the master branch when there's the release tag present. Otherwise it will just build and test your files.

@zaguiini
zaguiini / brick-wall.js
Last active December 2, 2019 03:22
Brick wall Leetcode solution
const wall = [
[1, 2, 2, 1],
[3, 1, 2],
[1, 2, 2],
[2, 4],
[3, 1, 2],
[1, 3, 1, 1]
]
const leastBricks = (wall) => {
import React from 'react'
const Store = React.createContext()
const useStore = () => React.useContext(Store)
const reducer = (state, action) => {
switch(action.type) {
case 'ADD_TODO':
return { ...state, todos: [...state.todos, action.payload] }
import { createStore } from 'easy-peasy'
const store = createStore({
todos: {
items: ['Create store', 'Wrap application', 'Use store'],
add: action((state, payload) => {
state.items.push(payload)
})
}
})
@zaguiini
zaguiini / flatten-list.js
Last active January 14, 2020 14:34
How to flatten a list using reduce and recursion
const flattenList = (array) => {
return array.reduce((flat, next) => {
return flat.concat(Array.isArray(next) ? flattenList(next) : next)
}, [])
}
{"lastUpload":"2021-09-13T13:13:59.269Z","extensionVersion":"v3.4.3"}
function sleep(ms) {
return new Promise((resolve) => setTimeout(resolve, ms));
}
async function performanceURL(url, sampleSize, sleepMs = 1000) {
const performanceList = [];
for (let i = 0; i < sampleSize; i++) {
const t0 = performance.now();
await window.wpcom.request({ method: 'GET', path: url });
const t1 = performance.now();
performanceList.push(t1 - t0);