Skip to content

Instantly share code, notes, and snippets.

View moreta's full-sized avatar

JungJoo Seo moreta

  • Brakio
  • Japan
View GitHub Profile
@moreta
moreta / imageAutoRotate.js
Created November 15, 2018 03:05
Read image's Exif meta, and auto rotate image.
import loadImage from 'blueimp-load-image'
const VueImageAutoRotate = {
install (Vue, options) {
Vue.directive('auto-rotate', {
bind (el, binding, vnode) {
if (vnode.tag !== 'img') {
console.error('Warning: auto-rotate directive valid in img tag.')
} else {
const imageUrl = vnode.elm.src
@moreta
moreta / hls-video.vue
Last active April 2, 2019 17:58
hls & mp4 all suport video tag - vue component
<template>
<video ref="video" v-bind="$attrs" muted controls preload="metadata" :poster="poster" v-on="$listeners">
<source v-if="isHls" :src="videoUrl" type="application/x-mpegURL" />
<source v-else :src="videoUrl" type="video/mp4">
</video>
</template>
<script>
import Hls from 'hls.js'
export default {
@moreta
moreta / contants.js
Last active August 31, 2018 05:54
vueでの定数とselect optionのためのselectOptionPlugin
/**
* 性別 - 定数
*/
export const SEX_TYPES = {
MALE: '1',
FEMALE: '2'
}
@moreta
moreta / vue_devtool_open_component_in_editor.md
Last active August 19, 2022 07:44
Vue devtool Open component in editor tips
@moreta
moreta / VueMomentPluginExample.vue
Last active January 16, 2018 09:46
vue moment plugin example
<template>
<el-date-picker
v-model="until_date"
type="date"
placeholder="日付を選択"
@change="until_date = $moment($event).endOf('day').format()">
</el-date-picker>
</template>
@moreta
moreta / http.js
Last active September 5, 2023 15:27
axios interceptor sample code
/**
* src/api/http.js
*/
import axios from 'axios'
import qs from 'qs'
/**
*
* parse error response
*/
@moreta
moreta / vuelidate_number.js
Created August 23, 2017 10:02
vuelidate number validator
import { withParams } from 'vuelidate/lib/validators/common'
import isFinite from 'lodash/isFinite'
import toNumber from 'lodash/toNumber'
export default withParams({ type: 'number' }, value => {
return isFinite(toNumber(value))
})
@moreta
moreta / vuelidate_biggerThan.js
Last active August 23, 2017 10:03
vuelidate biggerThan validator
import { ref, withParams } from 'vuelidate/lib/validators/common'
import toNumber from 'lodash/toNumber'
const numericExpr = /^[0-9]*$/
export default biggerThan => withParams(
{ type: 'biggerThan', bg: biggerThan },
function (value, parentVm) {
if (numericExpr.test(value) && numericExpr.test(ref(biggerThan, this, parentVm))) {
return toNumber(value) > toNumber(ref(biggerThan, this, parentVm))
} else {
@moreta
moreta / .gitmessage.txt
Created December 7, 2016 01:39
git's default commit message
# feat (feature)
# fix (bug fix)
# docs (documentation)
# style (formatting, missing semi colons, …)
# refactor
# test (when adding missing tests)
# chore (maintain)
feat(scope)[#x] title
@moreta
moreta / rename_file.sh
Created June 14, 2016 16:32
rename_file.sh
brew install rename
rename 's/(.+).html.markdown$/$1.md/' *.html.markdown