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 oauth.digest | |
(:import (javax.crypto Mac) | |
(javax.crypto.spec SecretKeySpec))) | |
(defn hmac | |
"Calculate HMAC signature for given data." | |
[^String key ^String data] | |
(let [hmac-sha1 "HmacSHA1" | |
signing-key (SecretKeySpec. (.getBytes key) hmac-sha1) | |
mac (doto (Mac/getInstance hmac-sha1) (.init signing-key))] |
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
Algorithm HmacSHA1 not available | |
[Thrown class java.security.NoSuchAlgorithmException] | |
Restarts: | |
0: [QUIT] Quit to the SLIME top level | |
Backtrace: | |
0: javax.crypto.Mac.getInstance(DashoA13*..) | |
1: user$eval2253.invoke(NO_SOURCE_FILE:1) | |
2: clojure.lang.Compiler.eval(Compiler.java:5424) |
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
phrygian:tracker wei$ cake repl | |
user=> (javax.crypto.Mac/getInstance "HmacSHA1") | |
java.security.NoSuchAlgorithmException: Algorithm HmacSHA1 not available (NO_SOURCE_FILE:0) | |
phrygian:tracker wei$ lein repl | |
"REPL started; server listening on localhost:35455." | |
user=> (javax.crypto.Mac/getInstance "HmacSHA1") | |
#<Mac javax.crypto.Mac@5759780d> |
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 map-keys [m f] | |
(into {} (for [[k v] m] [k (f v)]))) | |
;; recursive group-by | |
(defn group-by-> [starting-target starting-fns] | |
(loop [target starting-target fns starting-fns] | |
(if (nil? fns) target | |
(map-keys (group-by (first fns) target) #(recur % (rest fns)))))) | |
;; usage |
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
function modify_permalinks($permalink_structure, $category_base, $tag_base){ | |
global $wp_rewrite; | |
$permalink_structure = preg_replace('#/+#', '/', '/' . $permalink_structure); | |
$wp_rewrite->set_permalink_structure($permalink_structure); | |
$category_base = preg_replace('#/+#', '/', '/' . $category_base); | |
$wp_rewrite->set_category_base($category_base); | |
$tag_base = preg_replace('#/+#', '/', '/' . $tag_base); |
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
(lift loadserver | |
:compute ec2-service | |
:phase (phase (pallet.resource.package/package "curl"))) |
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
bottime-gae.core=> (baseline/run-threads 1 1) | |
#<ArityException clojure.lang.ArityException: Wrong number of args (1) passed to: baseline$run-threads$fn> | |
bottime-gae.core=> (baseline/run-threads 1) | |
#<ArityException clojure.lang.ArityException: Wrong number of args (1) passed to: baseline$run-threads> | |
bottime-gae.core=> (baseline/run-threads) | |
#<ArityException clojure.lang.ArityException: Wrong number of args (0) passed to: baseline$run-threads> | |
bottime-gae.core=> (baseline/run-threads 1 2 3) | |
#<ArityException clojure.lang.ArityException: Wrong number of args (3) passed to: baseline$run-threads> |
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 leaky-filter [pred l n] | |
(apply | |
concat | |
(filter #(or (some pred %) (< n (count %))) | |
(partition-by nil? l)))) | |
(is (= (leaky-filter [1 nil 2 nil nil nil nil 1 2 3] identity 3) | |
[1 2 nil nil nil nil 1 2 3])) |
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
<?xml version="1.0" encoding="UTF-8"?> | |
<project> | |
<modelVersion>4.0.0</modelVersion> | |
<groupId>org.clojars.yayitswei</groupId> | |
<artifactId>java-channels-api</artifactId> | |
<version>0.1-SNAPSHOT</version> | |
<name>java-channels-api</name> | |
<description>jacc</description> | |
<repositories> | |
<repository> |
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
;; this one fails with | |
;;#<IllegalStateException java.lang.IllegalStateException: Invalid use of SingleClientConnManager: connection still allocated. | |
;;Make sure to release the connection before allocating another one.> | |
(defn run-test [num-requests channel-name] | |
(let [channel (ChannelAPI.) | |
requests (init-requests num-requests channel-name) | |
listener (make-listener requests)] | |
(connect-at-sim channel channel-name listener) | |
(doall (map do-request requests)))) |
OlderNewer