Skip to content

Instantly share code, notes, and snippets.

View theotherzach's full-sized avatar

Zach Briggs theotherzach

View GitHub Profile
(define tests
'((eq? 5 (+ 2 3))
(eq? 5 (+ 3 3))))
(define (test-iter test-list results)
(cond
((null? test-list) results)
(else
(test-iter
(cdr test-list)
  • miracle
  • solution for house
  • setup sparring stuff
  • exercism group

Placeholder For Bottles Solutions

Bottles Challenge 2

Hand Cranked Human Pattern Matching

This is not a challenge so much as a new (to me) way of looking at refactoring. As always, complete in your language of choice. First, some background:

The ruby example below maximizes simplicity at the expense of flexibility.

class Bottles

Bottles Strategy Pattern

Challenge 1: Refactor starting from here to pattern matching/ strategy pattern so that neither Bottles nor Verse would need to be altered in order to replace verse 6 with lyrics regarding 6 packs. (Sample in the comments below. Any language of your choice as always.)

Challenge 2: Start thinking about a world where you can write 6.to_bottle. (Or however you would create a bottle number primitive in your language of choice.) I recommend against attempting to hand-crank your way there.

class Bottles
  def sing
// RE: https://twitter.com/j3/status/448686275751469056
function DNA(sequence){
"use strict";
var displayedMarkers = ['A', 'T', 'C', 'G'];
var acceptedMarkers = displayedMarkers + ['U'];
function stripCommas(input) {
return input.replace(/,/, '');
}
function ExpenseForm($el) {
$el.on('submit', clean)
function clean() {
$el.find('input[type=text]').each(function (index, field) {
field.value = stripCommas(field.value);

The problem: Active Record objects have built in serialization (to_json), but I want to use vanilla objects wherever possible.

My solution:

class Report
  attr_reader :data, :group_reports
  def initialize(data)
    @data = data
    @group_reports = (data.weekly_group_reports + [data.weekly_used_report]).map { |group_report|
<div class="large-6 columns" ng-controller="metricCtrl">
<select ng-model="selected['metric']" ng-options="m.name for m in metrics"></select>
<table>
<thead>
<tr>
<th>Dealership</th>
<th ng-repeat="metric in metrics" class="{{ activeClass(metric, selected) }}">{{ metric.name }}</th>
</tr>
</thead>
<tbody>
  • good code
  • steps of the walkthrough
  • javascript concepts