Re: What do Clojure developers use for recurring functions, other than at-at

2018-12-17 Thread Adam Clements
I think iirc that at-at uses scheduledexecutor and is a very simple and
stable library which only does one thing, but does it well and has no
feature requests. I wrote schejulure which does a very similar job but with
cron style time specifications rather than periodic and haven't touched it
for years because it just works and even though it's used in production
nobody has found any issues or needed it to do anything it doesn't already
do. I think the same is probably true of at-at.

Adam

On Mon, 17 Dec 2018, 9:46 pm  James Reeves, that does sound like the right way to go. I'll do that.
>
>
> On Monday, December 17, 2018 at 3:31:01 PM UTC-5, James Reeves wrote:
>>
>>
>> I'd use an executor:
>>
>>   (ns example.main
>> (:import [java.util.concurrent Executors TimeUnit]))
>>
>>   (def scheduler
>> (Executors/newScheduledThreadPool 32))
>>
>>   (defn fetch-files []
>> (println "Fetching files...))
>>
>>   (defn -main []
>> (.scheduleAtFixedRate scheduler ^Runnable fetch-files 15 15
>> TimeUnit/MINUTES))
>>
>> On Mon, 17 Dec 2018 at 20:14,  wrote:
>>
>>> I'm coming back to Clojure development after a year away. This is a fast
>>> moving community and it is hard to keep up when one is not working on it
>>> full time. I'm dusting off some code I wrote 2 years ago, and trying to
>>> bring all the dependencies up to their current versions.
>>>
>>> I have a function that fetches files from an AWS S3 bucket, every 15
>>> minutes. I had previously used the at-at library for this:
>>>
>>> https://github.com/overtone/at-at
>>>
>>> But at-at has not been updated in 6 years, so I assume it is abandoned.
>>> I have two questions about this:
>>>
>>> 1.) how else do Clojure programmers usually call recurring
>>> functionality?
>>>
>>> 2.) I am ignorant about the JVM, so I'm afraid I have to ask, at a
>>> fundamental level, how does at-at work? I know that if a function calls
>>> itself recurringly, on the JVM, one eventually gets stackoverflow. So how
>>> does at-at make its magic work?
>>>
>>> --
>>> You received this message because you are subscribed to the Google
>>> Groups "Clojure" group.
>>> To post to this group, send email to clo...@googlegroups.com
>>> Note that posts from new members are moderated - please be patient with
>>> your first post.
>>> To unsubscribe from this group, send email to
>>> clojure+u...@googlegroups.com
>>> For more options, visit this group at
>>> http://groups.google.com/group/clojure?hl=en
>>> ---
>>> You received this message because you are subscribed to the Google
>>> Groups "Clojure" group.
>>> To unsubscribe from this group and stop receiving emails from it, send
>>> an email to clojure+u...@googlegroups.com.
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>>
>>
>> --
>> James Reeves
>> booleanknot.com
>>
> --
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to clojure@googlegroups.com
> Note that posts from new members are moderated - please be patient with
> your first post.
> To unsubscribe from this group, send email to
> clojure+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/clojure?hl=en
> ---
> You received this message because you are subscribed to the Google Groups
> "Clojure" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to clojure+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Clojure android activity?

2017-07-01 Thread Adam Clements
That's great Alex, all sounds really promising, I'll work out the full list
of patches and make sure everything's labelled in JIRA, but from a cursory
glance it's looking good already (CLJ-1657 is merged, the ones you
mentioned above are on their way, and I think that's most of the patch
set). The default clojure-android also had a few performance enhancements
that were still in discussion at the time, including direct linking which
in turn allowed proguard to work and bring the method count below the 65k
limit for dalvik. It's two years since I looked at this though, so I don't
know what effect 1.8 and 1.9 will have had on this and whether android
tools have done away with the 65k limit (something they were working on),
so these may have just fixed themselves over the natural course of
development.

The one elephant in the room is the ClassLoader - clojure-android is
patched to use the dalvik classloader when working dynamically rather than
AOT compiled, and there's no convenient extension point to do that from a
library or anything, and I'm guessing no appetite for an official build
config to pull it in for a clojure-android artifact. There's been some
discussion before about making this a bit more extensible in core, but I
appreciate that's never going to have a quick fix. This one isn't the end
of the world for a couple of reasons - 1) it doesn't affect production
versions when everything's AOT anyway and 2) maintaining a single patch on
top of otherwise vanilla clojure is a much less arduous task, but I'd love
to see a better solution for that.

Adam

On Fri, Jun 30, 2017 at 5:25 PM Alex Miller <a...@puredanger.com> wrote:

> It's not really lack of interest from the core team, just a matter of not
> being able to do everything. I personally am not aware of any list of
> patches necessary to make Clojure work on Android (other than CLJ-1472,
> which has been the subject of some debate across Android and Clojure).
>
> I would love to have all problems filed as tickets in jira and marked with
> a common label. I just created an Android report based on the label
> "android" at
> https://dev.clojure.org/jira/secure/IssueNavigator.jspa?mode=hide=11701.
> Feel free to tag any issues with that label so they show up there.
>
> Would be happy to try to move any issues forward towards release. CLJ-1472
> btw would possibly be sidestepped by CLJ-1891 which would pull the use of
> the locking macro out of the default initialization path (which is why it
> became an issue when it did). Doesn't really fix the issue but probably
> makes it ignorable for now. I'm hoping to get CLJ-1891 into Clojure 1.9.
>
> Alex
>
>
> On Friday, June 30, 2017 at 9:56:43 AM UTC-5, Adam Clements wrote:
>>
>> Hey Mike,
>>
>> It's a case of life getting in the way - both Alex and myself got jobs
>> not in the Android space. That being said, looking at the issues that have
>> come up on the mailing list recently most would be fairly simple fixes, and
>> I don't think there would be much of a problem bringing it up to date with
>> the latest Clojure version.
>>
>> Michael - I agree about using react native if you're writing a
>> conventional app with activities etc, with the added benefit of iOS cross
>> compatibility. If you want to do anything more involved with the input
>> apis, wear apis etc, you'll probably need access to all the raw
>> functionality as clojure-android provides.
>>
>> It's a pity there was never any interest from core to acknowledge android
>> as a supported platform - the set of patches was (and still is) pretty tiny
>> to get it running - most of the custom work happened in lein-droid to
>> package it up appropriately.
>>
>> How many people want this? Is it worth spending some time bringing things
>> back up to date? I'm going fully freelance in a week or so, so might find
>> some time between projects (or if any companies want to use this and would
>> be willing to sponsor development, get in touch and we'll see what we can
>> do)
>>
>> Adam
>>
>> On Wed, Jun 28, 2017 at 5:12 PM Michael Blume <blume.m...@gmail.com>
>> wrote:
>>
>>> My impression is that if you want to write Clojure on Android in 2017
>>> you use React Native and write ClojureScript. Re-natal is a good starting
>>> point
>>>
>>> On Fri, Jun 23, 2017, 3:57 PM Mike Meyer <m...@mired.org> wrote:
>>>
>>>> Is there still any activity in the clojure-android space? The
>>>> clojure-android mail list is largely inactive, seems like the developers of
>>>> lein-droid haven't done anything in months (1.7.0-r4 is still used in the
>>>> templates), and the numerous references If ind f

Re: Clojure android activity?

2017-06-30 Thread Adam Clements
Hey Mike,

It's a case of life getting in the way - both Alex and myself got jobs not
in the Android space. That being said, looking at the issues that have come
up on the mailing list recently most would be fairly simple fixes, and I
don't think there would be much of a problem bringing it up to date with
the latest Clojure version.

Michael - I agree about using react native if you're writing a conventional
app with activities etc, with the added benefit of iOS cross compatibility.
If you want to do anything more involved with the input apis, wear apis
etc, you'll probably need access to all the raw functionality as
clojure-android provides.

It's a pity there was never any interest from core to acknowledge android
as a supported platform - the set of patches was (and still is) pretty tiny
to get it running - most of the custom work happened in lein-droid to
package it up appropriately.

How many people want this? Is it worth spending some time bringing things
back up to date? I'm going fully freelance in a week or so, so might find
some time between projects (or if any companies want to use this and would
be willing to sponsor development, get in touch and we'll see what we can
do)

Adam

On Wed, Jun 28, 2017 at 5:12 PM Michael Blume  wrote:

> My impression is that if you want to write Clojure on Android in 2017 you
> use React Native and write ClojureScript. Re-natal is a good starting point
>
> On Fri, Jun 23, 2017, 3:57 PM Mike Meyer  wrote:
>
>> Is there still any activity in the clojure-android space? The
>> clojure-android mail list is largely inactive, seems like the developers of
>> lein-droid haven't done anything in months (1.7.0-r4 is still used in the
>> templates), and the numerous references If ind for an android-clojure web
>> site are all dead.
>>
>> That said, things do seem to mostly work for stock android. But accessing
>> API's for android wear seems problematical (see
>> https://github.com/clojure-android/lein-droid/issues/162 for my bug
>> report).
>>
>> --
>> You received this message because you are subscribed to the Google
>> Groups "Clojure" group.
>> To post to this group, send email to clojure@googlegroups.com
>> Note that posts from new members are moderated - please be patient with
>> your first post.
>> To unsubscribe from this group, send email to
>> clojure+unsubscr...@googlegroups.com
>> For more options, visit this group at
>> http://groups.google.com/group/clojure?hl=en
>> ---
>> You received this message because you are subscribed to the Google Groups
>> "Clojure" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to clojure+unsubscr...@googlegroups.com.
>> For more options, visit https://groups.google.com/d/optout.
>>
> --
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to clojure@googlegroups.com
> Note that posts from new members are moderated - please be patient with
> your first post.
> To unsubscribe from this group, send email to
> clojure+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/clojure?hl=en
> ---
> You received this message because you are subscribed to the Google Groups
> "Clojure" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to clojure+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: The soul of case

2017-06-26 Thread Adam Clements
This came up in 2014 on the mailing list
https://groups.google.com/forum/m/#!topic/clojure/3yGjDO2YnjQ

And resulting enhancement requests Alex asked for:
https://dev.clojure.org/jira/browse/CLJ-1367
https://dev.clojure.org/jira/browse/CLJ-1368

For what it's worth (though I realise we don't want to break back
compatibility), I find the clojure behavior v surprising given that the
parallel switch/case in Java is so frequently used for exactly this sort of
const jump table. Intuitively it makes no sense for me that in this one
statement you would compare the symbol and not the const value. It actively
discourages naming magic constants if you don't want to fall back to slower
condp or a map lookup.

Adam

On Sun, 25 Jun 2017, 10:53 p.m. David Nolen,  wrote:

> On Sat, Jun 24, 2017 at 1:49 PM, Matching Socks 
> wrote:
>
>>
>> At any rate, I would like to put in either a documentation issue (if it's
>> a feature that ClojureScript's "case" does not work like Clojure's) or else
>> a defect issue (if it's a bug).
>>
>
> As I stated earlier, we're not going to remove it nor change the existing
> behavior in anyway whatsoever. And yes it will get documented.
>
> David
>
> --
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to clojure@googlegroups.com
> Note that posts from new members are moderated - please be patient with
> your first post.
> To unsubscribe from this group, send email to
> clojure+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/clojure?hl=en
> ---
> You received this message because you are subscribed to the Google Groups
> "Clojure" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to clojure+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Compiling gen-class runs static initializers: workarounds, solutions?

2017-03-28 Thread Adam Clements
Potentially relevant? I posted a patch two years ago for some static
initialisers still running in 1.8, not yet merged. It was actually the type
hints causing the initialisers to be run at compile time

http://dev.clojure.org/jira/browse/CLJ-1714

On Tue, Mar 28, 2017 at 10:21 AM 'Gunnar Völkel' via Clojure <
clojure@googlegroups.com> wrote:

> The JavaFX workaround consist of creating a javafx.embed.swing.JFXPanel
> statically in a namespace that is loaded before any other namespace that
> import problematic JavaFX classes as in [1,2].
> This initializes the JavaFX platform.
>
> [1]
> https://github.com/halgari/fn-fx/blob/master/src/fn_fx/render_core.clj#L20
> [2]
> https://github.com/zilti/clojurefx/blob/master/src/clojurefx/core.clj#L7
>
> --
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to clojure@googlegroups.com
> Note that posts from new members are moderated - please be patient with
> your first post.
> To unsubscribe from this group, send email to
> clojure+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/clojure?hl=en
> ---
> You received this message because you are subscribed to the Google Groups
> "Clojure" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to clojure+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Awesome Clojure Engineer Opportunity

2015-10-12 Thread Adam Clements
Hi Rameen,

I have attached my CV for your consideration, but be aware that I am only
currently considering remote working roles, and so more information would
be required.

Thanks,
Adam Clements


On Mon, Oct 12, 2015 at 9:07 PM Rameen Fattahi <rameenfatt...@gmail.com>
wrote:

> Hi Everyone,
>
> My name is Rameen and I'm looking for a passionate Clojure engineer for a
> very confidential project at one of the biggest companies in the world
> (cannot name it here for privacy reasons).
>
> This is a full time role on our Applied Machine Learning team. If you're
> interested, please send me your resume and I'd be happy to chat with you.
>
> Thanks a lot,
> Rameen Fattahi, *Technical Recruiter*
>
> --
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to clojure@googlegroups.com
> Note that posts from new members are moderated - please be patient with
> your first post.
> To unsubscribe from this group, send email to
> clojure+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/clojure?hl=en
> ---
> You received this message because you are subscribed to the Google Groups
> "Clojure" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to clojure+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Adam Clements CV (1).pdf
Description: Adobe PDF document


Clarity Keyboard by SwiftKey - Written in Clojure

2015-05-08 Thread Adam Clements
Hi all,

Just thought you might be interested to know that last week we (SwiftKey)
released an Android app, written from the ground up in Clojure, which as of
this morning has had 65k downloads. It's a keyboard we're using to test UI
ideas which didn't fit well with the existing app. We also took the
opportunity to try out a totally different tech stack, central to which are
Clojure and core.async.

There's a tech blog on the subject at my personal blog
http://adamclements.github.io/articles/clarity-keyboard-uses-clojure/ which
is reposted on SwiftKey's tech blog
http://swiftkey.com/en/blog/what-makes-clarity-keyboard-tick-clojure/ and
you can download the app and try it out from Google Play
https://play.google.com/store/apps/details?id=com.swiftkey.clarity.keyboardreferrer=utm_source%3Dclojurelist%26utm_medium%3Dmailinglist

Many thanks go to everyone who's worked on clojure and clojure-android for
making this possible, it's been a dream to develop! I hope this goes to
show that it's perfectly reasonable and possible to develop significant,
responsive mobile applications in pure Clojure.

I'd be interested to know your thoughts and comments, and if you're
interested we are currently hiring here at SwiftKey, both for this project
and in general.

Thanks,
Adam Clements

-- 
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
Clojure group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Clarity Keyboard by SwiftKey - Written in Clojure

2015-05-08 Thread Adam Clements
Haven't played with j2objc, but have had a play with compiling the core in
RoboVM using lein-fruit. The limitations are a bit different on iOS though,
for example the 40mb hard limit on ram usage for a keyboard before it is
forceably kicked out of memory, and that's around the low end of what we're
getting at the moment on Android, so it might need some different
optimizations before becoming a viable option there. In theory it should be
doable though.

Adam

On Fri, 8 May 2015 7:05 pm adrians nman...@gmail.com wrote:

 Just tried the keyboard on my old Galaxy Nexus and I have to say that it
 felt really responsive (prediction works great, too). This really validates
 Clojure (well Skummet) for Android development, IMO. Congrats on pushing
 the boundaries and for the writeup around what you've done. I'm curious if
 you're looking at j2objc in combination with Skummet for projects targeting
 Android + iOS.

 Cheers


 On Friday, May 8, 2015 at 7:18:50 AM UTC-4, Adam Clements wrote:

 Hi all,

 Just thought you might be interested to know that last week we (SwiftKey)
 released an Android app, written from the ground up in Clojure, which as of
 this morning has had 65k downloads. It's a keyboard we're using to test UI
 ideas which didn't fit well with the existing app. We also took the
 opportunity to try out a totally different tech stack, central to which are
 Clojure and core.async.

 There's a tech blog on the subject at my personal blog
 http://adamclements.github.io/articles/clarity-keyboard-uses-clojure/ which
 is reposted on SwiftKey's tech blog
 http://swiftkey.com/en/blog/what-makes-clarity-keyboard-tick-clojure/ and
 you can download the app and try it out from Google Play
 https://play.google.com/store/apps/details?id=com.swiftkey.clarity.keyboardreferrer=utm_source%3Dclojurelist%26utm_medium%3Dmailinglist

 Many thanks go to everyone who's worked on clojure and clojure-android
 for making this possible, it's been a dream to develop! I hope this goes to
 show that it's perfectly reasonable and possible to develop significant,
 responsive mobile applications in pure Clojure.

 I'd be interested to know your thoughts and comments, and if you're
 interested we are currently hiring here at SwiftKey, both for this project
 and in general.

 Thanks,
 Adam Clements

  --
 You received this message because you are subscribed to the Google
 Groups Clojure group.
 To post to this group, send email to clojure@googlegroups.com
 Note that posts from new members are moderated - please be patient with
 your first post.
 To unsubscribe from this group, send email to
 clojure+unsubscr...@googlegroups.com
 For more options, visit this group at
 http://groups.google.com/group/clojure?hl=en
 ---
 You received this message because you are subscribed to the Google Groups
 Clojure group.
 To unsubscribe from this group and stop receiving emails from it, send an
 email to clojure+unsubscr...@googlegroups.com.
 For more options, visit https://groups.google.com/d/optout.


-- 
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
Clojure group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Streaming a large file onto a channel

2015-03-18 Thread Adam Clements
It's possible you are simply not seeing the println output from a
background thread, depending on how your repl etc is set up.

On Wed, 18 Mar 2015 3:19 pm Adrian Mowat adrian.mo...@gmail.com wrote:

 Hi Erick

 Thanks for getting back to me.  On my system, I wasn't seeing the contents
 of my file being listed in the REPL.  Your code is working fine though and
 I can't see anything significantly different so I wonder if I had managed
 to corrupt my session in some way.

 Anyway, it's good to know I'm on the right path.  I'll post my solutions
 as I get things up and running

 Cheers

 Adrian



 On Wednesday, 18 March 2015 13:45:33 UTC, Erick Pintor wrote:

 Hi Adrian,

 What is exactly the issue that you're facing?
 I did my own version and it seems to be working fine.

 Please, take a look and I hope it helps.

 (defn process-file [ch file]
   (async/thread
 (with-open [input (io/reader file)]
   (doseq [line (line-seq input)]
 (async/!! ch line)

 (defn parse [line]
   (str Parsed:  line)) ; change it to do whatever you want

 (defn mapping [ch]
   (async/map parse [ch]))

 (defn start []
   (let [events (mapping
  (async/chan))]
 (process-file events 10_events.json)
 (async/go-loop []
(let [v (async/! events)]
  (println v)
  (recur)

 About your approach. For me, it seems a legitimate usage for core.async.
 Please, send us your impressions once you finish.

 Cheers,


 Em terça-feira, 17 de março de 2015 09:52:17 UTC-3, Adrian Mowat escreveu:

 Hi,

 I've played around with core.async a bit but now I'm trying to use it
 for a real project and I'm running into a problem getting data off a file
 and into a channel on the JVM (i.e. as opposed to ClojureScript)

 I have around 1GB of data sitting in a file.  Each line of the file
 contains a separate JSON document.  There are different types of document
 in the file and I would like use core.async to setup a pipeline of
 concurrent operations as follows so I can start processing the data before
 I've finished reading the file.

 1. Stream the raw data out of the file one line at a time, parse it as
 JSON and write each line to channel (1)
 2. Read channel (1) and divide the messages up by type and write them to
 new channels (2..n)
 3. Read channels (2..n) and apply business logic as appropriate

 I'd like the initial read to run in it's own thread because it will be
 IO blocking.  The others can run in core.async's thread pool

 I'm running into problems getting channels (1) and (2) to talk to one
 another.  Here's my initial spike and I would expect it to write the 10
 lines of json from the example file to stdout.

 (defn file-to-chan [ch file]
   (do
 (async/thread
   (with-open [rdr (io/reader file)]
 (doseq [line (line-seq rdr)]
   (!! ch line
 ch))

 (defn parse-line [s]
   (json/parse-string s (comp keyword str/lower-case)))

 (def events (chan 1 (map parse-line)))

 (go
   (while true
 (println (! events

 (file-to-chan events 10_events.json)

 I have a few questions...

 * Can anyone help me understand what's going wrong? (I'm sure it's
 something silly, but I'm going cross eyed looking at it)
 * It's effectively a batch process.  Is this an appropriate use case for
 core.async?
 * If so, am I on the right track or is there a better way to approach
 this?

 Many Thanks

 Adrian





  --
 You received this message because you are subscribed to the Google
 Groups Clojure group.
 To post to this group, send email to clojure@googlegroups.com
 Note that posts from new members are moderated - please be patient with
 your first post.
 To unsubscribe from this group, send email to
 clojure+unsubscr...@googlegroups.com
 For more options, visit this group at
 http://groups.google.com/group/clojure?hl=en
 ---
 You received this message because you are subscribed to the Google Groups
 Clojure group.
 To unsubscribe from this group and stop receiving emails from it, send an
 email to clojure+unsubscr...@googlegroups.com.
 For more options, visit https://groups.google.com/d/optout.


-- 
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
Clojure group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Clojurescript to target JVM?

2015-01-28 Thread Adam Clements
I'm currently using the fastload branch against alpha5, and it's pretty
good. You have to be careful though with namespace declarations as you may
end up loading more than you need to. I'm currently in the process of
breaking my app down into runlevels, where it loads the minimum needed to
get started and then once that's all done and the app is responsive it
starts loading the namespaces that might not be needed for a little while.
I got a large chunk of my start up time back by avoiding loading all of
tools.analyser for core.async (see my blog post on the subject here
http://adamclements.github.io/articles/core-async-runtime-dependencies/).

I think by doing this and being careful what you load (my build of clojure
has logging turned on for when it loads/compiles individual namespaces and
how long it takes repo here https://github.com/AdamClements/clojure), it
should be possible to get something up and running pretty quickly.

On Wed Jan 28 2015 at 16:34:52 Ashton Kemerling ashtonkemerl...@gmail.com
wrote:

 A lot of the slowness in Clojure comes down to how slow it is to load the
 main namespaces that are needed, especially clojure.core (see this post
 http://nicholaskariniemi.github.io/2014/02/25/clojure-bootstrapping.html
 ).

 You should also look into the Clojure fastload branch, which apparently
 helped out a few Android programmers according to the clojure-android
 google list.

 On Friday, November 21, 2014 at 2:48:20 PM UTC-7, Alan Moore wrote:


 On Friday, November 21, 2014 9:50:58 AM UTC-8, Uday Verma wrote:

 Hello Everyone,

 Basically the approach is this: cljs - js - rhino [3] - bytecode.
 Provides java interop through rhino.  By the time things get to rhino,
 google closure has already thrown away most of the runtime away since we
 didn't use it, and we end up with manageable amount of JS which is compiled
 to manageable amount of byte code.   All of jvm is still available.


 Sounds like the clojure compiler could benefit from dead code
 elimination. I'm not sure if that is possible or not but it does sound like
 it might work. Compiles would probably take longer so the gains might be
 offset by longer compile times. If this is the case then it wouldn't help
 development workflows but could provide deployment/runtime gains.

 I'm wondering if the availability of eval in clojure and the lack of it
 in clojurescript makes a difference - it might lead to some code that can't
 be properly analyzed.

 Alan

  --
 You received this message because you are subscribed to the Google
 Groups Clojure group.
 To post to this group, send email to clojure@googlegroups.com
 Note that posts from new members are moderated - please be patient with
 your first post.
 To unsubscribe from this group, send email to
 clojure+unsubscr...@googlegroups.com
 For more options, visit this group at
 http://groups.google.com/group/clojure?hl=en
 ---
 You received this message because you are subscribed to the Google Groups
 Clojure group.
 To unsubscribe from this group and stop receiving emails from it, send an
 email to clojure+unsubscr...@googlegroups.com.
 For more options, visit https://groups.google.com/d/optout.


-- 
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
Clojure group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [ANN] Clojure 1.7.0-alpha5 now available

2015-01-22 Thread Adam Clements
Just to follow up, doing the obvious (though perhaps naïve) fix of changing
forName to forNameNonLoading in the referenced maybeClass does seem to fix
the issue and I can now AOT compile my application without needing the
binaries for this machine. I don't know whether this change would have any
other repercussions though.

On Thu Jan 22 2015 at 17:49:37 Adam Clements adam.cleme...@gmail.com
wrote:

 I think I am seeing static initialisers being run at AOT time when the
 class is used as a type hint tag. This isn't a regression from previous
 versions of clojure, but with the forNameNonLoading changes that have gone
 in recently I was under the impression that this shouldn't be a problem any
 more.

 My specific case has a static initialiser which loads a native library
 (and I don't have the appropriate binary architecture for the machine doing
 the compilation).

 The function definition
 (defn some-function [^com.my_class.ExampleWhichLoadsNative x] ...)

 fails at AOT compile time with the (abridged) stack trace containing:
 ...
 at clojure.lang.Compiler.analyzeSeq(Compiler.java:6715)
 at clojure.lang.Compiler.analyze(Compiler.java:6499)
 at clojure.lang.Compiler.analyzeSeq(Compiler.java:6696)
 at clojure.lang.Compiler.analyze(Compiler.java:6499)
 at clojure.lang.Compiler.access$200(Compiler.java:38)
 at clojure.lang.Compiler$DefExpr$Parser.parse(Compiler.java:560)
 at clojure.lang.Compiler.analyzeSeq(Compiler.java:6708)
 at clojure.lang.Compiler.analyze(Compiler.java:6499)
 at clojure.lang.Compiler.analyze(Compiler.java:6460)
 at clojure.lang.Compiler.compile1(Compiler.java:7285)
 at clojure.lang.Compiler.compile(Compiler.java:7356)
 at clojure.lang.RT.compile(RT.java:406)
 ...
 Caused by:
 ...
 my class clinit
 at java.lang.Class.forName0(Native Method)
 at java.lang.Class.forName(Class.java:274)
 at clojure.lang.RT.classForName(RT.java:2127)
 at clojure.lang.RT.classForName(RT.java:2136)
 at clojure.lang.Compiler$HostExpr.maybeClass(Compiler.java:1000)
 at clojure.lang.Compiler$HostExpr.tagToClass(Compiler.java:1092)
 at clojure.lang.Compiler.tagClass(Compiler.java:8187)
 at clojure.lang.Compiler$FnMethod.parse(Compiler.java:5218)
 at clojure.lang.Compiler$FnExpr.parse(Compiler.java:3900)
 at clojure.lang.Compiler.analyzeSeq(Compiler.java:6706)
 ...

 On Wed Jan 21 2015 at 23:58:28 Alan Moore kahunamo...@gmail.com wrote:

 Sweet - thanks for the reply. I hope I didn't sound impatient... I'm very
 grateful for your hard work on it. I'd offer to help but I'm sure it is
 beyond me and my crazy-mad Clojure skillz(tm). I think I'll leave the hard
 stuff to the real experts :-)

 Alan


 On Wednesday, January 21, 2015 at 6:07:13 AM UTC-8, Alex Miller wrote:

 I am actively working on an updated set of patches, hopefully for
 inclusion in the next alpha.

 Alex

  --
 You received this message because you are subscribed to the Google
 Groups Clojure group.
 To post to this group, send email to clojure@googlegroups.com
 Note that posts from new members are moderated - please be patient with
 your first post.
 To unsubscribe from this group, send email to
 clojure+unsubscr...@googlegroups.com
 For more options, visit this group at
 http://groups.google.com/group/clojure?hl=en
 ---
 You received this message because you are subscribed to the Google Groups
 Clojure group.
 To unsubscribe from this group and stop receiving emails from it, send an
 email to clojure+unsubscr...@googlegroups.com.
 For more options, visit https://groups.google.com/d/optout.



-- 
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
Clojure group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [ANN] Clojure 1.7.0-alpha5 now available

2015-01-22 Thread Adam Clements
I think I am seeing static initialisers being run at AOT time when the
class is used as a type hint tag. This isn't a regression from previous
versions of clojure, but with the forNameNonLoading changes that have gone
in recently I was under the impression that this shouldn't be a problem any
more.

My specific case has a static initialiser which loads a native library (and
I don't have the appropriate binary architecture for the machine doing the
compilation).

The function definition
(defn some-function [^com.my_class.ExampleWhichLoadsNative x] ...)

fails at AOT compile time with the (abridged) stack trace containing:
...
at clojure.lang.Compiler.analyzeSeq(Compiler.java:6715)
at clojure.lang.Compiler.analyze(Compiler.java:6499)
at clojure.lang.Compiler.analyzeSeq(Compiler.java:6696)
at clojure.lang.Compiler.analyze(Compiler.java:6499)
at clojure.lang.Compiler.access$200(Compiler.java:38)
at clojure.lang.Compiler$DefExpr$Parser.parse(Compiler.java:560)
at clojure.lang.Compiler.analyzeSeq(Compiler.java:6708)
at clojure.lang.Compiler.analyze(Compiler.java:6499)
at clojure.lang.Compiler.analyze(Compiler.java:6460)
at clojure.lang.Compiler.compile1(Compiler.java:7285)
at clojure.lang.Compiler.compile(Compiler.java:7356)
at clojure.lang.RT.compile(RT.java:406)
...
Caused by:
...
my class clinit
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:274)
at clojure.lang.RT.classForName(RT.java:2127)
at clojure.lang.RT.classForName(RT.java:2136)
at clojure.lang.Compiler$HostExpr.maybeClass(Compiler.java:1000)
at clojure.lang.Compiler$HostExpr.tagToClass(Compiler.java:1092)
at clojure.lang.Compiler.tagClass(Compiler.java:8187)
at clojure.lang.Compiler$FnMethod.parse(Compiler.java:5218)
at clojure.lang.Compiler$FnExpr.parse(Compiler.java:3900)
at clojure.lang.Compiler.analyzeSeq(Compiler.java:6706)
...

On Wed Jan 21 2015 at 23:58:28 Alan Moore kahunamo...@gmail.com wrote:

 Sweet - thanks for the reply. I hope I didn't sound impatient... I'm very
 grateful for your hard work on it. I'd offer to help but I'm sure it is
 beyond me and my crazy-mad Clojure skillz(tm). I think I'll leave the hard
 stuff to the real experts :-)

 Alan


 On Wednesday, January 21, 2015 at 6:07:13 AM UTC-8, Alex Miller wrote:

 I am actively working on an updated set of patches, hopefully for
 inclusion in the next alpha.

 Alex

  --
 You received this message because you are subscribed to the Google
 Groups Clojure group.
 To post to this group, send email to clojure@googlegroups.com
 Note that posts from new members are moderated - please be patient with
 your first post.
 To unsubscribe from this group, send email to
 clojure+unsubscr...@googlegroups.com
 For more options, visit this group at
 http://groups.google.com/group/clojure?hl=en
 ---
 You received this message because you are subscribed to the Google Groups
 Clojure group.
 To unsubscribe from this group and stop receiving emails from it, send an
 email to clojure+unsubscr...@googlegroups.com.
 For more options, visit https://groups.google.com/d/optout.


-- 
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
Clojure group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Clojurescript to target JVM?

2015-01-15 Thread Adam Clements
I've been looking at getting my startup time down on my Clojure on android
app (it needs to be at least an order of magnitude smaller before I can
ship), and revisited this as a potential candidate. The biggest friction
point was that I would have to change which libraries I use and revisit all
the java interop to make it work nicely as clojurescript.

This got me wondering, would a hybrid approach work? If Rhino can use java
classes, could we rework the clojurescript emitter to emit javascript
corresponding to jvm clojure with rhino's java interop? Presumably if only
the javascript primitives were used and the java objects and interop
retained, the resulting rhino compiled bytecode would be fairly reasonable?
What's more, all the var indirection could be removed and macro
transformations baked in, making it less dynamic and workable for proguard
optimisation even if google's closure compiler didn't work very well with
it.

It's a fairly roundabout approach, and it might be that it would be quicker
to just implement a static production-mode compiler for clojure and skip
the clojurescript hack, but let me know if you think there would be some
mileage in using this to get something working in the short term.

Adam

On Sat Nov 22 2014 at 04:29:47 Sam Beran sbe...@gmail.com wrote:

 The code is still half-baked, but in leu of a blog post or code, I can
 summarize my reasoning and approach:


 *ClojureScript is Designed With UI Responsiveness In Mind*

 At present, JVM Clojure is not currently suitable for Android development.
  Since Android applications are structured around ephemeral Activities,
 any startup penalty over 250 ms is simply unacceptable. Current benchmarks
 [1] are showing 2-5 seconds of startup time, and I have seen no
 straightforward advice on how to achieve an order-of-magnitude increase in
 startup performance. ClojureScript (and JavaScript) is designed from the
 ground up with startup speed in mind. ClojureScript can be used to create
 responsive user interfaces on Android.


 *Selecting a Host Runtime*

 In order to run ClojureScript on Android, I considered the following
 options for host runtimes:

- *Android WebView * - we can achieve reasonable startup times with a
WebView, however any data must be serialized and deserialized in order to
communicate between a WebView and Java. Even worse, any long-running object
lifecycles must be manually managed, since we cannot rely on garbage
collection to maintain object references between the host VM and those of
the WebView.
- *V8 (JNI) - *I briefly considered compiling a V8 runtime to host
ClojureScript. Startup speed would probably outperform the WebView. This
would be a lot of work to develop a nice bridging mechanism. Object
lifecycle management is better than WebView, but still not ideal. With no
C++ or JNI background, I could tell very quickly that this would not be a
weekend project.
- *Rhino* - Rhino is a lightweight JavaScript runtime for the JVM.
Execution speed is not fast, and since Rhino is not actively maintained, it
will probably never support ES6 - not huge concerns for ClojureScript.
Since Rhino is a pure-Java runtime, there is very little overhead when
communicating between JS- Java, and Java GC can be used to maintain
object lifecycles.
- *Nashorn *- the successor to rhino. Not an option until Android
supports InvokeDynamic.[2]



 *Achieving Fast Startup on Rhino*

 When I initially ran ClojureScript on Rhino, Startup speed was around 8-10
 seconds - even worse than JVM Clojure! Some quick measurements indicated
 that the bulk of the time was spent with Rhino parsing the JS sources for
 cljs/core.js. I was pleased to discover that Rhino supports bytecode
 precompilation via the jsc utility [3]. I was able to precompile the
 ClojureScript output to bytecode, and achieve *much faster startup -
 around 150ms on device*. This is well within the target performance
 range, and is fast enough to eliminate any noticeable UI lag.

 One hurdle I ran into is the 64k method size limit for Java classes. Since
 jsc compiles all .js files to a single method in a Java class, compiling
 cljs/core.js caused errors when compiling to bytecode. I was able to get
 around this by splitting the JS files in half during the build process
 until they were small enough to compile. *I have since implemented some
 optimizations which bring the startup overhead of ClojureScript down to 
 100 ms.*


 *Pure ClojureScript Android Applications*

 Since I am precompiling the ClojureScript sources, I can also generate
 Java classes using ClojureScript macros. Here is an example of an Android
 Activity written in ClojureScript. This activity is compiled to Java in a
 similar manner to Clojure's gen-class mechanism:

 (ns cljs-hello.core
 (:require-macros [lambdroid.compile :refer [java-class]]))

 (java-class
 {:name io.lambdroid.MyActivity
  :extends 

Re: How can I remove the nils in the result?

2014-12-24 Thread Adam Clements
Colin, minor code review point that makes no real difference for this
example but is a good habit to get into: try not to use last on vectors,
use peek instead, otherwise it calls seq and steps through the entire
sequence on each call. peek on the other hand does what you'd expect. For
long lists this saves you a fair bit of work!

On Wed, 24 Dec 2014 1:54 am Colin Jones trptco...@gmail.com wrote:

 Thanks, I had fun with this!

 This isn't more concise, but I went in a little a different direction,
 trying to pull the various concerns apart. In particular I had fun
 separating:
 - the idea of intervals for which any predicate passed from the specific
 case of 0/1 equality comparison
 - the string representation of intervals from their computation
 - the idea of one-indexing from the rest of the problem

 https://gist.github.com/trptcolin/a573561ac9262092f254

 - Colin

 p.s. There was no need for me to use `juxt` in `format-interval` but
 honestly, if you're not going to use `juxt` at every conceivable
 opportunity, why bother?


 On Monday, December 22, 2014 10:09:06 PM UTC-6, Pauli wrote:

 Hi, all:

 I'm tring to solve such a problem: Given a string consisting of 1 and
 0, find all the locations of 1, and print them in the format of
 intervals.

 For example: 00101110101110 = 3, 5-7, 9, 11-13

 Here is my solution:

 (defn bar [x]
   (letfn [(foo [mystr]
 (-
   (map-indexed vector mystr)
   (filter #(= (second %) \1))
   (map (comp inc first))
   (partition-all 2 1)
   (filter #(= 2 (count %)]
 (let [y (map #(if ( (- (second %) (first %)) 1) (print (first %) ,  
 (second %) -)) (foo x))]
   (print (ffirst y) - y (last (last (foo x)))


 With the code above, I got many nils in the result:

 (bar 00101110101110) = 3 , 5 -nil - (nil nil 7 , 9 -nil 9 , 11 -nil
 nil nil nil) 13

 How can I remove them?

 And, is there any way to make my code more concise?



  --
 You received this message because you are subscribed to the Google
 Groups Clojure group.
 To post to this group, send email to clojure@googlegroups.com
 Note that posts from new members are moderated - please be patient with
 your first post.
 To unsubscribe from this group, send email to
 clojure+unsubscr...@googlegroups.com
 For more options, visit this group at
 http://groups.google.com/group/clojure?hl=en
 ---
 You received this message because you are subscribed to the Google Groups
 Clojure group.
 To unsubscribe from this group and stop receiving emails from it, send an
 email to clojure+unsubscr...@googlegroups.com.
 For more options, visit https://groups.google.com/d/optout.


-- 
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
Clojure group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Google Clojure REPL

2014-11-24 Thread Adam Clements
There are a number of issues with clojure on lollipop, the ART compiler
doesn't like the bytecode generated by closure for various reasons. I have
just today opened a dialogue with the ART developers at Google and at least
some of the issues have been fixed for the next release of Android. Others
might require changes to clojure though. Be reassured that there is some
movement in this area though.

If you are referring to the app store clojure REPL, that is probably
suffering from the same issues. I'm not sure who publishes that though, so
don't know whether it would be updated once this is resolved.

On Mon, 24 Nov 2014 4:14 pm Zach Oakes zsoa...@gmail.com wrote:

 I believe there are still issues with ART that need to be resolved before
 Clojure apps run on Lillipop. You may want to ask this on the
 clojure-android list instead:

 https://groups.google.com/forum/#!forum/clojure-android


 On Sunday, November 23, 2014 5:39:08 PM UTC-5, Lorentzz00 wrote:

 Hello to all;

 So, the Clojure REPL for Lollipop doesn't
 Work. Why? Why won't it install? When will you migrate to 1.6 or 1.7?

 Hope to hear something soon.
 Lorentzz

  --
 You received this message because you are subscribed to the Google
 Groups Clojure group.
 To post to this group, send email to clojure@googlegroups.com
 Note that posts from new members are moderated - please be patient with
 your first post.
 To unsubscribe from this group, send email to
 clojure+unsubscr...@googlegroups.com
 For more options, visit this group at
 http://groups.google.com/group/clojure?hl=en
 ---
 You received this message because you are subscribed to the Google Groups
 Clojure group.
 To unsubscribe from this group and stop receiving emails from it, send an
 email to clojure+unsubscr...@googlegroups.com.
 For more options, visit https://groups.google.com/d/optout.


-- 
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
Clojure group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Locking macro generated bytecode

2014-07-23 Thread Adam Clements
I'm compiling clojure on android and running it using the new ART runtime,
and all works fine apart from the locking macro which fails ART's bytecode
verification.

Example generated bytecode here:
https://gist.github.com/AdamClements/2ae6c4919964b71eb470

The try block in java doesn't cover the monitorenter, where in clojure it
does (this means that if the monitorenter fails, it will still attempt the
monitorexit which I think is wrong). I tried this change, but it still
fails ART's verification.

The other difference is that the java version also catches any exceptions
around *either* of the monitorexits and will retry the monitorexit
indefinitely. I couldn't find a way to replicate this in clojure.

Looking at the ART verifier source
https://android.googlesource.com/platform/art/+/kitkat-release/runtime/verifier/method_verifier.cc
on line 2731, it seems that the condition is that every instruction where
the monitorenter/exit tally  0 should be within a catch all block, which
it isn't in the clojure version, there's all sorts going on which isn't
within the finally's scope.

Any insight would be appreciated,

Adam

-- 
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
Clojure group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Locking macro generated bytecode

2014-07-23 Thread Adam Clements
So as an update to this for anybody who's interested, I now have a working
version with no verification errors simply by moving the monitor-enter
outside the try block, so that if monitor-enter fails to acquire the lock,
monitor-exit is not called.

(the reason this wasn't working before was that I was inadvertently
including both org.clojure/clojure and my patched
org.clojure-android/clojure due to transitive dependencies).

I've submitted a patch and ticket
http://dev.clojure.org/jira/browse/CLJ-1472


Adam


On Wed, Jul 23, 2014 at 1:28 PM, Adam Clements adam.cleme...@gmail.com
wrote:

 I'm compiling clojure on android and running it using the new ART runtime,
 and all works fine apart from the locking macro which fails ART's bytecode
 verification.

 Example generated bytecode here:
 https://gist.github.com/AdamClements/2ae6c4919964b71eb470

 The try block in java doesn't cover the monitorenter, where in clojure it
 does (this means that if the monitorenter fails, it will still attempt the
 monitorexit which I think is wrong). I tried this change, but it still
 fails ART's verification.

 The other difference is that the java version also catches any exceptions
 around *either* of the monitorexits and will retry the monitorexit
 indefinitely. I couldn't find a way to replicate this in clojure.

 Looking at the ART verifier source
 https://android.googlesource.com/platform/art/+/kitkat-release/runtime/verifier/method_verifier.cc
 on line 2731, it seems that the condition is that every instruction where
 the monitorenter/exit tally  0 should be within a catch all block, which
 it isn't in the clojure version, there's all sorts going on which isn't
 within the finally's scope.

 Any insight would be appreciated,

 Adam


-- 
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
Clojure group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Deploying to Clojars no longer works

2014-07-03 Thread Adam Clements
Have you tried upgrading leiningen to the latest version? I don't think you
can deploy from old versions, at least that's been a problem for me in the
past.
On 2 Jul 2014 20:55, Jacob Goodson submissionfight...@gmx.com wrote:

 I have been deploying the same project to clojars for quite a while now(5
 months?); for some reason it decided it no longer wanted to work.  After
 giving my pass phrase I get peer not authenticated.  I have not changed
 computers nor do I have a new internet connection.  Does anyone know what
 the heck I've done to blow it up?

 --
 You received this message because you are subscribed to the Google
 Groups Clojure group.
 To post to this group, send email to clojure@googlegroups.com
 Note that posts from new members are moderated - please be patient with
 your first post.
 To unsubscribe from this group, send email to
 clojure+unsubscr...@googlegroups.com
 For more options, visit this group at
 http://groups.google.com/group/clojure?hl=en
 ---
 You received this message because you are subscribed to the Google Groups
 Clojure group.
 To unsubscribe from this group and stop receiving emails from it, send an
 email to clojure+unsubscr...@googlegroups.com.
 For more options, visit https://groups.google.com/d/optout.


-- 
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
Clojure group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Performance trouble with Processing jar

2014-03-29 Thread Adam Clements
Have you got type hints? If you do a java method call on something which
isn't type hinted then clojure has to use reflection to look up a list of
the available methods, which is slw. If however you tell it what type
you expect it to be, it can better optimise it. So in the above code you
would have something more like (defn draw [^Applet applet] (.line applet
))

Look up how to turn on reflection warnings in your project and that will
highlight all the lines which need attention.

Hopefully it's as simple as that, but I would have expected quil to have
type hints already, so possibly not...

Adam


Adam


On Sat, Mar 29, 2014 at 6:20 AM, tamichan hogehogegeheg...@gmail.comwrote:

 Hi All

 I'm writing graphic clojure code with Processing jars.
 When I wrote heavy draw code, I found clojure code is slower than an
 equivalent of java.

 Probably, the cause is java method call.
 I call processing drawing method thousands times per one frame.
 (.line applet x1 y1 z1 x2 y2 z2)

 So decrease the call count, increase draw performance.
 Do you know anything speed up way of java method call?

 I tied quil, but it was same performance.
 clojure version is 1.5.1

 thanks

 --
 You received this message because you are subscribed to the Google
 Groups Clojure group.
 To post to this group, send email to clojure@googlegroups.com
 Note that posts from new members are moderated - please be patient with
 your first post.
 To unsubscribe from this group, send email to
 clojure+unsubscr...@googlegroups.com
 For more options, visit this group at
 http://groups.google.com/group/clojure?hl=en
 ---
 You received this message because you are subscribed to the Google Groups
 Clojure group.
 To unsubscribe from this group and stop receiving emails from it, send an
 email to clojure+unsubscr...@googlegroups.com.
 For more options, visit https://groups.google.com/d/optout.


-- 
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
Clojure group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [GSoC 2014] Looking for mentors: cljs graphics package (in the spirit of p5.js / quil / three.js)

2014-03-14 Thread Adam Clements
I'm keen to see graphics frameworks on clojure move away from imperative
api call wrappers and towards a more declarative approach, where you define
as data what you want to draw. I have done this for a number of personal
projects, using a hiccup like syntax to define my drawing operations, and
then have a thin rendering layer which takes the generated data and draws
it each frame/refresh etc. Longer term you could do far more clever things
with this approach like only redrawing what you need to, rendering sub
elements together and then compositing the final image etc. plus it would
be easy to implement this cross platform - it's just data.

For example:
[[:line {:colour :black :thickness 5} 0 0 20 20]
 [:circle {:colour :red :fill true} 200 200 20]
 [:text ]]

and so on. Defining basic drawing operations like this would be easily
extensible, attributes could be added, and rendering engines which don't
support all the features (say if you added a drop shadow attribute) could
degrade fairly gracefully. You can also save this nicely. Think of it like
a lispy SVG format, where you can manipulate graphics using higher order
functions.

You could also apply transforms using nesting and define things like (defn
box [attrs x1 y1 x2 y2] [[:line attrs x1 y1 x2 y1] [:line attrs x2 y1 x2
y2] ...]) which could be quite nice, giving you something like:

[:transform {:rotation 30} (box {:line-thickness 5} 0 0 50 30)]

Obviously all of this would need to be ironed out and the exact semantics
smoothed over, but what do people think in principle to a more declarative
graphics library which could then be optimised far more than manual api
calls ever could while encouraging a clean functional, testable approach.

Adam


Adam


On Thu, Mar 13, 2014 at 10:37 PM, Omer Shapira halus...@gmail.com wrote:

 Hey,

 I'm applying to GSoC this year, and I'm looking for mentors.

 I want to create a cljs-idiomatic web graphics package. I have graphics
 programming experience, being a member of the Processing and openFrameworks
 communities, and a researcher at Ken Perlin's lab at NYU.

 While I'm still learning Clojure's abstractions, I have been programming
 in Scheme for a long time.

 Anyone who wants to mentor me / chat about some ideas can reply here or
 find me at http://omershapira.com

 Thanks!
 Omer

 --
 You received this message because you are subscribed to the Google
 Groups Clojure group.
 To post to this group, send email to clojure@googlegroups.com
 Note that posts from new members are moderated - please be patient with
 your first post.
 To unsubscribe from this group, send email to
 clojure+unsubscr...@googlegroups.com
 For more options, visit this group at
 http://groups.google.com/group/clojure?hl=en
 ---
 You received this message because you are subscribed to the Google Groups
 Clojure group.
 To unsubscribe from this group and stop receiving emails from it, send an
 email to clojure+unsubscr...@googlegroups.com.
 For more options, visit https://groups.google.com/d/optout.


-- 
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
Clojure group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: case statement and java constants

2014-03-02 Thread Adam Clements
Oops, I already filed http://dev.clojure.org/jira/browse/CLJ-1367. Should
probably link/mark as dupe - I don't appear to be able to do anything other
than comment.


Adam


On Sun, Mar 2, 2014 at 4:35 PM, Herwig Hochleitner
hhochleit...@gmail.comwrote:

 Created: http://dev.clojure.org/jira/browse/CLJ-1368


 2014-03-01 2:58 GMT+01:00 Alex Miller a...@puredanger.com:

 I would appreciate a jira enhancement ticket for this.

 Alex

 --
 You received this message because you are subscribed to the Google
 Groups Clojure group.
 To post to this group, send email to clojure@googlegroups.com
 Note that posts from new members are moderated - please be patient with
 your first post.
 To unsubscribe from this group, send email to
 clojure+unsubscr...@googlegroups.com
 For more options, visit this group at
 http://groups.google.com/group/clojure?hl=en
 ---
 You received this message because you are subscribed to the Google Groups
 Clojure group.
 To unsubscribe from this group and stop receiving emails from it, send an
 email to clojure+unsubscr...@googlegroups.com.
 For more options, visit https://groups.google.com/groups/opt_out.


  --
 You received this message because you are subscribed to the Google
 Groups Clojure group.
 To post to this group, send email to clojure@googlegroups.com
 Note that posts from new members are moderated - please be patient with
 your first post.
 To unsubscribe from this group, send email to
 clojure+unsubscr...@googlegroups.com
 For more options, visit this group at
 http://groups.google.com/group/clojure?hl=en
 ---
 You received this message because you are subscribed to the Google Groups
 Clojure group.
 To unsubscribe from this group and stop receiving emails from it, send an
 email to clojure+unsubscr...@googlegroups.com.
 For more options, visit https://groups.google.com/groups/opt_out.


-- 
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
Clojure group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: A faster clojure startup

2014-02-28 Thread Adam Clements
This sounds like an awesome shortcut to speeding things up on android/ios
while we're waiting for CinC and friends. Do you know how much work it
would be to port your changes to clojure-android and try it out there? I'd
be very interested to test it out and do some debugging on android. Is it
just a tweaked Var class or is there more to it?


Adam


On Fri, Feb 28, 2014 at 3:16 PM, Gal Dolber g...@dolber.com wrote:

 Here're some notes on the lean compiler I've been working on for
 clojure-objc

 http://galdolber.tumblr.com/post/78110050703/reduce-startup

 Feedback's welcome

 --
 You received this message because you are subscribed to the Google
 Groups Clojure group.
 To post to this group, send email to clojure@googlegroups.com
 Note that posts from new members are moderated - please be patient with
 your first post.
 To unsubscribe from this group, send email to
 clojure+unsubscr...@googlegroups.com
 For more options, visit this group at
 http://groups.google.com/group/clojure?hl=en
 ---
 You received this message because you are subscribed to the Google Groups
 Clojure group.
 To unsubscribe from this group and stop receiving emails from it, send an
 email to clojure+unsubscr...@googlegroups.com.
 For more options, visit https://groups.google.com/groups/opt_out.


-- 
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
Clojure group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


case statement and java constants

2014-02-28 Thread Adam Clements
I'm having some trouble with java constants in a case statement. I know I
could use condp, but these are things I could put in a java switch
statement and so it's annoying to give up constant time dispatch:

(case (.getActionMasked event)
   MotionEvent/ACTION_POINTER_DOWN :down
   MotionEvent/ACTION_UP   :up
   MotionEvent/ACTION_POINTER_UP   :up
   MotionEvent/ACTION_MOVE :move
   MotionEvent/ACTION_CANCEL   :cancel
   MotionEvent/ACTION_OUTSIDE  :outside
   :none))

Always gives me :none because java constants aren't literals, it dispatches
on the symbol instead. Is there a way to do this without resorting to condp
= or am I stuck? Should this be a something that case handles by default? I
can't think of a reason these couldn't be converted to literals...

Thanks,

Adam

-- 
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
Clojure group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: case statement and java constants

2014-02-28 Thread Adam Clements
That works perfectly, thanks!

It does feel like it should just work as a normal case statement though,
where the value is static final, and warn if it isn't. Is there a good
reason this shouldn't be supported by the case statement that anyone can
think of? Worth filing an enhancement request on clojure core?

Thanks,
Adam


Adam


On Fri, Feb 28, 2014 at 4:21 PM, Ambrose Bonnaire-Sergeant 
abonnaireserge...@gmail.com wrote:

 I'm not 100% sure if this works, but have you tried writing a macro that
 gets the
 Java field value, and inserting into the case statement?

 (defmacro motion-case [...]
   `(case ..
  ~MotionEvent/ACTION_POINTER_DOWN ...
   ~ MotionEvent/ACTION_UP ...
 ))


 On Sat, Mar 1, 2014 at 12:15 AM, Adam Clements adam.cleme...@gmail.comwrote:

 I'm having some trouble with java constants in a case statement. I know I
 could use condp, but these are things I could put in a java switch
 statement and so it's annoying to give up constant time dispatch:

 (case (.getActionMasked event)
MotionEvent/ACTION_POINTER_DOWN :down
MotionEvent/ACTION_UP   :up
MotionEvent/ACTION_POINTER_UP   :up
MotionEvent/ACTION_MOVE :move
MotionEvent/ACTION_CANCEL   :cancel
MotionEvent/ACTION_OUTSIDE  :outside
:none))

 Always gives me :none because java constants aren't literals, it
 dispatches on the symbol instead. Is there a way to do this without
 resorting to condp = or am I stuck? Should this be a something that case
 handles by default? I can't think of a reason these couldn't be converted
 to literals...

 Thanks,

 Adam

 --
 You received this message because you are subscribed to the Google
 Groups Clojure group.
 To post to this group, send email to clojure@googlegroups.com
 Note that posts from new members are moderated - please be patient with
 your first post.
 To unsubscribe from this group, send email to
 clojure+unsubscr...@googlegroups.com
 For more options, visit this group at
 http://groups.google.com/group/clojure?hl=en
 ---
 You received this message because you are subscribed to the Google Groups
 Clojure group.
 To unsubscribe from this group and stop receiving emails from it, send an
 email to clojure+unsubscr...@googlegroups.com.
 For more options, visit https://groups.google.com/groups/opt_out.


  --
 You received this message because you are subscribed to the Google
 Groups Clojure group.
 To post to this group, send email to clojure@googlegroups.com
 Note that posts from new members are moderated - please be patient with
 your first post.
 To unsubscribe from this group, send email to
 clojure+unsubscr...@googlegroups.com
 For more options, visit this group at
 http://groups.google.com/group/clojure?hl=en
 ---
 You received this message because you are subscribed to the Google Groups
 Clojure group.
 To unsubscribe from this group and stop receiving emails from it, send an
 email to clojure+unsubscr...@googlegroups.com.
 For more options, visit https://groups.google.com/groups/opt_out.


-- 
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
Clojure group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: weird bug with cljs.core.async + macros

2014-02-18 Thread Adam Clements
I have had a similar thing happen with the core.match/match macro - a lot
of examples simply break when put inside a go block. I thought it might
have been something to do with aot compilation but I'm not sure.

Adam
On 18 Feb 2014 05:33, t x txrev...@gmail.com wrote:

 Building on Michal's example, here is a more minimal example --
 which also fails in Clojure:


 (ns test
   (:require [clojure.core.async :as async]))


 (defmacro silly [obj pat1 body1 other]
   `(case ~obj
  ~pat1 ~body1
  ~other))

 (let []

   (def out (java.io.StringWriter.))

   (defn log [ args]
 (doseq [arg args]
   (.write out (str arg))
   (.write out \n)))


   (async/!! (async/go
   (silly :dog
  :dog (log with-go: woof woof)
  (log with-go: other

   (str out))

 On Mon, Feb 17, 2014 at 5:14 PM, t x txrev...@gmail.com wrote:
  Hi Michal,
 
Does this mean:
 
(a) the reported behavior is normal (and my bug report is invalid) or
 
(b) this error happens in both cljs + clojure ?
 
  Thanks!
 
  On Mon, Feb 17, 2014 at 4:33 PM, Michał Marczyk
  michal.marc...@gmail.com wrote:
  Just to be clear, the above is a version of t x's bug-report modified
  to use a StringWriter instead of console.log.
 
  Cheers,
  Michał
 
 
  On 18 February 2014 01:25, Michał Marczyk michal.marc...@gmail.com
 wrote:
  The same thing happens in Clojure:
 
  (defmacro silly [object pat1 body1 pat2 body2]
`(case (:tag ~object)
   ~pat1 ~body1
   ~body2))
 
  (def out (java.io.StringWriter.))
 
  (defn log [ args]
(doseq [arg args]
  (.write out (str arg))
  (.write out \n)))
 
  (defn init []
(silly {:tag :dog}
   :dog (log without-go: woof woof)
   cat (log without-go: unrecognized))
(async/go
 (silly {:tag :dog}
:dog (log with-go: woof woof)
cat (log with-go: unrecognized
 
  (init)
 
  (print (str out))
  without-go: woof woof
  with-go: woof woof
  with-go: unrecognized
  nil
 
  Cheers,
  Michał
 
 
  On 18 February 2014 01:01, t x txrev...@gmail.com wrote:
  Thanks for verifying!
 
  @tbaldridge: can you enlighten us on if:
 
* I'm doing something stupid or
* this is an actual bug in cljs/core.async?
 
  Thanks!
 
  On Mon, Feb 17, 2014 at 2:10 PM, Manuel Paccagnella
  manuel.paccagne...@gmail.com wrote:
  Tested on Linux x64, Chromium 31.0.1650.63 and Firefox 26.0. Same
 behaviour
  that you have seen. However, I haven't looked at the code yet.
 
  Il giorno lunedì 17 febbraio 2014 20:34:22 UTC+1, t x ha scritto:
 
  Can anyone verify whether this bug is reproducible?
 
  On Mon, Feb 17, 2014 at 12:28 AM, t x txre...@gmail.com wrote:
   Hi,
  
 repo: https://github.com/txrev319/bug-report
  
 I have a really weird bug where:
  
 * (my-macro ...) == everything works
  
 * (async/go (my-macro ...)) == something weird happens
  
  
 A minimal failure case is documented at:
   https://github.com/txrev319/bug-report/blob/master/src/app.cljx
  
 It depends on the macro defined in:
  
 https://github.com/txrev319/bug-report/blob/master/src/macros.cljx
  
 The bug can be replicated by following the instructions at:
   https://github.com/txrev319/bug-report/blob/master/README.md
  
 I *believe* I have included everything required to replicate the
   bug. If I am missing anything, please let me know.
  
  
   Extra info:
  
   $ lein --version
   Leiningen 2.2.0 on Java 1.7.0_45 Java HotSpot(TM) 64-Bit Server VM
  
   I'm on 64-bit OSX.
  
  
   Thanks!
 
  --
  You received this message because you are subscribed to the Google
  Groups Clojure group.
  To post to this group, send email to clojure@googlegroups.com
  Note that posts from new members are moderated - please be patient
 with your
  first post.
  To unsubscribe from this group, send email to
  clojure+unsubscr...@googlegroups.com
  For more options, visit this group at
  http://groups.google.com/group/clojure?hl=en
  ---
  You received this message because you are subscribed to the Google
 Groups
  Clojure group.
  To unsubscribe from this group and stop receiving emails from it,
 send an
  email to clojure+unsubscr...@googlegroups.com.
  For more options, visit https://groups.google.com/groups/opt_out.
 
  --
  You received this message because you are subscribed to the Google
  Groups Clojure group.
  To post to this group, send email to clojure@googlegroups.com
  Note that posts from new members are moderated - please be patient
 with your first post.
  To unsubscribe from this group, send email to
  clojure+unsubscr...@googlegroups.com
  For more options, visit this group at
  http://groups.google.com/group/clojure?hl=en
  ---
  You received this message because you are subscribed to the Google
 Groups Clojure group.
  To unsubscribe from this group and stop receiving emails from it,
 send an email to clojure+unsubscr...@googlegroups.com.
  For more options, visit 

[ANN] latest-clojure-libraries emacs plugin

2013-10-22 Thread Adam Clements
This is an emacs plugin which uses lein-ancient[1] to automatically insert
the latest version vector of a library at the cursor in emacs. This works
with clojars, maven central and even compatible private repositories.

Simply M-x latest-clojure-libraries-insert-dependency, type the name of
your desired library, e.g. cheshire, and [cheshire 5.2.0] will be
inserted at the cursor position.

Better yet, if you have an nrepl running and pomegranate[2] in your
dependencies, it will ask you if you want to inject the dependency into the
running nrepl, meaning you can add dependencies without restarting your
program!

Further details and installation instructions are in the README at:
https://github.com/AdamClements/latest-clojure-libraries

Many thanks to Yannick Scherer (xsc) for incorporating the necessary
command into lein-ancient

Adam Clements

[1] https://github.com/xsc/lein-ancient
[2] https://github.com/cemerick/pomegranate

-- 
-- 
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
Clojure group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: clojars.org image for latest version of a project

2013-10-11 Thread Adam Clements
That's great, gets exactly the information I need from all the
repositories. I'll go fix up my library to use this instead. Thanks for the
tip off.


Adam Clements

+44 7947 724 795
--
This email and any files transmitted with it are confidential. If you are
not the intended recipient, you are hereby notified that any disclosure,
distribution or copying of this communication is strictly prohibited.


On Fri, Oct 11, 2013 at 12:19 AM, Karsten Schmidt i...@toxi.co.uk wrote:

 On 11 October 2013 00:01, Adam Clements adam.cleme...@gmail.com wrote:
  I find it ridiculously useful not having to go to my browser to look up
 the
  latest version of libraries I use all the time.

 Adam, you might want to check out this leiningen plugin then...
 https://github.com/xsc/lein-ancient

 K.

 --
 --
 You received this message because you are subscribed to the Google
 Groups Clojure group.
 To post to this group, send email to clojure@googlegroups.com
 Note that posts from new members are moderated - please be patient with
 your first post.
 To unsubscribe from this group, send email to
 clojure+unsubscr...@googlegroups.com
 For more options, visit this group at
 http://groups.google.com/group/clojure?hl=en
 ---
 You received this message because you are subscribed to the Google Groups
 Clojure group.
 To unsubscribe from this group and stop receiving emails from it, send an
 email to clojure+unsubscr...@googlegroups.com.
 For more options, visit https://groups.google.com/groups/opt_out.


-- 
-- 
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
Clojure group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: clojars.org image for latest version of a project

2013-10-11 Thread Adam Clements
I've submitted a pull request
https://github.com/xsc/lein-ancient/pull/17to get the latest version
vector from all repositories, clojars and
maven-central included with none of the nasty scraping. If that gets
accepted I'll push out the new version of my emacs plugin which lets you
insert the deps inline and automatically add it to your running nrepl.


Adam Clements

+44 7947 724 795
--
This email and any files transmitted with it are confidential. If you are
not the intended recipient, you are hereby notified that any disclosure,
distribution or copying of this communication is strictly prohibited.


On Fri, Oct 11, 2013 at 2:38 PM, Nelson Morris nmor...@nelsonmorris.netwrote:

 I'm glad to see you've found a solution that works for you.  I know of
 several people doing scraping of clojars to get info, and a real api is on
 my list to do when I find time.

 -
 Nelson Morris



 On Fri, Oct 11, 2013 at 7:45 AM, Adam Clements adam.cleme...@gmail.comwrote:

 That's great, gets exactly the information I need from all the
 repositories. I'll go fix up my library to use this instead. Thanks for the
 tip off.


 Adam Clements

 +44 7947 724 795
 --
 This email and any files transmitted with it are confidential. If you are
 not the intended recipient, you are hereby notified that any disclosure,
 distribution or copying of this communication is strictly prohibited.


 On Fri, Oct 11, 2013 at 12:19 AM, Karsten Schmidt i...@toxi.co.ukwrote:

 On 11 October 2013 00:01, Adam Clements adam.cleme...@gmail.com wrote:
  I find it ridiculously useful not having to go to my browser to look
 up the
  latest version of libraries I use all the time.

 Adam, you might want to check out this leiningen plugin then...
 https://github.com/xsc/lein-ancient

 K.

 --
 --
 You received this message because you are subscribed to the Google
 Groups Clojure group.
 To post to this group, send email to clojure@googlegroups.com
 Note that posts from new members are moderated - please be patient with
 your first post.
 To unsubscribe from this group, send email to
 clojure+unsubscr...@googlegroups.com
 For more options, visit this group at
 http://groups.google.com/group/clojure?hl=en
 ---
 You received this message because you are subscribed to the Google
 Groups Clojure group.
 To unsubscribe from this group and stop receiving emails from it, send
 an email to clojure+unsubscr...@googlegroups.com.
 For more options, visit https://groups.google.com/groups/opt_out.


  --
 --
 You received this message because you are subscribed to the Google
 Groups Clojure group.
 To post to this group, send email to clojure@googlegroups.com
 Note that posts from new members are moderated - please be patient with
 your first post.
 To unsubscribe from this group, send email to
 clojure+unsubscr...@googlegroups.com
 For more options, visit this group at
 http://groups.google.com/group/clojure?hl=en
 ---
 You received this message because you are subscribed to the Google Groups
 Clojure group.
 To unsubscribe from this group and stop receiving emails from it, send an
 email to clojure+unsubscr...@googlegroups.com.
 For more options, visit https://groups.google.com/groups/opt_out.


  --
 --
 You received this message because you are subscribed to the Google
 Groups Clojure group.
 To post to this group, send email to clojure@googlegroups.com
 Note that posts from new members are moderated - please be patient with
 your first post.
 To unsubscribe from this group, send email to
 clojure+unsubscr...@googlegroups.com
 For more options, visit this group at
 http://groups.google.com/group/clojure?hl=en
 ---
 You received this message because you are subscribed to the Google Groups
 Clojure group.
 To unsubscribe from this group and stop receiving emails from it, send an
 email to clojure+unsubscr...@googlegroups.com.
 For more options, visit https://groups.google.com/groups/opt_out.


-- 
-- 
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
Clojure group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: clojars.org image for latest version of a project

2013-10-10 Thread Adam Clements
Is there any chance we could get a route which simply returns this as plain
text? I have an emacs plugin which looks up the latest version of an
artifact on clojars (currently using some horrible regex)
https://github.com/AdamClements/latest-clojure-libraries which would be
much much nicer if it was using a supported api! I find it ridiculously
useful not having to go to my browser to look up the latest version of
libraries I use all the time.

Adam


Adam Clements

+44 7947 724 795
--
This email and any files transmitted with it are confidential. If you are
not the intended recipient, you are hereby notified that any disclosure,
distribution or copying of this communication is strictly prohibited.


On Mon, Oct 7, 2013 at 7:59 PM, Nelson Morris nmor...@nelsonmorris.netwrote:

 There is a new route on clojars.org that will create an svg of the lein
 coordinates for the latest version of a project. To use it add
 /latest-version.svg to a project url. An example can be found at
 https://clojars.org/compojure/latest-version.svg. This may be useful for
 a project readme.

 Many thanks to Alexander Yakushev (https://github.com/alexander-yakushev)
 for putting together the commit.

 -
 Nelson Morris

 --
 --
 You received this message because you are subscribed to the Google
 Groups Clojure group.
 To post to this group, send email to clojure@googlegroups.com
 Note that posts from new members are moderated - please be patient with
 your first post.
 To unsubscribe from this group, send email to
 clojure+unsubscr...@googlegroups.com
 For more options, visit this group at
 http://groups.google.com/group/clojure?hl=en
 ---
 You received this message because you are subscribed to the Google Groups
 Clojure group.
 To unsubscribe from this group and stop receiving emails from it, send an
 email to clojure+unsubscr...@googlegroups.com.
 For more options, visit https://groups.google.com/groups/opt_out.


-- 
-- 
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
Clojure group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: [ANN]: ova 0.9.6 - the bestest mutable array ever! (with lots of documentation)

2013-10-02 Thread Adam Clements
Perfect timing, I just sat down to solve this exact problem, sketched out a
vague idea of what I wanted and then saw this which does everything I
needed but better!

It's really handy for Component/Entity/System designs, as it essentially
takes care of the whole entity part of the program and allows you to query
for sets of entities affected by a given system really easily in a
threadsafe way.

Thanks!

Adam

On Mon, Sep 30, 2013 at 1:33 AM, zcaudate z...@caudate.me wrote:

 http://z.caudate.me/ova/

 ova has been designed especially for dealing with shared mutable state in
 multi-threaded applications. Clojure uses refs and atoms off the shelf to
 resolve this issue but left out methods to deal with arrays of shared
 elements. ova has been specifically designed for the following use case:


- Elements (usually clojure maps) can be added or removed from an array
- Element data are accessible and mutated from several threads.
- Array itself can also be mutated from several threads.

 Github:

 https://github.com/zcaudate/ova

 --
 --
 You received this message because you are subscribed to the Google
 Groups Clojure group.
 To post to this group, send email to clojure@googlegroups.com
 Note that posts from new members are moderated - please be patient with
 your first post.
 To unsubscribe from this group, send email to
 clojure+unsubscr...@googlegroups.com
 For more options, visit this group at
 http://groups.google.com/group/clojure?hl=en
 ---
 You received this message because you are subscribed to the Google Groups
 Clojure group.
 To unsubscribe from this group and stop receiving emails from it, send an
 email to clojure+unsubscr...@googlegroups.com.
 For more options, visit https://groups.google.com/groups/opt_out.


-- 
-- 
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
Clojure group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: [ANN] XCLJB v0.1.0: X protocol Clojure-language Binding

2013-09-25 Thread Adam Clements
Have you looked at core.async for shuttling asynchronous events back and
forth. This sounds to me like the sort of thing it was designed for
On 10 Sep 2013 06:30, Vincent Chen noodle...@gmail.com wrote:

 Hello everyone,

 XCLJB is a Clojure language binding for the X Window System, similar
 to the XCB (the X protocol C-language Bindings). It allows programmers
 to communicate with and write GUIs for an X server in Clojure, without
 having to drop down into C.

 Source code, README, and examples: https://github.com/noodlewiz/xcljb

 Leiningen dependency information:

 [xcljb 0.1.0]

 As the version number indicates, this is a developmental release. This
 means
   - Things are usable, but not yet feature complete.
   - API not necessarily stable, though I won't break compatibility for
 no reason.
   - Comments, suggestions welcome.

 Open problems looking for suggestions:
   - How should I signal errors? XCLJB, like XCB, is mostly
 asynchronous. Currently sending a request will immediately return a
 Clojure promise. The promise will be delivered with either a reply or
 an error when they arrive, this allows multiple requests to be sent
 without blocking (this is the asynchronous part). I'd like to raise an
 exception when a user deref the promise and the promise is an error,
 but there seems to be no way of doing so. Should I make my own promise
 type by implementing clojure.lang.IDeref? Is there another way of
 achieving what I had in mind?

   - Is there an easier way to match against records? Events are
 currently implemented as records, so event loops would have to look
 like

 (ns ...
   (:import [xcljb.gen.xproto_types ExposeEvent KeyPressEvent]))
 (while true
   (let [e (wait-event conn)]
 (condp instance? e
   ExposeEvent
   ...

   KeyPressEvent
   ...

   nil)))

 I'd prefer not to make my user import the event types as if they
 are Java classes. Is there a more Clojurey way of doing record type
 matching? Is there a better way of implementing events?

 Regards,

 Vincent Chen

 --
 --
 You received this message because you are subscribed to the Google
 Groups Clojure group.
 To post to this group, send email to clojure@googlegroups.com
 Note that posts from new members are moderated - please be patient with
 your first post.
 To unsubscribe from this group, send email to
 clojure+unsubscr...@googlegroups.com
 For more options, visit this group at
 http://groups.google.com/group/clojure?hl=en
 ---
 You received this message because you are subscribed to the Google Groups
 Clojure group.
 To unsubscribe from this group and stop receiving emails from it, send an
 email to clojure+unsubscr...@googlegroups.com.
 For more options, visit https://groups.google.com/groups/opt_out.


-- 
-- 
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
Clojure group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Safely flush old value out of an atom

2013-09-19 Thread Adam Clements
It's possible with a ref, but I don't need to coordinate multiple bits of
state so a ref feels like overkill, and it makes adding to the list far
more cumbersome as it needs to be inside a dosync, and I essentially end up
writing atom-like functions to make that easier... by which point I may as
well have used an atom and my function.

Are refs faster? I guess I could add to my list commutatively which might
give some slight benefit, depending how many threads are bashing it. But I
still think there's value in being able to retrieve the old value of an
atom as part of a reset! type operation.

Adam


Adam Clements

+44 7947 724 795
--
This email and any files transmitted with it are confidential. If you are
not the intended recipient, you are hereby notified that any disclosure,
distribution or copying of this communication is strictly prohibited.


On Thu, Sep 19, 2013 at 5:21 PM, Ben Wolfson wolf...@gmail.com wrote:

 Is there some reason you can't use a ref for this?


 On Thu, Sep 19, 2013 at 9:20 AM, Adam Clements adam.cleme...@gmail.comwrote:

 Hi,

 I have been working on a setup where I batch a number of updates in a
 queue, which I store in an atom with multiple threads potentially adding
 things to it. Periodically I want to flush that queue, leaving an empty
 list in the atom and passing the current batch of values on for further
 processing.

 I can't use swap! for this, because my further processing is side
 effecting and I wouldn't want to dispatch the same information twice, and I
 can't use reset! because that just throws away the old contents of the
 atom, and derefing it in the line before I am likely to lose data if
 another thread adds something at the last minute.

 I could change to an agent with append and flush actions which would get
 queued up and run only once each, and that would work. But it has quite a
 lot of thread overhead which I think is unnecessary.

 What I ended up doing was writing a version of reset! which returns the
 old value instead of the new value (why would I want the new value? I know
 that, I put it in!)

 (defn flush! [atom newval]
(let [val @atom]
   (if (compare-and-set! atom val newval)
  val
  (recur atom newval

 = (def a (atom [1 2 3 4]))
 #'user/a
 = (flush! a [])
 [1 2 3 4]
 = @a
 []

 Is there already a standard library fn I should be using for this? Is
 this a bad idea for some reason I don't fathom?

 Adam

 https://github.com/AdamClements

 --
 --
 You received this message because you are subscribed to the Google
 Groups Clojure group.
 To post to this group, send email to clojure@googlegroups.com
 Note that posts from new members are moderated - please be patient with
 your first post.
 To unsubscribe from this group, send email to
 clojure+unsubscr...@googlegroups.com
 For more options, visit this group at
 http://groups.google.com/group/clojure?hl=en
 ---
 You received this message because you are subscribed to the Google Groups
 Clojure group.
 To unsubscribe from this group and stop receiving emails from it, send an
 email to clojure+unsubscr...@googlegroups.com.
 For more options, visit https://groups.google.com/groups/opt_out.




 --
 Ben Wolfson
 Human kind has used its intelligence to vary the flavour of drinks, which
 may be sweet, aromatic, fermented or spirit-based. ... Family and social
 life also offer numerous other occasions to consume drinks for pleasure.
 [Larousse, Drink entry]

  --
 --
 You received this message because you are subscribed to the Google
 Groups Clojure group.
 To post to this group, send email to clojure@googlegroups.com
 Note that posts from new members are moderated - please be patient with
 your first post.
 To unsubscribe from this group, send email to
 clojure+unsubscr...@googlegroups.com
 For more options, visit this group at
 http://groups.google.com/group/clojure?hl=en
 ---
 You received this message because you are subscribed to the Google Groups
 Clojure group.
 To unsubscribe from this group and stop receiving emails from it, send an
 email to clojure+unsubscr...@googlegroups.com.
 For more options, visit https://groups.google.com/groups/opt_out.


-- 
-- 
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
Clojure group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Safely flush old value out of an atom

2013-09-19 Thread Adam Clements
Hi,

I have been working on a setup where I batch a number of updates in a
queue, which I store in an atom with multiple threads potentially adding
things to it. Periodically I want to flush that queue, leaving an empty
list in the atom and passing the current batch of values on for further
processing.

I can't use swap! for this, because my further processing is side effecting
and I wouldn't want to dispatch the same information twice, and I can't use
reset! because that just throws away the old contents of the atom, and
derefing it in the line before I am likely to lose data if another thread
adds something at the last minute.

I could change to an agent with append and flush actions which would get
queued up and run only once each, and that would work. But it has quite a
lot of thread overhead which I think is unnecessary.

What I ended up doing was writing a version of reset! which returns the old
value instead of the new value (why would I want the new value? I know
that, I put it in!)

(defn flush! [atom newval]
   (let [val @atom]
  (if (compare-and-set! atom val newval)
 val
 (recur atom newval

= (def a (atom [1 2 3 4]))
#'user/a
= (flush! a [])
[1 2 3 4]
= @a
[]

Is there already a standard library fn I should be using for this? Is this
a bad idea for some reason I don't fathom?

Adam

https://github.com/AdamClements

-- 
-- 
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
Clojure group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: [ANN] conf-er 1.0.1

2013-05-06 Thread Adam Clements
If you have a look in the tests you'll see how I override the config there,
but it is a bit naff making you with-redefs one of the library's internal
vars, and double naff that you have to wrap it in a delay.

(with-redefs [conf-er/config-map (delay {:test 42})]
  (fact (config :test) = 42))

If you do that for now, I'll include a tests util in the next release which
does the same from a guaranteed stable api function

Adam
On 6 May 2013 01:46, Russell Mull russell.m...@gmail.com wrote:

 This looks simple and useful, thanks!

 Supposing I had a function that called this library, how could I go about
 testing it easily? That is, the configuration file becomes implicitly an
 input to the function, one that I'd like to be able to control from my
 tests. Perhaps something like this could be used to provide or override
 config settings dynamically:

 (with-config {:username bogus}
   (...))

 I'm not trying to open the dynamic scoping can of worms here; this library
 clearly is a choice for people already willing to work in that way.


 On Thursday, May 2, 2013 9:40:29 PM UTC+9, Adam Clements wrote:

 A very simple library for loading application level config from a
 configuration file in a nice way, with caching and reloading functionality.

 Any other configuration libraries I found were either massively overkill
 for my needs (full on validation schemas built in), too complicated to set
 up and pass around or involved simply read-evaling a whole namespace which
 could be insecure depending where you get your config.

 Simple but useful - I found myself duplicating this code in almost all my
 projects before making it into a library! Well tested and documented,
 there are very few moving parts so I expect this to stay stable and not
 really change over time.

 Source:  
 https://github.com/TouchType/**conf-erhttps://github.com/TouchType/conf-er
 Clojars: [conf-er 1.0.1]

 The idea is to have a single configuration file which consists of a
 keyworded map, you then look up individual properties with nested keywords,
 for example your config file looks like this (simple EDN map):

 ;; my-config.conf
 {:username joe.bloggs
  :password letmein
  :database {:host 127.0.0.1
 :port 1234}
  :my.library/number 42}


 And then look up the configuration from anywhere within your program!
 Simply include the conf-er namespace

 (use 'conf-er)


 (config :username) = joe.bloggs
 (configured? :database) = true
 (config :database) = {:host 127.0.0.1 :port 1234}
 (config :database :port) = 1234



 Tell your program where to find the configuration file from your
 leiningen project.clj during development, or if you are distributing a jar
 then add the property onto the java command line call:

 ...
 :jvm-opts [-Dconfig=~/my-config.conf]
 ...


 (config :database :connections) = (Exception Couldn't find :database
 :connections in configuration file)
 (opt-config :database :connections) = nil

 If you use this from within a library, you must namespace your
 configuration in case the application using your library also wishes to use
 conf-er. You can do this like so:

 (ns my.library
   (:require [conf-er :refer [config]]))
 (config ::number) = 42


 Here :number will expand out to the namespaced keyword
 :my.library/number, which we put in our configuration file earlier.

 Hope this is of use to some people.

 Adam

  --
 --
 You received this message because you are subscribed to the Google
 Groups Clojure group.
 To post to this group, send email to clojure@googlegroups.com
 Note that posts from new members are moderated - please be patient with
 your first post.
 To unsubscribe from this group, send email to
 clojure+unsubscr...@googlegroups.com
 For more options, visit this group at
 http://groups.google.com/group/clojure?hl=en
 ---
 You received this message because you are subscribed to the Google Groups
 Clojure group.
 To unsubscribe from this group and stop receiving emails from it, send an
 email to clojure+unsubscr...@googlegroups.com.
 For more options, visit https://groups.google.com/groups/opt_out.




-- 
-- 
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
Clojure group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[ANN] conf-er 1.0.1

2013-05-02 Thread Adam Clements
A very simple library for loading application level config from a 
configuration file in a nice way, with caching and reloading functionality. 

Any other configuration libraries I found were either massively overkill 
for my needs (full on validation schemas built in), too complicated to set 
up and pass around or involved simply read-evaling a whole namespace which 
could be insecure depending where you get your config.

Simple but useful - I found myself duplicating this code in almost all my 
projects before making it into a library! Well tested and documented, there 
are very few moving parts so I expect this to stay stable and not really 
change over time.

Source:  https://github.com/TouchType/conf-er
Clojars: [conf-er 1.0.1]

The idea is to have a single configuration file which consists of a 
keyworded map, you then look up individual properties with nested keywords, 
for example your config file looks like this (simple EDN map):

;; my-config.conf
 {:username joe.bloggs
  :password letmein
  :database {:host 127.0.0.1
 :port 1234}
  :my.library/number 42}


And then look up the configuration from anywhere within your program! 
Simply include the conf-er namespace

(use 'conf-er) 


 (config :username) = joe.bloggs
 (configured? :database) = true
 (config :database) = {:host 127.0.0.1 :port 1234}
 (config :database :port) = 1234



Tell your program where to find the configuration file from your leiningen 
project.clj during development, or if you are distributing a jar then add 
the property onto the java command line call:

 ...
 :jvm-opts [-Dconfig=~/my-config.conf]
 ...


(config :database :connections) = (Exception Couldn't find :database 
:connections in configuration file)
(opt-config :database :connections) = nil

If you use this from within a library, you must namespace your 
configuration in case the application using your library also wishes to use 
conf-er. You can do this like so:

(ns my.library
   (:require [conf-er :refer [config]]))
 (config ::number) = 42

 
Here :number will expand out to the namespaced keyword :my.library/number, 
which we put in our configuration file earlier.

Hope this is of use to some people.

Adam 

-- 
-- 
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
Clojure group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[ANN] Schejulure 0.1.3

2013-04-15 Thread Adam Clements
0.1.3 - Bugfix release fixing a discrepancy between clj-time and cron's 
representation of Sunday (thanks dwwoelfel)

*What is Schejulure?*
Schejulure is a lightweight, cron-inspired, minute resolution scheduling 
library. It has a neat, concise api and no stateful central scheduler. 
 It's tiny (~60 lines) and aims to do one task well. It's modelled after 
futures, and in fact returns a future, so use it in the same places/way you 
might use a future, but for recurring events.

To schedule things, it's like a cron setup (so by default fires every 
minute of every hour of every day...) but you can merge a map with lists of 
times when it should fire, so for example {:minute [0 15 30 45] :day :tue} 
will fire every 15 minutes on a tuesday where {:hour 9} will fire every 
minute from 9-10am every day. Beyond that you simply call schedule with 
pairs of schedule maps to functions which should fire.

*Example:*
= (def my-running-scheduler
 (schedule {:hour 12 :minute [0 15 30 45]} my-function
   {:hour (range 0 24 6) :minute 0 :day [:sat :sun]} batch-job))

...
= (future-cancel my-running-scheduler)

Simple as that.

-- 
-- 
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
Clojure group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [ANN] Schejulure 0.1.3

2013-04-15 Thread Adam Clements
I forgot to mention, schejulure can be obtained from the normal places:

Github:
https://github.com/AdamClements/schejulure

Clojars:
[schejulure 0.1.3]


Adam Clements

+44 7947 724 795
--
This email and any files transmitted with it are confidential. If you are
not the intended recipient, you are hereby notified that any disclosure,
distribution or copying of this communication is strictly prohibited.


On Mon, Apr 15, 2013 at 11:27 AM, Adam Clements adam.cleme...@gmail.comwrote:

 0.1.3 - Bugfix release fixing a discrepancy between clj-time and cron's
 representation of Sunday (thanks dwwoelfel)

 *What is Schejulure?*
 Schejulure is a lightweight, cron-inspired, minute resolution scheduling
 library. It has a neat, concise api and no stateful central scheduler.
  It's tiny (~60 lines) and aims to do one task well. It's modelled after
 futures, and in fact returns a future, so use it in the same places/way you
 might use a future, but for recurring events.

 To schedule things, it's like a cron setup (so by default fires every
 minute of every hour of every day...) but you can merge a map with lists of
 times when it should fire, so for example {:minute [0 15 30 45] :day :tue}
 will fire every 15 minutes on a tuesday where {:hour 9} will fire every
 minute from 9-10am every day. Beyond that you simply call schedule with
 pairs of schedule maps to functions which should fire.

 *Example:*
 = (def my-running-scheduler
  (schedule {:hour 12 :minute [0 15 30 45]} my-function
{:hour (range 0 24 6) :minute 0 :day [:sat :sun]}
 batch-job))

 ...
 = (future-cancel my-running-scheduler)

 Simple as that.

 --
 --
 You received this message because you are subscribed to the Google
 Groups Clojure group.
 To post to this group, send email to clojure@googlegroups.com
 Note that posts from new members are moderated - please be patient with
 your first post.
 To unsubscribe from this group, send email to
 clojure+unsubscr...@googlegroups.com
 For more options, visit this group at
 http://groups.google.com/group/clojure?hl=en
 ---
 You received this message because you are subscribed to the Google Groups
 Clojure group.
 To unsubscribe from this group and stop receiving emails from it, send an
 email to clojure+unsubscr...@googlegroups.com.
 For more options, visit https://groups.google.com/groups/opt_out.




-- 
-- 
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
Clojure group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Leiningen exception when run inside a project

2013-04-10 Thread Adam Clements
Your project.clj probably has unmatched brackets, this error means it hit
the end of a file it was reading while still scanning for a closing
bracket.
On 10 Apr 2013 09:22, Dmytro Kozhukhar dkozhuk...@gmail.com wrote:

 Hello everyclojurer!

 Today I have problem with installing lein on WinXP.

 Lein run just fine in any folder, except it is a folder with project.
 If I run 'lein repl' or 'lein run' then I get this error:

 D:\lein\helloworldlein run
 Exception in thread main clojure.lang.LispReader$ReaderException:
 java.lang.Ru
 ntimeException: EOF while reading string
 at clojure.lang.LispReader.read(LispReader.java:220)
 at clojure.core$read.invoke(core.clj:3407)
 at clojure.core$read.invoke(core.clj:3405)
 at clojure.main$eval_opt$fn__6602.invoke(main.clj:306)
 at clojure.main$eval_opt.invoke(main.clj:306)
 at clojure.main$initialize.invoke(main.clj:327)
 at clojure.main$script_opt.invoke(main.clj:353)
 at clojure.main$main.doInvoke(main.clj:440)
 at clojure.lang.RestFn.invoke(RestFn.java:619)
 at clojure.lang.Var.invoke(Var.java:445)
 at clojure.lang.AFn.applyToHelper(AFn.java:202)
 at clojure.lang.Var.applyTo(Var.java:532)
 at clojure.main.main(main.java:37)
 Caused by: java.lang.RuntimeException: EOF while reading string
 at clojure.lang.Util.runtimeException(Util.java:219)
 at clojure.lang.LispReader$StringReader.invoke(LispReader.java:461)
 at clojure.lang.LispReader.readDelimitedList(LispReader.java:1148)
 at clojure.lang.LispReader$ListReader.invoke(LispReader.java:982)
 at clojure.lang.LispReader.readDelimitedList(LispReader.java:1148)
 at clojure.lang.LispReader$ListReader.invoke(LispReader.java:982)
 at clojure.lang.LispReader.readDelimitedList(LispReader.java:1148)
 at clojure.lang.LispReader$ListReader.invoke(LispReader.java:982)
 at clojure.lang.LispReader.readDelimitedList(LispReader.java:1148)
 at clojure.lang.LispReader$ListReader.invoke(LispReader.java:982)
 at clojure.lang.LispReader.read(LispReader.java:185)
 ... 12 more


 Any Ideas what goes wrong?

 --
 --
 You received this message because you are subscribed to the Google
 Groups Clojure group.
 To post to this group, send email to clojure@googlegroups.com
 Note that posts from new members are moderated - please be patient with
 your first post.
 To unsubscribe from this group, send email to
 clojure+unsubscr...@googlegroups.com
 For more options, visit this group at
 http://groups.google.com/group/clojure?hl=en
 ---
 You received this message because you are subscribed to the Google Groups
 Clojure group.
 To unsubscribe from this group and stop receiving emails from it, send an
 email to clojure+unsubscr...@googlegroups.com.
 For more options, visit https://groups.google.com/groups/opt_out.




-- 
-- 
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
Clojure group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[ANN] quit-yo-jibber 0.4.3 (Jabber library)

2013-03-27 Thread Adam Clements
Quit-yo-jibber is a fork of xmpp-clj based less around direct-response 
chatbots. It allows you to listen for presence changes, set availability 
and status messages and send messages unprompted among other things.

It is stable and auto-reconnects if the network should drop. I use it in 
two projects which have been running 24/7 for 6 months now without any 
issues.

https://github.com/AdamClements/quit-yo-jibber

Available on clojars as *[quit-yo-jibber 0.4.3]*

*Changelog:*

0.4.3
Set sent message type to chat - this means that asterisk *bold*, underbar 
_underline_ formatting and smileys are properly formatted by the gtalk 
client
Filter out only messages which contain a body, rather than chat type 
messages which were actually typing notifications causing extra events to 
fire in previous versions

0.4.2
Fix presence listeners
Added experimental ability to set-availability (experimental - not in core 
namespace but accessible in quit-yo-jibber.presence)

0.4.1
Add in API for detecting whether users are active on their android phone or 
a PC

0.4.0
API revision - major release


-- 
-- 
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
Clojure group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: fold over a sequence

2013-03-12 Thread Adam Clements
I've had exactly this problem trying to use reducers over a large file that 
wouldn't fit in memory.

I tried iota, but had the issue that it was still scanning and memory 
mapping the entire file before it would start doing anything (pulling the 
whole thing through ram and taking a fair few minutes).

How would feeding a line-seq into this compare to iota? And how would that 
compare to a version of iota tweaked to work in a slightly less eager 
fashion?

Adam

On Tuesday, March 12, 2013 1:34:43 PM UTC, Paul Butcher wrote:

 So this turned out to be pretty easy. I've implemented a function called 
 foldable-seq that takes a lazy sequence and turns it into something that 
 can be folded in parallel. I've checked an example program that uses it to 
 count words in a Wikipedia XML dump into GitHub:

 https://github.com/paulbutcher/foldable-seq

 The code for foldable-seq is here:


 https://github.com/paulbutcher/foldable-seq/blob/master/src/wordcount/reducers.clj#L60

 On my 4-core MacBook Pro, I see a 40 second runtime without parallel-seq, 
 13 seconds with.

 --
 paul.butcher-msgCount++

 Snetterton, Castle Combe, Cadwell Park...
 Who says I have a one track mind?

 http://www.paulbutcher.com/
 LinkedIn: http://www.linkedin.com/in/paulbutcher
 MSN: pa...@paulbutcher.com javascript:
 AIM: paulrabutcher
 Skype: paulrabutcher
  
 On 11 Mar 2013, at 13:38, Paul Butcher pa...@paulbutcher.comjavascript: 
 wrote:

 On 11 Mar 2013, at 11:00, Marko Topolnik marko.t...@gmail.comjavascript: 
 wrote:

 The idea is to transform into a lazy sequence of eager chunks. That 
 approach should work.


 Exactly. Right - I guess I should put my money where my mouth is and see 
 if I can get it working...

 --
 paul.butcher-msgCount++

 Snetterton, Castle Combe, Cadwell Park...
 Who says I have a one track mind?

 http://www.paulbutcher.com/
 LinkedIn: http://www.linkedin.com/in/paulbutcher
 MSN: pa...@paulbutcher.com javascript:
 AIM: paulrabutcher
 Skype: paulrabutcher
  



-- 
-- 
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
Clojure group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Automatically looking up and adding dependencies

2013-02-22 Thread Adam Clements
Hi, I made a thing: https://github.com/AdamClements/latest-clojure-libraries

It's an emacs command which when you do M-x insert-latest-clojure-library 
will ask you for the name of a library on clojars. It will then pull the 
clojars page, look at the latest version and insert the text e.g. 
[congomongo 0.4.0] into your buffer (usually you'd go to your 
project.clj, make a gap in your dependencies then run this command and 
it'll insert in place). 

It will then ask you if you want to add it to the classpath of your running 
repl (requires you to have pomegranate in your profiles.clj dependencies 
map).

Bingo, latest version of the library in your project.clj and your running 
nrepl, no restarts required.

Issues: It just pulls the clojars page and runs a nasty regex over it 
(bleurgh). I tried to use the lein search indices, but it keeps breaking on 
my machine and the output isn't ideal. Perhaps if people find this useful, 
someone could help me fix up lein search to work for this use case (only 
interested in latest version and closest match). The other advantage of 
that would be that it then searches repositories other than clojars, which 
would be nice.

Anyway, have a play and let me know what you think,

Adam

-- 
-- 
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
Clojure group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Loading in jars with dependencies at runtime into separate classloaders with independent classpaths

2013-02-19 Thread Adam Clements
Thanks, I've had a look at Immutant.

I don't really want to migrate my whole app to immutant's framework right 
now though (plus I'm just interested in how one might employ this pattern 
for things other than web apps too) so I've been looking through to see if 
I can work out how to do just the classloading/dependency resolution part. 
I can't seem to find anything though. Does that happen within the JBoss AS 
part of it rather than in clojure?

Any input is much appreciated, thanks

Adam

On Monday, February 18, 2013 7:07:21 PM UTC, Toby Crawley wrote:

 Adam: 

 You can do this exact thing in Immutant[1]. It can handle multiple 
 applications at the same time, with each application getting an isolated 
 ClassLoader. Each application can optionally have its dependencies 
 resolved at deploy time via pomegranate, and can be (re)deployed 
 independently of other applications within the same container. 

 [1]:http://immutant.org 

 Adam Clements writes: 

  I'm working on a web api wrapper around a number of java/clojure 
 libraries. 
  One problem that I have run into is transitive dependency conflicts, 
  especially when some of the projects are older than others. 
  
  What I want to do is have each API endpoint's final handler function in 
 its 
  own classloader, with its own dependencies, ideally downloaded at 
 runtime. 
  That way none of them will interfere with one another and I can add new 
 API 
  endpoints without restarting the entire api server process. 
  
  Is this possible? I have come across pomegranate for dependency 
 resolution 
  and classlojure for evaling in other classloaders, but I can't find any 
  examples of doing both at once, and my experiments have so far been 
  unsuccessful. 
  
  Any hints would be much appreciated, 
  
  Thanks, 
  Adam 
  
  -- 


 -- 
 Toby Crawley 
 http://immutant.org | http://torquebox.org 


-- 
-- 
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
Clojure group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Loading in jars with dependencies at runtime into separate classloaders with independent classpaths

2013-02-18 Thread Adam Clements
I'm working on a web api wrapper around a number of java/clojure libraries. 
One problem that I have run into is transitive dependency conflicts, 
especially when some of the projects are older than others. 

What I want to do is have each API endpoint's final handler function in its 
own classloader, with its own dependencies, ideally downloaded at runtime. 
That way none of them will interfere with one another and I can add new API 
endpoints without restarting the entire api server process.

Is this possible? I have come across pomegranate for dependency resolution 
and classlojure for evaling in other classloaders, but I can't find any 
examples of doing both at once, and my experiments have so far been 
unsuccessful. 

Any hints would be much appreciated,

Thanks,
Adam

-- 
-- 
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
Clojure group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [ANN] Schejulure 0.1.1

2013-01-19 Thread Adam Clements
Ah, thanks for the tip. I have now released 0.1.2 which is unchanged apart
from this fix (not leaking ExecutorServices) and improved documentation.

For the single threaded point, I have added in to the documentation that
tasks with a non-trivial running time should fire futures in order to avoid
affecting subsequent scheduled tasks, which I think is a reasonable
restriction to make given the resulting simplicity.

Thanks again for the useful feedback.

Adam
On 19 Jan 2013 09:53, Marko Topolnik marko.topol...@gmail.com wrote:

 There is no need to wrap the Executor Service in a* delay* because it
 already implements lazy-start semantics. From the *ThreadPoolExecutor*
  Javadoc:
 On-demand constructionBy default, even core threads are initially created
 and started only when new tasks arrive, but this can be overridden
 dynamically using 
 methodprestartCoreThread()http://docs.oracle.com/javase/6/docs/api/java/util/concurrent/ThreadPoolExecutor.html#prestartCoreThread()
  or 
 prestartAllCoreThreads()http://docs.oracle.com/javase/6/docs/api/java/util/concurrent/ThreadPoolExecutor.html#prestartAllCoreThreads().
 You probably want to prestart threads if you construct the pool with a
 non-empty queue.

 Also, if you constrain the design to a singleton scheduled thread pool,
 there is no pressing need to shut it down after all schedules are
 cancelled: a total of a few idle threads is deemed acceptable, especially
 because scheduling is either needed for the entire runtime, or not needed
 at all. The major issue were the abandoned schedulers, which you have
 solved.

 A more pressing concern is the size of the thread pool: with just one
 thread, only one task can run at a time. In practice many tasks are very
 short-lived and a single thread can take care of dozens of them, but some
 are quite long-lived, going for 10 minutes and more. Combining such tasks
 with the short-lived ones will result in the short-lived tasks executing on
 a very irregular schedule. This leads towards a configurable stateful
 implementation, which is against the first goal of your design.
 Regrettably, no obvious solutions come to mind.

 On Saturday, January 19, 2013 1:00:26 AM UTC+1, Adam Clements wrote:

 Hi Marko,

 I've addressed some of your concerns by re-using a single thread pool for
 multiple schedule calls in the current master. The original use case was
 one set of scheduled tasks running for the lifetime of my application. If
 you can suggest improvements to cover other use cases with more
 stopping/starting scheduled tasks and automatically cleaning up the
 executor service if it's no longer needed that would be great.

 Adam Clements

 On Fri, Jan 18, 2013 at 9:50 PM, Marko Topolnik marko.t...@gmail.comwrote:


 This looks great. I was building a couple of applications that run
 periodic tasks/services on top of quartzite, but I'll definitely play with
 this. Much nicer scheduling syntax, and the lack of a single stateful
 scheduler feels much more Clojurian (and cleaner, too).


 Behind the apparent elegance is a design that could be wasteful with
 system resources, starting another thread with each invocation of *
 schedule* and leaving the executor service running after the future is
 cancelled.

  --
 You received this message because you are subscribed to the Google
 Groups Clojure group.
 To post to this group, send email to clo...@googlegroups.com
 Note that posts from new members are moderated - please be patient with
 your first post.
 To unsubscribe from this group, send email to
 clojure+u...@**googlegroups.com
 For more options, visit this group at
 http://groups.google.com/**group/clojure?hl=enhttp://groups.google.com/group/clojure?hl=en


  --
 You received this message because you are subscribed to the Google
 Groups Clojure group.
 To post to this group, send email to clojure@googlegroups.com
 Note that posts from new members are moderated - please be patient with
 your first post.
 To unsubscribe from this group, send email to
 clojure+unsubscr...@googlegroups.com
 For more options, visit this group at
 http://groups.google.com/group/clojure?hl=en

-- 
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Re: [ANN] Schejulure 0.1.1

2013-01-18 Thread Adam Clements
Hi Marko,

I've addressed some of your concerns by re-using a single thread pool for
multiple schedule calls in the current master. The original use case was
one set of scheduled tasks running for the lifetime of my application. If
you can suggest improvements to cover other use cases with more
stopping/starting scheduled tasks and automatically cleaning up the
executor service if it's no longer needed that would be great.

Adam Clements

On Fri, Jan 18, 2013 at 9:50 PM, Marko Topolnik marko.topol...@gmail.comwrote:


 This looks great. I was building a couple of applications that run
 periodic tasks/services on top of quartzite, but I'll definitely play with
 this. Much nicer scheduling syntax, and the lack of a single stateful
 scheduler feels much more Clojurian (and cleaner, too).


 Behind the apparent elegance is a design that could be wasteful with
 system resources, starting another thread with each invocation of *
 schedule* and leaving the executor service running after the future is
 cancelled.

  --
 You received this message because you are subscribed to the Google
 Groups Clojure group.
 To post to this group, send email to clojure@googlegroups.com
 Note that posts from new members are moderated - please be patient with
 your first post.
 To unsubscribe from this group, send email to
 clojure+unsubscr...@googlegroups.com
 For more options, visit this group at
 http://groups.google.com/group/clojure?hl=en


-- 
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

[ANN] Schejulure 0.1.1

2013-01-17 Thread Adam Clements
So there are a few scheduling libraries around, I wanted one for cron-like 
job scheduling and my options were quite limited, there are things like 
clj-cronlike and quartzite but I found the syntax quite clunky and didn't 
like the central stateful scheduler idea. There are also things like at-at, 
but that's more for events recurring over seconds/minutes or one-shot 
events, so that was out too.

In the end I wrote my own library. It's tiny (~60 lines) and does one task 
quite well. It's modelled after futures, and in fact returns a future, so 
use it in the same places/way you might use a future, but for recurring 
events.

To schedule things, it's like a cron setup (so by default fires every 
minute of every hour of every day...) but you can pass a map of times when 
it should fire, so for example {:minute [0 15 30 45] :day :tue} will fire 
every 15 minutes on a tuesday where {:hour 9} will fire every minute from 
9-10am every day. Beyond that you simply call schedule with pairs of 
schedule maps to functions which should fire.

Example:
= (def my-running-scheduler
 (schedule {:hour 12 :minute [0 15 30 45]} my-function
   {:hour (range 0 24 6) :minute 0 :day [:sat :sun]} batch-job))

...
= (future-cancel my-running-scheduler)

Simple as that.

Like I say, this was to scratch my own itch, but if anyone else finds it 
useful, great. If it nearly does what you want but not quite... hey, it's 
only 60 lines, fork it/fix it. If anyone has suggestions for features, 
bugfixes or other libraries I should be contributing this code to instead, 
that would be useful knowledge too.

-- 
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Re: [ANN] Schejulure 0.1.1

2013-01-17 Thread Adam Clements
A URL would probably help: https://github.com/AdamClements/schejulure

On Thursday, January 17, 2013 5:56:40 PM UTC, Adam Clements wrote:

 So there are a few scheduling libraries around, I wanted one for cron-like 
 job scheduling and my options were quite limited, there are things like 
 clj-cronlike and quartzite but I found the syntax quite clunky and didn't 
 like the central stateful scheduler idea. There are also things like at-at, 
 but that's more for events recurring over seconds/minutes or one-shot 
 events, so that was out too.

 In the end I wrote my own library. It's tiny (~60 lines) and does one task 
 quite well. It's modelled after futures, and in fact returns a future, so 
 use it in the same places/way you might use a future, but for recurring 
 events.

 To schedule things, it's like a cron setup (so by default fires every 
 minute of every hour of every day...) but you can pass a map of times when 
 it should fire, so for example {:minute [0 15 30 45] :day :tue} will fire 
 every 15 minutes on a tuesday where {:hour 9} will fire every minute from 
 9-10am every day. Beyond that you simply call schedule with pairs of 
 schedule maps to functions which should fire.

 Example:
 = (def my-running-scheduler
  (schedule {:hour 12 :minute [0 15 30 45]} my-function
{:hour (range 0 24 6) :minute 0 :day [:sat :sun]} 
 batch-job))

 ...
 = (future-cancel my-running-scheduler)

 Simple as that.

 Like I say, this was to scratch my own itch, but if anyone else finds it 
 useful, great. If it nearly does what you want but not quite... hey, it's 
 only 60 lines, fork it/fix it. If anyone has suggestions for features, 
 bugfixes or other libraries I should be contributing this code to instead, 
 that would be useful knowledge too.


-- 
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Re: [ANN] Dire, Erlang-style error handling

2012-12-29 Thread Adam Clements
Hey,

I really like the idea of pulling out exception handling from the function 
bodies. The try catch form has always bugged me a little bit.

One thing that worries me though. While this is fine for examples where you 
simply log the exception and move on, what if you need to do something more 
complicated with the actual data? Say for example you need to queue/trigger 
a retry, you no longer have your local bindings to work with so you'd have 
to go back to a normal try/catch (disclaimer - didn't read the paper, just 
going off the code and your comments)

Couple of thoughts on the code:

If you want to attach the error handlers to a particular function var 
(task), why not alter-meta and add the handler function there rather than 
maintaining a separate atom? Given that the deftask is pretty much 
redundant anyway, I don't really see the point in making the distinction. 
 Plus I think your current code is dropping namespaces, causing potential 
future explosions?

I'd be tempted to make a supervise function which simply takes a handler 
map and do away with the macros altogether, you can still def handlers at 
the top level if you want to re-use them, but you could also merge sets of 
handlers if you wanted, or pass in handlers which have some idea of what 
task you're supervising because they have been declared in the same lexical 
scope, e.g.

(let [currenturl ...] 
   (supervise {ConnectionError (fn [e] (queue-retry! currenturl))
   NotFoundError   (fn [e] (log failed: currenturl 
(.getMessage e))}
  fetch-url currenturl :timeout 10))

or your example would look like:
(defn divider [a b]
   (/ a b))

(def div-zero-handler 
{ArithmeticException (fn [e] (println Cannot divide by zero))})

(def npe-handler
{NullPointerException (fn [e] (println ...))})

(def supervised-divider (partial divider (merge div-zero-handler 
npe-handler)))

(supervised-divider 10 0)...

Which I would argue is a lot more idiomatic and flexible. I think macros 
are overkill and unnecessary complexity here, you just need a supervise 
function which takes responsibility for catching errors and lets you re-use 
handlers

Adam

On Friday, December 28, 2012 7:14:34 PM UTC, Michael Drogalis wrote:

 Hey folks,

 After watching The Language of the System and being directed to Joe 
 Armstrong's paper on error handling, I concurred that his approach is 
 fantastic. I really wanted the same thing for more rudimentary operations, 
 like file handling. So I wrote Dire 
 https://github.com/MichaelDrogalis/dire

 The pros are of this are that error handling code is removed from 
 application logic and it is not order complected.
 The cons are that tasks are not as strongly isolated as they are in 
 Erlang. Also, because it is so simple (16 lines),
 there's no way for a supervisor to restart a child task. (Yet, I guess. 
 Ideas?)

 Can such a thing be useful in a non-distributed environment? Or does this 
 look like a hassle to use?




-- 
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Re: Countdown numbers game in clojure.core.logic

2012-12-13 Thread Adam Clements
Hi, so I chose this problem as my first foray into core.logic too

My solution is here 
https://github.com/AdamClements/countdown/blob/master/src/countdown/core.clj

My solution is a little slow, depending on how tricky a problem it is, it 
can take from milliseconds to seconds. I ran [75 9 1 3 4] with a each 
target from 0 to 999 and got an average time of 824ms (including a lot 
where the search was exhausted). In the solvable ones it usually returns 
quicker than that.

Like I said, this is my first attempt at logic programming, so if anyone 
can see how to make my solution more concise/elegant/faster, tips are much 
appreciated!

Thanks

Adam Clements

On Saturday, August 18, 2012 3:36:01 PM UTC+1, David Powell wrote:


 I just had a go of solving the Numbers Game from the UK gameshow Countdown 
 [1] in clojure.core.logic.

 https://gist.github.com/3374505 

 It works, but it is a bit slow.

 Anybody got any ideas on better approaches?

 [1] http://en.wikipedia.org/wiki/Countdown_(game_show)#Numbers_round

 -- 
 Dave



-- 
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en