Build an Algorithm Processing Website

Why Care?

A friend of mine was interested in an idea for beating the casino at roulette.

His theory is that if he keeps playing either red or black, but adding to the bet, there is a mathematical certainty of winning at some point.

First spin, go red with $10.

Second spin, go red with $22.

Third spin, go red with $33.

Or something like that.

I told him I could write a program that would tell him the number of consecutive results from 50/50 roulette spins.

This is how we did it:

Tutorial For Launching Simple Algorithm Tools

Learning Algorithmic Technology

At this tutorial’s core, this is an HTML5 tutorial.

HTML5 incorporates HTML and JavaScript together. HTML5 incorporates CSS as well, but this tutorial doesn’t discuss that because design hasn’t been addressed here.

This tutorial takes the watcher on a journey of creating a simple web tool. In it we:

  • Start a project using command line interface (CLI) tools
  • Write the JavaScript algorithmic logic for the probability
  • Write the HTML5 user input form and clickable submit button
  • Link the JavaScript algorithm and the HTML5 input to work as a graphic user interface
  • Write clear directions for what the tool is used for
  • Initialize the project as a git project (version history software)
  • Sync our project with a GitHub repository
  • Publish the tool using GitHub pages

The tool is now available on the internet to whomever cares to view it. Click here to check it out:

www.ianrobinson.net/roulettespinner

If I were to answer my buddies specific question, this tool need more work. We would need to incorporate the increments of betting in order for us to get a specific plan to beat roulette…. but at the end of the day, this isn’t about beating the casinos. Even if we started beating casinos, the casinos would just kick us out.

The cool thing about this is that it helps us think algorithmically about complex issues. Using computers as tools, we can run massive tests in the blink of an eye. My computer only starts to have slow results (requiring 2-3 seconds) around 100 million spins. Imagine how long it would take to do 100 million spins in real life.

Algorithms are fun.

Fixing “Single arity template handlers are deprecated” error when upgrading from Rails 5.2 to Rails 6.0

DEPRECATION WARNING: Single arity template handlers are deprecated. Template handlers must
now accept two parameters, the view object and the source for the view object.
Change:
  >> Coffee::Rails::TemplateHandler.call(template)
To:
  >> Coffee::Rails::TemplateHandler.call(template, source)
 (called from at /Users/MediocreManta/Desktop/freedom_podcasting/Rakefile:6)

This was an error I encountered while upgrading my application from Rails 5.2 to Rails 6.0. I found the fix on this Github page, but I thought I’d write it out here to make it a bit clearer for the young programmers out there.

To fix it, I upgraded the coffee-rails by doing the following:

  • Open Gemfile
  • Change gem 'coffee-rails', '~> 4.2'` to `gem 'coffee-rails', '~> 5.0.0'
  • Stop server in terminal by pressing ctrl + s
  • Running the command bundle
  • Restarting the server with rails s

Hope this helps!

I’ve added some language to the Rails documentation via this PR. Hopefully the powers that be accept the addition so future generations can skip having to look this up.