Skip to content

Instantly share code, notes, and snippets.

View dakrone's full-sized avatar

Lee Hinman dakrone

View GitHub Profile
~/src/clj/clj-http:pr/235 λ| lein all test :all
Performing task 'test' with profile(s): 'dev,1.5'
Reflection warning, clj_http/multipart.clj:26:4 - call to org.apache.http.entity.mime.content.FileBody ctor can't be resolved.
Reflection warning, clj_http/test/client.clj:35:48 - reference to field getBytes can't be resolved.
lein test clj-http.test.client
"a=1&b=%7B%3Ac+%222%22%7D"
lein test :only clj-http.test.client/roundtrip

Since String.format() is not in the whitelist, sometimes it's nice to be able to use string interpretation in scripts. Groovy allows doing this with GString interpretation.

Create an index

DELETE /script
{}
(defun add-to-path (path-element)
"Add the specified path element to the Emacs PATH"
(interactive "DEnter directory to be added to path: ")
(if (file-directory-p path-element)
(setenv "PATH"
(concat (expand-file-name path-element)
path-separator (getenv "PATH")))))
Buildfile: /Users/hinmanm/src/java/lucene_trunk/lucene/queryparser/build.xml
clean:
[delete] Deleting directory /Users/hinmanm/src/java/lucene_trunk/lucene/build/queryparser
ivy-availability-check:
ivy-fail:
ivy-configure:
diff --git a/lucene/core/src/java/org/apache/lucene/search/BooleanQuery.java b/lucene/core/src/java/org/apache/lucene/search/BooleanQuery.java
index 209a6dc..d0f5df0 100644
--- a/lucene/core/src/java/org/apache/lucene/search/BooleanQuery.java
+++ b/lucene/core/src/java/org/apache/lucene/search/BooleanQuery.java
@@ -165,6 +165,9 @@ public class BooleanQuery extends Query implements Iterable<BooleanClause> {
@Override
public Query rewrite(IndexReader reader) throws IOException {
+ if (clauses.size() == 0) {
+ return new MatchNoDocsQuery();
λ ant clean test
Buildfile: /home/hinmanm/src/elisp/jdee/build.xml
init:
clean:
[delete] Deleting directory /home/hinmanm/src/elisp/jdee/build
init:
[mkdir] Created dir: /home/hinmanm/src/elisp/jdee/build
; The execution macro
(defmacro exec
"Execute a command on the shell, passing to the given function
the lazy sequence of lines read as output, and the rest of arguments."
[cmd pred & args]
`(with-open [br# (BufferedReader. (InputStreamReader. (.getInputStream (.exec (Runtime/getRuntime) ~cmd))))]
(~pred (line-seq br#) ~@args)))
; This works
(defn get-groups
(ns timetest
(:use clojure.contrib.shell-out))
; Execute and return a list of lines, think of it as a helper for (sh)
(defn sh-lines
"Given a program and a list of args, run it and return an array
of the lines for stdout"
[& body]
(.split (:out (apply sh :return-map true body)) "\n"))
@dakrone
dakrone / trapr
Created June 9, 2009 16:35
Nesting traps that untrap in Ruby
#!/usr/bin/env ruby
class Object
def trapr_wrap(signal, newproc, function, *args)
#puts "Trapping #{signal} with #{newproc.inspect}"
oldproc = trap "#{signal}", newproc
self.send("#{function}", *args)
ensure
#puts "Reseting trap. #{signal} -> #{oldproc.inspect}"
trap "#{signal}", oldproc
#!/usr/bin/env ruby
#
# forkoff proc test
#
require 'forkoff'
require 'pp'
a = []