yif042 / mistwave.github.io Goto Github PK
View Code? Open in Web Editor NEWMy personal blog
Home Page: http://duanyifu.com
My personal blog
Home Page: http://duanyifu.com
https://duanyifu.com/2019/08/30/variance/
一些定义 考虑类型A和C,以及泛型构造器F<T>: 如果我们在一个需要A的地方,总能使用C,我们就可以说C是A的子类型(subtype)[1],记作C <: A。 如果F是协变的(covariant),且C <: A,则有F<C> <: F<A>。 如果F是逆变的(contravariant),且C <: A,则有F<A>
https://duanyifu.com/2016/09/13/PIHex10/
Programming in Haskell是一本入门Haskell的好书,介绍页面以及配套的slides, vedios, codes都在这里。 第九章的习题暂时跳过了,先更第十章。 开学了,事情多了起来,还要找工作,加把劲最近把这本书刷完吧!:P 其实从第8章开始,这本书对于monad就讲的太少,过几天这本书要出第二版,希望能在这方面改进改进。。。 我下单了一本《Haskell趣学指南》,打
https://duanyifu.com/2019/07/28/monoid-in-FP/
Monoid 是什么? 我们先看两组例子: 123456789// string concatenationconcat("foo","bar") == "foobar"concat("", "latte") == concat("latte", "") == "latte"concat("a", concat("b", "c")) == concat(concat("a", "b"), "c")
https://duanyifu.com/2019/09/30/functor-in-FP/
什么是Functor? 先看一段代码: 12345678910111213// jsArray(1,2,3) .map(i => i ** 2) .map(i => i ** i)// [1, 16, 81]// scalaRight(3).map(n => n + " cats!")// res2: Either[Nothing, String] = Right("3 ca
B站首页有一些板块实在是辣眼睛,所以得想办法处理一下。 准备工作 我常用的浏览器是Chrome,所以就用Tampermonkey来加载脚本。 原理也很简单,等页面加载完成后,我们可以用Tampermonkey再跑一段自定义的JavaScript,用来操作DOM树。 然后通过Chrome的审查元素,得知,需要去除的元素id分别为bili_report_live和reportFirst2。
https://duanyifu.com/2016/08/23/hexo-deploy-problem/
问题描述 用hexo d命令部署的时候总是会卡住很久,反复尝试了几次后,每次都是control+C告终。 1234567▶ hexo dINFO Deploying: gitINFO Clearing .deploy_git folder...INFO Copying files from public folder...On branch masternothing to commit,
https://duanyifu.com/2016/08/22/PIHex1/
Programming in Haskell是一本入门Haskell的好书,介绍页面以及配套的slides, vedios, codes都在这里。 给出double (double 2)的另外一种可能解释。 书上给的例子是应用序和正则序(从左向右),可以将正则序(从右向左)当作答案。 1234567double (double 2)= double 2 + double 2= double 2
https://duanyifu.com/2016/08/31/PIHex7/
Programming in Haskell是一本入门Haskell的好书,介绍页面以及配套的slides, vedios, codes都在这里。 用map和filter表示[f x | x <- xs, p x] 123-- [f x | x <- xs, p x]-- [f x | x <- xs, p x]-- = map f (filter p xs) 定义高阶函数al
https://duanyifu.com/2020/03/31/kafka-producer-message-lost/
背景 通过Spark SQL从Hive读取大约1M行的数据,一次性写入Kafka时,大概会丢失20%的数据。 producer的设置只设置了acks=all,使用的是异步的send()。 Kafka Cluster有4个brokers。 排查 首先,注意到producer在程序结束时没有调用flush(),加上flush()之后,问题依旧。 从Kafka The Definitive Guide中
https://duanyifu.com/2019/12/30/ForkJoinPool/
TL;DR ForkJoinPool是实现了work stealing的线程池,其中所有线程都是daemon thread。 几个栗子🌰 123456// Java 7+CompletableFuture.supplyAsync(() -> 10) .thenCombineAsync(CompletableFuture.supplyAsync(() -> 32),
https://duanyifu.com/2017/05/02/ycombinator-in-scheme/
前言 在Lambda演算中,函数是没有名字的(都是匿名函数),那么如果函数没有名字,也就无法在函数体内显式地调用自身,也就无法定义递归函数,Y combinator就是用来解决这个问题的。 这篇文章想抛开那些数学概念,用程序语言(Scheme)的形式来讲解我们是如何推导出Y combinator的。 运行环境: IDE:DrRacket
https://duanyifu.com/2019/10/31/monad-in-FP-part-I/
Monad ---- “the m-word”,“a monoid in the category of endofunctors”. see A monad is just a monoid in the category of endofunctors, what’s the problem? for fun 在FP的路上,不可避免地会碰到monad这个拦路虎。绕是绕不过去的,那就学咯。 “
https://duanyifu.com/2016/08/27/PIHex5/
Programming in Haskell是一本入门Haskell的好书,介绍页面以及配套的slides, vedios, codes都在这里。 用List Comprehension计算1到100平方和 1sum [x^2 | x <- [1..100]] 定义库函数replicate 12345-- > replicate 3 True-- [True, True, True]
https://duanyifu.com/2016/08/23/PIHex2/
Programming in Haskell是一本入门Haskell的好书,介绍页面以及配套的slides, vedios, codes都在这里。 给算数表达式加上括号 按照运算符优先级就可以,略过。 修改代码,使之正确 将length xs用括号括起来即可。 尝试定义last last: 返回非空list的最后一个元素 1mylast a = a !! ((length a) - 1) 尝试定
https://duanyifu.com/2016/08/24/write-haskell-with-sublime/
基础准备 Haskell (我选择的是Haskell Platform 8.0.1) Sublime Text Package Control: The Sublime Text package manager 安装插件 SublimeHaskell 在Package Control中安装SublimeHaskell。 插件安装完成后,重启Sublime报错,提示需要安装hsdev cabal
https://duanyifu.com/2016/08/26/PIHex4/
Programming in Haskell是一本入门Haskell的好书,介绍页面以及配套的slides, vedios, codes都在这里。 定义 halve 12halve :: [a] -> ([a], [a])halve a = let n = (length a) div
2 in (take n a, drop n a) 用三种方式定义safetail 12345678
https://duanyifu.com/2016/09/08/PIHex8/
Programming in Haskell是一本入门Haskell的好书,介绍页面以及配套的slides, vedios, codes都在这里。 这章信息量简直爆炸,书上给的东西太少了,讲的又太多了。找了一堆资料看了好久才弄明白。 结合的参考资料如下: Chapter8讲课视频 Monadic Parsing in Haskell “Programming In Haskell” error
https://duanyifu.com/2016/08/25/PIHex3/
Programming in Haskell是一本入门Haskell的好书,介绍页面以及配套的slides, vedios, codes都在这里。 写出这些表达式的type 12345['a', 'b', 'c'] -- :: [Char]('a', 'b', 'c') -- :: (Char, Char, Char)[(False, 'O'),
https://duanyifu.com/2016/08/28/PIHex6/
Programming in Haskell是一本入门Haskell的好书,介绍页面以及配套的slides, vedios, codes都在这里。 这一章节就是在讲递归,所以下面的定义都是默认用递归定义。 定义幂函数 12345678910mypow :: Int -> Int -> Intmypow _ 0 = 1mypow x n = x * mypow x (n-1)-- *M
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.