Skip to content

Instantly share code, notes, and snippets.

View azl397985856's full-sized avatar
😟
I may be slow to respond.

lucifer azl397985856

😟
I may be slow to respond.
View GitHub Profile
@azl397985856
azl397985856 / index.html
Created June 30, 2016 08:14 — forked from anonymous/index.html
monad-code-pen
<div id="content">123</div>
@azl397985856
azl397985856 / bfs_and_dfs.md
Created August 28, 2018 02:14 — forked from chrisco/bfs_and_dfs.md
Breadth First Search And Depth First Search

Breadth First Search

Algorithm for searching graph-like data structures, one level at a time.


Step by Step

  • Start a queue
  • Check current node - if false, mark as visited, continue
@azl397985856
azl397985856 / listen1_aha_playlist.md
Last active September 5, 2018 07:51
updated by Listen1(http://listen1.github.io/listen1/) at 2018/9/5 下午3:51:39

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

@azl397985856
azl397985856 / svg-frame-animation.less
Created May 9, 2019 01:28
SVG - frame- animation
<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;
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;
}
@azl397985856
azl397985856 / disable-react-redux-devtool.md
Created August 5, 2019 08:57
生产模式下禁止React Developer Tools、Redux DevTools的使用

React Developer Tools

window.__REACT_DEVTOOLS_GLOBAL_HOOK__.inject = function () {}
import {
 disableReactDevTools
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 / headless-check.md
Created August 9, 2019 09:54
检查是否是无头浏览器

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".

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
};