This file contains hidden or 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
open Syntax | |
module IntMap = Map.Make(struct type t = int let compare = compare end) | |
module List = struct | |
include List | |
let zip xs ys = | |
let rec go acc = function | |
| [], _ | _, [] -> List.rev acc | |
| x::xs, y::ys -> go ((x,y)::acc) (xs,ys) |
This file contains hidden or 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
const ctx = new globalThis.AudioContext() | |
// 音符频率(基于 A4 = 440Hz) | |
const A4 = 440 // Hz | |
const NOTE_FREQ = new Map([ | |
['Digit1', A4 * 2 ** (-9 / 12)], // C4 | |
['Digit2', A4 * 2 ** (-7 / 12)], // D4 | |
['Digit3', A4 * 2 ** (-5 / 12)], // E4 | |
['Digit4', A4 * 2 ** (-4 / 12)], // F4 | |
['Digit5', A4 * 2 ** (-2 / 12)], // G4 |
This file contains hidden or 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
public interface ExpressionProblem { | |
/* | |
问题: | |
实现一个简单的数学表达式语言,比如 1 + 2, 3 * 4, (1 + 2) * 3 | |
1. 初始的特性 | |
表达式类型:证书字面量,加法 | |
操作:计算表达式的值 |
This file contains hidden or 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
public class IDObfuscation { | |
private static final char[] ALPHABET = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789".toCharArray(); | |
private static final int BASE = ALPHABET.length; | |
private static final byte[] PADDING = {0x29, 0x28, 0x27, 0x26, 0x25, 0x24, 0x23, 0x22, 0x21, 0x20, 0x1F, 0x1E, 0x1D, 0x1C, 0x1B, 0x1A, 0x19, 0x18, 0x17}; | |
private static final byte NEGATIVE = 0x2A; | |
private int key; | |
public IDObfuscation(int key) { | |
this.key = key; | |
} |
This file contains hidden or 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
/** | |
* memorized | |
* @param func function | |
* @param createKeyFunc function cachedKey使用调用参数生成 默认参数toString & 连接 | |
* @return mixed | |
* @author xiaofeng | |
*/ | |
var memorized = function(func, createKeyFunc) { | |
if(typeof func !== "function") { | |
throw new Error("argument error") |
This file contains hidden or 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
/** | |
* curry | |
* @param function func | |
* @param boolean variableArg 是否可变参数 | |
* @param boolean autoCompleted 参数补全之后是否自动求解 | |
* @return mixed | |
* @author xiaofeng | |
*/ | |
var curry = function(func, variableArg, autoCompleted) { | |
variableArg = !!variableArg |
This file contains hidden or 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
<?php | |
error_reporting(E_ALL); | |
/** | |
* Class Lazy | |
* 适合大量数据的流式数组操作类 | |
* Generator::Iterator | |
* 提示: | |
* Generator是一次性的,无法rewind | |
* 同一个Iterator在多个循环中会互相影响 |
This file contains hidden or 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
<?php | |
error_reporting(E_ALL); | |
class test { | |
const C = "im const\n"; | |
public static function hello($name) { | |
echo "hello, $name!" . PHP_EOL; | |
} | |
} |
This file contains hidden or 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
<?php | |
error_reporting(E_ALL); | |
// require __DIR__ . '/AopClass.php'; | |
class A { | |
public $property; | |
public function __construct($x) { | |
$this->x = $x; | |
} |
This file contains hidden or 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
<?php | |
/** | |
* Class ProxyMethod | |
* @author xiaofeng | |
* 代理类的方法 | |
* 可以代理private protected方法,不使用setAccessible,无副作用 | |
*/ | |
class ProxyMethod | |
{ | |
private static $staticMethods = []; // bug |
NewerOlder