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 / README.md
Last active January 18, 2024 15:28
nginx接口转发/代理/单页面应用配置

关于nginx的小小笔记

不常用,没过一段时间都要去搜一下,干脆自己记下来

重启nginx服务器

/etc/init.d/nginx restart
# or
service nginx restart
@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 / 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
Last active January 22, 2022 12:14
NodeJs项目目录结构

NodeJs 项目目录

.
├── logs                                                        # 存放日志
│   ├── 1.log
│   └── 2.log
├── package.json                                                # 依赖包
├── scripts                                                     # 脚本集合
│   └── do_some_thing.js
@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 / str2color.js
Last active March 20, 2021 14:02
根据一个字符串,生成一个动态的hex颜色
var stringToColor = function(str) {
var hash = 0;
for (var i = 0; i < str.length; i++) {
hash = str.charCodeAt(i) + ((hash << 5) - hash);
}
var color = '#';
for (var i = 0; i < 3; i++) {
var value = (hash >> (i * 8)) & 0xFF;
color += ('00' + value.toString(16)).substr(-2);
}