Skip to content

Instantly share code, notes, and snippets.

View axetroy's full-sized avatar
💭
Get busy living or get busy dying

Axetroy axetroy

💭
Get busy living or get busy dying
View GitHub Profile
@axetroy
axetroy / ImageViewer.js
Created April 22, 2024 13:45
Image viewer
class ImageViewer {
/** @type {string | undefined} */
url = void 0;
/** @type {HTMLElement | undefined} */
$app = void 0;
/** @type {HTMLElement | undefined} */
$img = void 0;
/** @type {number} */
scaleRate = 1;
@axetroy
axetroy / binary-search-tree.js
Last active September 29, 2023 15:16
算法
/**
* 二叉树搜索
*/
var arr = [5, 8, 10, 3, 1, 6, 9, 7, 2, 0, 4];
function search(searchValue) {
var index = 0;
var root = {
@axetroy
axetroy / README.md
Created September 23, 2022 02:37
页面防打印方案

收集几种方案,用于防止页面被打印出来。

  1. 模糊法

页面失去焦点时,模糊页面,使其打印的页面也模糊。

有效:Chrome/Firefox 无效:IE (模糊无法使用,但可以在 IE 环境使其完全空白作为备选方案)

这个方案体验稍差

@axetroy
axetroy / index.html
Last active August 23, 2022 16:25
前端水印方案
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>水印生成器</title>
</head>
<body>
<div id="root">
<div>
<div>
@axetroy
axetroy / README.md
Created December 8, 2021 01:59
设置开机启动

如果使用 gnome 桌面环境(Ubuntu)

gnome-session-properties 
@axetroy
axetroy / index.js
Created October 25, 2021 01:25
Babel plugin demo
const babel = require('babel-core')
const code = `
const abc = 1 + 2 // foo
const defghijk = 3 + 4 // bar
`
const result = babel.transform(code, {
plugins: [require('./plugin')]
})
@axetroy
axetroy / README.md
Created October 15, 2021 08:37
macOS 查看应用签名
$ codesign -dvvv /Applications/云盒子.app/
Executable=/Applications/云盒子.app/Contents/MacOS/云盒子
Identifier=cloudoc
Format=app bundle with Mach-O thin (x86_64)
CodeDirectory v=20500 size=1747 flags=0x10000(runtime) hashes=46+5 location=embedded
Hash type=sha256 size=32
CandidateCDHash sha1=f9f5ad4252b097b1ff33c9d1102f8599f139f207
CandidateCDHashFull sha1=f9f5ad4252b097b1ff33c9d1102f8599f139f207
CandidateCDHash sha256=ebfa600510ea8d96807d8d1f033271148e4c9fec
@axetroy
axetroy / glob2regexp.js
Last active November 9, 2023 17:50
Glob string transform to javascript RegExp
function glob2regexp(glob) {
const prefix = "^/?(.*/)*";
const suffix = "$";
const content = glob
.replace(/\./g, ".")
.replace(/\*{2,}/, "**")
.replace(/\*{1,}\/?/g, function (match, b, c, d) {
const matchSlash = match[match.length - 1] === "/";
match = !matchSlash ? match : match.substr(0, match.length - 1);
@axetroy
axetroy / grid.scss
Created February 13, 2021 14:47
通用的 web app 原子类样式
.flex {
display: flex;
}
.row {
position: relative;
height: auto;
margin-right: 0;
margin-left: 0;
zoom: 1;
@axetroy
axetroy / BigFloat.ts
Created January 27, 2021 01:51
Big Float
type Numeric = number | string | BigInt
function getType(o: unknown): string {
const matcher = Object.prototype.toString.call(o).match(/\s(\w+)/)
if (!matcher) {
return ''
}
return matcher[1]