Skip to content

Instantly share code, notes, and snippets.

View ZhihaoLau's full-sized avatar
💭
Meh

lzo ZhihaoLau

💭
Meh
View GitHub Profile
@ZhihaoLau
ZhihaoLau / ywapi.js
Created June 29, 2020 13:48
ywapi.js
(function () {
/**
* YWApiCore
*/
YWApiCore = {
__GLOBAL_FUNC_INDEX__: 0,
invokeClientMethod: function (module, name, parameters, callback) {
var url = "mm://" + module + "/" + name + "?p=" + encodeURIComponent(JSON.stringify(parameters || {}));
if (callback) {
@ZhihaoLau
ZhihaoLau / arrow.svg
Last active October 31, 2019 10:07
icon svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@ZhihaoLau
ZhihaoLau / gist:f92b2ee21061f2c0e3e88f1d092862b0
Created September 14, 2019 04:02 — forked from mediavrog/gist:49c4f809dffea4e00738a7f5e3bbfa59
CORS in Google Cloud Functions for Firebase
const cors = require('cors')({origin: true});
exports.sample = functions.https.onRequest((req, res) => {
cors(req, res, () => {
res.send('Passed.');
});
});
@ZhihaoLau
ZhihaoLau / select.pug
Created June 10, 2018 16:11
select.pug
tf-select(
:options="devicesList",
:disabled="false",
v-model="webcam",
placeholder="请选择设备"
)
<tf-select :options="devicesList" :disabled="false" v-model="webcam" placeholder="请选择设备"></tf-select>
<script id="jsbin-source-html" type="text/html">tf-select(
:options="devicesList",
:disabled="false",
v-model="webcam"
placeholder="请选择设备"
)</script>
<tf-select :options="devicesList" :disabled="false" v-model="webcam" placeholder="请选择设备"></tf-select>
<script id="jsbin-source-html" type="text/html">tf-select(
:options="devicesList",
:disabled="false",
v-model="webcam"
placeholder="请选择设备"
)</script>
@ZhihaoLau
ZhihaoLau / parseUrl.js
Created April 10, 2018 17:29
parseUrl
export function parseUrl(url) {
let a = document.createElement('a')
a.href = url
return {
href: a.href,
protocol: a.protocol,
host: a.host,
hostname: a.hostname,
port: a.port,
@ZhihaoLau
ZhihaoLau / step1.js
Created March 10, 2018 15:15 — forked from getify/step1.js
transducing in javascript
function add1(v) { return v + 1; }
function isOdd(v) { return v % 2 == 1; }
function sum(total,v) { return total + v; }
var list = [2,5,8,11,14,17,20];
list
.map( add1 )
.filter( isOdd )
.reduce( sum );
@ZhihaoLau
ZhihaoLau / vsconfig.json
Created January 4, 2018 11:59
VSCode config
{
"terminal.integrated.shell.windows": "C:\\WINDOWS\\Sysnative\\cmd.exe",
"window.zoomLevel": 0,
// Controls the font family.
"editor.fontFamily": "'Operator Mono', Consolas, 'Courier New', monospace, 微软雅黑",
// "editor.fontFamily": "Consolas, 'Courier New', monospace, 微软雅黑",
// Controls the font weight.
"editor.fontWeight": "300",
// Controls the line height. Use 0 to compute the lineHeight from the fontSize.
"editor.lineHeight": 30,
@ZhihaoLau
ZhihaoLau / quickSort.js
Created October 8, 2017 15:50
quickSort in ES6 favor
function quickSort(list) {
if (list.length < 2) return list
let medIdx = Math.floor(list.length / 2),
medItem = list[medIdx],
newList = [...list.slice(0, medIdx), ...list.slice(medIdx+1)],
left = newList.filter(item => item <= medItem),
right = newList.filter(item => item > medItem)
return [...quickSort(left), medItem, ...quickSort(right)]