Skip to content

Instantly share code, notes, and snippets.

View paulmelero's full-sized avatar
Creative developer

Paul Melero paulmelero

Creative developer
View GitHub Profile
@paulmelero
paulmelero / index.js
Created September 25, 2019 13:42
`nuxtServerInit` checking if it's mobile
/*
This needs to be in the store/index.js
*/
const mutationTypes = {
SET_MOBILE: 'SET_MOBILE',
}
const checkIfMobileOnServerSide = ({ req, isServer }) => {
if (isServer) return false
@paulmelero
paulmelero / README.md
Last active November 29, 2021 19:02
Simple Debounce Vue 2 Mixin: `simple-debounce-vue-mixin`

SimpleDebounce (Vue Mixin)

If you are listening to changes on an Event (DOM Events) to execute any side effects like performing network requests, you'd probably want to "debounce" your attached function executions.

This is an alternative to lodash.debounce but "vanilla js" packed as a Vue SFC to import it as a mixin.

@paulmelero
paulmelero / index.js
Created August 21, 2019 09:04
Detect if device is mobile from User Agent on Vuex
// See https://github.com/nuxt-community/device-module
const mutationTypes = {
CHANGE_MOBILE: 'CHANGE_MOBILE',
}
const checkIfMobileOnServerSide = ({ req, isServer }) => {
if (isServer) return false
const userAgent = req && req.headers['user-agent']
const isMobile = /mobile/i.test(('' + userAgent).toLowerCase())
@paulmelero
paulmelero / README.md
Last active October 7, 2024 19:45
`copytoclipboard`: Alternative to clipboard.js: Async implementation of "Copy to clipboard" in plain JS. Works in Safari, Chrome, Firefox, Opera and Edge Canary. Less than 1kb minified.

copyToClipBoard.js

copytoclipboard: Alternative to clipboard.js: Async implementation of "Copy to clipboard" in plain JS. Works in Safari, Chrome, Firefox, Opera and Edge Canary. Less than 1kb minified.

copyToClipBoard accepts an html element and returns a Promise.

Copies the content of the html element with the format included and also as plain text (both options).

📦 Install

@paulmelero
paulmelero / call vs bind
Last active July 4, 2019 16:32
A11y porpuse gists (for embedded code images)
// ⚡️
funFunction.bind(this).call()
// is the same as
funFunction.call(this)
@paulmelero
paulmelero / command.sh
Created July 25, 2018 08:30
PM2 start nuxt
# now run in your console: (I'm actually using powershell)
pm2 start .\ecosystem.config.js
@paulmelero
paulmelero / easing.js
Created April 6, 2018 21:11 — forked from gre/easing.js
Simple Easing Functions in Javascript - see https://github.com/gre/bezier-easing
/*
* Easing Functions - inspired from http://gizma.com/easing/
* only considering the t value for the range [0, 1] => [0, 1]
*/
EasingFunctions = {
// no easing, no acceleration
linear: function (t) { return t },
// accelerating from zero velocity
easeInQuad: function (t) { return t*t },
// decelerating to zero velocity
@paulmelero
paulmelero / index.html
Created April 4, 2018 11:22
vue simplest example
<div id="simplest-example">
<h1>{{ text }}</h1>
</div>
@paulmelero
paulmelero / _cols.scss
Last active March 27, 2018 08:15
Dynamic RWD cols
// collections
$CONTAINER-WIDTHS: (
5,
10,
20,
30,
40,
50,
60,
@paulmelero
paulmelero / startup.ps
Last active December 19, 2017 19:21
powershell startup command
powershell.exe -new_console:a -NoExit -command "& {Set-Location C:\htdocs}"