Skip to content

Instantly share code, notes, and snippets.

View heycqing's full-sized avatar
👾
wroking

heycqing heycqing

👾
wroking
View GitHub Profile
@heycqing
heycqing / use-node-unix.bat
Last active February 6, 2024 07:05
用于切换不同项目下window的node版本
#!/bin/bash
TARGET_VERSION="14"
# 检查 nvm 是否已安装
if ! command -v nvm &> /dev/null; then
echo "nvm is not installed. Installing nvm..."
# 安装 nvm (这里仅提供了基本的安装命令,实际安装可能更复杂)
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.1/install.sh | bash
export NVM_DIR="$([ -z "${XDG_CONFIG_HOME-}" ] && printf %s "${HOME}/.nvm" || printf %s "${XDG_CONFIG_HOME}/nvm")"
@heycqing
heycqing / somthink.md
Last active October 10, 2023 07:30
some think

[] 适合游戏人的 游戏搬砖 - 多开服务

@heycqing
heycqing / kye_require2import_text.js
Last active October 10, 2023 08:08
require to import to kye
const fs = require('fs');
const path = require('path');
function findRequireStatements(dir, results = []) {
const files = fs.readdirSync(dir);
files.forEach(file => {
const filePath = path.join(dir, file);
const stats = fs.statSync(filePath);
@heycqing
heycqing / require2import.js
Created October 9, 2023 09:57
require to import
const fs = require('fs');
const path = require('path');
const directoryPath = './your_directory_path';
function replaceRequiresWithImports(directoryPath) {
fs.readdir(directoryPath, (err, files) => {
if (err) {
console.error('Error reading directory:', err);
return;
@heycqing
heycqing / withSharedState.js
Last active October 10, 2023 02:17
vue2的高阶函数
/**
* 里面的运作原理:
* 1. props的传递方式: props: WrappedComponent.props,
* 2. emit事件的传递方式: this.$emit(eventName, eventValue)
* 3. HOC内部的共用的逻辑处理,与简单操作原理
*
* @param {component} WrappedComponent
* @returns component
*/
export default function withSharedState(WrappedComponent) {
'use strict';
module.exports = {
types: [
{value: 'feat', name: '特性: 一个新的特性'},
{value: 'fix', name: '修复: 修复一个Bug'},
{value: 'docs', name: '文档: 变更的只有文档'},
{value: 'style', name: '格式: 空格, 分号等格式修复'},
{value: 'refactor', name: '重构: 代码重构,注意和特性、修复区分开'},
@heycqing
heycqing / husky.package.json
Created January 19, 2021 07:41
在package.json文件中添加针对文件类型的格式化和校验
"lint": "eslint --ext .js --ext .vue src/",
"lint-fix": "eslint --fix --ext .js --ext .vue src/",
"prettier-fix": "prettier --write 'src/**/*.json' 'src/**/*.md' ",
"husky": {
"hooks": {
"pre-commit": "lint-staged"
}
},
"lint-staged": {
module.exports = {
env: {
browser: true,
es6: true,
},
extends: [
'eslint:recommended',
'airbnb-base',
'plugin:prettier/recommended',
'plugin:vue/essential',
module.exports = {
globals: {
require: true,
process: true,
module: true,
},
env: {
browser: true,
es6: true,
},
@heycqing
heycqing / check_webp_support.js
Created May 21, 2020 08:48
判断是否支持检查webp格式
export const check_webp_support = () => {
return new Promise( reslove => {
let img = new Image();
img.onload = function () {
let result = (img.width > 0) && (img.height > 0);
reslove(result)
};
img.onerror = function () {
reslove(false)
};