Re: with-open and for

2013-06-11 Thread Ray Miller
The 'reduce' solution is very elegant, but you can simplify it further: (defn filter-file [filename] (with-open [rdr (io/reader filename)] (reduce (fn [words line] (into words (filter #(<= 4 (count %) 9) (str/split line #"\s+" #{} (line-seq rdr

DBM libraries

2013-06-16 Thread Ray Miller
Hi, Is there a maintained and widely-adopted Clojure interface to any of the Java DBM libraries (jdbm, jdbm2, BerkeleyDB or MapDB) ? If not, is there a preferred alternative for persisting a large hash-map to disk? (Ideally I'd like random access to records without reading the whole thing into me

Cambridge (UK) Clojure user group

2013-06-22 Thread Ray Miller
The Cambridge (UK) Clojure group used to meet monthly, but has recently lost momentum. I'm trying to turn that around and get us back on track with a regular monthly meet-up. If you are in the Cambridge area and might be interested in attending these meet-ups, please take a few minutes to compl

Re: clojure.set/union bug?

2013-07-01 Thread Ray Miller
On 1 July 2013 21:39, Cedric Greevey wrote: > > What bugs me is that "sorted-set-by" needs "apply" to convert a coll into > a sorted set; there's no short-and-pithy "into" for that case, and no > coll-taking and varargs version pair like vec/vector either. > (into (sorted-set) coll) -- -- You

Re: clojure.set/union bug?

2013-07-02 Thread Ray Miller
Jul 2, 2013 at 2:40 AM, Ray Miller wrote: > >> On 1 July 2013 21:39, Cedric Greevey wrote: >> >>> >>> What bugs me is that "sorted-set-by" needs "apply" to convert a coll >>> into a sorted set; there's no short-and-pithy "

Re: Clojure: Elegance vs. Performance?

2013-07-09 Thread Ray Miller
On 9 July 2013 16:11, Alexander Gunnarson wrote: > > *Example 1: Tail-call recursion* > > *Scheme* > One example would be tail-call recursion. For instance, normally in Scheme > I'd naively implement an iterative exponent function like this: > > (define (expt x n) > > (cond ((= 0 n) 1) > >

Fwd: Hands-on Clojure: Collaborative Filtering

2013-08-17 Thread Ray Miller
if any of you are in Cambridge (UK) next Thursday evening, you're be welcome to join us at the next Camclj Meetup. Details below. -- Forwarded message -- From: Ray Miller Date: 17 August 2013 15:47 Subject: Hands-on Clojure: Collaborative Filtering To: cam...@googlegroup

Re: Current state of the art in Web deployment?

2013-08-17 Thread Ray Miller
On 17 August 2013 21:52, John Jacobsen wrote: > > So, what do all y'all do? What is a good lightweight but robust way to get > a fairly simple Compojure/Ring app backed by Datomic facing the outside > world? Not too worried about massive scalability at this point; simplicity > will be a plus (am

Re: Current state of the art in Web deployment?

2013-08-18 Thread Ray Miller
On 18 August 2013 17:21, John Jacobsen wrote: > On Aug 17, 2013, at 4:52 PM, Ray Miller wrote: > >> One option is simply to write an upstart script that invokes 'lein >> ring server-headless' and sit an apache or nginx proxy in front of it. >> That

Re: vec to map with consolidated vals

2013-08-18 Thread Ray Miller
On 18 August 2013 12:31, Timo Mihaljov wrote: > On 17.08.2013 08:40, David Chelimsky wrote: >> Which led me to this: >> >> (defn to-consolidated-map [parts] >> (apply merge-with + (map (partial apply hash-map) parts))) > > This is exactly what I came up with after reading your first message. > A

Re: [OT?] Best DB/architecture for n-gram corpus?

2015-03-07 Thread Ray Miller
On 7 March 2015 at 00:25, Sam Raker wrote: > I'm trying to create an n-gram[1] corpus out of song lyrics. I'm breaking > individual songs into lines, which are then split into words, so you end up > with something like > > {0 {0 "go" 1 "tell" 2 "aunt" 3 "rhodie"} 1 {0 "the" 1 "old" 2 "grey" 3 > "

Re: [OT?] Best DB/architecture for n-gram corpus?

2015-03-10 Thread Ray Miller
On 10 March 2015 at 17:58, Sam Raker wrote: > I more meant deciding on a maximum size and storing them qua ngrams--it > seems limiting. On the other hand, after a certain size, they stop being > ngrams and start being something else--"texts," possibly. Exactly. When I first read your post, I almo

Re: [OT?] Best DB/architecture for n-gram corpus?

2015-03-10 Thread Ray Miller
On 10 March 2015 at 20:03, Sam Raker wrote: > That's honestly closer to what I was originally envisioning--I've never > really looked into graph dbs before, but I'll check out Neo4j tonight. Do > you know whether you can model multiple edges between the same nodes? Yes, certainly possible. If yo

Re: clojure.lang.LazySeq cannot be cast to clojure.lang.IFn

2015-05-08 Thread Ray Miller
Looks like the exception is thrown during config parsing. You probably need to enclose the email addresses in a vector [] rather than a list (). Ray. On 8 May 2015 at 08:01, Alexey Astafyev wrote: > I'm new to Riemann and Clojure. All I want to do is to send email > notifications to three email

Re: Code Review

2015-05-15 Thread Ray Miller
If I've understood the problem correctly, you can simplify the code by implementing a transpose function: (defn transpose [xs] (apply map vector xs)) Then define a wanted? function for filtering the lines you want to include: (defn wanted? [xs] (some zero? xs)) ...and a helper function to left-

Re: Using an atom for a caching map

2014-08-30 Thread Ray Miller
On 30 August 2014 06:26, Colin Fleming wrote: > > I want to use a map to cache values based on a key. I'm planning to use an > atom for this. My basic operation is "give me the value for this key" - if > the value exists in the map then that value should be returned, otherwise a > new value should

Re: Lein feature to check for updates in dependencies?

2014-09-11 Thread Ray Miller
https://github.com/xsc/lein-ancient On 11 September 2014 14:41, Jonathon McKitrick wrote: > I thought for sure I saw this feature, but I can't find it. > > Isn't there a way to scan for possible updates to dependencies in a project? > > -- > You received this message because you are subscribed to

Re: Clojure beginner: angst about "doing things right"

2014-09-22 Thread Ray Miller
A general rule of thumb is to prefer higher-order functions to explicit recursion. When you are trying to accumulate something (here, you are accumulating a list of zeroes and ones), you can usually use reduce. This is a little bit more tricky here as you need to keep track of which bits of the inp

Re: Is Pallet abandoned? Alternatives?

2016-09-30 Thread Ray Miller
I also got excited about pallet a year or so ago. There are some awesome ideas in there, but I found that in practice it was slow to develop with and much less flexible than it promised. In the end I switched to ansible and achieved more in 1 day than I had in a week's effort with pallet. I think t

Problem with buddy.core.keys/private-key in uberjar

2016-12-21 Thread Ray Miller
Hi, I ran into a problem reading a private key from a file using buddy-core version 1.1.1. I created a private key using: openssl genrsa -aes256 -out resources/auth_privkey.pem 2048 Here's the code: (ns tryme-buddy.core (:require [buddy.core.keys :as ks] [clojure.java.io :as io])

Re: Deploying multiple Clojure apps on one server using Reagent, Nginx, and Supervisor (Solved)

2017-01-07 Thread Ray Miller
If you're using ring, you can use the lein-ring plugin to build the uberwar: simply `lein ring uberwar`. Check out the README for options if you need to deviate from the defaults: https://github.com/weavejester/lein-ring You'll end up with an uberwar for each application you want to deploy. These

Re: Starting Clojure again

2017-09-06 Thread Ray Miller
On 6 September 2017 at 09:50, Cecil Westerhof wrote: > > ​I am trying the following throwaway code: > (defn create-pin > ([] (create-pin 8)) > ([n] >{:pre [(<= n 128) >(>= n 4)]} >(let [chars (into [] (concat (range (int \0) (inc (int \9))) (range > (int \A) (inc (int \F)] >

Re: Starting Clojure again

2017-09-06 Thread Ray Miller
On 6 September 2017 at 11:01, Cecil Westerhof wrote: > ​With the help of this list I rewrote it to: > (def digits > (apply str (map char (range (int \0) (inc (int \9)) > (def hex-digits > (apply str digits (map char (range (int \A) (inc (int \F)) > > (defn create-pin > ([] (cr

Clojure for big data

2017-10-18 Thread Ray Miller
Hi, Here at Metail we have been using Clojure for medium-sized data processing on AWS EMR. We started out with Cascalog about 5 years ago, switched to Parkour 2 years ago, and are now considering a move to Spark. My question is: is Clojure still a good choice for medium/large data processing on E

Re: Lazy Flatten; One seq at a Time

2017-11-24 Thread Ray Miller
If I've understood your problem correctly, clojure.core/lazy-cat does exactly what you need. Ray. On 22 November 2017 at 22:31, Stephen Nelson wrote: > ``` > (->> (repeatedly >(fn [] > (lazy-seq >(println "New seq...") >(map (fn [x] + x (rand-int 10)) (r

Re: partition-all in clojure.core.asyncn channel does not work

2017-12-06 Thread Ray Miller
On 6 December 2017 at 11:23, Jacek Grzebyta wrote: > > I have to populate a triple store with a big number of data (~38k records > x 12) and there is a deadly narrow bottleneck - IO operations speed. To fix > it I did: > 1. To avoid threads overflow I put all compute results into channel. >

Re: sorting a list based on the order of its items in another list

2017-12-12 Thread Ray Miller
Very similar to your solution: (filter (set small-list) big-list) On 12 December 2017 at 13:24, Deyan Yotsov wrote: > Hello, > > I have one list of potentially up to 2 million strings: big-list. > > Then I have another list, small-list, the elements of which are a subset > of the elements of big

Re: newbie Q: where is isSymbolicLink function and how to access it ?

2015-10-05 Thread Ray Miller
You need Java interop for this: (import 'java.nio,file.Files) (Files/isSymbolicLink (.toPath (io/file "/some/path"))) See http://docs.oracle.com/javase/7/docs/api/java/nio/file/Files.html for the other methods provided by this class. On 5 October 2015 at 16:47, wrote: > > In the clojure.java.

Re: core.cache limits?

2015-11-03 Thread Ray Miller
On 3 November 2015 at 01:23, William la Forge wrote: > There was just so much more there than I had ever dreamed. I had looked at > destructuring, but had been unaware of the various directives. :D > > I found this post by Jay Fields a useful resource for learning about destructuring: http://blo

Re: best practice with forked libraries

2015-11-17 Thread Ray Miller
On 17 November 2015 at 13:21, Bobby Bobble wrote: > Say there's a dependency that I fork and add some features I need for my > team's project. I can use my fork locally with lein install no problem, and > so can others *if* they clone my fork and do the same. It would be more > convenient if I co

Re: Macro usage within Clojure community and naming functions which perform actions under certain conditions

2016-04-26 Thread Ray Miller
On 25 April 2016 at 21:03, Rafał Cieślak wrote: > Hi, > > I'm writing a turn-based game and one of the biggest functions is the one > which handles player moves. It receives the current game state (a map) and > the index of the cell that the player clicked on (an integer). > > It has to make a co

Re: Where is the rotations function?

2014-02-11 Thread Ray Miller
I'm not sure if that function exists in a new contrib library, but it's trivial to implement: (defn rotations [xs] (take (count xs) (partition (count xs) 1 (cycle xs On 11 February 2014 05:53, Mars0i wrote: > At one time there was a function named "rotations" in clojure.contrib.seq, > and at

Re: dependencies from github

2014-03-27 Thread Ray Miller
Have you considered pushing your build of the package to Clojars under the org.clojars.USERNAME group? Ray. On 27 March 2014 09:16, t x wrote: > Hi, > > ## Context: > > * I'm using lein. > * In my project.clj, I have something like: > > :dependencies[ [org.clojure/clojure "1.5.1"] >

Re: what's the elegant way to write this code in clojure?

2014-04-18 Thread Ray Miller
On 18 April 2014 15:05, sd song wrote: > i use clojure and korma libs. > now i need to add some search conditions to users-sql at > "need_do_something_here",i can describe it in imperative style: > > if ( nick_name != nil) > users-sql = (where users-sql (like :nick_name nick_name) > > if (max_

Re: determining repl environment vs. uberjar environment?

2014-05-08 Thread Ray Miller
On 8 May 2014 16:22, Dave Tenny wrote: > James, All well and good, but you still need to know if you're running in a > REPL environment, and make sure you do NOT call System/exit for any > (typical) reason in that environment. The idea is to test your (-main) > function from the REPL, without hav

What is fn* ?

2014-05-26 Thread Ray Miller
I was looking at the source for clojure.java.jdbc, and came across the following macro: (defmacro with-db-transaction [binding & body] `(db-transaction* ~(second binding) (^{:once true} fn* [~(first binding)] ~@body) ~@(rest (rest binding I understa

Re: What is fn* ?

2014-05-26 Thread Ray Miller
.cgrand.net/2013/09/11/macros-closures-and-unexpected-object-retention/ Ray. > On Mon, May 26, 2014 at 9:08 AM, Ray Miller wrote: >> >> I was looking at the source for clojure.java.jdbc, and came across the >> following macro: >> >> (defmacro with-db-transactio

Re: [ANN] monarch 0.2.0 - Simple database migrations for Clojure.

2014-05-27 Thread Ray Miller
On 27 May 2014 01:02, Michael Cramm wrote: > Good question. I had originally wanted a separate, untracked config file but > couldn't decide on a format. (like separating out protocol, host, port, etc) > Exporting the environment variable felt the most non-committal at the time. Don't underestimat

Re: [ANN] monarch 0.2.0 - Simple database migrations for Clojure.

2014-05-27 Thread Ray Miller
On 27 May 2014 09:35, Manuel Paccagnella wrote: > >> I've found confijulate, here. It might be useful. > > > Well, ok. Another configuration library that I wasn't aware of when I wrote > confunion. Another one that I found after writing mine is carica, which > seems quite good. There are a bunch o

Re: clj-commons-exec/sh adding newline to command

2014-06-09 Thread Ray Miller
On 9 June 2014 02:03, gvim wrote: > (ns gh1.tmp > (:require [clj-commons-exec :as exec] > [clj-time.core :as t])) > > > > (defn calc [day month year hour min sec zone] > (let [bin "/Users/zephyr/html/astro/bin/swetest" > data (str "-p0123456789t -fPZl -b" day "

Re: clj-commons-exec/sh adding newline to command

2014-06-09 Thread Ray Miller
On 9 June 2014 12:39, gvim wrote: > Then why does this work when executed manually in the shell? > > ./swetest -p0123456789t -fPZl -b14.10.1960 -ut13:45 -roundmin -head > -true -eswe I suspect exec/sh is expecting a list of options. The way you are calling it, swetest is called with only tw

Re: How to unit test (defn-) functions?

2014-06-12 Thread Ray Miller
On 12 June 2014 09:44, Hussein B. wrote: > Hi, > > I like to use (defn-) when it comes to internal implementation functions. > But since they aren't exposed, how to unit test them? > > Of course, I'm using Lein and clojure.test It feels like a bit of a hack, but: (#'other-ns/private-fn ...) sho

Re: Help with writing a function to merge two maps

2014-06-17 Thread Ray Miller
On 17 June 2014 13:24, Shoeb Bhinderwala wrote: > Can someone help me write the following function: > > I have two lists of maps as inputs: > > (def xs [{:id 1 :val 10} > {:id 2 :val 20} > {:id 3 :val 30} > {:id 4 :val 40}]) > > (def ys [{:id 2 :val 20} >

Re: SQL to logic rule mapping

2013-10-30 Thread Ray Miller
On 30 October 2013 11:47, Kris Jenkins wrote: > FWIW, I too am interested in a better SQL tool for Clojure, but my take on > it is that we don't need a new language on top of SQL, but a better way to > use SQL directly. > > My thinking, plus an *alpha-grade* library, can be found here: > https://

Re: [ANN] Yesql 0.2.1 - Clojure & SQL queries rethought.

2013-11-18 Thread Ray Miller
Hi Gary et al, On 15 November 2013 23:55, Gary Johnson wrote: > I really like your approach, but I've also been feeling the burn a bit > with having to store each SQL query in its own file (especially since my > data exploration frequently leaves me cataloging hundreds of them). Take a > look at

Re: How could you solve this problem

2013-11-18 Thread Ray Miller
Just for contrast, here's a fairly succinct solution I put together: https://gist.github.com/ray1729/7534528#file-ring_of_primes-clj It uses a basic depth-first search. Ray. -- -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group,

Re: java.jdbc DSLs (java.jdbc.sql / java.jdbc.ddl)

2013-11-20 Thread Ray Miller
On 20 November 2013 22:25, Sean Corfield wrote: > > Is anyone using the java.jdbc.sql namespace? (besides World Singles :) > Only the 'where' function, in a few places. Ray. -- -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group

Re: How can I improve this?

2014-01-10 Thread Ray Miller
On 10 January 2014 14:59, Colin Yates wrote: > I have a sequence of file names and I want to make them unique. (uniquify > ["a" "b" "c" "a"]) => ["a" "b" "c" "a_1"]) > > This is what I have come up with, but surely there is a better way? > > I would do something like: (defn uniquify ([xs]

[Job Opportunity] Clojure Web Developer Role

2014-01-20 Thread Ray Miller
A UK-based Clojure job for a change... Metail is a start-up with a tech team based in the centre of Cambride. We are looking to recruit a junior developer to work on a mix of RESTful API handlers and frontend web applications, all build using Clojure. This is an ideal job for a recent graduate or s

Re: tools.cli and required arguments

2014-01-22 Thread Ray Miller
On 22 January 2014 13:21, Alf Kristian Støyle wrote: > Thanks! That does explain it :) > > Would be nice to be able to specify that an option "must be specified in > every invocation" though. I think it would lead to better error messages, > e.g. if several "mandatory" options are forgotten, they

Re: why do I get Null pointer on this GMT SimpleDateFormat?

2013-03-04 Thread Ray Miller
You've assigned to date-formatter-set-to-gmt-time the return value from the setTimeZone method call. This method returns null, hence the null pointer exception when you try to call the format method. 'doto' might help here, like: (let [gmt-date-formatter (doto (SimpleDateFormat. "-MMM-dd HH:mm

Re: CLI sub-commands in an uberjar?

2013-05-12 Thread Ray Miller
On 12 May 2013 10:37, Dick Davies wrote > > I've got a half-decent utility written that i want to provide to our > ops team (and not let them know it's Clojure based ssshhh). > > Works great with 'lein run -m thingy.core/fn1 arg', but there are several > functions > I want to expose as 's

Re: clj-ldap - Clojure LDAP client

2011-03-16 Thread Ray Miller
On 15 March 2011 08:46, Saul Hazledine wrote: > On Mar 15, 1:30 am, Paul Dorman wrote: > One thought though is that it may be quicker simply do a lookup on the > directory server, obtain the password and then do a compare. In > OpenLDAP, posixUser uids are indexed by default. Java libraries are >

Re: ClojureQL and Oracle

2011-04-19 Thread Ray Miller
On 19 April 2011 22:34, Michael wrote: > > As far as I can tell, ClojureQL does not directly support Oracle. Has > anybody been able to get Clojure QL to work with Oracle?  Are there > plans to directly support it? Would be great to use this with Clojure > inside the corporate ship. I've used it

Re: Parsing Log Files with Interspersed Multi-line Log Statements

2012-10-21 Thread Ray Miller
As Dave says, you can do this using line-seq, but you'll have to accumulate some state as you read the lines so you can return all the lines for a given thread's ReqStart to ReqEnd. Once you've returned that block, you can delete the state for that thread-id, so your accumulated state will only con

Re: Vector of different refs?

2012-12-11 Thread Ray Miller
(repeatedly 10 #(ref 100)) Ray. On 11 December 2012 16:44, Thomas wrote: > Hi, > > How do I create a vector of different refs? > > I would like to have a vector with in each cell a ref so that I can > manipulate them independently from each other (Is that a good idea > anyway?). But when I do

Re: clojure.contrib.base64

2011-10-06 Thread Ray Miller
On 6 October 2011 18:27, Aaron Bedra wrote: > This actually introduces an opportunity for a much larger set of utilities. > > clojure.data.crypto > > base64 is part of this idea anyways, and putting it in place along with > nice wrappers around the messy java crypto bits I think could provide a >

Re: clojure.contrib.base64

2011-10-09 Thread Ray Miller
On 6 October 2011 19:38, Ray Miller wrote: > > Incidentally, I used the Apache Commons Base64 encoder, as the one in > contrib was producing different results from the Apache Commons and > Perl implementations. Perhaps a bug? > Here's the problem I alluded to above. I

Re: clojure.contrib.base64

2011-10-09 Thread Ray Miller
On 9 October 2011 20:13, Teemu Antti-Poika wrote: > On Oct 9, 12:56 pm, Ray Miller wrote: >> On 6 October 2011 19:38, Ray Miller wrote: >> > Incidentally, I used the Apache Commons Base64 encoder, as the one in >> > contrib was producing different results from the A

Re: Macro to ease multiple-key sorting

2011-12-08 Thread Ray Miller
On 8 December 2011 01:51, Andy Fingerhut wrote: > I've been going through the PLEAC web site, writing Clojure examples > corresponding to the Perl code examples from the Perl Cookbook: > > http://pleac.sourceforge.net > > Michael Bacarella started a github repo to collect these together, and I'm >