Skip to content

Instantly share code, notes, and snippets.

View yantze's full-sized avatar
🤤
Out sick

zhi yantze

🤤
Out sick
View GitHub Profile
@yantze
yantze / .npmrc
Last active March 4, 2022 09:28
electron npm 源,配置好 npmrc 后, yarn 如果没有 .yarnrc 也会使用 .npmrc
registry=https://registry.npmmirror.com/
disturl=https://registry.npmmirror.com/dist
chromedriver-cdnurl=https://registry.npmmirror.com/mirrors/chromedriver
couchbase-binary-host-mirror=https://registry.npmmirror.com/mirrors/couchbase/v{version}
debug-binary-host-mirror=https://registry.npmmirror.com/mirrors/node-inspector
flow-bin-binary-host-mirror=https://registry.npmmirror.com/mirrors/flow/v{version}
fse-binary-host-mirror=https://registry.npmmirror.com/mirrors/fsevents
fuse-bindings-binary-host-mirror=https://registry.npmmirror.com/mirrors/fuse-bindings/v{version}
git4win-mirror=https://registry.npmmirror.com/mirrors/git-for-windows
gl-binary-host-mirror=https://registry.npmmirror.com/mirrors/gl/v{version}
function topK (n, k, arr1) {
let x1 = n - 1
let y1 = n - 1
let x2 = n - 1
let y2 = n - 1
let endX = x1
let endY = y1
let arr = [arr1[y1][x1]]
// 1 2 3 4
@yantze
yantze / calibre_viewer.css
Created October 7, 2019 01:58
Calibre Viewer Theme
body {
font-family: PingFangSC, "simsun", "Hiragino Sans GB", "TIBch", "Classic Grotesque W01","Helvetica Neue", Arial, "STHeiti", "Microsoft YaHei", "WenQuanYi Micro Hei", SimSun, sans-serif !important;
font-size: 1.1em;
color:rgb(96,62,36);
background-color: rgb(250,244, 233);
text-align:justify;
text-indent:2em;
line-height: 1.8em !important;
@yantze
yantze / caesar-chipper.js
Created October 19, 2018 01:09
简单的凯撒加解密,移位算法
/**
* 凯撒加解密
*/
// 这里的 26 是必须的,否则导致解密溢出
const num = ~~(Math.random() * 100) % 26
const event = "simple world!"
const MIN = "A".charCodeAt(0)
@yantze
yantze / fibonacci.js
Created February 27, 2018 08:53
fibonacci 的三种实现方法的耗费时间
/*
* 1 , 1 , 2 , 3 , 5 , 8 , 13 , 21 , 34 , 55 , 89 , 144
*/
function fibonacci(n) {
if (n < 2) return 1
return fibonacci(n-1) + fibonacci(n-2)
}
@yantze
yantze / deepCopy.js
Last active June 16, 2018 12:57
deep copy a object
/*
* https://gist.github.com/yantze/c428dd022c0c85db2d14c37da4c1dec0
* https://github.com/pvorb/clone/blob/master/clone.js#L74:8
* author: yantze
* typeoof
* 对象为 function ,可能是 Function, class, Symbol, 不复制,因为这些是非结构化对象,但可以生成实例
* 对象为 object, 可能是 Date 实例, class 实例,{}, [], Regex 实例, Buffer 实例, 错误实例
*/
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>JS Bin</title>
<style id="jsbin-css">
.spinner {
height: 50px;
width: 50px;
@yantze
yantze / create_vultr_server
Last active October 30, 2017 14:26
Create vultr server from snapshot by script
#!/usr/bin/env bash
# author: yantze
# date: 2017-10-30
VULTR_API_KEY=KEYKEYKEYKEYKEYKEYKEYKEYKEY
snapshot_id="get snapshot_id from end"
subid=$(vultr server create -n "vultr-cli" -r 7 -p 201 --snapshot=$snapshot_id | tail -n 1 | awk '{print $1}')
sleep 30
@yantze
yantze / keybase
Created July 29, 2017 03:41
keybase
### Keybase proof
I hereby claim:
* I am yantze on github.
* I am yantze (https://keybase.io/yantze) on keybase.
* I have a public key ASCp9eP7ivUZs7_AovNqQS3CJKyDrTI17SPObayJmlr96Qo
To claim this, I am signing this object:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>JS Bin</title>
<style id="jsbin-css">
.img {
width:40px;
height: 40px;