Skip to content

Instantly share code, notes, and snippets.

app.factory('trackMethods', [
'ApiKey',
'measure',
function (ApiKey, measure) {
return {
getUrl: function () {
return this.resource_uri +
'?apikey=' + ApiKey;
},
"use strict";
describe("trackMethods factory", function () {
var trackMethods;
beforeEach(module("agora"));
beforeEach(function () {
module(function ($provide) {
$provide.value('ApiKey', "fakeApiKey");
"use strict";
app.controller('TracksIndexPageController', [
'$scope',
'$filter',
'$http',
'Track',
'currentUser',
'Categories',
'AccumulatedStatistics',
"use strict";
app.controller('TracksIndexPageController', [
'$scope',
'Categories',
'accumulatedStatistics',
'categoryListWidgetFactory',
'Pagination',
'activitiesWidgetFactory',
'applicationEvents',
(ns gilded-rose.core-test
(:use midje.sweet)
(:use [gilded-rose.core]))
(defn pass-days [n inventory]
(nth (iterate update-quality inventory) n))
(facts
"about gilded rose"
(ns gilded-rose.core)
(defn update-quality [items]
(map
(fn[item] (cond
(and (< (:sell-in item) 0) (= "Backstage passes to a TAFKAL80ETC concert" (:name item)))
(merge item {:quality 0})
(or (= (:name item) "Aged Brie") (= (:name item) "Backstage passes to a TAFKAL80ETC concert"))
(if (and (= (:name item) "Backstage passes to a TAFKAL80ETC concert") (>= (:sell-in item) 5) (< (:sell-in item) 10))
(merge item {:quality (inc (inc (:quality item)))})
;;--------------
;;
;; Sequence comprehensions
;;
;;--------------
;; Clojure generalizes the notion of list comprehension to sequence comprehension
;; Clojure comprehension uses the for macro
@trikitrok
trikitrok / bank_account_test.clj
Created May 12, 2015 15:31
Bank Account exercise tests from Exercism
(ns bank.test (:use clojure.test))
(load-file "bank.clj")
;; The BankAccount module should support four calls:
;;
;; open-account
;; Called at the start of each test. Returns a BankAccount.
;;
;; close-account account
@trikitrok
trikitrok / BankAccountReadme.md
Created May 12, 2015 15:32
Bank Account README from Exercism

Bank Account

Bank accounts can be accessed in different ways at the same time.

A bank account can be accessed in multiple ways. Clients can make deposits and withdrawals using the internet, mobile phones, etc. Shops can charge against the account.

Create an account that can be accessed from multiple threads/processes (terminology depends on your programming language).

@trikitrok
trikitrok / fizzbuzz.clj
Last active August 29, 2015 14:21
fizzbuzz not depending on rules order
(ns fizz-buzz2.core)
(defn- divisible-by? [divisor number]
(zero? (mod number divisor)))
(defn- divisible-only-by-3? [number]
(and (divisible-by? 3 number)
(not (divisible-by? 5 number))))
(defn- divisible-only-by-5? [number]