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

React

https://react.dev/

class:

class MyComponent extends React.Component {
  /* Adding state and binding custom methods */
  constructor() {
 super()
@azl397985856
azl397985856 / 楠楠.md
Last active January 6, 2024 13:20
楠楠资料,进度
  • JavaScript
  变量:名字(identifier) + 值(类型)
  基础类型:栈里分配。(栈==函数调用栈)
  引用类型:堆里分配。
 作业:
  1. 闭包与作用域:https://lucifer.ren/fe-interview/#/topics/js/scope&closures
  2. 引用和操作符优先级
 3. this

思考步骤

  1. 未知量是什么?
  2. 已经数据是什么?
  3. 引入适当的符号,用哪个字母表示未知量?
  4. 联系上述未知量的条件是什么?
  5. 为了确定未知量是否需要辅助元素(引入几个新的符号。比如题目求 x^4 + 3x^2 = 15 最简单的引入 y = x^2,等价于 y^2 + 3y = 15)?
  6. 这是一个合理的题目吗?(条件是否足以确定未知量)
  7. 有没有可能将其转化为一个已经学习过的知识?(观察未知量,并尽量想出一道你所熟悉的具有相同或相似未知量的题目。每道题都按照这个步骤思考, 那么这个步骤 7 就不会很难)如果还是不能,不妨尝试变化,转化,修改题目,然后重新描述(比如简化或消除题目中的某几个未知量)。
  8. 你卡在了哪个环节?为什么卡到这里了?
/**
* RuntimeGlobalsChecker
*
* You can use this utility to quickly check what variables have been added (or
* leaked) to the global window object at runtime (by JavaScript code).
* By running this code, the globals checker itself is attached as a singleton
* to the window object as "__runtimeGlobalsChecker__".
* You can check the runtime globals programmatically at any time by invoking
* "window.__runtimeGlobalsChecker__.getRuntimeGlobals()".
*
@azl397985856
azl397985856 / template.sh
Created December 28, 2020 08:16
bash template
#!/usr/bin/env bash
set -Eeuo pipefail
trap cleanup SIGINT SIGTERM ERR EXIT
script_dir=$(cd "$(dirname "${BASH_SOURCE[0]}")" &>/dev/null && pwd -P)
usage() {
cat <<EOF
Usage: $(basename "${BASH_SOURCE[0]}") [-h] [-v] [-f] -p param_value arg1 [arg2...]
@azl397985856
azl397985856 / browser-detect.mjs
Created September 22, 2020 07:01
浏览器检测
class BrowserDetector {
constructor() {
// 测试条件编译
// IE6~10支持
this.isIE_Gte6Lte10 = /*@cc_on!@*/false;
// 测试documentMode
// IE7~11支持
this.isIE_Gte7Lte11 = !!document.documentMode;

检查弹出是否被屏蔽(比如插件屏蔽)

let blocked = false;

try {
  let wroxWin = window.open("http://www.wrox.com", "_blank");
  if (wroxWin == null){
    blocked = true;
 }
// multi-part
// client.mjs
import fs from "fs";
import path, { dirname } from "path";
import request from "request";
import { fileURLToPath } from "url";
var r = request.post("http://localhost:7001/low-code/api/v1/magic", function(
err,
@azl397985856
azl397985856 / traceId-spanId.js
Last active July 16, 2020 07:38
traceId-spanId 全链路追踪
// 根据 traceId 可以找出一个链路的所有请求
// 根据 spanId 可以就上面找到的所有请求画出调用树🌲
function a({ traceId, spanId, random }) {
if (random > 0.5) {
b({ traceId, spanId: spanId + "." + 1, random: Math.random() });
} else {
c({ traceId, spanId: spanId + "." + 1, random: Math.random() });