Skip to content

Instantly share code, notes, and snippets.

View dakrone's full-sized avatar

Lee Hinman dakrone

View GitHub Profile
(ns jmockit.core
(:import [mockit Mockit]))
(defprotocol MList
(add [a]))
(deftype MockList [] MList
(add [a] (println "mocked")))
(Mockit/setUpMock java.util.ArrayList MockList)
(defmacro mock-2
[class method arglist result]
(let [mocked (gensym class)]
`(let [~mocked (org.mockito.Mockito/mock ~class)]
~(list '.thenReturn
(list 'org.mockito.Mockito/when
(list* (symbol (str \. method)) mocked arglist))
result))))
user=> (macroexpand-1 '(mock-2 File myMethod ["foo" "foo"] "bar"))
(ns seed-example
(:use [clomoios.contextsearcher :as cs])
(:use [clomoios.seededcontextsearcher :as scs])
(:use [clojure.contrib.pprint :only [pprint]]))
; Both contextsearcher and seededcontextsearcher have different protocols that both have 'score' and 'rank' methods
;‹ ~/src/clj/clomoios › ∴ clj examples/ford/seed-example.clj
;WARNING: score already refers to: #'clomoios.contextsearcher/score in namespace: seed-example, being replaced by: #'clomoios.seededcontextsearcher/score
acm.upgrade.bottomPanel = new Ext.Panel({
id: 'acm.upgrade.bottomPanel',
labelAlign: 'top'
,frame:true
,layout: 'fit'
,items: [{
layout: 'column'
,items: [{
columnWidth: .10
,layout: 'form'
(ns clomoios.contextsearcher
(:use [clomoios.core])
(:require [opennlp.nlp :as nlp]))
(defprotocol Searcher
"An interface for searching"
(score [this term text] "Score this text in similarity")
(rank [this term text] "Rank sentences in this text"))
(defprotocol Searcher
"An interface for searching"
(score [this term text] "Score this text in similarity")
(rank [this term text] "Rank sentences in this text"))
(defrecord ContextSearcher [get-sentences tokenize pos-tag])
; ... lots of impelementation details here ...
(ns web-tag.core
(:require [opennlp.nlp :as nlp])
(:use [compojure.core]
[ring.adapter.jetty]))
(defn parse-page
[url]
(println (str "url is " url)) ; printing nil for some reason
(str "<h1>parsing: " url "</h1>"))
#!/usr/bin/python
import sys
import shutil
import os
import os.path
if os.path.exists("$(sourceFolder)"):
try:
shutil.rmtree("$(sourceFolder)")
(defn- strip-funny-chars
"Strip out some characters that might cause trouble parsing the tree."
[s]
(-> s
(.replaceAll "'" "-SQUOTE-")
(.replaceAll "\"" "-DQUOTE-")
(.replaceAll "~" "-TILDE-")
(.replaceAll "`" "-BACKTICK-")
(.replaceAll "," "-COMMA-")
(.replaceAll "\\\\" "-BSLASH-")
nmap <C-m> ggVG<C-c><C-c>