This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* @name promisifychannel | |
* @brief Promisify an event-based channel | |
* @version 2 | |
* @license MIT | |
* @copyright luo3house | |
* @requires JSON, ES2015 or later (Promise lib) | |
*/ | |
// util types |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Step 1: 修改 /etc/hosts,把 CORS 合法域名指向本机 | |
// Step 2: 当前目录准备该域名的证书 tls.crt | |
// Step 3: 当前目录准备该域名的证书 tls.key | |
// Step 4: 修改 TARGET 为本地开发环境的 URL | |
// Step 5: node server.js | |
var http = require('http'), https = require('https'), fs = require('fs') | |
var TARGET = 'http://localhost:8080' | |
var PORT = 443 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { getDependencyTree, Reaction } from "mobx" | |
import React, { useRef, useState, useLayoutEffect } from "react" | |
import { isUsingStaticRendering } from "./staticRendering" | |
import { printDebugValue } from "./utils/printDebugValue" | |
function observerComponentNameFor(baseComponentName: string) { | |
return `observer${baseComponentName}` | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
port: 7890 | |
socks-port: 7891 | |
allow-lan: true | |
mode: Global | |
log-level: info | |
external-controller: 127.0.0.1:9090 | |
# https://developer.android.com/studio/run/emulator-networking?hl=zh-cn#networkaddresses | |
proxies: | |
- {name: "AVD Host", desc: "(10.0.2.2)", server: 10.0.2.2, port: 7890, type: socks5 } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import 'package:flutter/widgets.dart'; | |
class TouchOpacity extends StatefulWidget { | |
final Widget child; | |
final void Function()? onTap; | |
const TouchOpacity({ | |
super.key, | |
this.child = const SizedBox(), | |
this.onTap, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Translation { | |
// "zh-a-b-c" -> m"-c" | |
static final _localeSuffixRE = RegExp(r"-[^-]+$"); | |
final bool localeCaseSensitive; | |
var _currentLocale = "en"; | |
var _fallbackLocale = "en"; | |
Map<String, Map<String, String>> dict = Map(); | |
Translation({ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// if true, will pop the last | |
typedef LRUPolicyTest<K, V> = bool Function(LRULinkedMap lru, _Node<K, V> item); | |
class _Node<K, V> { | |
late K key; | |
late V value; | |
_Node<K, V>? prev; | |
_Node<K, V>? next; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
typedef Middleware<C> = dynamic Function(C context, Function() next); | |
class Interceptor<C> { | |
static _noop() {} | |
final List<Middleware<C>> middlewares = List.empty(growable: true); | |
Future<void> call<T>(C context, [Function() fn = _noop]) async { | |
if (middlewares.isEmpty) return fn(); | |
return middlewares.reduce((pre, cur) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class VariableTokenStore<Token> { | |
/// validate token is valid | |
/// - true = ok | |
/// - false = not ok | |
/// - neverthrow | |
final Future<bool> Function(Token token) checkToken; | |
/// fetch a new token | |
/// - null = require authenticate | |
/// - not null = ok |
OlderNewer