Fork me on GitHub
#clojure
<
2016-04-16
>
rmuslimov00:04:23

I’d say that libraries for SQL manipulation, they have to have an explanation in readme on the front page - Why do they exists and why they’re better that korma/yesql/hugsql/whatever?

isak00:04:51

he talked about it a little bit https://youtu.be/zvocHR_gg1Y?t=9m52s

isak00:04:57

i can't vouch for it though, haven't used it

isak00:04:11

but yes i agree

fasiha02:04:24

I think this ought to a simple question but I'm afraid it'll turn out to be complicated: why does transit-clj (https://github.com/cognitect/transit-clj#usage) need me to provide a byte array of some fixed size (in the example there, 4KB) to fill with transit-ified content? (I ask because transit-cljs, the ClojureScript version, is delightfully simple to use without what seems to be the limitation of a fixed-length buffer.)

hiredman02:04:43

fashiha: I think you are misunderstanding the example

hiredman02:04:36

the example creates a bytearray outputstream, which is an outputstream (something you can write to) and then turn in to a byte array

hiredman02:04:39

the bytearrayoutputstream does an arraylist sort of growing of the buffer it writes to, but you can also give it a size to preallocate, which is what that 4k is

hiredman02:04:17

but you can wrap any output stream in a transit writer

fasiha02:04:14

@hiredman: well I'll be a monkey's uncle.

fasiha02:04:04

@hiredman: ok, so if I omit 4096 from that example, it continues to work. Very nice! But ok, then here's the other difference with the (what seems to be simpler) cljs version: subsequent calls to transit/write append to the ByteArrayOutputStream, leaving previously written values in-place . I don't want to do that, I want to write one cljs value to transit, do something to that (send it over websocket, spit to file, etc…), then write another value, overwriting the original.

hiredman02:04:03

you are bringing a spoon to a knife fight

hiredman02:04:39

whatever library you use on the jvm will almost certainly expose an outputstream for writing stuff, just wrap that in a transit writer

jtackett02:04:05

Anyone know a library where you can read emails and tell if they are read or unread?

jtackett02:04:12

would also be nice to be able to delete emails

hiredman02:04:02

email is very complicated, best to avoid it

hiredman02:04:58

my last job was at an email archiving company

hiredman02:04:03

it is going to depend on if you are accessing email on some server (if this is the case you are almost certainly using imap) or locally in some storage format (mbox, maildir, etc)

hiredman02:04:46

if it is in on disk in maildir you are pretty much home free

fasiha03:04:23

@hiredman: you're right! http-kit websocket API does accept a stream 😮 ! http://www.http-kit.org/server.html#websocket

fasiha03:04:33

Hmm, so http-kit's websocket API's send! (http://www.http-kit.org/server.html#websocket) does use a stream, but strictly an InputStream or byte[]. In transit-clj's example, the transit writer populates an OutputStream, ByteArrayOutputStream to be precise (https://github.com/cognitect/transit-clj#usage). Last year, @arohner suggested creating a fresh ByteArrayOutputStream for each invocation of transit's write and convert that to a string for subsequent use (http://clojurians-log.mantike.pro/clojure/2015-07-24.html). But @hiredman's comments above make me think I should be able to connect the stream being populated by transit to a stream being emptied by http-kit—is this a reasonable idea?

fasiha03:04:02

I've never used Java streams so it's very likely my understanding of how this could work has huge holes in it.

fasiha04:04:16

After some reading, I think I understand more how ByteArrayOutputStreams are used in Java simple_smile and will create them each time I need to make a transit payload, convert it to string, and send it out. Some day this nubness will pass!

bwstearns07:04:55

I think I'm having a dense moment. I'm trying to work with instaparse, and it's being required weird. There's nothing defined at insta/something but insta tab complete shows instaparse.abnf, instaparse.auto-flatten-seq, etc. Anyone have any idea why it's not showing up as just insta like in the examples?

(ns proj.strategies
   (:require [instaparse.core :as insta]))

lvh19:04:18

Does Java annotation interop work with definterface/gen-interface?

lvh19:04:57

woo, apparently the answer is yes

nimalan20:04:28

is it possible to call (swap! atom f) on an atom and return additional information from the f, rather than just the updated value of the atom?

nimalan20:04:02

i.e. i have a set of things in an atom.. i want to add some other things to the set and return the set of things that were already in the set

jswart20:04:32

@nimalan: using add-watch is likely what I would do in that instance

nimalan20:04:30

@jswart: thanks, that makes sense.. kinda a bummer that it wont be in the context of the function call in which im updating the atom

jswart20:04:10

Yeah, one of two things is likely happening. Either your code can be changed so that you don’t need an atom and you can do it in the scope of your function call.

jswart20:04:20

Or you can’t, and so you need to do something like you are considering now.

nimalan21:04:01

👍:skin-tone-5: got it!

hiredman22:04:43

there is a function, I forget what it is called, compare-and-set! maybe, which you can use to write your own version of swap! that does whatever you want

hiredman22:04:46

do do silly things with a second atom, or a promise, or add-watch, or whatever

nimalan23:04:39

Ah yes, cool I'll take a look at that