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
AsyncHttpClient c = getAsyncHttpClient(new AsyncHttpClientConfig.Builder().setFollowRedirects(true).build()); | |
WebSocket websocket = c.prepareGet("ws://127.0.0.1:8080/atmosphere-jquery-pubsub/pubsub/chat") | |
.execute(new WebSocketUpgradeHandler()).get(); | |
websocket.addMessageListener(new WebSocketListener() { | |
@Override | |
public void onMessage(byte[] message) { | |
System.out.println(new String(message)); | |
} | |
@Override |
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
#!/usr/bin/env perl | |
# Remember `chmod a+x hslint, after putting on path. | |
$ghc = '/usr/bin/ghc'; # where is ghc | |
@ghc_options = ('-Wall'); # e.g. ('-fglasgow-exts') | |
@ghc_packages = (); # e.g. ('QuickCheck') | |
### the following should not been edited ### | |
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 wiki.core | |
(:use net.cgrand.moustache | |
ring.adapter.jetty | |
ring.util.response | |
[ring.middleware params stacktrace reload] | |
hiccup.core | |
com.ashafa.clutch) | |
(:require [clojure.string :as s]) | |
(:import org.pegdown.PegDownProcessor)) |
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
package demo | |
class Coder(words: List[String]) { | |
private val mnemonics = Map( | |
'2' -> "ABC", '3' -> "DEF", '4' -> "GHI", '5' -> "JKL", | |
'6' -> "MNO", '7' -> "PQRS", '8' -> "TUV", '9' -> "WXYZ") | |
private val charCode: Map[Char, Char] = | |
for ((digit, str) <- mnemonics; letter <- str) yield letter -> digit |
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
;; 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 |
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 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 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 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 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 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; |
NewerOlder