Reads the next object from stream, which must be an instance of
java.io.PushbackReader
or some derivee. Stream defaults to the current value of*in*
.
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
;;Using the Cassowary constraint solver from ClojureScript | |
;;This demo shows using multimethods for readable constraint syntax using +, -, and =. | |
;;Output is a row of circles with random radii spaced so that the space between their boundaries is uniform. | |
(ns c2.main | |
;;refer-clojure :exclude is currently broken in ClojureScript master | |
;;Ticket open: http://dev.clojure.org/jira/browse/CLJS-114 | |
;;Fix applied here: https://github.com/lynaghk/clojurescript/tree/114-refer-clojure-exclude | |
(:refer-clojure :exclude [+ - =]) | |
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 pigeonhole-sort) | |
(defn int-sort [s] | |
(let [listmap (reduce #(update-in | |
(update-in %1 [%2] (fnil inc 0)) | |
[:max] max %2) {:max 0} s)] | |
(mapcat #(repeat (get listmap % 0) %) | |
(range (inc (:max listmap)))))) |
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 long-polling | |
(:require [clojure.data.json :as json])) | |
(def timeout 100) ; sec | |
;[clojure.contrib.http.agent :as h] | |
;(use 'clojure.contrib.http.agent) | |
; fetch, this will wait if no messages are active | |
;(string (http-agent "http://127.0.0.1/activity?id=1")) |
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
@startuml | |
class Car | |
Driver - Car : drives > | |
Car *- Wheel : have 4 > | |
Car -- Person : < owns | |
@enduml |
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
(defproject gridsystem "0.1.0-SNAPSHOT" | |
:dependencies [[org.clojure/clojure "1.5.1"] | |
[compojure "1.1.5"] | |
[garden "1.0.0-SNAPSHOT"] | |
[ring/ring-jetty-adapter "0.2.5"] | |
[hiccup "1.0.4"]] | |
:plugins [[lein-ring "0.8.5"]] | |
:ring {:handler semantic-gs.handler/app} | |
:profiles | |
{:dev {:dependencies [[ring-mock "0.1.5"]]}}) |
Seperate paragraphs using Python/Sublime2 regular expressions:
\s*?\n\s*?\n\s*?
Fetch all predicate symbol names in second group
(\(defn )(\w.*\?)
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
;variants of the code from point #2 of: | |
; http://www.tbray.org/ongoing/When/200x/2009/12/01/Clojure-Theses | |
;original | |
(apply merge-with + | |
(pmap count-lines | |
(partition-all *batch-size* | |
(line-seq (reader 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
;; | |
;; NS CHEATSHEET | |
;; | |
;; * :require makes functions available with a namespace prefix. | |
;; | |
;; * :use makes functions available without a namespace prefix | |
;; (i.e., refers functions to the current namespace). | |
;; | |
;; * :import refers Java classes to the current namespace. | |
;; |
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
;; Note: for the best result/experience you should download LightTable at www.lighttable.com | |
;; Open the program, press [^-Space] (Control-Space) and type "Insta" then click/press [Return] to open one and paste this in | |
;; Macro to define/create namespace and bind neatly only the required functions (explicit use of :refer key) | |
(ns clj-no.de | |
^{:doc "Namespace and directives for easy inspection of symbols, hash-maps, namespaces and so on." | |
:author "Rob Jentzema" | |
:version "0.01"} | |
;; These provide us with easy access to some very useful functions |