Skip to content

Instantly share code, notes, and snippets.

var mSum = (m, n, a) =>
a.length ? m > 2 ? mSum(m, n, a.slice(0, a.length - 1)).concat(
mSum(m - 1 , n - a[a.length - 1], a.slice(0, a.length - 1)).map(e => e.concat([a[a.length - 1]]))) :
twoSum(n, a) :
[];
var twoSum = (n, a) => {
a.sort((x, y) => x - y);
var r = [];
if(a.length < 2) return r;
<template>
<div class="ct" style="transform:translate({{x}}, {{y}})" onpanstart=starthandler onpanmove=movehandler>
<text style="font-size: 42;">Move me!</text>
<image class="img" style="width: 400px; height: 400px;" src="{{img}}"></image>
</div>
</template>
<style>
.ct {
width: 750;
// 2018.5.11更新: 减少了swap
function qSort(compare) {
var swap = (p1, p2) => {
var tmp = this[p1];
this[p1] = this[p2];
this[p2] = tmp;
}
var sortRange = (start, end) => {
var midValue = this[start];
var p1 = start + 1, p2 = end - 1;
@wintercn
wintercn / yc.js
Last active April 3, 2019 17:52
ycombinator in es2015
//yc here
var y = g =>
(f=>f(f))(
self =>
g( (...args)=>self(self)(...args) )
)
//use yc
var f = y(self =>
n => n < 0 ? 0 : n + self(n-1))
<a class="question_link" target="_blank" href="/question/30746665/answer/49332475">会写 Parser、Tokenizer 是什么水平?</a><br/><br/>大多数编译原理书前100页的内容,说明大学听了一半左右的编译原理课,通俗地说,写了这个只能证明你不是个棒槌。<br><br><br>所以其实你更应该关心不会tokenizer和parser是什么水平。
<span class="answer-date-link-wrap">
<a class="answer-date-link last_updated meta-item" data-tip="s$t$发布于 2015-05-29" target="_blank" href="/question/30746665/answer/49332475">编辑于 2015-05-29</a>
</span>
<hr/><a class="question_link" target="_blank" href="/question/30703519/answer/49150834">王垠到底对 winter 做了什么?</a><br/><br/>你可以理解为是路边看到一坨**,忍不住想去一脚踩爆它的心态。(虽然我知道这么做无聊而且会沾一脚)<br><br>想了想,可能还有一点觉得他的粉丝很可怜的,想让他们停止吃**的心态吧,虽然我知道"然而没卵用"。<br><br>回到题主的问题,要问做了什么,那就是“他是**,还碰巧被我看到了”,这样的事情,简直无法被饶恕。
@wintercn
wintercn / lightpromise.js
Last active January 4, 2022 01:45
一组小清新的promise风格小函数
function get(uri) {
return http(uri,'GET');
}
function post(uri,data) {
if(typeof data === 'object' && !(data instanceof String || (FormData && data instanceof FormData))) {
var params = [];
for(var p in data) {
if(data[p] instanceof Array) {
for(var i = 0; i < data[p].length; i++) {
params.push( encodeURIComponenet(p) + '[]=' + encodeURIComponenet(data[p][i]);
@wintercn
wintercn / magic.py
Created June 4, 2014 14:05
python magic
#:tabstop=4
if 1 :
if 1 :
if 0 :
print 1
else :
print 2
#:tabstop=8
if 1 :
<pre>
<script>
function levenshtein(a,b) {
var table = [[[]]];
for(var j = 1; j <= b.length; j++) {
table[0][j] = b.slice(0,j).map(function(e,j){return {action:"insert",element:e,position:j}});
}
@wintercn
wintercn / unhappy.md
Last active May 9, 2016 09:06
一件不开心的事

有一天,我切了个页面,有个按钮点了以后要跳转到另一个页面,于是我把代码这么写:

    window.location = "xxxxxx";

结果那个页面lazyload组件有bug,跳过去一片灰色,沟通了半天没解决,经过反复试验,我发现只要我页面的滚动位置不在顶部就会有问题,于是我想办法绕了过去,代码变成了这样:

 document.body.style.display = "none";
@wintercn
wintercn / JD.md
Last active December 29, 2015 14:58

移动富交互应用Job Design

Moria[Mobile Rich Interactive App]

工作职责

  • 负责Mobile端创意营销和游戏化场景的业务开发