Skip to content

Instantly share code, notes, and snippets.

View old2son's full-sized avatar
😅
mess

CJY old2son

😅
mess
View GitHub Profile
@old2son
old2son / SlimVid.js
Last active April 15, 2026 07:02
视频压缩
const { execSync } = require('child_process');
const fs = require('fs');
const path = require('path');
const inputDir = './videos';
const outputDir = './outputVideos';
if (!fs.existsSync(outputDir)) fs.mkdirSync(outputDir);
const files = fs.readdirSync(inputDir).filter((f) => f.endsWith('.mp4'));
@old2son
old2son / HorizontalScrollBar.html
Last active January 3, 2024 08:28
scrollbar custom, haven't check yet 😅
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1, minimum-scale=1, maximum-scale=1, user-scalable=no">
<title>demo mobile</title>
<style>
.cont {
height: 300px;
@old2son
old2son / stream .js
Last active December 20, 2023 03:22
stream easy demo
const http = require('http');
const cors = require('cors');
const fs = require('fs');
const PORT = 3000;
const server = http.createServer(async (req, res) => {
cors()(req, res, () => {});
if (req.url === '/stream-data' && req.method === 'GET') {
import { src, dest, watch, series, parallel } from 'gulp';
import babel from 'gulp-babel';
import jshint from 'gulp-jshint';
import ugilfy from 'gulp-uglify';
import rename from 'gulp-rename';
import browserSync from 'browser-sync';
import replace from 'gulp-replace';
import concat from 'gulp-concat';
import zip from 'gulp-zip';
// import sourcemaps from 'gulp-sourcemaps'; // 安装后 gulp 内置
@old2son
old2son / ws.html
Last active May 17, 2023 09:14
websocket easy demo
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>first socket</title>
</head>
<body>
<h1>myfitst room</h1>
<input type="text" id="snedTxt" />
@old2son
old2son / textEllipsis.js
Last active July 16, 2024 09:06
textEllipsis
function textEllipsis(eleClassName) {
const eles = document.querySelectorAll(eleClassName);
const formatStr = (ele) => {
const text = ele.innerHTML;
const totalTextLen = text.length;
const lineNum = 3;
const baseWidth = window.getComputedStyle(ele).width;
const baseFontSize = window.getComputedStyle(ele).fontSize;
const lineWidth = +baseWidth.slice(0, -2); // 去除单位