This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export default (chars = 'ABCDEFGHJKMNPQRSTUVWXYZ0123456789') => { | |
const checksum = input => { | |
const { sum } = input.split('').reverse().reduce((acc, char) => { | |
const addend = acc.factor * chars.indexOf(char); | |
acc.factor = acc.factor === 2 ? 1 : 2; | |
acc.sum += Math.floor(addend / chars.length) + (addend % chars.length); | |
return acc; | |
}, { sum: 0, factor: 2 }); | |
const remainder = sum % chars.length; | |
return chars[(chars.length - remainder) % chars.length]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* import StaggerDirective from '@/utils/directive.stagger'; | |
* Vue.directive('stagger', StaggerDirective); | |
* | |
* Optional directive value selects elements through CSS selectors v-stagger="'.stagger-item'" | |
* Optional argument defines generic stagger interval v-stagger:250 (default: 100ms) | |
* Optional data-stagger for single item delay | |
*/ | |
export default { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* Validation schema example */ | |
$schema = [ | |
'id' => ['field' => 'id'], | |
'name' => [ | |
'field' => 'name', | |
'required' => true, | |
'validation' => ['type' => 'string'] | |
], |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* Cache proxy for darksky.net API requests */ | |
define('API_KEY', '***********************'); | |
define('TIMEOUT', 10 * 60); // In seconds (10 minutes) | |
// Coordinates MUST be the first element in URL as https://api.server.io/v1/weather/[LAT,LON] | |
$params = explode('/', trim($_SERVER['PATH_INFO'], '/')); | |
$coords = filter_var(array_shift($params), FILTER_SANITIZE_STRING); | |
// Validate coordinates |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<template lang="html"> | |
<label class="drop-box" ref="dropBox" v-drop-file="load"> | |
<img v-if="image" :src="image" /> | |
<span v-else> | |
<i class="icon">cloud_upload</i> | |
{{ message }} | |
</span> | |
<input | |
type="file" | |
accept="image/*" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export default { | |
bind(el, bindings) { | |
el.dragEvents = ['dragenter', 'dragover', 'dragleave', 'drop']; | |
el.dragEvents.forEach(dragEvent => { | |
el.addEventListener(dragEvent, (event) => { | |
if (!el.classList.contains(dragEvent)) { | |
el.classList.remove(...el.dragEvents); | |
el.classList.add(dragEvent); | |
} | |
event.preventDefault(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export default { | |
bind(el, binding) { | |
const { value: { msg, callback } } = binding; | |
el.ask = () => { | |
if (confirm(msg)) callback(); | |
}; | |
el.addEventListener('click', el.ask); | |
}, | |
unbind(el) { el.removeEventListener('click', el.ask); } | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.scroll-show { | |
opacity: 0; | |
transition: all 0.5s ease-in-out; | |
} | |
.scroll-show-enter { opacity: 1; } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
rules: { | |
'no-console': process.env.NODE_ENV === 'production' ? 'error' : 'off', | |
'no-debugger': process.env.NODE_ENV === 'production' ? 'error' : 'off', | |
'no-tabs': 'off', | |
'indent': ['error', 'tab', { | |
'SwitchCase': 1 | |
}], | |
'max-len': ['error', { | |
'code': 100, | |
'ignoreTrailingComments': true, |
NewerOlder