Skip to content

Instantly share code, notes, and snippets.

View ashafa's full-sized avatar

Tunde Ashafa ashafa

View GitHub Profile
ackage cr.canopy.tunde.canopy.manager;
import android.content.res.AssetManager;
import android.support.v4.app.FragmentActivity;
import android.util.Log;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
(defn format-history-lines
[history-lines]
((comp
format-history-map
(partial take 10)
sort-by-weight
counts
(partial map history-line->command))
history-lines))
/* 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 */
(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)) "")
/*
* * 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){
(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))))))
(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)
(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)
(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*))
(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})