Skip to content

Instantly share code, notes, and snippets.

View xhsdnn's full-sized avatar

xhsdnn xhsdnn

  • beijing
View GitHub Profile
@xhsdnn
xhsdnn / big-red-button.css
Last active April 16, 2024 11:53
按钮按下触感样式
/*
* reference: https://learn.svelte.dev/tutorial/dom-event-forwarding
*/
button {
font-size: 1.4em;
width: 6em;
height: 6em;
border: none;
border-radius: 50%;
background: radial-gradient(circle at 25% 25%, hsl(0, 100%, 50%) 0, hsl(0, 100%, 40%) 100%);
const { createReadStream, createWriteStream } = require('fs');
const tar = require(tar);
const dest = process.cwd();
// A: remote download
// A1: use lib
let res = await axios.get(url, {
responseType: 'stream'
});
let writer1 = createWriteStream(dest, {
const http = require('http');
let server;
function onRequest(req, res) {
console.log('[' + this.name + ']', req.method, req.url);
res.setHeader('Access-Control-Allow-Origin', '*');
res.writeHead(200, {'Content-Type': 'text/plain'});
res.end('Hello World\n');
}
// https://eslint.org/docs/user-guide/configuring
/*
* 0 - off
* 1 - warn
* 2 - error
*/
module.exports = {
extends: "eslint:recommended",
parser: "@typescript-eslint/parser",
parserOptions: {
/* 切换滚动条页面闪动 */
html {
overflow-y: scroll;
}
:root {
overflow-y: auto;
overflow-x: hidden;
}
@xhsdnn
xhsdnn / TextEllipsis.vue
Created August 9, 2019 08:35
单/多行文本截断的vue组件
<template>
<div class="text-ellipsis" :style="{height: textHeight,lineHeight: lineHeight}">
<div class="ellipsis-before" :style="{height: textHeight}"></div>
<div class="ellipsis-content">
<template v-if="$slots.default">
<slot></slot>
</template>
<template v-else>{{text}}</template>
</div>
<div class="ellipsis-after" :style="{top: '-'+lineHeight, height: lineHeight}">...</div>
#!/usr/bin/env bash
set -euxo pipefail # 抛出异常
dd # 删除一行
yy # 复制一行
p # 粘贴
cp Filename newFilename # 复制文件
ctrl+d # 向下翻半页
echo $diff_info | awk -F "[version]" '{print $0}'
@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 : '';
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 / 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)