Skip to content

Instantly share code, notes, and snippets.

View rab's full-sized avatar
👨‍💻
Home Office is a mess (as usual)

Rob Biedenharn rab

👨‍💻
Home Office is a mess (as usual)
View GitHub Profile
# frozen_string_literal: true
def get_input(prompt = '--> ')
puts ''
puts 'Please enter a number, odd or even.'
print prompt
# if the end-of-input was reached and gets returned a nil
# or the word 'exit' or 'quit' appears (ignoring case) in the input
if (input = gets).nil? || /exit|quit/i =~ input
nil # just return a nil
else
module Beer
class Song
VERSE_TEMPLATE = "%d bottles of beer on the wall, %d bottles of beer.\n" +
"Take one down and pass it around, %d bottle%s of beer on the wall.\n"
PENULTIMATE_VERSE = "1 bottle of beer on the wall, 1 bottle of beer.\n" +
"Take it down and pass it around, no more bottles of beer on the wall.\n"
FINAL_VERSE = "No more bottles of beer on the wall, no more bottles of beer.\n" +
"Go to the store and buy some more, 99 bottles of beer on the wall.\n"
def verses(starting, ending=0)
@rab
rab / Gemfile
Created May 21, 2013 23:43 — forked from jimweirich/Gemfile
source 'https://rubygems.org'
gem 'celluloid'
gem 'celluloid-io'

Pi+RoR+Heroku Demo

Background

Over the course of the past two school years, my colleague Rob Biedenharn and I have been working with Tom Brinkmann's students at Little Miami High School, attempting to teach them Web development using Ruby on Rails to aid in their participation in Business Professionals of America competitions and to provide them with skills very much in demand locally.

We provided the students all the usual links to facilitate self-guided learning on Windows PCs but it quickly became evident that we were facing two challenges:

@rab
rab / RobGreg.rb
Created November 21, 2012 01:13 — forked from st23am/robot3.rb
BaselineBot
require 'rrobots'
class RobGreg
include Robot
attr_reader :events
def near_a_wall?
x <= size || y <= size || x >= battlefield_width - size || y >= battlefield_height - size
end
@rab
rab / Bot.scala
Created November 14, 2012 01:02 — forked from geofflane/Bot.scala
Scalatron Bot
import util.Random
// rab - Rob Biedenharn
// based on Geoff Lane's Bot
// Wed Nov 14 17:44:48 EST 2012
/**
* This bot builds a 'direction value map' that assigns an attractiveness score to
* each of the eight available 45-degree directions. Additional behaviors:
* - aggressive missiles: approach an enemy master, then explode
@rab
rab / gist:2938025
Created June 15, 2012 18:27 — forked from st23am/gist:2937073
Git branch parsing
function parse_git_dirty {
[[ $(git status 2> /dev/null | tail -n1) != "nothing to commit (working directory clean)" ]] && echo "*"
}
@rab
rab / hello.clj
Created May 8, 2012 22:14 — forked from gigasquid/swarmcoding
Swarm coding instructions
(ns cincyfp.hello)
(+ 1 1)
;; given 3 integers in a sequence
;; generate the number of lights that are on in a berlin clock,
;; returning 5 rows
(defn make-counts [[hours minutes seconds]]
[
(- 1 (mod seconds 2))
class Person
include ActiveModel::MassAssignmentSecurity
attr_accessor :name, :birthday, :handsomeness
attr_protected :handsomeness
def initialize(params = {})
self.attributes = params
end
def mask(x)y=x.dup;y[6...-4]=y[6...-4].gsub(/./,'*');y end