This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| (ns rubric.core) | |
| (defn average | |
| "Averages a set of scores" | |
| [& scores] | |
| (/ (apply + scores) (count scores))) | |
| (defn- sum-of | |
| "Sum the collection after applying the given function" | |
| [f coll] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| (ns simple-csp.core | |
| ( :refer-clojure :exclude [==]) | |
| (:use clojure.core.logic)) | |
| (defne arco [x y] | |
| ([:sa :wa]) | |
| ([:sa :nt]) | |
| ([:sa :q]) | |
| ([:sa :nsw]) | |
| ([:sa :v]) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| (ns simple-csp.core) | |
| (def arcs [ | |
| #{:sa :wa} | |
| #{:sa :nt} | |
| #{:sa :q} | |
| #{:sa :nsw} | |
| #{:sa :v} | |
| #{:wa :nt} | |
| #{:nt :q} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ; Standard k nearest neighbors classifier | |
| ; Does not handle | |
| ; > 2 classes | |
| ; even values of k | |
| ; any bad input, really | |
| ; | |
| ; David Andrzejewski ([email protected]) | |
| ; | |
| ; Command-line arguments | |
| ; 0 training data filename |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* | |
| Hi, I'm Reservation. | |
| I dont need an interface because I am a carrier of data. | |
| Like a good carrier, I can be instantiated in any layer and used | |
| in any other layer. | |
| [CR] Nomenclature! "Data carriers" are *not* domain models. They are | |
| DataTransferObjects (DTOs). What I call domain model, you seem to call | |
| Service Object, whereas what I mean by "Service Object" is something | |
| altogether different...so maybe this is part of the reason we're not |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* This is my interface, my API, my contract. */ | |
| interface IReservation { | |
| IList<IGuest> getGuests(); | |
| Duration getLength(); | |
| Amount getBalance(); | |
| Amount getTotal(); | |
| bool cancel(); | |
| // By the way pay() could have been in IPaymentMethod as well but you know what? | |
| // I called first and so I win! | |
| // Or both of us would end up implementing pay() in which case we would smartly delegate |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| module SQLGrowler | |
| class Subscriber < ActiveRecord::Railties::Subscriber | |
| def sql(event) | |
| super | |
| g('%s (%.1fms) %s' % [event.payload[:name], event.duration, event.payload[:sql].squeeze(' ')]) | |
| end | |
| end | |
| def self.enable | |
| if Kernel.respond_to?(:g) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env ruby | |
| puts "looking for the gems to upgrade..." | |
| gem_info = Struct.new(:name, :version) | |
| to_reinstall = [] | |
| Dir.glob('/Library/Ruby/Gems/**/*.bundle').map do |path| | |
| path =~ /.*1.8\/gems\/(.*)-(.*?)\/.*/ | |
| name, version = $1, $2 | |
| bundle_info = `file path` | |
| to_reinstall << gem_info.new(name, version) unless bundle_info =~ /bundle x86_64/ | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env ruby | |
| require 'rubygems' | |
| require 'octopi' | |
| require 'choice' | |
| include Octopi | |
| Choice.options do | |
| header '' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/sh | |
| trap "exit 2" 1 2 3 13 15 | |
| OPTS="--no-rdoc --no-ri" | |
| if [ -f "/etc/lsb-release" ]; then | |
| ### bootstrap with git. | |
| apt-get update -y && apt-get upgrade -y --force-yes && apt-get install -y git-core vim | |