Instruction
stringlengths
14
778
input_code
stringlengths
0
4.24k
output_code
stringlengths
1
5.44k
Check the namespace appears in the fact output.
(ns implementation.firm-check-failures (:use midje.sweet midje.test-util)) ; The namespace of the test should appear in test failure report (capturing-failure-output (fact (+ 1 1) => 4) (fact @fact-output => #"implementation.firm-check-failures"))
Add node definition for the artifacts server
(ns circle.backend.nodes.circle-artifact (:require pallet.core pallet.phase [pallet.action.user :as user] [pallet.action.directory :as directory] [pallet.action.package :as package] [pallet.crate.java :as java] [pallet.action.remote-file :as remote-file] [pallet.action.service :as service] ...
Add unit test for util.clj
(ns ruuvi.util-test (:require [ruuvi.util :refer :all] [midje.sweet :refer :all] ) ) (fact "process-id returns process id" (let [pid (process-id)] pid => #(> % 0) ))
Add DataScript schema generation for entities
(ns workflo.macros.entity.datascript (:require [datascript.core :as d] [workflo.macros.entity.schema :as es])) (defn attr-schema [attr-opts] (reduce (fn [opts opt] (cond-> opts (= :ref opt) (assoc :db/valueType :db.type/ref) (= :many opt) ...
Add more examples from chapter 5
(ns clojure.cfbt.ch05) (defn wisdom [words] (str words ", Daniel-san")) (wisdom "Always bathe on Friday") ;; "Always bathe on Friday, Daniel-san" ;; non-pure functional (defn year-end-evaluation [] (if (> (rand) 0.5) ("You get a raise!" "Better luck next year!"))) (defn analysis [text] (str "Char...
Introduce unit tests for satellite.recipes.
;; Copyright 2015 TWO SIGMA OPEN SOURCE, LLC ;; ;; Licensed under the Apache License, Version 2.0 (the "License"); ;; you may not use this file except in compliance with the License. ;; You may obtain a copy of the License at ;; ;; http://www.apache.org/licenses/LICENSE-2.0 ;; ;; Unless required by applicable law o...
Test clblast engine on CPU.
(ns uncomplicate.neanderthal.clblast-cpu-test (:require [midje.sweet :refer :all] [uncomplicate.commons.core :refer [with-release]] [uncomplicate.clojurecl [core :refer [*command-queue* with-platform platforms devices with-queue with-context context]] [legacy :refer [...
Add map file generation service
{ :name "make-map", :path "", :func (let [ot (volatile! nil) leftover (volatile! "") m {0 "+", 16 "-"}] (fn [map-file rec] (when (nil? (deref ot)) (infof "make-maps: Opening %s" map-file) (vswap! ot (fn[_ f] (aio/open-file f :out)) map-file)) ...
Add code for seeding database
(ns cglossa.seeds (:require [datomic.api :refer [delete-database create-database transact connect tempid db]] [datomic-schema.schema :refer [part schema fields generate-parts generate-schema]] [cglossa.server :as server] [cglossa.data-import.shared :as data-import])) (defn dbschem...
Add tests for the user config API (the routes located in user_config_resource.clj).
(ns mofficer.service.user-config-resource-test (:use [midje.sweet]) (:require [mofficer.infrastructure.datastructures.either] [cheshire.core :as ches] [mofficer.domain.business.user-config-business :as user-config-business] [mofficer.service.user-config-resource :as user-config-r...
Use generative testing of (· demunge munge)
(ns grimoire.util-test (:require [grimoire.util :as util] [clojure.test :refer :all] [clojure.test.check.clojure-test :refer [defspec]] [clojure.test.check :as tc] [clojure.test.check.generators :as gen] [clojure.test.check.properties :as prop])) (defspec m...
Add namespace for concurrency primitives.
(ns apio.concurrency.core (import (java.util.concurrent ForkJoinPool))) ;; TODO: initialize forkjoin pool in dynamic context ;; using dynamic loaded configuration. (def *thread-pool* (ForkJoinPool.))
Add a test for the permanent fs
(ns doctopus.storage.storage-impls.permanent-fs-test (:require [clojure.test :refer :all] [doctopus.files :as files] [doctopus.storage.storage-impls.permanent-fs :refer :all] [me.raynes.fs :as fs])) (def test-vec (files/read-html "resources/test/html")) (deftest permanent-fs-test...
Add a basic drawing cell function
(ns life.core (:require [om.core :as om :include-macros true] [om.dom :as dom :include-macros true])) (defonce app-state (atom)) (enable-console-print!) (defn draw-cells [] (let [context (.getContext (.getElementById js/document "canvas") "2d")] (doseq [n (take 10 (repeatedly 1)) ] (.fillRe...
Add a simple test for init
(ns worker.main-test (:use clojure.test worker.main)) (deftest init-test (is (= nil (init "http://github.com/peritus/geocommit" "github.com/peritus/geocommit"))))
Add an integration test for victorops
(ns riemann.victorops-test (:use riemann.victorops clojure.test) (:require [riemann.logging :as logging])) (def api-key (System/getenv "VICTOROPS_API_KEY")) (def routing-key (System/getenv "VICTOROPS_ROUTING_KEY")) (when-not api-key (println "export VICTOROPS_API_KEY=\"...\" to run these tests.")) (whe...
Add tests for executor api.
(ns futura.executor-tests (:require [clojure.core.async :as a] [clojure.test :refer :all] [clojure.java.io :as io] [clojure.pprint :refer [pprint]] [futura.executor :as exec])) (deftest iexecutor-tests (let [p (promise)] (exec/execute #(deliver p true)) (is (...
Add new namespace for id generation
(ns chazel.ids (:import (com.hazelcast.core HazelcastInstance IdGenerator) (com.hazelcast.flakeidgen FlakeIdGenerator))) (defn safe-generator ^FlakeIdGenerator [^HazelcastInstance hz ^String gname] (.getFlakeIdGenerator hz gname)) (defn unsafe-generator ;; DEPRECATED ^IdGenerator [^HazelcastIns...
Add a basic datomic component
(ns comic-reader.database (:require [com.stuartsierra.component :as component] [datomic.api :as d])) (def uri "datomic:dev://localhost:4334/comics") (defrecord Database [uri conn] component/Lifecycle (start [component] (println "Comic-Reader: Connecting to database...") (let [uri (:uri comp...
Add tests for ns vault.store.
(ns vault.store-test (:require [clojure.test :refer :all] [vault.blob :as blob] [vault.store :refer :all])) (deftest blob-containment (let [blobref (blob/hash-content :sha1 "foo bar")] (is (false? (contains-blob? (reify BlobStore (stat [this blobref] nil)) blobref))) (is (true? (co...
Add compare flow for tnseq
{:nodes {:comp {:name "calc-tnseq-fitness", :type "tool", :args []} :prn1 {:type "func", :name "prn"}}, :edges {:comp [:prn1]}}
Implement initial simplistic engine test
(ns io.cyanite.engine-test (:require [io.cyanite.engine :as e] [com.stuartsierra.component :as component] [clojure.test :refer :all] [io.cyanite.test-helper :refer :all])) (deftest engine-test (with-config {:engine (component/using (e/map->Engine ...
Work around dangerous default behaviour of Clojure.
(ns clojars.main (:require [clojars.scp] [ring.adapter.jetty :refer [run-jetty]] [clojars.web :refer [clojars-app]] [clojars.promote :as promote] [clojars.config :refer [config configure]] [clojure.tools.nrepl.server :as nrepl]) (:import com.martiansoftwar...
(ns clojars.main (:require [clojars.scp] [ring.adapter.jetty :refer [run-jetty]] [clojars.web :refer [clojars-app]] [clojars.promote :as promote] [clojars.config :refer [config configure]] [clojure.tools.nrepl.server :as nrepl]) (:import com.martiansoftwar...
Add stub for grade-school exercise
(ns grade-school) (defn grade [] ;; <- arglist goes here ;; your code goes here ) (defn add [] ;; <- arglist goes here ;; your code goes here ) (defn sorted [] ;; <- arglist goes here ;; your code goes here )
Add code to interface with DAISY pipeline
(ns mdr2.pipeline1 (:use [clojure.java.shell :only [sh]]) (:require [clojure.string :as s])) (defn validate [file] (sh "daisy-pipeline" "/usr/lib/daisy-pipeline/scripts/verify/ConfigurableValidator.taskScript" (str "--validatorInputFile=" file) ;; make sure it has to be a DTBook file "--v...
Add a test for the compile task.
(ns test-compile (:use [clojure.test] [clojure.contrib.java-utils :only [delete-file-recursively file]] [clojure.contrib.shell-out :only [with-sh-dir sh]])) (deftest test-compile (delete-file-recursively (file "sample" "classes" "nom") true) (with-sh-dir "sample" (sh "lein" "compile")) (is ...
Test for column name generator.
(ns grafter.sequences-test (:require [clojure.test :refer :all] [grafter.sequences :refer :all])) (deftest column-names-seq-test (testing "iterates alphabet repeatedly like it's numeric" (is (= ["A" "B" "AA" "AB" "BA" "BB" "AAA" "AAB"] (take 8 (column-names-seq "AB"))))))
Add utilities for showing titles
(ns re-demo.utils (:require [re-com.core :refer [title]] [reagent.core :as reagent])) (def panel-title-style { :font-family "Ubuntu" :font-weight "300" ;; :font-style "bold" :font-size "24px" :color "#FF6522" ;; orange :margin-top "7px" }) (defn panel-t...
Add benchmarks for different byte buf strategies
(ns caesium.byte-bufs-benchmark (:require [caesium.crypto.secretbox :as sb] [caesium.crypto.secretbox-test :as st] [caesium.byte-bufs :as bb] [criterium.core :refer [bench]] [clojure.test :refer [deftest]])) (defn secretbox-easy-wrap-byte-array [m n k] (let [c (byt...
Add test case for cljam.cigar
(ns cljam.t-cigar (:require [midje.sweet :refer :all] [cljam.cigar :as cgr])) (fact "about parse-seq" (cgr/parse-seq "8M4I4M1D3M" "TTAGATAAAGAGGATACTG") => '({:n 8, :op \M, :seq [\T \T \A \G \A \T \A \A]} {:n 4, :op \I, :seq [\A \G \A \G]} ...
Write a basic unit test for the http handler
(ns icecap.handlers.http-test (:require [clojure.core.async :as a] [manifold.deferred :as d] [icecap.handlers.core :refer [execute]] [icecap.handlers.http] [aleph.http :as h] [clojure.test :refer :all])) (def step {:type :http :url "http://www.example.com...
Move emacs helpers to clj folder
(ns koeeoadi.emacs-helpers) (defn plist-to-map [plist] (let [plist-to-map' (fn [x] (if (coll? x) (into {} (mapv #(into [] %) (partition 2 2 x))) x))] (vec (reverse (mapv plist-to-map' plist)))))
Update codeina plugin version to 0.3.0.
{:dev {:dependencies [[org.clojure/tools.namespace "0.2.11"] [criterium "0.4.3"]] :source-paths ["dev"] :codeina {:sources ["src"] :reader :clojure :target "doc/dist/latest/api" :src-uri "http://github.com/funcool/cats/blob/master/" :src-uri-prefix "...
{:dev {:dependencies [[org.clojure/tools.namespace "0.2.11"] [criterium "0.4.3"]] :source-paths ["dev"] :codeina {:sources ["src"] :reader :clojure :target "doc/dist/latest/api" :src-uri "http://github.com/funcool/cats/blob/master/" :src-uri-prefix "...
Add lightweight abstraction for data encoding with nippy.
;; Copyright 2015 Andrey Antukh <niwi@niwi.nz> ;; ;; Licensed under the Apache License, Version 2.0 (the "License") ;; you may not use this file except in compliance with the License. ;; You may obtain a copy of the License at ;; ;; http://www.apache.org/licenses/LICENSE-2.0 ;; ;; Unless required by applicable law ...
Add a 'junit-with-default' emission plugin.
(ns ^{:doc "JUnit formatter for Midje that keeps original stdout output."} midje.emission.plugins.junit.with-default (:require [midje.emission.plugins.junit :as junit] [midje.emission.plugins.default :as default] [midje.emission.state :as state])) (defn merge-functions [oldf newf] (fn [& ...
Create FileSystemWatcher with constructor fn
(ns figwheel-sidecar.components.css-watcher (:require [figwheel-sidecar.components.file-system-watcher :as fsw] [figwheel-sidecar.utils :as utils] [figwheel-sidecar.components.figwheel-server :as fig])) (defn make-css-file [path] { :file (utils/remove-root-path path) :type :css } ) (defn send-css-fil...
(ns figwheel-sidecar.components.css-watcher (:require [figwheel-sidecar.components.file-system-watcher :as fsw] [figwheel-sidecar.utils :as utils] [figwheel-sidecar.components.figwheel-server :as fig])) (defn make-css-file [path] { :file (utils/remove-root-path path) :type :css } ) (defn send-css-fil...
Fix off by one error in find-unbound
(ns refactor-nrepl.find-unbound (:require [clojure.set :as set] [clojure.tools.analyzer.ast :refer [nodes]] [refactor-nrepl [analyzer :refer [ns-ast]] [util :refer :all]])) (defn find-unbound-vars [{:keys [file line column]}] {:pre [(number? line) (number?...
(ns refactor-nrepl.find-unbound (:require [clojure.set :as set] [clojure.tools.analyzer.ast :refer [nodes]] [refactor-nrepl [analyzer :refer [ns-ast]] [util :refer :all]])) (defn find-unbound-vars [{:keys [file line column]}] {:pre [(number? line) (number?...
Fix codox src-dir-uri for 0.1.0
(defproject finagle-clojure "0.1.0" :description "A light wrapper around Finagle for Clojure" :url "https://github.com/twitter/finagle-clojure" :license {:name "Apache License, Version 2.0" :url "https://www.apache.org/licenses/LICENSE-2.0"} :dependencies [[finagle-clojure/core "0.1.0"] ...
(defproject finagle-clojure "0.1.0" :description "A light wrapper around Finagle for Clojure" :url "https://github.com/twitter/finagle-clojure" :license {:name "Apache License, Version 2.0" :url "https://www.apache.org/licenses/LICENSE-2.0"} :dependencies [[finagle-clojure/core "0.1.0"] ...
Create functions for handling indentation.
(ns berry.formatting) (defn- indent-with [character width] (apply str (repeat width character))) (def tab (partial indent-with "\t")) (def space (partial indent-with " ")) (defn indent [text {apply-indentation :indent-style indent-size :indent-size level :level}] (let [width (* indent-size level)] (str (...
Solve Simple Sum in clojure
(ns main) (defn main [] (let [a (Integer/parseInt (read-line)) b (Integer/parseInt (read-line))] (+ a b))) (println "SOMA =" (main))
Add initial approach for client-server communication.
(ns uxbox.repo "A main interface for access to remote resources." (:refer-clojure :exclude [do]) (:require [postal.client :as ps] [beicon.core :as rx])) (def ^:private ^:const +client+ "https://test.uxbox.io") (defn novelty [type data] (rx/from-promise (ps/novelty +client+ type data))) (de...
Add a test for jungerer.io/load-pairs!
(ns jungerer.io-test (:require [clojure.test :refer :all] [clojure.java.io :as io] [jungerer.graph :as g] [jungerer.io :refer :all])) (def sample-pairs-f (io/resource "sample.pairs")) (deftest load-pairs!-test (testing "returns nil if loading is succeeded" (is (nil? (load-p...
Test that we can correctly permute byte types
(ns caesium.binding-test (:require [caesium.binding :as b] [clojure.test :refer [deftest is]])) (deftest permuted-byte-types-test (is (= '[[^long ^{size_t {}} crypto_secretbox_keybytes []]] (#'b/permuted-byte-types '[^long ^{size_t {}} crypto_secretbox_keybytes []]))))
Add tests for dasherize & co
(ns useful.string-test (:use useful.string clojure.test)) (deftest to-camel (are [in out] (= out (camelize in)) "the-string" "theString" "this-is-real" "thisIsReal" "untouched" "untouched")) (deftest from-camel (are [in dashed underscored] (= [dashed underscored] ...
Add two initial tests for handshake and query response.
(ns postal.core-tests (:require [cljs.test :as t] [cats.core :as m] [promesa.core :as p] [beicon.core :as s] [postal.core :as pc] [postal.socket :as ps])) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; Tests ;;;;;;;...
Mark slack tests as integration
(ns riemann.slack-test (:use riemann.slack clojure.test) (:require [riemann.logging :as logging])) (def api-key (System/getenv "SLACK_API_KEY")) (def room (System/getenv "SLACK_ALERT_ROOM")) (def account (System/getenv "SLACK_ALERT_ACCOUNT")) (def user "Riemann_Slack_Test") (when-not api-key (println "...
(ns riemann.slack-test (:use riemann.slack clojure.test) (:require [riemann.logging :as logging])) (def api-key (System/getenv "SLACK_API_KEY")) (def room (System/getenv "SLACK_ALERT_ROOM")) (def account (System/getenv "SLACK_ALERT_ACCOUNT")) (def user "Riemann_Slack_Test") (when-not api-key (println "...
Add manual performance test to be run from REPL
(ns clj-gatling.perf-test (:require [clj-gatling.core :as gatling]) (:gen-class)) (defn- create-scenario [url] {:name "Test scenario" :requests [{:name "Request" :http url}]}) (defn run-simulation [url users] (gatling/run-simulation [(create-scenario url)] users {:root "tmp"}))
Add bootstrap quartz table migration
(ns cmr.bootstrap.migrations.002-update-quartz-to-2-2-2 (:require [clojure.java.jdbc :as j] [config.migrate-config :as config])) (defn up "Migrates the database up to version 2. Adds a column needed for Quartz 2.2.0 and higher." [] (println "migrations.002-update-quartz-to-2-2-2 up...") (j/db-do-...
Add basic structure and an example field
(ns bejeweled-bot.solver) (use 'bejeweled-bot.gems) (defn solve "puikula" [gem-array] (map-indexed (fn [colIdx col] (map-indexed (fn [rowIdx item] (check-matches colIdx rowIdx item)) col)) gem-array)) (defn check-matches [x y gem-type] ()) (def testArray [[:ruby :opal ...
Add stub for scrabble score
(ns scrabble-score) (defn score-letter [] ;; <- Arglist goes here ;; your code goes here ) (defn score-word [] ;; <- Arglist goes here ;; your code goes here )
Add namespace for common command fx
(ns braid.base.server.cqrs-fx "Namespace that collects common CQRS command fx" (:require [braid.base.server.socket :as socket] [braid.core.server.sync-helpers :as helpers] [braid.core.server.db :as db])) (def run-txns! db/run-txns! ) (def chsk-send! socket/chsk-send!) (def group-broadcast! helpers/br...
Add test for complicated pipelines
(ns dataframe.pipeline-test (:require [dataframe.core :refer :all] [expectations :refer [expect]])) (expect (frame {:a [1 2 3] :b [10 20 30] :c [6 7 8] :d [16 27 38]}) (with-> (frame {:a [1 2 3] :b [10 20 30]}) (assoc-col :c (add $a...
Add job flow for wgset phase 0 processing
{:nodes {:ph0 {:name "wgseq-phase0", :type "tool", :args []} :prn1 {:type "func", :name "prn"}}, :edges {:ph0 [:prn1]}}
Create file for default projections
(ns photon.default-projs (:require [serializable.fn :as sfn] [photon.streams :as streams])) (def stream-fn (sfn/fn [p n] (merge-with #(assoc %1 :total-events (+ (:total-events %1) (:total-events %2))) p {(:stream-name n) {:total-events 1}}))) (...
Add phase-0d after all - manually made sample fqs can make use of this
{:nodes {:ph0 {:name "tnseq-phase0-d", :type "tool", :args []} :prn1 {:type "func", :name "prn"}}, :edges {:ph0 [:prn1]}}
Add namespace for PSL loading and lookup.
(ns inet.data.dns.psl "Functions for interfacing with Mozilla Public Suffix List format files." (:refer-clojure :exclude [load]) (:require [clojure.string :as str] [clojure.java.io :as io] [inet.data.dns :as dns]) (:import [java.io Reader])) (def ^:dynamic *default-psl-url* "URL of th...
Implement the utility functions for generating puzzles
(ns ^:figwheel-always randometer.core (:require [reagent.core :as reagent :refer [atom]])) (enable-console-print!) (println "Edits to this text should show up in your developer console.") ;; define your app data so that it doesn't get over-written on reload (defonce app-state (atom {:text "Hello w...
(ns ^:figwheel-always randometer.core (:require [reagent.core :as reagent :refer [atom]])) (enable-console-print!) (def size [24 6]) (defn show-trial [x] (if x "●" "○")) (defn trial [] (> 0.5 (rand))) (defn biased-trial [propensity] (> propensity (rand))) (defn muted-trial [propensity memo...
Add a more simplified version of mnist looking much like the scrabble example.
(ns mnist.core-simplified (:require [clojure.core.matrix :as mat] [cortex.optimise :as opt] [thinktopic.datasets.mnist :as mnist] [cortex.network :as net])) (defn- mnist-labels [class-labels] (let [n-labels (count class-labels) labels (mat/zero-array [n-labels 10])...
Add unit tests for mailgun output
(ns riemann.mailgun-test (:require [riemann.mailgun :as mailgun] [clj-http.client :as client] [clojure.test :refer [deftest testing is are]])) (defn- mock-post [result-atom email event] (with-redefs [client/post (fn [url opts] (reset! result-atom ...
Add initial code for slack-rtm lib
(ns in.co.sdslabs.slack-lens.lib.slack-rtm (:require [clj-slack.rtm :as rtm] [aleph.http :as http] [manifold.stream :as s])) (defn- get-connection-map [url token] {:api-url url :token token}) (defn- get-rtm-ws-url [url token] (-> (get-connection-map url token) rtm/start ...
Add simple wireframe for clojure protocol extensions
; This is the main interface to exntending core.matrix's protocols (ns gpu.matrix (:require [clojure.core.matrix.protocols :as mp]) (:import gpu.matrix.NDArray)) (extend-protocol mp/PImplementation NDArray (implementation-key [m] :gpu-matrix) (meta-info [m] {}) (construct-matrix [m data] ; TODO (l...
Add STAR capable job flow
{:nodes {:ph1 {:name "rnaseq-star-phase1", :type "tool", :args []} :prn1 {:type "func", :name "prn"}}, :edges {:ph1 [:prn1]}}
Add examples from chapter 5
;; Note: replace ch03-xx the right number (ns clojure-walkthrough.cjia.ch05-xx (:require [clojure.data.json :as json] [clojure.xml :as xml-core]) (:gen-class)) ;; import java (import 'java.util.Date 'java.text.SimpleDateFormat) ;; import more than one at a time from the same package ;; in this case fr...
Add naive clojure implementation - without validation.
(ns roman-to-decimal.core) (use ['clojure.string :only '(split)]) ;;; This is a fairly messy implementation, since I have almost 0 expirence with ;;; clojure. Please forgive me then, and please leave a note if you have tips or ;;; comments. (defn roman-to-decimal [roman] ;; Converts roman numbers represented as str...
Add tests for padding implementation.
;; Copyright 2015 Andrey Antukh <niwi@niwi.be> ;; ;; Licensed under the Apache License, Version 2.0 (the "License") ;; you may not use this file except in compliance with the License. ;; You may obtain a copy of the License at ;; ;; http://www.apache.org/licenses/LICENSE-2.0 ;; ;; Unless required by applicable law ...
Add a string formatting function
(ns riemann.campfire "Forwards events to Campfire" (:use [clojure.string :only [join]]) (:require [clj-campfire.core :as cf])) (defn cf-settings "Setup settings for campfire. Required information is your api-token, ssl connection true or false, and your campfire sub-domain." [token ssl sub-domain] {:api-...
(ns riemann.campfire "Forwards events to Campfire" (:use [clojure.string :only [join]]) (:require [clj-campfire.core :as cf])) (defn cf-settings "Setup settings for campfire. Required information is your api-token, ssl connection true or false, and your campfire sub-domain." [token ssl sub-domain] {:api-...
Add very simple tests for bzzz.state
(ns bzzz.state-test (:use clojure.test [bzzz.state :as state]) (:import (java.util HashMap Map)) (:import (bzzz.java.query TermPayloadClojureScoreQuery))) (defn ro-get-in [k & [default]] (get-in TermPayloadClojureScoreQuery/EXPR_GLOBAL_STATE_RO k default)) (defn ro-get-in-equals-to [k target] (is (=...
Add template for project list.
(ns hatnik.web.client.project-list (:require goog.net.XhrIo [om.core :as om :include-macros true] [om.dom :as dom :include-macros true] [hatnik.web.client.components :as widget])) (def app-state (atom {:num 0 :projects []})) (defn click-handler [] (swap! app-state ...
Introduce Bresenham routine for line-segment drawing
(ns goya.components.bresenham) ;; ============================================================================= ;; Bresenham line drawing algorithm ;; Stolen from: ;; http://rosettacode.org/wiki/Bitmap/Bresenham's_line_algorithm#Clojure (defn bresenham [x0 y0 x1 y1] (let [len-x (js/Math.abs (- x0 x1)) le...
Add work exploring the usage of enums
(ns beehive.exploration (:import (net.uncontended.precipice Failable))) (def thing (gen-class :name clojure.examples.impl :extends Enum :prefix "test-" :methods []))
Resolve a very big sum.
; https://www.hackerrank.com/challenges/a-very-big-sum (use '[clojure.string :only (split triml)]) (let [n_t (read-line) n (Integer/parseInt n_t) arr_temp (read-line) arr_t (split arr_temp #"\s+") arr (map #(Integer/parseInt %) arr_t)] (println(reduce + arr)))
Add a test to verify the queue broker wrapper moves messages to a failed state after all retries are exhausted.
(ns cmr.message-queue.test.queue.queue-broker-wrapper-test "Functions for testing the queue broker wrapper we use for testing." (:require [clojure.test :refer :all] [cmr.common.lifecycle :as lifecycle] [cmr.message-queue.queue.memory-queue :as memory-queue] [cmr.message-queue.queue.queue-protocol :a...
Solve Salary with Bonus in clj
(ns main) (defn main [] (let [_ (read-line) a (Double/parseDouble (read-line)) b (Double/parseDouble (read-line))] (format "%.2f" (+ a (* b 0.15))))) (printf "TOTAL = R$ %s%n" (main))
Add test namespace for layers with generative testing
(ns cortex.layers_test "Tests for behaviour of standard layer implementations" (:use [clojure.test]) (:use [cortex.core]) (:require [clojure.core.matrix :as m] [cortex.layers :as layers] [cortex.util :as util] [clojure.test.check :as sc] [clojure.test.check.genera...
Add macros to help define a multi-reducer
(ns clojure-rest.store) (defmacro def-multi-reducer [name reducer-map] `(def ~name (clojure-rest.store/multi-reducer ~reducer-map) ))
Add some tests for middleware->
(ns rook.middleware-spec (:use speclj.core io.aviso.rook)) (def terminal-handler identity) (defn wrap-with-gnip [handler metadata] (if-let [value (:gnip metadata)] (fn [request] (handler (assoc request :gnip value))))) (defn wrap-with-plug [handler metadata tag] (if (:plug metadata) (...
Add migration for moving indexed documents to raw db
(ns subman.migrations "Migration which should be run manually from repl." (:require [monger.collection :as mc] [clojurewerkz.elastisch.rest.document :as esd] [environ.core :refer [env]] [clj-di.core :refer [get-dep]] [subman.handlers :refer [init-models]] ...
Test for resembling Java OrderServiceTest. Using map and pmap.
(ns no.knowit.clojure_functional.order-service (:use [clojure.test]) (:import no.knowit.java_functional.product.Product) (:import [no.knowit.java_functional.order TrainJourney Order]) (:import [org.joda.time DateTime])) (defn create-order [train-journey] (do (Thread/sleep 200) (new Order train-journey 1...
Add a basic test to ensure libssh2 is JNA-ed properly.
(ns clj-libssh2.test-libssh2 (:require [clojure.test :refer :all] [clj-libssh2.libssh2 :as libssh2])) (deftest check-libssh2-version-is-ok "This shoudln't change by surprise!" (is (= "1.6.0" (libssh2/version))))
Add a ns for working with Ruby from Clojure
(ns circle.ruby (:import javax.script.ScriptEngine) (:import javax.script.ScriptEngineManager) (:import org.jruby.embed.ScriptingContainer) (:import org.jruby.RubySymbol)) (def engine (-> (ScriptEngineManager.) (.getEngineByName "jruby"))) (defn eval-ruby "Eval a ruby string." [s] (-> engine ...
Add PubsubIO source and sink
(ns datasplash.pubsub (:require [datasplash.core :refer :all]) (:import (com.google.cloud.dataflow.sdk.io PubsubIO$Read PubsubIO$Write) (com.google.cloud.dataflow.sdk.values PBegin) (com.google.cloud.dataflow.sdk Pipeline))) (defn read-from-pubsub "Create an unbounded PCollection from a pub...
Add support for an annotated failure
(ns mdr2.failjure (:require [failjure.core :as fail])) (defrecord AnnotatedFailure [message data] fail/HasFailed (failed? [self] true) (message [self] (:message self)))
Add initial SICP chapter 1 notes file
; ; Chapter 1.1 - Notes ; ; defining a function (defn square [x] (* x x)) ; using the function as a building block in other functions (defn sum-of-squares [x y] (+ (square x) (square y))) ; once again, using functions as building blocks (defn f [x] (sum-of-squares (* x 2) (+ x 10))) ; expressing conditional w...
Solve Simple Product in clojure
(ns main) (defn main [] (let [a (Integer/parseInt (read-line)) b (Integer/parseInt (read-line))] (* a b))) (println "PROD =" (main))
Add missing file, RVM actions
(ns circle.backend.action.rvm "actions for dealing with RVM during builds" (:require [circle.backend.action :as action]) (:use [circle.backend.build :only (checkout-dir)]) (:require [circle.sh :as sh]) (:use [circle.backend.action.bash :only (remote-bash-build bash)])) (defn trust [] (action/action :nam...
Add test facts to ClojureScript
(ns clara.rules.testfacts "This namespace exists primary for testing purposes, working around the fact that we cannot AOT compile test classes. This should be moved to the tests once a workaround for this is solved.") ;; Reflection against records requires them to be compiled AOT, so we temporarily ;; place them her...
Add tests for parkour.toolbox functions.
(ns parkour.toolbox-test (:require [clojure.test :refer :all] [clojure.string :as str] [clojure.java.io :as io] [clojure.core.reducers :as r] [parkour (conf :as conf) (fs :as fs) (cstep :as cstep) , (wrapper :as w) (mapreduce :as mr) (toolbox :as ptb)...
Add file that interfaces with javascript files
(ns storemi.js (:require [clj-rhino :as js] [clojure.walk :refer [keywordize-keys]])) (def parser-scope (doto (js/new-safe-scope) (js/eval (slurp "resources/public/js/underscore-min.js")) (js/eval (slurp "resources/public/js/parser.js")))) (defn parse-script [script] (let [sc (js/new-scope nil...
Add template for routing / load balancing
global daemon maxconn 256 defaults mode http timeout connect 5000ms timeout client 50000ms timeout server 50000ms frontend http bind *:9999 <% (doseq [[{name :name regex :regex}] services] %>acl <%= name %>-regex path_reg <%= regex %> use_backend <%= name %>-backends if <%= n...
Add SPScrapeTripReport which implements ScrapeTripReport protocol.
(ns scrape-trs.summitpost.core (:require [scrape-trs.summitpost [extract-pager-urls :refer [extract-all-pager-urls]] [extract-result-urls :refer [extract-result-urls]] [extract-trip-report :refer [extract-trip-report]]]) (:import scrape_trs.protocol.ScrapeTripReport)) (def ba...
Prepare a workaround for the Leiningen 2 Preview 9 provisioning issue
;; https://github.com/technomancy/leiningen/issues/747#issuecomment-8024136 (swap! leiningen.core.project/default-profiles update-in [:base] assoc :repositories [["clojars" {:url "https://clojars.org/repo/"}]])
Add migration to remove provider specific services tables and sequences.
(ns migrations.053-remove-provider-services-tables (:require [clojure.java.jdbc :as j] [config.migrate-config :as config] [config.mdb-migrate-helper :as h] [cmr.metadata-db.data.oracle.concept-tables :as ct])) (defn up "Migrates the database up to version 53." [] (println "m...
Add generic mac engine abstraction for low level but clojure idiomatic access to mac.
;; Copyright (c) 2013-2015 Andrey Antukh <niwi@niwi.be> ;; ;; Licensed under the Apache License, Version 2.0 (the "License") ;; you may not use this file except in compliance with the License. ;; You may obtain a copy of the License at ;; ;; http://www.apache.org/licenses/LICENSE-2.0 ;; ;; Unless required by applic...
Create separate namespace for multiple libs
(ns discuss.lib.views (:require [om.core :as om :include-macros true] [om.dom :as dom :include-macros true])) (defn fa-icon "Wrapper for font-awesome icons." ([class] (dom/i #js {:className (str "fa " class)})) ([class f] (dom/i #js {:className (str "pointer fa " class) :onClic...
Add function for transforming a seq with a name and a value into a JSON member
(ns berry.converters.to-member (:require [berry.formatting :refer [indent]])) (declare colon transform-name) (defn to-member [[name value] options to-json] (let [{prettify? :prettify?} options name (transform-name name options) value (to-json value options to-json)] (str name (colon...
Comment out basic auth - no need for fn here
; Copyright © 2015, JUXT LTD. (ns yada.walk (:require [clojure.walk :refer [postwalk]]) (:import [yada.handler Handler] [yada.resource Resource])) ;; Functions to update inner routes (defn update-routes [routes f & args] (postwalk (fn [x] (if (or (instance? Handler x) ...
; Copyright © 2015, JUXT LTD. (ns yada.walk (:require [clojure.walk :refer [postwalk]]) (:import [yada.handler Handler] [yada.resource Resource])) ;; Functions to update inner routes (defn update-routes [routes f & args] (postwalk (fn [x] (if (or (instance? Handler x) ...
Add test for deploy task.
(ns test-deploy (:use [leiningen.deploy] :reload) (:use [clojure.test] [clojure.java.io :only [file]] [leiningen.core :only [read-project defproject]] [leiningen.util.file])) (def test-project (read-project "test_projects/sample/project.clj")) (deftest test-deploy (delete-file-recursivel...
Add ability to run aggregation separate from std phase-2 run
{:nodes {:ph2 {:name "tnseq-phase2b", :type "tool", :args []} :prn1 {:type "func", :name "prn"}}, :edges {:ph2 [:prn1]}}
Add a stupid ideally-failing core test
(ns desdemona.ui.core-test (:require [desdemona.ui.core :as c] [cljs.test :as t :refer-macros [deftest testing is are]])) (deftest add-tests (is (= (c/add 1 2) 3)))
Add lein file in clojure config folder
{:user {:ultra {:color-scheme :solarized_dark :stacktraces true} :plugins [[lein-try "0.4.3"] [lein-ancient "0.6.10-SNAPSHOT"] [lein-kibit "0.1.2"] [jonase/eastwood "0.2.3"] ;[venantius/ultra "0.5.0"] ]}}