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
@rab
rab / .gitconfig
Last active May 14, 2024 07:05
A good starting point for ~/.gitconfig
# -*- Conf -*-
[color]
branch = auto
diff = auto
status = auto
showbranch = auto
ui = true
# color.branch
# A boolean to enable/disable color in the output of git-branch(1). May be set to always, false (or
@rab
rab / image_size.rb
Created April 3, 2009 12:46
ImageSize finds the width x height
# image_size.rb
#
# Copyright (c) 2007 Rob Biedenharn
# Rob [at] AgileConsultingLLC.com
# Rob_Biedenharn [at] alum.mit.edu
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to
# deal in the Software without restriction, including without limitation the
# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
@rab
rab / test_new_fk_to_old_table.rb
Last active October 4, 2017 23:56
New bigint(20) cannot be FK reference to int(11)
# frozen_string_literal: true
# https://gist.github.com/rab/9b63001d5f926468afdfa00248cf648e
begin
require "bundler/inline"
rescue LoadError => e
$stderr.puts "Bundler version 1.10 or later is required. Please update your Bundler"
raise e
end
# 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
@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
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'
@rab
rab / Ruby 2.0 Module#prepend
Created February 12, 2013 19:29
Experiments with where Module#prepend locates the module in the ancestors chain.
[ruby-2.0.0dev] code/ruby $ irb
irb2.0.0> module Bar; def who; puts 'bar'; end; end
#2.0.0 => nil
irb2.0.0> class Baz; def who; puts 'baz'; end; end
#2.0.0 => nil
irb2.0.0> class Foo < Baz; def who; puts 'foo'; end; end
#2.0.0 => nil
irb2.0.0> Foo.ancestors
#2.0.0 => [Foo, Baz, Object, Kernel, BasicObject]

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 / CycleRGB.ino
Created January 20, 2013 03:13
Arduino Digispark Sketch for cycling the RGB Shield
const int ledRed = 0;
const int ledGreen = 1;
const int ledBlue = 2;
const unsigned long delayTime = 20;
// Base the cycle on the graph ( http://upload.wikimedia.org/wikipedia/commons/5/5d/HSV-RGB-comparison.svg )
// at http://en.wikipedia.org/wiki/HSL_and_HSV#From_HSV
int maxVal = 127;