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 cc-rev | |
[s] | |
(let [paren? (fn [ch] (or (= ch \() (= ch \))))] | |
(apply str | |
(concat | |
(flatten | |
(->> s | |
(partition-by paren?) | |
(remove #(paren? (first %))) | |
(map-indexed (fn [idx ss] (if (odd? idx) (reverse ss) ss))))))))) |
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
(import '(org.yaml.snakeyaml Yaml)) | |
(defn parse-yaml-str | |
[^String yaml-str] | |
(let [y-parser (Yaml.)] | |
(.load ^org.yaml.snakeyaml.Yaml y-parser | |
^String (or yaml-str "")))) | |
;; gives |
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
(defmacro execute-query | |
"Wrapper around with-connection & with-query-results" | |
[results query & body] | |
`(do | |
(debug (str "[SQL] " ~query)) | |
(with-connection {:datasource (data-source)} | |
(with-query-results ~results [~query] ~@body)))) | |
(defmacro with-items-in | |
[ids options & 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
(use 'clojure.contrib.seq-utils) | |
(defn- in-range? | |
[i pair] | |
(and (>= i (first pair)) (<= i (last pair)))) | |
(defn- glue-pairs | |
[pairs] | |
(let [idxs (flatten pairs) | |
freqs (frequencies idxs)] |
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
(declare occurs-memo) | |
(defn occurs-naive | |
[pattern ss] | |
(cond | |
(= 0 (count pattern)) 1 | |
(= 0 (count ss)) 0 | |
true (if (= (first pattern) (first ss)) | |
(+ (occurs-memo (rest pattern) (rest ss)) | |
(occurs-memo pattern (rest ss))) |
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 set-log4j-level! [level] | |
"Sets the log4j root logger's level." | |
(let [root-logger (org.apache.log4j.Logger/getRootLogger)] | |
(.setLevel root-logger level))) | |
(defn set-log4j-to-debug! | |
[] | |
(set-log4j-level! org.apache.log4j.Level/DEBUG)) | |
(defn set-log4j-to-info! |
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 index-file-with-writer [config-id index-writer fname] | |
(let [req-counter (ref 0)] | |
(do | |
(println (str "Parsing " fname)) | |
(doall (map (partial process-request-log config-id index-writer) | |
(partition-by | |
#(if (. #^String % startsWith "Processing") | |
(dosync (alter req-counter inc)) | |
(deref req-counter)) | |
(line-seq (reader fname)))))))) |
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
;; make sure you have c3p0 jar in classpath | |
(def *c3p0-datasource* | |
(let [db-config (org.ho.yaml.Yaml/load (java.io.File. "../../config/database.yml")) | |
env-config (get db-config rails-env) ] | |
(doto (com.mchange.v2.c3p0.ComboPooledDataSource.) | |
(.setDriverClass "com.mysql.jdbc.Driver") | |
(.setJdbcUrl (str "jdbc:mysql://" (get env-config "host") "/" (get env-config "database"))) | |
(.setConnectionTesterClassName "com.mysql.jdbc.integration.c3p0.MysqlConnectionTester") | |
(.setIdleConnectionTestPeriod 120) |
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
From cece59d0bb84e4bde30e8062ac4a4217313f3298 Mon Sep 17 00:00:00 2001 | |
From: Sergey Pariev <spariev@gmail.com> | |
Date: Tue, 2 Feb 2010 12:43:25 +0300 | |
Subject: [PATCH 1/2] support for self-install on Windows using bitsadmin | |
--- | |
bin/lein.bat | 28 +++++++++++++++++++--------- | |
1 files changed, 19 insertions(+), 9 deletions(-) | |
diff --git a/bin/lein.bat b/bin/lein.bat |
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
def handle_xls_links | |
if params[:xls_link] | |
uri = request.request_uri | |
uri.gsub!(/[\?\&]xls_link=true/,'') | |
resp = %Q{ | |
<html> | |
<head> | |
<META HTTP-EQUIV="Refresh" | |
CONTENT="0; URL=#{uri}"> | |
</head> |
NewerOlder