Skip to content

Instantly share code, notes, and snippets.

View SVMBrown's full-sized avatar

Scot Brown SVMBrown

  • Orillia, Ontario, Canada
  • 17:07 (UTC -04:00)
View GitHub Profile
(defn gen-doors []
(update (vec (repeat 3 0)) (rand-int 3) inc))
(defn stay [doors chosen]
(doors chosen))
(defn switch [doors chosen]
(let [reveal (rand-nth
(keep
(fn [[idx v]]
(def right
{:N :E
:E :S
:S :W
:W :N})
(def left
(clojure.set/map-invert right))
(defn bound [bottom top n]
(defn frame-size [[a :as rolls]]
(if (= 10 a)
1
2))
(defn frame-score [[a b c :as rolls]]
(if (>= 10 (+ a b))
(+ a b c)
(+ a b)))
class Post < ActiveRecord::Base
scope :task -> { joins(:ideas)}
scope :crowdfunding -> { joins(:crowdfunding)}
scope :tailored_for_user -> { order("created_at DESC").tagged_with.current_user.tag_list }
scope :popular -> { order("cached_votes_score DESC") }
...
end
class PostsController < ApplicationController
...
@SVMBrown
SVMBrown / Cartesian Product
Created May 6, 2015 14:33
Cartesian Product
(defn cartesianProduct [a b]
(clojure.set/union
(map
#(into []
(list*
(first b)
(if (coll? %)
%
(list %)
)