Skip to content

Instantly share code, notes, and snippets.

View yuxino's full-sized avatar
🍊
seize the day

Gavin yuxino

🍊
seize the day
  • Gensokyo
View GitHub Profile
@yuxino
yuxino / check-host.js
Created June 1, 2020 07:32
check local and network host
const os = require("os");
const protocol = "https";
const port = "8080";
// 运行端口host打印
const interfaces = os.networkInterfaces();
// 处理 IPV4
Object.keys(interfaces).forEach((key) => {
(interfaces[key] || [])
@yuxino
yuxino / set-env.js
Created June 1, 2020 06:56
dot env read env file
const { exec } = require("child_process");
const dotenv = require("dotenv");
const env = {};
const mode = process.env.MODE;
const files = [".env", `.env.${mode}`];
files.forEach((file) => {
const { parsed } = dotenv.config({ path: `${__dirname}/${file}` });
var video = document.getElementsByTagName("video")[0];
video.currentTime = video.duration;
import 'package:flutter/foundation.dart';
import 'dart:async';
class Debounce {
final int milliseconds;
VoidCallback action;
Timer _timer;
Debounce({this.milliseconds});
@yuxino
yuxino / excel.js
Last active November 2, 2020 11:26
excel export by json
import XLSX from "xlsx";
/**
* 更换data的key为map里面的value
* 比如说data是这样子的: [ name: 'perter' ]
* map是这样子的: [ name: '姓名' ]
* 经过这个方法转换之后就会变成 [ '姓名': 'peter' ]
* 这样到 `XLSX.utils.json_to_sheet` 方法运行的时候
* 就能解析出正确的表头
* @param { data } array JSON 数组 { key: value }[]
@yuxino
yuxino / sticker.png
Last active May 26, 2019 08:50
two~
sticker.png
@yuxino
yuxino / sticker.png
Last active May 26, 2019 08:48
one~
sticker.png
@yuxino
yuxino / excel
Created March 25, 2019 08:58
Export json to excel
import XLSX from "xlsx";
/**
* 转换Json为Excel文件并下载
* @param {data} array JSON 数组 { 名字: 值 }[]
* @param {header} array excel 表格的名字
* @param {sheet} string 工作簿
* @param {filename} string 文件名
*/
export function exportJson({ data, header, sheet, filename }) {
const wb = XLSX.utils.book_new();
@yuxino
yuxino / isElementInViewport.js
Created May 29, 2018 09:48
check element is in the viewport
isElementInViewport = (el) => {
let rect = el.getBoundingClientRect();
return (
rect.top >= 0 &&
rect.left >= 0 &&
rect.bottom <= (window.innerHeight || document.documentElement.clientHeight) &&
rect.right <= (window.innerWidth || document.documentElement.clientWidth)
);
}
@yuxino
yuxino / easing.js
Created April 19, 2018 02:52 — 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