Archive of posts in category “programming”
An 🎃 easy 👻 but 🍬 spooky 💀 Ruby challenge
“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!
- Categories: programming
- Tags: ruby, code golf, fooling around
Labeled
break
,next
, andredo
in RubyMany 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.- Categories: programming
- Tags: meta programming, ruby
I made this, for the number of days in a week is prime
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.
- Categories: programming
- Tags: selfhosting, linux, ruby
Using ntfy to warn me when my computer is discharging
I use udev and systemd to send a notification to my phone via ntfy automatically whenever my laptop is discharging.
- Categories: programming
- Tags: selfhosting, linux
Typesetting math in emails
After some comparison among solutions, I use KaTeX to typeset math in my emails.
- Categories: programming
- Tags: jekyll, ruby, tex
Writing a DSL with commands split by space
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 commandsa
,b
, andc
one after another! This trick is heavily applied in my project alda-rb. How do I achieve this?- Categories: programming
- Tags: ruby, meta programming
Running Jekyll myself
I have got tired of letting GitHub Pages to run Jekyll for me. I cannot use custom plugins! I decide to run Jekyll myself and push the built result to GitHub repo. I wrote a script to do this.
- Categories: programming
- Tags: jekyll
The structure of a basic RM game
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.
- Categories: programming
- Tags: ruby, javascript, rgss
Monkey-patching graciously
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).- Categories: programming
- Tags: ruby, meta programming, long paper