Re: [ANN] HugSQL 0.1.1 - Embrace SQL

2015-10-21 Thread Andrey Antukh
Really great! I have find in the past some library like yesql that not
dependes on the clojure.java.jdbc.

Nice work!

On Thu, Oct 22, 2015 at 4:10 AM, Robin Heggelund Hansen <
skinney...@gmail.com> wrote:

> This looks great, seems to solve all the problems I have with YeSQL. Great
> work :D
>
> --
> 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.
>



-- 
Andrey Antukh - Андрей Антух - 
http://www.niwi.nz
https://github.com/niwinz

-- 
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: is there a community "best practice" for including your co-workers libraries?

2015-10-21 Thread Daniel Compton
The S3 Wagon is a great option for hosting Maven deps. It takes virtually
no maintenance, is backed by AWS, and is dirt simple to configure. It isn't
as full featured as some of the other options, but it can't be beat for
simplicity.

On Sat, Oct 17, 2015 at 4:42 PM Robert Levy  wrote:

> Many use s3-wagon or a hosted maven. Or you could install dependencies
> locally, but that's a pain. On the other hand putting AWS credentials in CI
> for example to use s3-wagon can be annoying too.
>
> What about depending on a specific git remote / commit?  This library
> might be worth giving a shot: https://github.com/tobyhede/lein-git-deps
>
>
> On Fri, Oct 16, 2015 at 7:14 PM, Shantanu Kumar 
> wrote:
>
>> We are using Artifactory for our internal Maven repo (supports enterprise
>> Single-Sign-On):
>> https://www.jfrog.com/open-source/
>>
>> Shantanu
>>
>>
>> On Saturday, 17 October 2015 02:47:29 UTC+5:30, Lawrence Krubner wrote:
>>>
>>> I know this question has been asked before, but when I went searching I
>>> mostly found old entries that were on a somewhat different topic, such as
>>> "How to add a java library (that is not in maven) as a dependency for a
>>> clojure library?"
>>>
>>> I wrote a Clojure app and my co-worker wrote a Java app. I have another
>>> co-worker who is working on an app that would include the first 2 apps as
>>> libraries.
>>>
>>> I have been able to get the combination working using the Leiningen
>>> plugin "localrepo" but my co-worker wants me to make the other 2 libraries
>>> available from some central repo that Leiningen can download from. How is
>>> this usually done? Do I set up a Maven repo on one of the company servers?
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>> --
>> 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.
>
-- 
Daniel

-- 
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] HugSQL 0.1.1 - Embrace SQL

2015-10-21 Thread Robin Heggelund Hansen
This looks great, seems to solve all the problems I have with YeSQL. Great 
work :D

-- 
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.


[ANN] HugSQL 0.1.1 - Embrace SQL

2015-10-21 Thread Curtis Summers
I'm happy to announce a new library for working with SQL in your Clojure 
projects: 

*HugSQL*

https://github.com/layerware/hugsql

HugSQL takes the position that SQL is the right tool for the job when 
working with a relational database. Embrace SQL!

At a glance, HugSQL:

   - uses simple conventions in your SQL files to define (at compile time) 
   database functions in your Clojure namespace, creating a clean separation 
   of Clojure and SQL code.
   - supports run-time replacement of SQL value parameters (e.g., where id 
   = :id), SQL identifiers (i.e. table/column names), raw SQL keywords, and 
   your own parameter types.
   - has protocol-based adapters supporting multiple database libraries and 
   ships with adapters for clojure.java.jdbc (default) and clojure.jdbc


This library is still in early development, and at this point I'm looking 
for feedback, rough-edges, your particular use cases, etc.

See the README for clojar install information: 
https://github.com/layerware/hugsql


Thanks,

Curtis Summers


-- 
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: HP Fortify Security Scanner and Clojure

2015-10-21 Thread Alex Miller
In general, Clojure code cannot be decompiled from .class to .java as the 
Clojure generated bytecode does things that cannot be represented in Java. 
The particular issue below looks like the local-clearing code. It is 
possible to turn that off during compilation, however there are likely 
other things as well that cannot be decompiled satisfactorily.

FindBugs works directly from bytecode (not source code) so might be more 
amenable for this kind of analysis. There is a sonar plugin 
(https://github.com/zmsp/sonar-clojure) which uses Eastwood and Kibit that 
might also be useful.

FYI, Clojure is registered in CVE with id CVE-2015-4653 (although there are 
no reports registered yet). I gather that it is useful to create at least 
one such thing to make it searchable and I have that on my todo list 
(although it's not a high priority). 

Alex


On Wednesday, October 21, 2015 at 3:41:21 PM UTC-5, ryan medlin wrote:
>
> A customer requires that we scan our clojure projects with this tool:
>
> http://www8.hp.com/us/en/software-solutions/static-code-analysis-sast/
>
>
> They must get some meaningful report from this.
>
> So I thought, well why don't I compile and then decompile the class files 
> and then scan those to at least give them something.
>
> However when I do that I get a TON of high security issues in multiple 
> dependencies (ring, clojure.core)
>
> Here is the most prevalent:
>
> https://cwe.mitre.org/data/definitions/476.html
>
> /* */ package nio;
> /* */ 
> /* */ import clojure.lang.AFunction;
> /* */ import clojure.lang.IFn;
> /* */ import clojure.lang.RT;
> /* */ import clojure.lang.Var;
> /* */ import java.nio.Buffer;
> /* */ import java.nio.ByteBuffer;
> /* */ 
> /* */ public final class core$fn__1869 extends AFunction
> /* */ {
> /* 284 */   public static final Var const__0 = (Var)RT.var("clojure.core", 
> "make-array");
> /* */ 
> /* */   public Object invoke(Object x)
> /* */   {
> /* 297 */ x = null; Object x = ((ByteBuffer)x).duplicate();
> /* 298 */ Object array = 
> ((IFn)const__0.getRawRoot()).invoke(Byte.TYPE, 
> Integer.valueOf(((Buffer)x).remaining()));
> /* 299 */ x = null; ((ByteBuffer)x).get((byte[])array); array = null; 
> return array;
> /* */   }
> /* */ }
>
>
> Decompiler:
>
> http://jd.benow.ca/
>
> Id the decompiler somehow generating code with these security issues and 
> the actual bytecode does not have them maybe?
>
>
> I have no idea how to move forward with this.  We have to "check a box" 
> for them in corporate speak yet there is no clear path to run a dependable 
> security scan against the codebase.
>
>
> Yes I realize this is silly to demand running this tool.
>
> Any other tools out there that might be able to scan Clojure code like 
> this?
>
>
>
>

-- 
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: HP Fortify Security Scanner and Clojure

2015-10-21 Thread Andrey Antukh
Maybe you can found the answer here http://stackoverflow.com/a/6590437

Regards.
Andrey

On Wed, Oct 21, 2015 at 11:35 PM, ryan medlin 
wrote:

> A customer requires that we scan our clojure projects with this tool:
>
> http://www8.hp.com/us/en/software-solutions/static-code-analysis-sast/
>
>
> They must get some meaningful report from this.
>
> So I thought, well why don't I compile and then decompile the class files
> and then scan those to at least give them something.
>
> However when I do that I get a TON of high security issues in multiple
> dependencies (ring, clojure.core)
>
> Here is the most prevalent:
>
> https://cwe.mitre.org/data/definitions/476.html
>
> /* */ package nio;
> /* */
> /* */ import clojure.lang.AFunction;
> /* */ import clojure.lang.IFn;
> /* */ import clojure.lang.RT;
> /* */ import clojure.lang.Var;
> /* */ import java.nio.Buffer;
> /* */ import java.nio.ByteBuffer;
> /* */
> /* */ public final class core$fn__1869 extends AFunction
> /* */ {
> /* 284 */   public static final Var const__0 = (Var)RT.var("clojure.core",
> "make-array");
> /* */
> /* */   public Object invoke(Object x)
> /* */   {
> /* 297 */ x = null; Object x = ((ByteBuffer)x).duplicate();
> /* 298 */ Object array =
> ((IFn)const__0.getRawRoot()).invoke(Byte.TYPE,
> Integer.valueOf(((Buffer)x).remaining()));
> /* 299 */ x = null; ((ByteBuffer)x).get((byte[])array); array = null;
> return array;
> /* */   }
> /* */ }
>
>
> Decompiler:
>
> http://jd.benow.ca/
>
> Id the decompiler somehow generating code with these security issues and
> the actual bytecode does not have them maybe?
>
>
> I have no idea how to move forward with this.  We have to "check a box"
> for them in corporate speak yet there is no clear path to run a dependable
> security scan against the codebase.
>
>
> Yes I realize this is silly to demand running this tool.
>
> Any other tools out there that might be able to scan Clojure code like
> this?
>
>
>
> --
> 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.
>



-- 
Andrey Antukh - Андрей Антух - 
http://www.niwi.nz
https://github.com/niwinz

-- 
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.


HP Fortify Security Scanner and Clojure

2015-10-21 Thread ryan medlin
A customer requires that we scan our clojure projects with this tool:

http://www8.hp.com/us/en/software-solutions/static-code-analysis-sast/


They must get some meaningful report from this.

So I thought, well why don't I compile and then decompile the class files 
and then scan those to at least give them something.

However when I do that I get a TON of high security issues in multiple 
dependencies (ring, clojure.core)

Here is the most prevalent:

https://cwe.mitre.org/data/definitions/476.html

/* */ package nio;
/* */ 
/* */ import clojure.lang.AFunction;
/* */ import clojure.lang.IFn;
/* */ import clojure.lang.RT;
/* */ import clojure.lang.Var;
/* */ import java.nio.Buffer;
/* */ import java.nio.ByteBuffer;
/* */ 
/* */ public final class core$fn__1869 extends AFunction
/* */ {
/* 284 */   public static final Var const__0 = (Var)RT.var("clojure.core", 
"make-array");
/* */ 
/* */   public Object invoke(Object x)
/* */   {
/* 297 */ x = null; Object x = ((ByteBuffer)x).duplicate();
/* 298 */ Object array = ((IFn)const__0.getRawRoot()).invoke(Byte.TYPE, 
Integer.valueOf(((Buffer)x).remaining()));
/* 299 */ x = null; ((ByteBuffer)x).get((byte[])array); array = null; 
return array;
/* */   }
/* */ }


Decompiler:

http://jd.benow.ca/

Id the decompiler somehow generating code with these security issues and 
the actual bytecode does not have them maybe?


I have no idea how to move forward with this.  We have to "check a box" for 
them in corporate speak yet there is no clear path to run a dependable 
security scan against the codebase.


Yes I realize this is silly to demand running this tool.

Any other tools out there that might be able to scan Clojure code like this?



-- 
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: How to tell buffy which file to read?

2015-10-21 Thread William la Forge
Sounds like one of the X9 standard protocols. What a pain.

-- 
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: How to tell buffy which file to read?

2015-10-21 Thread Amith George
I seem to have misunderstood what buffy is meant to do. I thought I could 
create a spec (using its dynamic frames feature) for the entire file and 
pass to buffy this spec and the file name. When I query for a certain 
field, it would skip the required number of bytes and load into memory only 
those bytes that comprise the field I queried. I thought this would be an 
efficient way to read only a part of the file in a structured manner. 

That however seems to be incorrect. If I create the spec for the entire 
file, then the buffer passed to buffy has to contain the data for the 
entire file. In the case of a 500MB file, I would have to read the entire 
500MB into a buffer and pass that to buffy. That kinda seems inefficient 
when I only wish to query certain fields from the spec. 

The binary file has its data stored in a custom format. A lot of data is 
stored as a pair representing size of data (1 to 4 bytes of data is used to 
store the size) and actual bytes of data. Existing code is littered with 
custom `readInt(), readShort()` method to read the size of data and 
`skip(size)` to skip over it. This is done many times till it reaches the 
beginning of the interesting data. I was hoping to somehow avoid that using 
buffy and its spec. 


On Wednesday, 21 October 2015 20:09:58 UTC+5:30, Amith George wrote:
>
> I am interested in using buffy[1] to read data from multiple binary files. 
> The files have sizes varying from 10MB to 500MB. From the documenation, 
> buffy seems to work directly on a buffer and not a file. It can either 
> create a heap or off-heap buffer of size equaling the size of the spec or 
> it can wrap a passed in buffer. *With the former, how does it know which 
> file to read from? *
>
> If we choose the latter, ie pass in an existing buffer, how do we go about 
> creating that buffer? I am new to Java, so what should I take into account? 
> Reading blog posts, the general trend seems to be to create a buffer from 
> the inchannel of a RandomAccessFile opened in read mode. The size of the 
> buffer can either match the file size or be a fixed size. Depending on the 
> size of the buffer, `buffer.flip()` is called once or once for each 
> iteration of the read loop. The other alternative seems to be to create a 
> memory mapped buffer, either of size equalling file size or of a fixed 
> size. Since my file size won't go beyond 500MB and I can create a direct 
> buffer using standard allocation code, do I need to use a memory mapped 
> buffer? If I am not using a memory mapped buffer, do I need to call 
> buffer.flip() before passing it to buffy? 
>
> Also, how does buffy handle reading in data that is of size larger than 
> the fixed size buffer? In this specific scenario, I would be interested in 
> only about 5-10MB of data, located somewhere in the middle of the 500MB 
> sized file. I don't see the value in creating a buffer of size 500MB. Can I 
> create a 1MB fixed size buffer and tell buffy to read in a dynamic type 
> field whose size in that file happens to be 2.5MB? 
>
> I looked at other binary file reading libraries and their documentation 
> also don't mention how to create the buffer. I feel like I am overlooking 
> something basic. 
>
> [1] - https://github.com/clojurewerkz/buffy
>

-- 
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: State Change Listener in Clojure on a Database

2015-10-21 Thread Michael Ball
I've had this working a few months ago using 
http://impossibl.github.io/pgjdbc-ng/. Here's the clojure used.

https://gist.github.com/mikeball/ba04dd5479f51c00205f

I don't have time to test this now, but it should get you started.













On Monday, October 19, 2015 at 8:06:01 AM UTC-7, Adrian Cooley wrote:
>
> Hi all,
>
> I'm new to Clojure and I've been exploring the possibility of using it to 
> handle a large list of Users stored in a Postgresql Database. I can see 
> that there are some great sql libraries for clojure to query a Postgresql 
> database and this is fine. However, I was wondering if there are any useful 
> Clojure features or libraries that could allow me to 'listen' for changes 
> to a Users Table in the Database. A use case scenario to describe what I 
> want would be as follows: Say someone registers their details on a website 
> and their details are persisted to the Database. I then want some process 
> to pick up that a new user is now in the database and send this user 
> information to a client that has registered to listen for new users. Is 
> something like this possible in Clojure where it can handle listening to 
> state changes and trigger a notification? Thanks in advance to anyone who 
> chimes in with advice,
>
> Regards,
> 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.


Re: [ANN] ClojureCL - OpenCL 2.0 Clojure library (GPGPU and high performance parallel computing)

2015-10-21 Thread Dragan Djuric
New version of ClojureCL 0.3.0 is out in Clojars. 
http://clojurecl.uncomplicate.org

On Wednesday, June 17, 2015 at 4:59:02 PM UTC+2, Dragan Djuric wrote:
>
> Certainly, but that is not a priority, since I do not use (nor need) 
> OpenGL myself. I would be very interested to include contributions as soon 
> as I get them, and the foundations are already there (in JOCL), so it is 
> not that hard at might look at first glance - I just do not have time to be 
> sure that I do it properly now.
>
> On Wednesday, June 17, 2015 at 4:54:45 PM UTC+2, Bobby Bobble wrote:
>>
>> superb!
>>
>> are there any plans to include opengl context sharing for visualisation ?
>>
>

-- 
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: How to tell buffy which file to read?

2015-10-21 Thread William la Forge
Buffers are allocated using a static method in Java, so 
(ByteBuffer/allocate 42) returns a byte buffer with space for 42 bytes of 
data. Buffers can be used in read/write operations with FileChannel.

I suggest that you study the javadoc for (java.nio.channels FileChannel) 
and (java.nio ByteBuffer) before trying to use a library like buffy.

I make good use of ByteBuffer and FileChannel in the durable applications 
for aatree, though I do not use buffy: https://github.com/laforge49/aatree

Bill


-- 
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.


How to tell buffy which file to read?

2015-10-21 Thread Amith George
I am interested in using buffy[1] to read data from multiple binary files. 
The files have sizes varying from 10MB to 500MB. From the documenation, 
buffy seems to work directly on a buffer and not a file. It can either 
create a heap or off-heap buffer of size equaling the size of the spec or 
it can wrap a passed in buffer. *With the former, how does it know which 
file to read from? *

If we choose the latter, ie pass in an existing buffer, how do we go about 
creating that buffer? I am new to Java, so what should I take into account? 
Reading blog posts, the general trend seems to be to create a buffer from 
the inchannel of a RandomAccessFile opened in read mode. The size of the 
buffer can either match the file size or be a fixed size. Depending on the 
size of the buffer, `buffer.flip()` is called once or once for each 
iteration of the read loop. The other alternative seems to be to create a 
memory mapped buffer, either of size equalling file size or of a fixed 
size. Since my file size won't go beyond 500MB and I can create a direct 
buffer using standard allocation code, do I need to use a memory mapped 
buffer? If I am not using a memory mapped buffer, do I need to call 
buffer.flip() before passing it to buffy? 

Also, how does buffy handle reading in data that is of size larger than the 
fixed size buffer? In this specific scenario, I would be interested in only 
about 5-10MB of data, located somewhere in the middle of the 500MB sized 
file. I don't see the value in creating a buffer of size 500MB. Can I 
create a 1MB fixed size buffer and tell buffy to read in a dynamic type 
field whose size in that file happens to be 2.5MB? 

I looked at other binary file reading libraries and their documentation 
also don't mention how to create the buffer. I feel like I am overlooking 
something basic. 

[1] - https://github.com/clojurewerkz/buffy

-- 
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: Use of dosync within defrecord

2015-10-21 Thread Alex Miller
It's perfectly fine to use dosync/alter within a defrecord function. Couple 
other things:
- alter takes a fn and then the args but without parens
- you can (and should) refer to fields of a record directly within the 
defrecord functions, so this is simpler:
- withdraw was misspelled
- withdraw should subtract money, not add it

(defrecord bankAccount [balance holder]
  IBankAccount 
  (deposit [this amount] (dosync (alter + balance amount)))
  (withdraw [this amount] (dosync (alter - balance amount

However, I would suggest that in most cases I would not create an interface 
for this purpose (I'm guessing you're coming from an OO background). And I 
would also consider making the bank account simply data without state and 
instead wrapping the state around the data.

;; just data, just values
(defrecord BankAccount [balance holder])

;; deposit takes an account and modifies it to return a new account
;; as much as possible, just write functions that take and return values
(defn deposit [bank-account amount]
  (update bank-account :balance + amount))

;; same for withdraw
(defn withdraw [bank-account amount]
  (update bank-account :balance - amount))

;; then if you need a stateful bank account, wrap that state around the data
(def checking (ref (->BankAccount 1000 "Alex")))
(def savings (ref (->BankAccount 500 "Alex")))

;; and maybe create some functions that work specifically on stateful 
entities
(defn transfer [from to amount]
  (dosync
(alter from withdraw amount)
(alter to deposit amount)))
   
(transfer checking savings 200)
@checking  ;; #user.BankAccount{:balance 800, :holder "Alex"}
@savings  ;; #user.BankAccount{:balance 700, :holder "Alex"}




On Wednesday, October 21, 2015 at 6:45:23 AM UTC-5, Alex Floor wrote:
>
> Hello all,
>
> I am currently studying Clojure and wanted to make a bankaccount with 
> reference, so I came up with the following approach:
>
> (defprotocol IBankAccount
>  (deposit [this amount])
>  (widthraw [this amount])
>  )
>
>
> (defrecord bankAccount
>  [balance holder]
>  
>  ;implements the IBankAccount
>  IBankAccount
>  
>  (deposit [this amount] (dosync (alter (+ (:balance this) 
>  amount
>  (widthraw [this amount] (dosync (alter (+ (:balance this) 
> + amount
> )
>
> And the balance needs to be a ref, I think I misunderstood somethingh but 
> couldn 't find a clear answer about the use of dosync -> alter within a 
> defrecord.
>
>
>

-- 
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: State Change Listener in Clojure on a Database

2015-10-21 Thread Kyle Cordes
On October 21, 2015 at 6:22:10 AM, Jony Hudson (jonyepsi...@gmail.com) wrote:
The Java JDBC drivers support listening, although you have to do it by polling:

https://jdbc.postgresql.org/documentation/80/listennotify.html


This alternative JDBC driver in progress, apparently supports push 
notification. I encountered it when I had a similar need, haven’t tried it yet.

https://github.com/impossibl/pgjdbc-ng

This repo is some kind of experiment in talking to PG using libpq, no JDBC. 
Looks like it didn’t get very far:

https://github.com/benfante/libpq-wrapper

There is one more similar thing out there somewhere. I encountered it when 
looking around a few months ago, but cannot find it now. It is a much more 
complete Java (and possibly even Clojure) library to work with PG, but not 
using the JDBC API.



-- 
Kyle Cordes
http://kylecordes.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.


Use of dosync within defrecord

2015-10-21 Thread Alex Floor
Hello all,

I am currently studying Clojure and wanted to make a bankaccount with 
reference, so I came up with the following approach:

(defprotocol IBankAccount
 (deposit [this amount])
 (widthraw [this amount])
 )


(defrecord bankAccount
 [balance holder]
 
 ;implements the IBankAccount
 IBankAccount
 
 (deposit [this amount] (dosync (alter (+ (:balance this) 
 amount
 (widthraw [this amount] (dosync (alter (+ (:balance this) 
+ amount
)

And the balance needs to be a ref, I think I misunderstood somethingh but 
couldn 't find a clear answer about the use of dosync -> alter within a 
defrecord.


-- 
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: State Change Listener in Clojure on a Database

2015-10-21 Thread Jony Hudson
Postgres has LISTEN/NOTIFY that you can use for triggering something like 
this:

http://www.postgresql.org/docs/9.4/static/sql-notify.html
http://www.postgresql.org/docs/9.4/static/sql-listen.html

The Java JDBC drivers support listening, although you have to do it by 
polling:

https://jdbc.postgresql.org/documentation/80/listennotify.html

Are you sure that you want to do this in an event driven way though? Other 
alternatives would be:

- when you add the user, also add their ID to a table of new users. 
Periodically poll this table and handle any new users, marking them as 
handled once you've sent the message to clients.

- use a queue of some sort to manage asynchronous tasks.

The first is simple, and has the advantage that it doesn't require any 
fancy DB features. The second is worth thinking about if you're going to 
have any other kind of triggered tasks, but is probably overkill just for 
this. Both have the advantage that the desire to perform an action (notify 
clients) is explicitly represented somewhere rather than just existing 
implicitly in the state of the running process.


Jony


On Monday, 19 October 2015 16:06:01 UTC+1, Adrian Cooley wrote:
>
> Hi all,
>
> I'm new to Clojure and I've been exploring the possibility of using it to 
> handle a large list of Users stored in a Postgresql Database. I can see 
> that there are some great sql libraries for clojure to query a Postgresql 
> database and this is fine. However, I was wondering if there are any useful 
> Clojure features or libraries that could allow me to 'listen' for changes 
> to a Users Table in the Database. A use case scenario to describe what I 
> want would be as follows: Say someone registers their details on a website 
> and their details are persisted to the Database. I then want some process 
> to pick up that a new user is now in the database and send this user 
> information to a client that has registered to listen for new users. Is 
> something like this possible in Clojure where it can handle listening to 
> state changes and trigger a notification? Thanks in advance to anyone who 
> chimes in with advice,
>
> Regards,
> 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.


Re: State Change Listener in Clojure on a Database

2015-10-21 Thread Ole Krüger
Check out https://github.com/relaynetwork/irmgard 

On Monday, October 19, 2015 at 5:06:01 PM UTC+2, Adrian Cooley wrote:
>
> Hi all,
>
> I'm new to Clojure and I've been exploring the possibility of using it to 
> handle a large list of Users stored in a Postgresql Database. I can see 
> that there are some great sql libraries for clojure to query a Postgresql 
> database and this is fine. However, I was wondering if there are any useful 
> Clojure features or libraries that could allow me to 'listen' for changes 
> to a Users Table in the Database. A use case scenario to describe what I 
> want would be as follows: Say someone registers their details on a website 
> and their details are persisted to the Database. I then want some process 
> to pick up that a new user is now in the database and send this user 
> information to a client that has registered to listen for new users. Is 
> something like this possible in Clojure where it can handle listening to 
> state changes and trigger a notification? Thanks in advance to anyone who 
> chimes in with advice,
>
> Regards,
> 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.