- Oct 31, 2023
βItβs the weekend and youβve just completed a seance with friends. After communing with the dead, you realize a mysterious message was left behind.β What is the decoded message? Use your Ruby skills to find out!
- May 9, 2023
Suppose there are n distinguishable boxes and k indistinguishable balls. Now, we randomly put the balls into the boxes. For each of the boxes, what is the probability that it contains m balls? This is a simple combanitorics problem that can be solved by the stars and bars method. It turns out that in the limit n,kββ with k/n fixed, the distribution tends to be a geometric distribution.
- May 7, 2023
Many languages support breaking out of nested loops, such as Perl, Java, JavaScript, C#, etc. Languages that have goto
can also do this easily. However, in most other languages, it is not easy to break out of nested loops. I want to introduce a way to do this in Ruby.
- Dec 5, 2022
The number of days in a week is prime, so we cannot utilize weekly periods to help us remember periodical events unless the period is a multiple of 7. However, there may be something that we need to get reminded of which happens once per two days or three days. For example, I wash my hair once per two days and wash my clothes once per eight days. To solve the problem, I wrote a Ruby program to help remind me of those routines.
- Nov 8, 2022
After some comparison among solutions, I use KaTeX to typeset math in my emails.
- Apr 28, 2020
Hamiltonian mechanics gives us a good way to simulate mechanical systems as long as we can get its Hamiltonian and its initial conditions. I implemented this simulation in RGSS3, the game scripting system shipped with RPG Maker VX Ace.
- Apr 27, 2020
DSL means domain-specific language. Ruby is a powerful script language in terms of building DSLs (as sublanguages of Ruby). In this article, I implemented my idea of a DSL with commands split by space. For example, you may just write a b c
to run the commands a
, b
, and c
one after another! This trick is heavily applied in my project alda-rb. How do I achieve this?
- Apr 8, 2020
In this article, I present minimal examples of a RM game. They only illustrate the basic concepts of how a RM game is structured and what is the running logic of it.
- Feb 9, 2020
Monkey-patching is a powerful tool in programming. In this article, I used techniques of Ruby metaprogramming to define a series of methods def_after
, def_before
, etc. to help monkey-patching. They look graciously in that we can use it to shorten the codes for monkey-patching (avoiding aliasing and repeating codes).