Skip to content

Instantly share code, notes, and snippets.

function daysInMonth (year, month) {
return /8|3|5|10/.test(month) ? 30 : month === 1 ? (!(year % 4) && year % 100) || !(year % 400) ? 29 : 28 : 31
}
function formatDate (date, format, translation) {
translation = (!translation) ? en : translation
let year = date.getFullYear()
let month = date.getMonth() + 1
let day = date.getDate()
let str = format
```
const test = Vue.component('test', {
props: ['msg'],
template:'<div><p>{{msg}}</p><slot name="action">xx</slot></div>'
})
new Vue({
el: '#app',
var subItems = Array.from(document.querySelectorAll('.sub-item'))
subItems.forEach((item) => {
item.onclick = function() {
var classList = this.classList
if (classList.contains('animation-open')) {
classList.remove('animation-open')
} else {
classList.add('animation-open')
}
@Yang03
Yang03 / children
Last active June 6, 2018 09:35
react
function RadioOption(props) {
return (
<label>
<input type="radio" value={props.value} name={props.name} />
{props.label}
</label>
)
}
function renderChildren(props) {
!function(){
var IS_IOS = /iPad|iPhone|iPod/.test(navigator.userAgent);
var IS_ANDROID = /android/i.test(navigator.userAgent);
var IS_TOUCH = createjs.Touch.isSupported();
var SCREEN_SHOW_ALL = true;
var width = 640;
var height = 1000;
var stage, queue;
var isMove = 0; //qp_o
var score = 0;
@Yang03
Yang03 / sha1.js
Created May 4, 2018 06:36
nodejs
function passwordDigest(str, password) {
// digest = base64 ( sha1 ( nonce + created + password ) )
var pwHash = crypto.createHash('sha1');
// var rawNonce = new Buffer(nonce || '', 'base64').toString('binary');
var s = str.concat(shaPwd(password));
pwHash.update(s);
var str = new Buffer(pwHash.digest()).toString('base64');
console.log(str);
return str;
};
<template>
<section class="bx-muti-img-bar">
<div class="slide-items" :style="style">
<div class="slide-item" v-for="(slide, index) in value.slides"
:key="index"
:style="[slideStyle[index], getStyle(index)]"
>
<img :src="slide['image']">
</div>
</div>
@Yang03
Yang03 / gist:763b81fd6a8da38e20d0587c18127715
Created February 11, 2018 10:36
mapGetters vs mapState
...mapGetters({
x1: 'widgets/x1'
}),
...mapState('widgets', ['xx'])
state = {
xx: 0
}
import Vue from 'vue'
import App from './app'
new Vue({
el: '#app',
render: h => h(App, {
props: {
message: '小程序2'
}
{"type":"FeatureCollection","features":[{"id":"710000","type":"Feature","geometry":{"type":"MultiPolygon","coordinates":[[[[120.005817,23.469568],[120.060116,23.545228],[120.005817,23.469568]]],[[[120.443536,22.441261],[120.274291,22.560197],[120.200415,22.721097],[120.132976,23.000352],[120.022152,23.06007],[120.107847,23.341264],[120.121753,23.504658],[120.096239,23.570106],[120.102762,23.70097],[120.175354,23.807398],[120.255474,23.851801],[120.278257,23.927783],[120.451468,24.182705],[120.546295,24.370432],[120.642772,24.49016],[120.688678,24.600694],[120.881267,24.745821],[120.908484,24.851995],[121.024684,25.040488],[121.209299,25.127094],[121.371868,25.159867],[121.413467,25.238928],[121.485729,25.292878],[121.602414,25.304355],[121.745253,25.161944],[121.928777,25.130097],[121.941769,25.038471],[122.012201,25.001451],[121.845043,24.836255],[121.84152,24.734083],[121.892504,24.617927],[121.885457,24.529684],[121.826735,24.423573],[121.809157,24.339072],[121.638554,24.08434],[121.65937,24.006899],[121.4