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
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="UTF-8"> | |
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
<meta http-equiv="X-UA-Compatible" content="ie=edge"> | |
<title>Document</title> | |
</head> |
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
{"lastUpload":"2019-01-17T10:23:30.548Z","extensionVersion":"v3.2.4"} |
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 _call = (result) => typeof result === 'function' ? result() : result; | |
const IF = (condition) => (result, otherResult = null) => _call(condition ? result : otherResult); | |
const FooComponent = () => ( | |
<div> | |
{IF(true)( | |
<span>here is true and evaluated before the condition</span>, | |
_ => <p>here is false and will not be evaluated</p> | |
)} | |
</div> |
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
/** | |
* @typedef {{delay: number, concurrent: number, holdOn: boolean, onHoldMax: (number|boolean)}} Option | |
*/ | |
/** | |
* 用于应对大量的输入,有如下方式: | |
* - 对所有入队的数据按一定的时间间隔,逐个处理 | |
* - 当固定的时间间隔内没有新输入,或到达一定时间,对当前整个队列处理 | |
* @param handler | |
* @param {Option} options | |
* @returns {Object} |
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
'scroll-at': { | |
/** | |
* @example: <div v-scroll-at.bottom="loadMore"></div> | |
*/ | |
_bind() { | |
this.el.addEventListener('scroll', this.scrollHandler) | |
}, | |
_unbind() { | |
this.el.removeEventListener('scroll', this.scrollHandler) |
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
// 从国内某知名企业 IM 的讨论界面开始运行以下语句 | |
var userAndlunch = e => e.querySelector('.message') && [e.querySelector('.user-name').textContent, e.querySelector('.message pre').textContent.trim().split('\n')[0]] | |
var lunchs = [].map.call($('.msg-box'), userAndlunch).filter(a => a && ~a[1].search(/^\$[^\$]*/)).map(a => a.join(':')) | |
JSON.stringify(lunchs, null, 2) | |
// 将上面输出的字符串复制,到美团商铺页面粘贴并赋值给全局变量 lunchs,再还行剩余所有语句 | |
var lunchNames = lunchs.map(str => str.replace(/^.*\:\$/, '')) | |
function addCart(foods, lunchNames) { | |
[].slice.call(foods).filter(e=> ~lunchNames.indexOf($(e).find('[title]').text().trim())) | |
.map(e => e.querySelector('.j-addcart')) |
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/sh | |
## Tested in ArchLinux | |
npm ls 2>/dev/null | grep "UNMET PEER DEPENDENCY" | awk '{print $NF}' | xargs npm install |
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
from itertools import product | |
def expand(segment): | |
if '-' in segment: | |
start, end = map(int, segment.split('-')) | |
return map(str, range(start, end + 1)) | |
else: | |
return [segment] | |
def parse_ip(ip): |
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
class NumberBaseConverter(object): | |
def __init__(self, base=10): | |
if not (2 <= base <= 36): | |
raise | |
self.base = base | |
def _remainder_map(self, remainder): | |
if remainder < 10: | |
return str(remainder) |
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
#!/usr/bin/env python | |
from subprocess import call | |
from time import time | |
from argparse import ArgumentParser | |
def pull(path, fname): | |
if call(['scp', path, fname]) != 0: | |
raise Exception(path + ' :File path or host seems wrong') | |
call(['cp', fname, fname + '.bak']) |
NewerOlder