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
#!/bin/bash | |
# build wasm | |
wasm-pack build --target web | |
# find wasm files | |
wasm_file=$(find pkg -name "*.wasm") | |
name=$(basename -s "_bg.wasm" $wasm_file) | |
js_file="pkg/${name}.js" | |
old_js_file="pkg/${name}.old.js" |
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 instances = new WeakMap(); | |
// Create a singleton instance. | |
export function singleton<T>(fn: () => T): () => T { | |
return () => { | |
let instance = instances.get(fn); | |
if (!instance) { | |
instance = fn(); | |
instances.set(fn, instance); |
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
import {createStore} from './store'; | |
const [store, watch] = createStore({ counter: 1 }); | |
watch((data) => { | |
console.log(data.counter); | |
}); | |
store.counter += 1; | |
store.counter += 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
<?php | |
define('REFERER', 'joyqi.github.io'); | |
define('REDIS_CACHE', '127.0.0.1:6379'); | |
define('TIMEOUT', 5); | |
function check_host($host) { | |
if ('localhost' == $host) { | |
return false; | |
} |