All 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...→ -
NUSMorge and My First Hackathon
Posted on 27 February 2013
I had my 24-hour hackathon from this Sunday to Monday. Really great experience. Stayed up all night long coding non-stopped and produced something that actually works. Take a look at my github profile page - there were 108 commits during that period! This is kind of funny because it is exactly half the number of commits I have pushed in a year. Working in a team of four was also great. I don’t have to...
Read more...→ -
Shuffling Cities
Posted on 30 November 2012
So I am currently interning at NonStop Games, an awesome startup that focuses on mobile and social gaming using HTML5 technology and node.js. And here’s an image about an ultra-secret project we are currently working on: Anyway, recently I was assigned a task to write a world map generator for this game, and I thought the algorithm I came up with is worthy of a blog post ;) Please note that all codes in this...
Read more...→