This file contains 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 clj-record.query | |
(:require [clojure.contrib.str-utils :as str-utils])) | |
(defn- clause-and-parameters [join-with values] | |
[(str-utils/str-join join-with (reduce (fn [v1 v2] (conj v1 (if (nil? v2) "NULL" "?"))) [] values)) (filter (complement nil?) values)]) | |
(defn between [value1 value2] | |
(fn [attribute] | |
(let [[clause parameters] (clause-and-parameters " AND " [value1 value2])] |
This file contains 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
;; I want to be able to do something like this... | |
(defdbtest has-and-belongs-to-many-creates-find-functions | |
(let [humedai (manufacturer/create (valid-manufacturer-with {:name "Humedai Automotive"})) | |
s3000xi (product/create {:name "S-3000xi" :manufacturer_id (:id humedai)}) | |
s3000xl (product/create {:name "S-3000xl" :manufacturer_id (:id humedai)}) | |
chambars (dealer/create {:name "Chambers Motors"}) | |
ira (dealer/create {:name "IRA Autos"}) | |
tundre (dealer/create {:name "Tundre Automotives"})] | |
(dealer/insert-relationship chambars (:id s3000xi)) |
This file contains 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 clojure-couchdb | |
(:use com.ashafa.couchdb | |
(clojure.contrib [test-is :as test-is]))) | |
(set-couchdb-config! {:language "clojure"}) | |
(def test-doc-1 {:name "John Smith" | |
:email "john.smith@test.com" | |
:score 65}) |
This file contains 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 contest | |
(:require [clojure.contrib.str-utils :as s]) | |
(:import (java.math BigInteger) | |
(java.util.concurrent ScheduledThreadPoolExecutor))) | |
(def *phrase-int* (BigInteger. (com.ashafa.SHA1/hash "I would much rather hear more about your whittling project") 16)) | |
(def *words-list* (vec (.split #"\r?\n" (slurp "words.txt")))) | |
(def *words-count* (count *words-list*)) |
This file contains 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
(defmulti watch-changes | |
"Provided a database (database meta, java.net.URL, or database name) and a callback, watches | |
for changes to the database and executes the given callback (takes one argument) on every change | |
to a document in the given database, using the meta of the changed document as the only | |
argument of the callback." | |
database-arg-type) | |
(defn- watch-changes-handler | |
[url-str agnt] | |
(if (h/success? agnt) |
This file contains 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
(defmulti watch-changes | |
"Provided a database (database meta, java.net.URL, or database name) and a callback, watches | |
for changes to the database and executes the given callback (takes one argument) on every change | |
to a document in the given database, using the meta of the changed document as the only | |
argument of the callback." | |
database-arg-type) | |
(defn- watch-changes-handler | |
[url-str agnt] | |
(if (h/success? agnt) |
This file contains 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
(defn wait-for-changes | |
[& _] | |
(let [update-seq (:update_seq (database-info "test-changes"))] | |
(with-open [is (with-db "test-changes" | |
(couchdb-request (assoc config :read-json-response false) | |
:get (str "_changes?feed=continuous&heartbeat=5000&since=" update-seq)))] | |
(loop [lines (io/read-lines is)] | |
(if-let [line (first lines)] | |
line | |
(recur lines)))))) |
This file contains 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
/* | |
* * JavaScript Pretty Date | |
* * Copyright (c) 2008 John Resig (jquery.com) | |
* * Licensed under the MIT license. | |
* */ | |
// Takes an ISO time and returns a string representing how | |
// long ago the date represents. | |
function prettyDate(time){ |
This file contains 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 twansit.server.handler) | |
(defmacro respond-with | |
[& body] | |
(let [args (or (last (filter vector? body)) ['req 'res]) | |
res-code (or (last (filter integer? body)) 200) | |
headers (merge {:Content-Type "text/html; charset=UTF-8"} | |
(or (last (filter map? body)) {})) | |
output (or (last (filter list? body)) | |
(last (filter string? body)) "") |
This file contains 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
/* Smartphones (landscape) ----------- */ | |
@media only screen and (min-width : 321px) and (max-device-width: 569px) { | |
/* Styles */ | |
} | |
/* Smartphones (portrait) ----------- */ | |
@media only screen and (max-width : 320px) and (max-device-width: 320px) { | |
/* Styles */ |
OlderNewer