Skip to content

Instantly share code, notes, and snippets.

View alsotang's full-sized avatar

alsotang alsotang

View GitHub Profile
@alsotang
alsotang / Dockerfile
Last active March 20, 2021 13:30
Dockerfile for typescript project
# Use the official lightweight Node.js lts image.
# https://hub.docker.com/_/node
FROM node:lts-alpine AS build
# Create and change to the app directory.
WORKDIR /usr/src/app
# Copy application dependency manifests to the container image.
# A wildcard is used to ensure copying both package.json AND package-lock.json (when available).
@alsotang
alsotang / install.sh
Created August 15, 2020 06:27
puppeteer 依赖
apt-get install -y -q xvfb libgtk2.0-0 libxtst6 libxss1 libgconf-2-4 libnss3 libasound2 libatk-bridge2.0-0 libgtk-3-0
@alsotang
alsotang / main.js
Created August 6, 2020 15:57
重复调用异步函数时,批量返回首次调用的结果
async function _getCgiData() {
return new Promise(resolve => {
setTimeout(() => {
resolve('cgi data')
}, 5000);
})
}
let isGetting = false;
@alsotang
alsotang / evict.sh
Last active January 30, 2024 02:51
Release all local copy of iCloud drive. Run this script in a certain iCloud drive dir.
find . -type f ! -name '*.icloud' ! -name '.DS_Store' -exec brctl evict {} \;
@alsotang
alsotang / tmall.py
Created November 12, 2019 11:47
2019年天猫双11交易额预测
# coding=utf-8
import numpy as np
x = range(2009, 2019) # 年份
y = [0.5, 9.36, 52, 191, 350, 571, 912, 1207, 1682, 2135] # 2009到2018年的交易额
fittedPara = np.polyfit(x, y, 3) # 进行3次方多项式拟合
fx = np.poly1d(fittedPara)
Y = fx(range(2009, 2020)) # 用历年数据得出的拟合公式,预测2019年的交易额
const map = {
"(": 3n,
"[": 5n,
"{": 7n,
")": -3n,
"]": -5n,
"}": -7n
};
var isValid = function(s) {
@alsotang
alsotang / diff.js
Created August 26, 2018 18:46
diff two text with enhanced inline diff
require('colors');
const jsdiff = require('diff')
const stringSimilarity = require('string-similarity');
const text1 = `
{
"name": "calcit-editor",
"version": "0.3.50",
"description": "Cirru Calcit Editor",
"bin": {
"calcit-editor": "dist/server.js",
while true
do
sleep 1
wget -qO- http://107.170.206.53/hk1
done
function forceInterval(fn, time) {
var lastRunTime = new Date();
return setInterval(function () {
var currentTime = new Date()
if ((new Date - lastRunTime) < time) {
fn();
} else {
var count = ~~((new Date - lastRunTime) / time)
for (var i = 0; i < count; i++) {
@alsotang
alsotang / 提问的智慧.md
Created August 6, 2016 04:51 — forked from zer4tul/提问的智慧.md
Simplified Chinese edition of "How To Ask Questions The Smart Way"