Skip to content

Instantly share code, notes, and snippets.

View xhsdnn's full-sized avatar

xhsdnn xhsdnn

  • beijing
View GitHub Profile
function clone(obj) {
if ((typeof (obj) == "object") && (obj != null)) {
if (obj instanceof Array) {
//如果是Array
let newObj = [];
for (let i = 0; i < obj.length; i++) {
if (typeof (obj[i]) == "object") {
newObj[i] = clone(obj[i]);
} else {
newObj[i] = obj[i];
vi ~/.bash_profile
export JAVA_8_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_171.jdk/Contents/Home
export JAVA_9_HOME=/Library/Java/JavaVirtualMachines/jdk-9.0.1.jdk/Contents/Home
export JAVA_HOME=$JAVA_8_HOME
source ~/.bash-profile
@xhsdnn
xhsdnn / git_toturial
Last active April 3, 2023 02:14 — forked from guweigang/git_toturial
git命令大全
git init # 初始化本地git仓库(创建新仓库)
git config --global user.name "xxx" # 配置用户名
git config --global user.email "[email protected]" # 配置邮件
git config --global color.ui true # git status等命令自动着色
git config --global color.status auto
git config --global color.diff auto
git config --global color.branch auto
git config --global color.interactive auto
git config --global --unset http.proxy # remove proxy configuration on git
git clone git+ssh://[email protected]/VT.git # clone远程仓库
@xhsdnn
xhsdnn / vue.config.js
Last active July 6, 2018 02:49
vue脚手架基本配置
const webpack = require("webpack")
module.exports = {
baseUrl: "/",
outputDir: "dist",
// 打包之后静态资源保存的目录
assetsDir: "assets",
// 配置多页引用的入口
pages: {
index: "src/main.js",
@xhsdnn
xhsdnn / vue.config.js
Created July 6, 2018 02:48
vue多页配置
const webpack = require("webpack");
const HtmlWebpackPlugin = require('html-webpack-plugin');
module.exports = {
baseUrl: "/",
outputDir: "dist",
// 打包之后静态资源保存的目录
assetsDir: "assets",
// 配置多页引用的入口
pages: {
@xhsdnn
xhsdnn / gulpfile.js
Created July 30, 2018 03:38
基本任务即插件
const gulp = require("gulp");
const spritesmith = require("gulp.spritesmith"); // https://github.com/twolfson/gulp.spritesmith
const imagemin = require('gulp-imagemin');
const concat = require('gulp-concat');
const uglify = require('gulp-uglify');
const rename = require('gulp-rename');
const sass = require('gulp-sass');
// 默认任务
gulp.task('default', function () {
@xhsdnn
xhsdnn / drawPolygon.js
Last active August 9, 2018 06:48
three.js绘制多边形的顶点矩阵
/* 前提需要先引入three.js
* n —— 正多边形边数
* r —— 正多边形所在外接圆的半径
* cx —— 正多边形所在外接圆的圆形X轴坐标(默认为:0)
* cy —— 正多边形所在外接圆的圆形Y轴坐标(默认为:0)
*/
function drawPolygon(n ,r, cx = 0, cy = 0) {
let vertexs = [];
for(let i=0; i<n; i++) {
let x = cx + r*Math.sin(2*Math.PI/n*i);
@xhsdnn
xhsdnn / drawCoordSystem.js
Created August 9, 2018 06:51
three.js中创建辅助坐标系
/* 绘制坐标系
* scene —— 要绘制坐标系的场景(let scene = new THREE.Scene())
*/
function drawCoordSystem(scene) {
// 创建三个坐标轴的几何模型
let geometryX = new THREE.Geometry();
geometryX.vertices.push(
new THREE.Vector3(-5, 0, 0),
new THREE.Vector3(5, 0, 0),
new THREE.Vector3(4.8, 0.2, 0)
var express = require('express');
var app = express();
app.use(express.static('dist'));
//设置跨域访问
app.all('*', function(req, res, next) {
res.header("Access-Control-Allow-Origin", "*");
res.header("Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, Accept");
res.header("Access-Control-Allow-Methods","PUT,POST,GET,DELETE,OPTIONS");
@xhsdnn
xhsdnn / js-tools.js
Last active December 21, 2023 07:11
js工具方法
/**
* 正则字符串去重
*
* @param {string} str —— 需要去重的字符串
* @returns
*/
function clearRepeat(str) {
let regex = /(.)?/g;
return str.replace(regex, function($1, $2, $3, $4) {
return $4.indexOf($2) === $3 ? $2 : '';