Skip to content

Instantly share code, notes, and snippets.

View bokmann's full-sized avatar

David Bock bokmann

View GitHub Profile
@bokmann
bokmann / JRuby Awesome Performance
Last active August 31, 2023 07:32
brief summary of massive performance improvements with JRuby
# Thee will be more information here when I share the entire problem space I'm working on, but
# in short, this is preview material for my second talk in a series called "What Computer Scientists Know".
# The first talk is on recursion, and goes through several examples., leading up to a problem based
# on a simple puzzle that initial estimates based on performance of a previous puzzle would take years
# to solve on modern computers with the techniques shown in Ruby. That sets the stage for improving the
# performance of that problem with threading, concurrency, and related tuning.
#
# The second talk is on threading and concurrency, touching on algorithmic performance as well.
# Using some knowledge of the problem (board symmetry, illegal moves, etc), we reduce the problem space
# to about .5% of what we initially thought it was. Still, the initial single threaded solution took more
@bokmann
bokmann / browniechew.md
Last active April 28, 2023 01:27
Javaguy's Chewy Brownie Manifesto

For about 2 months I've been making brownies. I've consulted dozens of cookbooks, websites, and TV shows looking for the ultimate chewy brownie recipe. I think I have constructed it from several sources:

  1. James' Beard's 1972 American Cookery
  2. Cooks Illustrated "The Science of Good Cooking"
  3. Good Eats Reloaded "Art of Darkness II"

Elements of this recipe are taken from all three sources, along with testing in my own kitchen. I still have more tests of this recipe to do before I call it 'final', but enough people have been asking for it I've decided to share it as a 'beta brownie'.

Brownies fall someplace in the 'brownie triangle' between cakey, chewy, and fudgy. IMHO, brownies are the only true form to get 'chew' out of a baked good beyond a pizza crust... if I want cake I'll eat that. So I want something on the fudgy/chewy side of the triangle, leaning toward the chew. I've pulled every trick I can find from every cookbook to get that to work.

@bokmann
bokmann / no_such_thing.rb
Created February 23, 2012 15:43
The code of the talk from my Feb 22nd Arlington Ruby talk 'There is No Such Thing as Metaprogramming'.
# This is the code from my 'There is No Such Thing as Metaprogramming' talk,
# which premiered at the Arlington, VA Ruby Users Group on Feb 22nd.
# Without the deliver and walk-through to the solution below this example
# will be missing quite an important bit of content (mainly the tracking of
# 'self' while developing the solution, but it still a useful read.
# Here is the Toddler with no metajuju. Note that the developer, as well as
# the code, is completely unuaware of the interpreter. A developer with a
# background in compiled languages would be comfortable looking at this.
https://www.dcode.fr/caesar-cipher
Wkh wzr zruvw Pduyho yloodlqv duh Wkdqrv dqg Ornl
https://www.dcode.fr/monoalphabetic-substitution
EO EB M YXFETN TV ZEQER GMF.
FXLXR BYMZXBKEYB, BOFECEWS

Keybase proof

I hereby claim:

  • I am bokmann on github.
  • I am bokmann (https://keybase.io/bokmann) on keybase.
  • I have a public key ASC0rVKIk0CgFYKyZw5fX99-1eWbAdPz6nwitYLIVQeO-go

To claim this, I am signing this object:

@bokmann
bokmann / ActiveRepository.rb
Created March 27, 2012 16:15
ActiveRepository Strawman
# MOTIVATION: As rails apps are growing, people are noticing the drawbacks
# of the ActiveRecord pattern. Several apps I have seen, and several
# developers I have spoken to are looking towards other patterns for object
# persistence. The major drawback with ActiveRecord is that the notion
# of the domain object is conflated with what it means to store/retrieve
# it in any given format (like sql, json, key/value, etc).
#
# This is an attempt to codify the Repository pattern in a way that would
# feel comfortable to beginner and seasoned Ruby developers alike.
#
@bokmann
bokmann / the_daycare.txt
Last active April 2, 2017 11:43
This problem was originally in the 2015 VCU Computer Science Competition
Problem A The Daycare
The daycare Nannies R Us has installed a new high-tech system for keeping track of which children are under
its supervision at any moment in time. Each parent of a child has a card with a unique ID, where the ID is
some integer x. Every morning, the parent swipes the card at a card-reader when dropping their child off at
the daycare. The system then adds x to an array of integers. In the evening, when the parent comes to pick
up the child, the same card is swiped, and a second copy of x is added to the list. Each night at midnight,
the array is wiped clean and reset to have zero elements. In this way, the daycare can quickly check every
afternoon which children are yet to be picked up by their parents by picking out the array elements that
occur precisely once. Unfortunately, at 4:55 pm on Friday, March 13, 2015, the daycare realizes that
somewhere in their daycare is precisely one child who is yet to be picked up – can you help them determine
@bokmann
bokmann / triangle_peg.rb
Last active June 14, 2016 18:57
An example from "What Computer Scientists Know: Thinking Recursively, Part 2. In this example we are going to explore how we use our newfound knowledge of recursion to search through all the solutions of a simple puzzle using recursive backtracking.
# This is a programming chellenge from David Bock's series
# "What Computer Scientists Know". This is a problem that can
# be used to discuss a bunch of computer science topics, but
# as I'm providing most of the skeleton of the solution, the
# point of this exercise is to demonstrate 'recursive backtracking'.
# http://en.wikipedia.org/wiki/Backtracking
# this problem is based on the classic 'triange peg game', a common
# sight in roadside diners in America, in particular, Cracker
@bokmann
bokmann / C4Board.rb
Last active January 1, 2016 18:49
A Connect Four Coding Challenge form my talk series, "What Computer Scientists Know"
# This is an example Connect Four board. It is a data structure
# that represents the current state of the board game; the colors
# of pieces already in position, the current player to move, and
# also supplies a 'move(x)' method, where you just specify the
# column to drop a piece in; the board will automatically 'drop'
# the piece to the next available position, set the player to
# the opponent, and return a brans new instance of the board.
#
# This may seem strange to those of you who have not written
# board game playing apps before, but it is common practice to make
@bokmann
bokmann / C4Board.rb
Created December 9, 2013 23:47
a board class template for connect 4, for a coding challenge.
class C4Board
BLACK = :black
RED = :red
EMPTY = nil
# returns an array of all the columns a piece can be dropped in currently
def moves
end