Solving Dice Problems with Markov Chains

probability
A colleague asked me an interesting probability problem involving dice. If you roll a die continuously, are you more likely to roll two consecutive 5’s or a 5 immediately followed by a 6? On average how many rolls are required to roll two consecutive 5’s? How about rolling 5 immediately followed by a 6? Interactive Example Roll 5,5 Roll 5,6 Solution Reveal the Solution The state machine diagram for rolling two consecutive 5’s: Read more...

A New Way to Write Microservice Code

programming
Microservices are getting really popular, but have we reached the pinnacle of microservice design? I’ve been imagining a new way to write microservice code where you can annotate functions you want to be microservices. That way, you get the microservice architecture directly baked into the code. Sounds a bit like the new hit buzzword “Infrastructure as code” that everyone is using. Selling the idea The concept is simple. You can decorate functions that you want to be highly available, highly durable, highly reliable, highly resilient, highly fault-tolerant, or anything else scalability preachers might want. Read more...

Dealer Router Pattern in NNG

programming
NNG is a broker-less message queue that is a lightweight alternative to ZeroMQ and supersedes the older nanomsg project. It offers a more “orthogonal” API and does a few things better than ZeroMQ. Thread-safe sockets Websocket transport support POSIX-compliant sockets API True zero-copy messaging A common messaging pattern is Dealer-Router which can be easily implemented using ZeroMQ’s DEALER and ROUTER sockets. Unfortunately, NNG does not have such sockets and implementing the pattern is not trivial. Read more...

Problems with Proxying Images

programming
Let’s face it. Serving images on the web sucks. You have to manage endless formats, dimensions, variants, and more. What are some of the solutions we have at the moment? imgproxy imgix ImageKit Optimole Let’s discuss some flaws that affect each of these services. imgproxy is a self-hosted solution for proxying images. The core is open source but advanced features are paid. One major downside is that you must pay for concurrency, making it not suitable for real-time image transformations. Read more...

The Basketball Tryout

probability
Here’s another interesting probability question that I’ve found in Adrian Torchiana’s Probability Math Puzzles app. You’re trying out for a basketball team, and the coach gives you two options: you can take six shots, or you can take four. In both cases you have to make at least half of the shots, or you’ll be cut from the team. Each shot you take has a fixed probability of succeeding. Read more...

FUSEing for Fun

programming
Something that I find absolutely fascinating are Filesystems in USErspace (FUSE). What is FUSE? FUSE, to put it simply, allows people to implement filesystems in userspace. Filesystems are traditionally implemented in the kernel, but when using FUSE, non-privileged programs can be used to create custom filesystems. Why is it cool? Filesystems don’t need to be concrete! You can implement virtual filesystems with little or no limitations. Don’t want files to write to disk? Read more...

Generating Images with Serverless

programming
One thing I’ve always wanted to do was write a serverless function that could generate CS:GO crosshair images. The serverless platform that I chose is Cloudflare Workers which utilizes a vast edge network and supports 0 ms cold starts. Writing a serverless function for this task didn’t seem too difficult, but I quickly ran into some issues. Using node-canvas Modern browsers are equipped with the Canvas API which makes it extremely easy to create 2D graphics. Read more...

The Gambler's Ruin

probability
Here’s an interesting probability question that I’ve found in Adrian Torchiana’s Probability Math Puzzles app (highly recommended!) back in high school. You find $2 in your pocket and decide to go gambling. Fortunately, the game you’re playing has very favorable odds: each time you play, you gain $1 with probability 3/4 and lose $1 with probability 1/4. Suppose you continue playing so long as you have money in your pocket. Read more...

Secret Sharing by Example

cryptography
1. The Scenario You are haphazardly appointed as the group in charge of authorizing the launch of your country’s nuclear weapons. No idea how you got appointed, maybe you were just unlucky 🤷‍♂️. Knowing that you are tasked with managing the launch code, you’ve decided that the only way to ensure no one abuses this code is to share the code in such a way that you and your friends must come together to reveal the secret code. Read more...

Algorithms in Javagony

programming
The Javagony First coined by flawr, Javagony is Java with a few statements made not available. Here are the statements that are not available: for (){} if (){} else if (){} else {} while (){} do {} while () switch (){} ?: These statements can be substituted for try catch statements and recursion. Although Javagony is not the least bit fun to write, it makes you think about clever tricks that utilize many of Java’s obscure features. Read more...
1 of 1