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
// A cancellable Promise with timeout for JS/TS | |
class OperationCancelledError extends Error { | |
constructor(reason: string = '') { | |
super(reason); | |
Object.setPrototypeOf(this, OperationCancelledError.prototype); | |
} | |
} |
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
// Fixed-Point PID Algorithm | |
// Ported from: https://gist.github.com/bradley219/5373998 | |
// Author: Li "oldrev" Wei <oldrev@gmail.com> | |
#include <stdio.h> | |
#include <stdint.h> | |
#include <string.h> | |
#include <stdio.h> | |
#define FIXED32_Q (16) |
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
function visitAndExpression(exprNode: any): any { | |
const conditions = exprNode.expressions.map(function (expr: any) { return visitExpression(expr) }) | |
return function (it: any) { return conditions.every(function (c: any) { return c(it) }) } | |
} | |
function visitOrExpression(exprNode: any): any { | |
const conditions = exprNode.expressions.map(function (expr: any) { return visitExpression(expr) }) |
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
//JS 实现的WGS84 坐标系转火星坐标系 GCJ-02 转百度坐标系 BD-09 | |
function _transformLat(x, y) { | |
var ret = -100.0 + 2.0 * x + 3.0 * y + 0.2 * y * y + 0.1 * x * y + 0.2 * Math.sqrt(Math.abs(x)); | |
ret += (20.0 * Math.sin(6.0 * x * Math.PI) + 20.0 * Math.sin(2.0 * x * Math.PI)) * 2.0 / 3.0; | |
ret += (20.0 * Math.sin(y * Math.PI) + 40.0 * Math.sin(y / 3.0 * Math.PI)) * 2.0 / 3.0; | |
ret += (160.0 * Math.sin(y / 12.0 * Math.PI) + 320 * Math.sin(y * Math.PI / 30.0)) * 2.0 / 3.0; | |
return ret; | |
} |
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
#encoding: utf-8 | |
# Orchard Language Package Cleanner | |
# Author: Wei "oldrev" Li <liwei@sandwych.com> | |
# License: New BSD | |
import sys, os, shutil | |
LOCAL = 'zh-CN' |
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
#encoding: utf-8 | |
''' | |
中文互联网上迄今为止实现最正确、代码最漂亮且效率最高的大写人民币金额转换代码 | |
作者:李维 <oldrev@gmail.com> | |
版权所有 (c) 2013 李维。保留所有权利。 | |
本代码基于 BSD License 授权。 | |
''' | |
from io import StringIO | |
import math |
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
/** 中文互联网上迄今为止实现最正确、代码最漂亮且效率最高的大写人民币金额转换代码 | |
* 作者:李维 <oldrev@gmail.com> | |
* 版权所有 (c) 2013 昆明维智众源企业管理咨询有限公司。保留所有权利。 | |
* 本代码基于 BSD License 授权。 | |
* */ | |
using System; | |
using System.Collections.Generic; | |
using System.Text; | |
using System.Diagnostics; |