Skip to content

Instantly share code, notes, and snippets.

View gangsthub's full-sized avatar
Creative developer

Paul Melero gangsthub

Creative developer
View GitHub Profile
@gangsthub
gangsthub / 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
@gangsthub
gangsthub / 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.

@gangsthub
gangsthub / 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())
@gangsthub
gangsthub / README.md
Last active July 16, 2020 16:40
`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

@gangsthub
gangsthub / 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)
@gangsthub
gangsthub / 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
@gangsthub
gangsthub / 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
@gangsthub
gangsthub / index.html
Created April 4, 2018 11:22
vue simplest example
<div id="simplest-example">
<h1>{{ text }}</h1>
</div>
@gangsthub
gangsthub / _cols.scss
Last active March 27, 2018 08:15
Dynamic RWD cols
// collections
$CONTAINER-WIDTHS: (
5,
10,
20,
30,
40,
50,
60,
@gangsthub
gangsthub / startup.ps
Last active December 19, 2017 19:21
powershell startup command
powershell.exe -new_console:a -NoExit -command "& {Set-Location C:\htdocs}"