The `db-spec` can have a `:connection` member and all operations will
use that. You are responsible for closing it when you're done.
Something like (untested, off the top of my head):
(with-open [conn (get-connection db-spec)]
(let [db (assoc db-spec :connection conn)]
...
(query db ...)
Does db-transaction work in your case?
"Evaluates body in the context of a transaction on the specified database
connection.
The binding provides the database connection for the transaction and the name
to which
that is bound for evaluation of the body.
See db-transaction* for more details."
G
I think you can use db-connection, something like:
(let [conn (db-connection spec)
meta (.getMetaData conn)]
(doall (.getTables meta nil "schema" "%s" nil))
(.close conn))
Or what have you. I wrote a little macro `with-meta-data` that was something
like that, with added try/ca
Hello. I've coded quite a lot of JDBC usage in Java, and enough Clojure to
know my way around pretty well; yet I've been unable to figure out the
following by reading the source and docs for clojure.java.jdbc. I've read
http://clojure.github.io/java.jdbc/ and many pages linked from there.
The q
Thanks!
On Tuesday, August 13, 2013 12:18:33 PM UTC-7, Norman Richards wrote:
>
>
>
>
> On Mon, Aug 12, 2013 at 4:03 PM, Mark >wrote:
>
>>
>> At run level 6, I get all the permutations of [1 2 3], just as expected.
>> However, at 7, the program does not terminate and I'd like to understand
>
On Wednesday, August 14, 2013 10:14:24 AM UTC-7, Rick Moynihan wrote:
> Subjectively I found Erlang's syntax pretty horrible (though I like the
> language itself), Ruby's is superficially beautiful but in practice
> ambiguous and not without its warts...
>
Have you had a chance to check out Eli
So I'm new to Clojure, and have been working through how to make Clojure
code performant (i.e. what approaches are faster than others, how to
profile, etc) by writing a (embarrassingly) simple ray-tracer.
In a ray tracer there is a tight loop that runs per pixel, where you
determine which of a
No; functions with :inline-* metadata (go look at the source for +, for
example) are...inlined, thus eliminating var lookups, and any effect of
binding, with-redefs, etc. The workaround for this is to call through
the var:
user=> (with-redefs [+ list] (#'+ 1 2))
(1 2)
Cheers,
- Chas
On 08/
Is this a bug?
user> (with-redefs [list +] (list 1 2)) ;; expected: 3
3 ;; huzzah
user> (with-redefs [+ list] (+ 1 2)) ;; expected: (1 2)
3 ;; blast!
--
Ben Wolfson
"Human kind has used its intelligence to vary the flavour of drinks, which
may be sweet, aromatic, fermented or spirit-based. ..
Sorry, somehow I got the wrong line pasted in there! Should be:
user=> (defn is-day-of-week? [day-enum] (= (.get (Calendar/getInstance)
Calendar/DAY_OF_WEEK) (day-enum weekdays)))
...but you probably figured that out. ;-)
DD
(2013/08/14 12:43), Daniel Meneses Báez wrote:
> m... the function y
and the non-reflective version which also fixes the typos and the
inefficient transform from keyword -> symbol.
(def ^:private day->int
{:MONDAY 2 :TUESDAY 3 :WEDNESDAY 4 :THURSDAY 5 :FRIDAY 6 :SATURDAY 7
:SUNDAY 1})
(defn is-today?
([s ^java.util.GregorianCalendar instant]
(= (.get instant
Ahhh, the good old Lisp syntax debate!
I learned Clojure back in 2008, and it was my first Lisp (and is still the
only Lisp I'm comfortable with).
I've had lots of Java experience, and a fair amount of Ruby experience over
the years... With occasional bits and pieces in other languages like
Erlan
On 14/08/13 16:45, Daniel Meneses Báez wrote:
(defn is [s instant]
(= (.get instant Calendar/DAY_OF_WEEK)
(. Calendar s)))
(def ^:private day->int
{:MONDAY 2 :TUESDAY 3 :WEDNESDAY 4 :THURSDAY 5 :FRIDAY 6 :SATURDAY 7
:SUNDAY 1})
(defn is-today?
([s instant]
(= (.get inst
m... the function you wrote only returns true on saturdays
but I get the point!
thanks for your answer
On Wed, Aug 14, 2013 at 12:14 PM, Dave Della Costa wrote:
> I know you said clj-time solved this for you, but here's another way to
> handle it which avoids using a macro (using a map of keyw
On Wed, Aug 14, 2013 at 12:08 PM, Chris Ford wrote:
> Two obviously. It's the only compromise between those who want everything
> to be a prime number, and those who want everything to be a power of two.
>
I used to sometimes use 3 spaces, just to be a contrarian. Then I learned
the error of my
And if you're a JavaScript developer with an extreme mind, you minimize
your code to have no space.
Le 14 août 2013 18:12, "Dan Cross" a écrit :
> On Wed, Aug 14, 2013 at 12:08 PM, Chris Ford
> wrote:
>
>> Two obviously. It's the only compromise between those who want everything
>> to be a prime
I know you said clj-time solved this for you, but here's another way to
handle it which avoids using a macro (using a map of keywords to
java.util.Calendar weekday enums for convenience and to be more
Clojure-esque, but it isn't necessary):
user=> (def weekdays {:mon Calendar/MONDAY :tues Calendar
Two obviously. It's the only compromise between those who want everything
to be a prime number, and those who want everything to be a power of two.
On 14 August 2013 18:48, Phillip Lord wrote:
> Răzvan Rotaru writes:
> > Statistics. I want to know how many Clojure users actually like the
> syn
Răzvan Rotaru writes:
> Statistics. I want to know how many Clojure users actually like the syntax
> and find it beautiful, and how many just go along with it, with it's good
> and bad. No school or employer assignment.
> I am surprised and happy that so many have expressed their opinion on this
I don't know if you have a differente approach, but as a defn it doesn't
work
user> (import '[java.util Calendar])
java.util.Calendar
user> (defn is [s instant]
(= (.get instant Calendar/DAY_OF_WEEK)
(. Calendar s)))
CompilerException java.lang.NoSuchFieldException: s,
compiling
why on earth is this a macro and not a regular fn?
Jim
On 14/08/13 16:19, Daniel Meneses wrote:
Hi!
Thanks for your answer Sean I got it solved using clj-time
Also I found the problem with my macro attempt
user> (defmacro is
[s instant]
`(= (.get ~instant Calendar/DAY_OF_WEE
Hi!
Thanks for your answer Sean I got it solved using clj-time
Also I found the problem with my macro attempt
user> (defmacro is
[s instant]
`(= (.get ~instant Calendar/DAY_OF_WEEK)
(. Calendar ~s)))
#'current-day.core/is
user> (is FRIDAY (Calendar/getInstance))
false
marți, 13 august 2013, 23:13:39 UTC+3, Russell Whitaker a scris:
>
> Speaking of "the purpose of the poll," what is it? What purpose does an
> off-list
> poll serve that an on-list answer doesn't? I'm curious: is this for a
> school assignment
> or for an employer or...?
>
> R
>
>
Statistics
One of the things that I find unusual with clojure is the requirement
for forward declaration. While I can see the advantages, managing it by
hand can be a pain.
So I was wondering, are there any tools for adding declare statements
when necessary. And better for working out how to reorder functi
24 matches
Mail list logo