Skip to content

Instantly share code, notes, and snippets.

💭
sleeping

Li "oldrev" Wei oldrev

💭
sleeping
Block or report user

Report or block oldrev

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
@oldrev
oldrev / fixedpoint-pid.c
Created Jul 25, 2019
Fixed-Point PID Algorithm
View fixedpoint-pid.c
// 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)
@oldrev
oldrev / tsast2lambdas.ts
Created Jan 10, 2018
Typescript Expression Tree to Lambda Expression
View tsast2lambdas.ts
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) })
View gis_coords_convert.js
//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;
}
View orchard_clear.py
#encoding: utf-8
# Orchard Language Package Cleanner
# Author: Wei "oldrev" Li <liwei@sandwych.com>
# License: New BSD
import sys, os, shutil
LOCAL = 'zh-CN'
@oldrev
oldrev / rmb_upper.py
Last active Sep 27, 2019
转换人民币大写 Python 版
View rmb_upper.py
#encoding: utf-8
'''
中文互联网上迄今为止实现最正确、代码最漂亮且效率最高的大写人民币金额转换代码
作者:李维 <oldrev@gmail.com>
版权所有 (c) 2013 李维。保留所有权利。
本代码基于 BSD License 授权。
'''
from io import StringIO
import math
@oldrev
oldrev / RmbUpperConverter.cs
Last active Dec 23, 2015
中文互联网上迄今为止实现最正确、代码最漂亮且效率最高的大写人民币金额转换代码
View RmbUpperConverter.cs
/** 中文互联网上迄今为止实现最正确、代码最漂亮且效率最高的大写人民币金额转换代码
* 作者:李维 <oldrev@gmail.com>
* 版权所有 (c) 2013 昆明维智众源企业管理咨询有限公司。保留所有权利。
* 本代码基于 BSD License 授权。
* */
using System;
using System.Collections.Generic;
using System.Text;
using System.Diagnostics;
You can’t perform that action at this time.