Skip to content

Instantly share code, notes, and snippets.

View dcrosby42's full-sized avatar

David Crosby dcrosby42

  • Cisco Systems, Inc.
  • Grand Rapids MI
View GitHub Profile
@dcrosby42
dcrosby42 / car_sample.rb
Created May 1, 2012 15:07
Conject blog post samples
class Car
construct_with :chassis, :engine, :highway
end
car = Conject.default_object_context[:car]
@dcrosby42
dcrosby42 / example_use_of_ish.rb
Created October 25, 2012 01:37
Example snippets for #ish blog post
assert_equal record.created_at, Time.now.ish
assert_equal bullet.velocity, 5.25.ish
@dcrosby42
dcrosby42 / jr_serial_port.rb
Created December 4, 2012 05:40
JrSerialPort Example Code
require 'java'
require_relative 'RXTXcomm.jar'
import('gnu.io.CommPortIdentifier')
import('gnu.io.SerialPort') { 'GnuSerialPort' }
class JrSerialPort
NONE = GnuSerialPort::PARITY_NONE
def initialize name, baud, data, stop, parity
@dcrosby42
dcrosby42 / nuke_plant.rb
Created June 7, 2012 03:47
Example of using piece_pipe to generate a health summary of multiple nuke plants based on reactor leakage.
PiecePipe::Pipeline.new.
source([{region: region}]).
step(FetchPowerPlantsByRegion).
step(FindWorstReactor).
step(DetermineStatusClass).
step(BuildPlantHealthSummary).
step(SortByRadiationLevelsDescending).
collect(:plant_health_summary).
to_enum
@dcrosby42
dcrosby42 / Rakefile
Created September 19, 2012 03:18
Rake tasks to use Inkscape to convert SVGs into PDFs.
#
# This Rakefile provides convenience tasks for converting SVG documents to PDF on OS X using Inkscape.
#
# ASSUMES Inkscape IS INSTALLED IN /Applications (see below to modify this assumption).
#
# Examples:
# $ rake convert file=my_drawing.svg # => my_drawing.pdf
# $ rake all # => *.svg now accompanied by *.pdf
#
# David Crosby