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 / README.md
Last active July 16, 2020 15:34
Remove unwanted HTML tags from an HTML string (for security reasons)
/// <reference types="jest" />
import { mount } from '@vue/test-utils'
import IntersectionComponent from './IntersectionComponent.vue'
const mountComponent = props =>
mount(IntersectionComponent, {
propsData: {
callback: jest.fn().mockImplementation(isVisible => isVisible),
...props
@gangsthub
gangsthub / line-clamp.scss
Created March 6, 2020 11:06
Truncate lines utility classes scss
// `.truncate-1-line` and `truncate-2-lines`
@each $lines in (1, 2) {
:root .truncate-#{$lines}-line#{if($lines > 1, 's', '')} {
display: -webkit-box;
overflow: hidden;
-webkit-line-clamp: $lines;
-webkit-box-orient: vertical;
}
}
@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 / 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 / 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,