Examining Parlays in Prediction Markets

probability
It’s been a while since I last wrote on this blog. 😅 I’d like to share a quick post on something I’ve been noticing on prediction markets like Polymarket regarding parlay contracts. Overview of Prediction Markets For those who don’t know, here’s a quick primer on how prediction markets work: A Prediction Market is an “Information Market” A prediction market, similar to an option market, is a platform where participants can buy and sell contracts that pay out based on the outcome of future events. Rather than paying out based on the price of an underlying asset, like a stock option, these contracts pay out based on a specific events, such as the outcome of an election or a sports game. Ignoring the financial incentives, prediction markets can be seen as a way to aggregate information from a diverse group of participants to make predictions about future events. Read more...

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. Fortunately, using NNG’s raw mode sockets we can emulate Dealer-Router. 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. Moreover, it can be expensive to self-host multiple image proxies, making it hard to deploy image proxies to the edge, increasing latency to your users. 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. What is the probability of making a successful shot, in which it makes no difference what option you choose? 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? Implement a “ramdisk” in FUSE. Want to use Amazon S3 as if it is a hard drive on your computer? Use s3fs-fuse. Want to be evil 😈 and store files on Google sheets? Use spreadsheetfs. Introducing dsfs Dsfs is an experimental filesystem written in Go and backed by Discord attachments. 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. Although this API is meant to be used in the browser, Automattic (the maker of WordPress) has an implementation of Canvas for Node.js called node-canvas. 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. If you lose your first two bets, you go broke and go home after only two rounds; but if you win forever, you’ll play forever. 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