Recent posts
-
A quick example of async/await
Posted on 20 April 2019
Note: all the code in this post is in TypeScript. Suppose we want to implement the following function: function retry<T>(action: () => Promise<T>, n: number): Promise<T> such that it performs the action and retrieves the value and retries up to n times, if the action fails. Had action been a synchronous function, it may be natural to use a for loop, which is easy to write and pretty readable. But we can’t use a for...
Read more...→ -
Add some colorful cowsay to your terminal
Posted on 20 September 2014
So I often get asked about my terminal because it’s a little bit flamboyant: So today I am going to write about how this can be achieved. Here’s the tools that you need: cowsay, fortune, gshuf and lolcat. cowsay, fortune and gshuf are binaries so depending on your OS, you can use your package manager to install them. lolcat is a ruby gem so you will need to install ruby first, then do you usual...
Read more...→ -
Markmon - a fast markdown previewer
Posted on 15 December 2013
Github link If you use markdown often, chances are that you also use some sort of markdown previewers. Unfortunately, most of them simply generate the HTML and refresh the content when there’s an update - which is fine for a lot of use cases, but not when you need to do some post-processing like MathJax. So I built markmon which focus on improving the re-rendering speed. The problem with refreshing page is that it will...
Read more...→ -
Hearts with POMDP
Posted on 11 December 2013
This project is hosted on Github Also try here: http://hearts.yjyao.com Hearts is one of the few card games that I know how to play, thanks to Microsoft Windows and the countless boring hours. So based on what I have done Gomoku and solitaire, it seems natural to fuse the two and write a hearts card game with AI. It turns out that Hearts is a lot trickier than the simple Gomoku - it’s multiplayer and...
Read more...→ -
Web Daemon - Pin Websites to Menubar
Posted on 14 June 2013
This project is hosted on Github This is a convenient Mac app I made quite some time ago. The idea is based on my previous app treb, but this time it is Mac only and not Qt-based cross-platform, because I found Qt Webkit to be rather inadequate. Anyway, Web Daemon allows you to pin ‘small versions’ of websites into your status bar. You can pin as many as you like, so long as your menubar...
Read more...→