WishMeLz

生活其实很有趣

微信机器人

https://github.com/padlocal/wechaty-puppet-padlocal/wiki/TOKEN-%E7%94%B3%E8%AF%B7%E6%96%B9%E6%B3%95app.tsimport { PuppetPadlocal } from "wechaty-puppet-padlocal"; import { Contact, log, Message, ScanStatus, Wechaty, Friendship } from "wechaty"; const puppet = new PuppetPadloc...

Centos 6 yum 错误

Error: All mirror URLs are not using ftp, http[s] or file. Eg. Invalid release/repo/archcd /etc/yum.repos.d/ 修改 CentOS-Base.repo注释掉 mirrorlist= 开头的注释取消 baseurl 开头的注释将 baseurl 中的mirrorlist.centos.org 改为 vault.centos.org

阿里STS权限管理

打开地址  https://ram.console.aliyun.com/roles创建用户来获取 accessKeyId accessKeySecretRAM角色管理,创建RAM角色,选择阿里云给角色添加权限,可以添加无数个,最重要的是添加AliyunSTSAssumeRoleAccesslet OSS = require('ali-oss'); let STS = OSS.STS; let sts = new STS({ accessKeyId: 'LTAI5*******e4eSf', ...

MySql拿到插入的ID

场景:插入一条数据,这条数据的ID是自增的主键.需要在插入的时候拿到这个IDnpm i mysql conn.query(sql,(err,data)=>{ console.log(data.insertId) })

Nginx分流

server { listen 443 ssl; server_name api.xxx.com; # index index.html index.htm index.php; # root /aweb/api; ssl_certificate cert/api.pem; ssl_certificate_key cert/api.key; ssl_session_timeout 5m; ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HI...

NodeJs抓取页面

npm i cheerio request iconv-lite思路:通过 request 获取到页面。在使用 iconv-lite 编译数据。在使用 cheerio 拿到对应的元素。这里以抓取微博热搜为例const cheerio = require('cheerio'); const request = require('request'); const iconv = require('iconv-lite'); function http(url, decode = 'utf8') { return new Promise((res...

NodeJs抓取页面内容

const cheerio = require('cheerio'); const request = require('request'); let url = 'https://btc.com/' request({ url: url, encoding: null }, function (error, response, body) { if (!error && response.statusCode == 200) { var buf = iconv.decode(body...

随机数

function getRandom(start, end, fixed = 0) { let differ = end - start let random = Math.random() return (start + differ * random).toFixed(fixed) }getRandom(1,5) 1<= num >=5

H5打电话发短信

<meta name="format-detection" content="telephone=yes"/> <a href="tel:13660007710">13660007710</a> <a href="sms:13660007710">13660007710</a>

保存图片文件,下载图片

function downloadIamge(imgsrc, name) { //下载图片地址和图片名 let image = new Image(); // 解决跨域 Canvas 污染问题 image.setAttribute("crossOrigin", "anonymous"); image.onload = function () { let canvas = document.createElement("canvas"); ...

赛邮云通信SUBMAIL

NodeJs发送短信var request = require('request'); let post = function (url, postdata) { let options = { url: url, formData: postdata }; return new Promise(function (resolve, reject) { request.post(options, function (err, response, body) { ...

根据元素宽度设定高度比例

要求:图片根据宽度设置高度。正方形.shopimg { width: 100%; height: 0; padding-bottom: 100%; // 这个就是高的比例 position: relative; } .shopimg-info { position: absolute; top:0; left: 0; bottom: 0; right: 0; } .shopimg img { width: 100%; height: 100%; }

Vue中可以选择文字高亮的插件

npm install --save vue-text-highlightimport TextHighlight from ‘vue-text-highlight’; Vue.component(‘text-highlight’, TextHighlight);<text-highlight :queries="queries">{{ description }}</text-highlight> data() { return { queries: ['birds', 'scatt'],//需要高亮的文字 ...

粘贴图片 ctrl+v

document.addEventListener("paste", function (event) { var isChrome = false; if (event.clipboardData || event.originalEvent) { //某些chrome版本使用的是event.originalEvent var clipboardData = event.clipboardData || event.originalEvent.clipboard...

JS判断是否为IE浏览器

function IEVersion() { var userAgent = navigator.userAgent; //取得浏览器的userAgent字符串 var isIE = userAgent.indexOf("compatible") > -1 && userAgent.indexOf("MSIE") > -1; //判断是否IE<11浏览器 var isEdge = userAgent.indexOf("Edge") > -1 ...