Skip to content

Instantly share code, notes, and snippets.

@kellywoo
kellywoo / vee-validate-basic.js
Last active April 23, 2017 19:32
vee-validate
<div class="column is-12">
<label class="label" for="email">Email</label>
<p :class="{ 'control': true }">
<input v-validate="'required|email'"
:class="{'input': true, 'is-danger': errors.has('email') }"
name="email" type="text" placeholder="Email" />
<span v-show="errors.has('email')" class="help is-danger">
{{ errors.first('email') }}
</span>
</p>
@kellywoo
kellywoo / vee-validate-password.js
Last active April 23, 2017 18:42
vee-validate-password
import Validate , { Validator } from 'vee-validate'
Validator.extend( 'password',{
getMessage: field => `${field} should include lower-case,
numeric digit, special chracter($@$!%*#?&).`,
validate: value => {
return /^.*(?=.*[a-zA-Z])(?=.*[0-9])(?=.*[$@$!%*#?&]).*$/.test(value)
}
})
@kellywoo
kellywoo / README-Template.md
Created September 24, 2018 10:03 — forked from PurpleBooth/README-Template.md
A template to make good README.md

Project Title

One Paragraph of project description goes here

Getting Started

These instructions will get you a copy of the project up and running on your local machine for development and testing purposes. See deployment for notes on how to deploy the project on a live system.

Prerequisites

@kellywoo
kellywoo / git tag
Last active October 18, 2018 07:32
reference
# create tag
git add .
git commit -m “Initial release”
git tag v0.1.0
git push origin master --tags
# or git push origin v1.5
# search tag
git tag -l 'v1.4.2.*'
// [1,2,3,4,5,6]
const recursive = (arr, i) => arr.length === i ? 0 : (arr[i] + recursive(arr, i+1));
const recursiveWrapper = (arr) => recursive(arr, 0);
const recursiveTail = (arr, i, v)=> arr.length === i ? v : recursiveTail(arr, i+1, v+arr[i]);
const recursiveTailWrapper = (arr) => recursiveTail(arr, 0, 0);
const recursiveToFor = (arr) => {
let sum = 0;
for (let i = arr.length -1; i>=0; i--) {
sum+= arr[i]
const validator = {
isArray(arr) {
return Array.isArray(arr);
}
};
const {arrayForPublic, arrayRecursivePublic, arrayRecursiveTailPublic} = (() => {
const trimAndWrap = (str, start, end) => {
return `${start}${str.replace(/,\s*$/, '')}${end}`;
const {stringify} = (() => {
const separator = () => ',';
const processChar = (char) => {
switch (char) {
case '\\':
return '\\\\';
case '\n':
return '\\n';
@kellywoo
kellywoo / generators
Last active April 26, 2021 02:20
stringify
function* pipe(arr, operators) {
if (!Array.isArray(arr)) {
throw 'It is not Array.';
}
if (!Array.isArray(operators)) {
throw 'operators should be type of Array<[type: string; fn: (v:any) => any]>';
}
const cpArr = [...arr];
let muatated = [];
let i = 0;
const {stringify} = (() => {
// simple
const strRegexp = [[/\\/g, '\\\\'], [/\n/g, '\\n'], [/\t/g, '\\t'], [/\v/g, '\\v'], [/[\b]/g, '\\b'], [/[\r]/g, '\\r'], [/"/g, '\\"']]
class ResultRecords {
constructor() {
this.data = [];
}
}