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 com.freiheit.clojure.appengine.appengine-local | |
| (:use | |
| [compojure.http routes servlet helpers] | |
| clojure.contrib.test-is | |
| compojure.server.jetty | |
| [clojure.contrib def str-utils duck-streams]) | |
| (:require | |
| [clojure.contrib.logging :as log]) | |
| (:import | |
| [com.google.appengine.api.labs.taskqueue.dev LocalTaskQueue] |
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
| (doseq [[fn-name fn-doc] [testname "sample doc" anothername "detailed documentation"]] | |
| `(defn ~fn-name ~fn-doc [a] a)) |
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 wl.core | |
| (:use compojure.core, aleph.core, aleph.http, hiccup.core, hiccup.page-helpers) | |
| (:require [compojure.route :as route]) | |
| (:gen-class)) | |
| (def broadcast-channel (channel)) | |
| (defn chat-handler [ch handshake] | |
| (receive ch | |
| (fn [name] |
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
| // http://aboutcode.net/2010/11/11/list-github-projects-using-javascript.html | |
| jQuery.githubUser = function(username, callback) { | |
| jQuery.getJSON("http://github.com/api/v1/json/" + username + "?callback=?", callback); | |
| } | |
| jQuery.fn.loadRepositores = function(username) { | |
| this.html("<span>Querying GitHub for repositories...</span>"); | |
| var target = this; |
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
| @Test(groups = "standalone") | |
| public void basicDefaultTest() throws Throwable { | |
| AsyncHttpClientConfig client = new AsyncHttpClientConfig.Builder().setResumableDownload(true).build(); | |
| AsyncHttpClient c = new AsyncHttpClient(client); | |
| final RandomAccessFile file = new RandomAccessFile("800m.avi", "rw"); | |
| Response r = c.prepareGet("http://192.168.2.106:8081/800m.avi").execute(new AsyncCompletionHandlerBase(){ | |
| private long byteTransferred = 0; |
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
| Configuring Apache Client | |
| HttpParams params = new BasicHttpParams(); | |
| params.setParameter(HttpProtocolParams.PROTOCOL_VERSION, | |
| HttpVersion.HTTP_1_1); | |
| params.setBooleanParameter(HttpProtocolParams.USE_EXPECT_CONTINUE, | |
| false); | |
| params.setBooleanParameter(HttpConnectionParams.STALE_CONNECTION_CHECK, | |
| false); | |
| params.setIntParameter(HttpConnectionParams.SOCKET_BUFFER_SIZE, |
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
| Client: Mac Pro OS X, 2.8Ghz Quad-Core Intel Xeon, 8 GB 1066 Mhz DDR3 | |
| Server: lighttpd/1.4.26 -> Ubuntu, 2.8Ghz Duo-Core Intel Xeon, 6 1066 Mhz DDR3 | |
| 50 threads that does 50 requests, done 50 times. | |
| Async Http Client 1.5.0 (Config http://is.gd/7rGGWU) | |
| ============================================================= | |
| BenchmarkResult{requestsPerSecond=1578.96, threads=50, batches=50, targetRequests=125000, successfulRequests=125000, failedRequests=0, averageRequestTime=0.63ms, averageBatchTime=1583.32ms, totalBenchmarkTime=79166.03ms} | |
| (last 5 runs) |
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
| ~/$ lein new ring-on-heroku | |
| Created new project in: /home/jim/Development/ring-on-heroku | |
| ~/$ cd ring-on-heroku | |
| ~/ring-on-heroku$ echo 'web: lein run -m ring-on-heroku.core' > Procfile | |
| ~/ring-on-heroku$ cat > src/ring_on_heroku/core.clj | |
| (ns ring-on-heroku.core | |
| (:use ring.util.response | |
| ring.adapter.jetty)) | |
| (defn app [req] |
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 test | |
| (require clojure.java.io | |
| clojure.string)) | |
| (def *keys* {\2 #{\a \b \c}, \3 #{\d \e \f}, \4 #{\g \h \i}, \5 #{\j \k \l}, \6 #{\m \n \o}, \7 #{\p \q \r \s}, \8 #{\t \u \v}, \9 #{\w \x \y \z}}) | |
| (def *mapping* (into {} (mapcat (fn [[k v]] (map #(vector % k) v)) *keys*))) | |
| (def *words* (line-seq (clojure.java.io/reader "/usr/share/dict/words"))) |
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
| ;; Adapted from "An empirical comparison of C, C++, Java, Perl, | |
| ;; Python, Rexx, and Tcl for a search/string-processing program" | |
| ;; by Lutz Prechelt | |
| ;; This was a 15-minute effort while listening to a talk. It's *not* | |
| ;; well thought-out or designed. | |
| ;; By Stuart Sierra, | |
| ;; @stuartsierra on Twitter |
OlderNewer