Get Homebrew installed on your mac if you don't already have it
Install highlight. "brew install highlight". (This brings down Lua and Boost as well)
(defn get-hash [type data] | |
(.digest (java.security.MessageDigest/getInstance type) (.getBytes data) )) | |
(defn sha1-hash [data] | |
(get-hash "sha1" data)) | |
(defn get-hash-str [data-bytes] | |
(apply str | |
(map | |
#(.substring |
(ns test) | |
(defn try-times | |
"Try executing a thunk `retries` times." | |
[retries thunk] | |
(if-let [res (try | |
[(thunk)] | |
(catch Exception e ; can be any exception | |
(when (zero? retries) | |
(throw e))))] |
connection = Faraday::Connection.new('http://example.com') do |builder| | |
builder.request :url_encoded # for POST/PUT params | |
builder.adapter :net_http | |
end | |
# same as above, short form: | |
connection = Faraday.new 'http://example.com' | |
# GET | |
connection.get '/posts' |
Hey <github-handle> | |
Thanks that you run your test on Travis-CI. | |
Just to let you know: your tests failing because you haven't included rake in your Gemfile. | |
Please be so kind to add rake and your tests should run as you expect. | |
Thanks again for using Travis-CI | |
your Travis-Team |
~/projects/jruby $ ant -q -Djruby.default.ruby.version=1.9 | |
[echo] Updating Constants.java | |
[echo] ...using git revision = 19f613b, tzdata = 2010k | |
[javac] warning: [options] bootstrap class path not set in conjunction with -source 1.5 | |
[javac] 1 warning | |
[apt] Since compiler setting isn't classic or modern, ignoring fork setting. | |
[apt] Since compiler setting isn't classic or modern, ignoring fork setting. | |
[jar] Warning: selected jar files include a META-INF/INDEX.LIST which will be replaced by a newly generated one. | |
BUILD SUCCESSFUL |
/** | |
* The Matrix Example | |
* http://wiki.neo4j.org/content/The_Matrix | |
*/ | |
case class Matrix(name: String, profession: String) | |
object TheMatrix extends App with Neo4jWrapper with EmbeddedGraphDatabaseServiceProvider { | |
ShutdownHookThread { | |
shutdown(ds) |
# Workaround for IO.popen.readlines being allowed to block indefinitely even if | |
# wrapped in a Timeout::timeout call. | |
# | |
# Test case: | |
# $ time jruby -rtimeout -e "timeout(1) { IO.popen('sleep 10').readlines }" | |
require 'jruby' | |
module Timeout | |
def self.timeout(sec, klass=nil) | |
return yield(sec) if sec == nil or sec.zero? |
(with-collection "docs" | |
(find { :inception_year { $lt 2000 $gte 2011 } }) | |
(fields { :inception_year 1 :name 1 }) | |
(skip 10) | |
(limit 20) | |
(batch-size 50) | |
(hint "my-index-name") | |
(snapshot)) |
Get Homebrew installed on your mac if you don't already have it
Install highlight. "brew install highlight". (This brings down Lua and Boost as well)
// Modified SpamLord.java to call clojure code | |
public List<Contact> processFile(String fileName, BufferedReader input) { | |
List<Contact> contacts = new ArrayList<Contact>(); | |
// for each line | |
Matcher m; | |
String email; | |
try { | |
List results = new spamlord().process(input); |