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
/** | |
* Polyfill for "fixing" IE's lack of support (IE < 9) for applying slice | |
* on host objects like NamedNodeMap, NodeList, and HTMLCollection | |
* (technically, since host objects are implementation-dependent, | |
* IE doesn't need to work this way). Also works on strings, | |
* fixes IE to allow an explicit undefined for the 2nd argument | |
* (as in Firefox), and prevents errors when called on other | |
* DOM objects. | |
* @license MIT, GPL, do whatever you want | |
-* @see https://gist.github.com/brettz9/6093105 |
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
<?php | |
/** | |
* 加密 hash,生成发送给用户的 hash 字符串 | |
* | |
* @param array $hash_data | |
* @param string $hash_key | |
* @return string | |
*/ | |
function encode_hash($hash_data, $hash_key = false) |
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 Track(src, spriteLength, audioLead) { | |
var track = this, | |
audio = document.createElement('audio'); | |
audio.src = src; | |
audio.autobuffer = true; | |
audio.load(); | |
audio.muted = true; // makes no difference on iOS :( | |
/* This is the magic. Since we can't preload, and loading requires a user's | |
input. So we bind a touch event to the body, and fingers crossed, the |
This project is a tiny compiler for a very simple language consisting of boolean expression.
The language has two constants: 1
for true and 0
for false, and 4 logic gates:
!
(not), &
(and), |
(or), and ^
(xor).
It can also use parentheses to manage priorities.
Here is its grammar in BNF format:
expr ::= "0" | "1"
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 compress(string, encoding) { | |
const byteArray = new TextEncoder().encode(string); | |
const cs = new CompressionStream(encoding); | |
const writer = cs.writable.getWriter(); | |
writer.write(byteArray); | |
writer.close(); | |
return new Response(cs.readable).arrayBuffer(); | |
} | |
function decompress(byteArray, encoding) { |