Skip to content

Instantly share code, notes, and snippets.

@oubenruing
oubenruing / rollup-typescript.md
Last active March 6, 2023 06:20 — forked from aleclarson/rollup-typescript.md
The best Rollup config for TypeScript libraries

Features

🔥 Blazing fast builds
😇 CommonJS bundle
🌲 .mjs bundle
.d.ts bundle + type-checking
🧐 Source maps

Install

@oubenruing
oubenruing / README
Created January 18, 2022 08:17 — forked from luoshu/README
ipv6 hosts
#Google和各种网站的IPv6服务hosts
#利用IPv6技术翻墙,保证Google服务可用,校园网用户使用IPv6应该不收取上网费用(至少我们学校如此)
#最下方有各种网站的IPv6hosts列表
#欢迎转载,请注明来源,谢谢
#本文的发布地址:http://docs.google.com/View?id=dfkdmxnt_61d9ck9ffq
#本文的共享链接:https://docs.google.com/View?docID=0ARhAbsvps1PlZGZrZG14bnRfOTVmZzR4NjRkdA&revision=_latest
#表格版的host列表地址:http://spreadsheets.google.com/ccc?key=0AhhAbsvps1PldEVXVzBkR3hBaWFnbEQ0OWIwMU5ycmc&hl=zh_CN
#Google IPv6 地址及对应证书列表(不再细分):https://docs.google.com/Doc?docid=0ARhAbsvps1PlZGZrZG14bnRfOTVmZzR4NjRkdA&hl=en
@oubenruing
oubenruing / useApi.ts
Created November 26, 2021 01:52 — forked from mortezasabihi/useApi.ts
Vue 3 axios composition api
/* eslint-disable @typescript-eslint/no-unsafe-assignment */
import { reactive, toRefs } from 'vue';
import axios,{ AxiosRequestConfig, AxiosError, AxiosResponse } from 'axios';
export enum Status {
IDLE = 'idle',
LOADING = 'loading',
SUCCESS = 'success',
ERROR = 'error',
@oubenruing
oubenruing / gist:e975364f341fcf24300de4ddd3c59be7
Last active May 20, 2021 06:04
修改url参数,若不存在则添加
function getUrlParam(name) {
var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)");
var r = window.location.search.substr(1).match(reg);
if (r != null) return unescape(r[2]); return null;
}
function replaceParamVal (oUrl, paramName, replaceWith) {
var re = new RegExp('(' + paramName + '=)([^&]*)', 'gi')
var nUrl = oUrl.replace(re, paramName + '=' + replaceWith)
console.log('replaceParamVal:' + nUrl)
@oubenruing
oubenruing / NeuQuant.js
Last active April 7, 2020 10:21
使用OMGGIF 和 NeuQuant取gif的调色板颜色。
/*
* NeuQuant Neural-Net Quantization Algorithm
* ------------------------------------------
*
* Copyright (c) 1994 Anthony Dekker
*
* NEUQUANT Neural-Net quantization algorithm by Anthony Dekker, 1994. See
* "Kohonen neural networks for optimal colour quantization" in "Network:
* Computation in Neural Systems" Vol. 5 (1994) pp 351-367. for a discussion of
* the algorithm.
@oubenruing
oubenruing / 计算两经纬度的距离
Created November 20, 2019 09:45
计算两经纬度的距离
/**********************计算两经纬度的距离**************************/
var EARTHRADIUS = 6370996.81;
function _getRange(v, a, b) {
if (a != null) {
v = Math.max(v, a);
}
if (b != null) {
v = Math.min(v, b);
}
return v;
var browser = {
versions: function () {
var ua = navigator.userAgent,
app = navigator.appVersion;
return { //移动终端浏览器版本信息
trident: ua.indexOf('Trident') > -1, //IE内核
presto: ua.indexOf('Presto') > -1, //opera内核
webKit: ua.indexOf('AppleWebKit') > -1, //苹果、谷歌内核
gecko: ua.indexOf('Gecko') > -1 && ua.indexOf('KHTML') == -1, //火狐内核
mobile: !!ua.match(/AppleWebKit.*Mobile.*/), //是否为移动终端
@oubenruing
oubenruing / 判断浏览器类型
Created June 13, 2019 01:53
判断浏览器类型
function BrowserType()
{
var userAgent = navigator.userAgent; //取得浏览器的userAgent字符串
var isOpera = userAgent.indexOf("Opera") > -1; //判断是否Opera浏览器
// var isIE = userAgent.indexOf("compatible") > -1 && userAgent.indexOf("MSIE") > -1 && !isOpera; //判断是否IE浏览器
var isIE=window.ActiveXObject || "ActiveXObject" in window
// var isEdge = userAgent.indexOf("Windows NT 6.1; Trident/7.0;") > -1 && !isIE; //判断是否IE的Edge浏览器
var isEdge = userAgent.indexOf("Edge") > -1; //判断是否IE的Edge浏览器
var isFF = userAgent.indexOf("Firefox") > -1; //判断是否Firefox浏览器
var isSafari = userAgent.indexOf("Safari") > -1 && userAgent.indexOf("Chrome") == -1; //判断是否Safari浏览器
function deepCopy (obj, cache = []) {
function find (list, f) {
return list.filter(f)[0]
}
// just return if obj is immutable value
if (obj === null || typeof obj !== 'object') {
return obj
}
$('input').on("blur",function(){
document.activeElement.scrollIntoViewIfNeeded();
})