Skip to content

Instantly share code, notes, and snippets.

😟
I may be slow to respond.

lucifer azl397985856

😟
I may be slow to respond.
Block or report user

Report or block azl397985856

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@azl397985856
azl397985856 / chunkAsync.ts
Last active Nov 13, 2019
异步分段加载(可以用于性能优化)
View chunkAsync.ts
/**
*
* @param size 分段的大小
* @param arr 需要被处理的数组
*/
function chunk<T>(size: number, arr: Array<T>): Array<Array<T>> {
return Array.from({ length: Math.ceil(arr.length / size) }, (_, i) =>
arr.slice(i * size, i * size + size)
);
}
View draw-taro.js
import Taro, { Component } from '@tarojs/taro';
import { Canvas, View, Image } from '@tarojs/components';
import { AtButton } from 'taro-ui';
function getTouchPos(e) {
const rect = {
left: 0,
top: 0,
};
View draw.js
import React, { Component } from 'react';
import { render } from 'react-dom';
// Get the position of the mouse relative to the canvas
function getMousePos(canvasDom, mouseEvent) {
var rect = canvasDom.getBoundingClientRect();
return {
x: mouseEvent.clientX - rect.left,
y: mouseEvent.clientY - rect.top
};
@azl397985856
azl397985856 / headless-check.md
Created Aug 9, 2019
检查是否是无头浏览器
View headless-check.md

It seems he's doing something with header detection. I used Puppeteer to play around with the site and various configurations I use when scraping. In headless Chrome, the "Accept-Language" header is not sent. In Puppeteer, one can force the header to be sent by doing:

page.setExtraHTTPHeaders({ 'Accept-Language': 'en-US,en;q=0.9' })

However, Puppeteer sends that header as lowercase: accept-language: en-US,en;q=0.9

So it seems the detection is as simply: if there is no 'Accept-Language' header (case-sensitive), then "Headless Chrome"; else, "Not Headless Chrome".

View Bypassing anti-incognito detection in Google Chrome.md
if ('storage' in navigator && 'estimate' in navigator.storage) {
	const {usage, quota} = await navigator.storage.estimate();
    console.log(`Using ${usage} out of ${quota} bytes.`);

	if(quota < 120000000){
        console.log('Incognito')
    } else {
        console.log('Not Incognito')
    }	
@azl397985856
azl397985856 / disable-react-redux-devtool.md
Created Aug 5, 2019
生产模式下禁止React Developer Tools、Redux DevTools的使用
View disable-react-redux-devtool.md

React Developer Tools

window.__REACT_DEVTOOLS_GLOBAL_HOOK__.inject = function () {}
import {
  disableReactDevTools
@azl397985856
azl397985856 / memory.js
Last active Jul 8, 2019
Automatically detect memory leaks with Puppeteer
View memory.js
// from : https://github.com/chrisguttandin/standardized-audio-context/blob/master/test/integration/memory.js
const MemoryFileSystem = require('memory-fs'); // eslint-disable-line no-undef
const puppeteer = require('puppeteer'); // eslint-disable-line no-undef
const webpack = require('webpack'); // eslint-disable-line no-undef
// eslint-disable-next-line padding-line-between-statements
const compileBundle = () => {
return new Promise((resolve, reject) => {
const memoryFileSystem = new MemoryFileSystem();
View setCookie.js
function setCookie(cookieName,value,expiresTime,path){
expiresTime = expiresTime || "Thu, 01-Jan-2030 00:00:01 GMT";
path = path || "/";
document.cookie=cookieName+ "=" +encodeURIComponent(value)+ "; expires="+ expiresTime+ "; path="+path;
}
View svg-frame-animation.less
<svg viewBox="0, 0, 91, 94" class="warm-face">
<image xlink:href="//yun.duiba.com.cn/h5/millionaire-custom/top-180118/assets/faces.png" width="3458" height="94" />
</svg>
.warm-face {
position: relative;
@azl397985856
azl397985856 / listen1_aha_playlist.md
Last active Sep 5, 2018
updated by Listen1(http://listen1.github.io/listen1/) at 2018/9/5 下午3:51:39
View listen1_aha_playlist.md

本歌单由Listen1创建, 歌曲数:1,歌单数:1,点击查看更多

You can’t perform that action at this time.