Fork me on GitHub
#clojure
<
2016-03-15
>
jonathanj08:03:43

Reading backlog, coming from Python webdev I found Clojure really refreshing. The way mutability permeates every aspect of Python really makes life difficult beyond the very early toy stages of an application.

jonathanj08:03:32

It’s also nice to be able to lean on the builtin data structures because they have good support right out of the box, in Python it’s extremely common to implement a bunch of small objects here and there because, for example, dict (and the support for working with it) is so bad.

gareth10:03:04

hi, does anyone know of a good place to ask questions about Parkour?

lumengxi16:03:47

hey guys, im struggling with pulling large datasets from postgresql database using java.jdbc. Looks like it tried to pull everything into memory first, which is causing OOM errors. i have tried to add things like :fetch-size etc but it doesnt help at all. thoughts?

donaldball16:03:00

You need to do the dance to enable streaming result sets

donaldball16:03:34

Afraid I don’t know the steps for postgresql, but you may find some love here: https://simplefeatures.wordpress.com/2011/09/30/jdbc-tweaks-to-enable-streaming-result-sets/

lumengxi17:03:40

interesting, will take a look, thanks @donaldball

lumengxi17:03:40

!! @donaldball works like a charm, thanks!

lumengxi17:03:04

looks like fetch-size and setAutoCommit need to be both configured to make it work

ghadi18:03:08

just set these magic parameters @donaldball @lumengxi 😃

arohner18:03:23

Hey there. I’m having some unicode issues. Another API is giving me corrupted unicode, like “I contain \342\200\223 an en-dash”, where the numbers there are the octal codes for the 3-byte unicode for which is the EN-DASH character. I could write a parser for this, but is there some Java magic I can do to fix this before going down that rathole?

cky18:03:46

Fun times with mojibake. 😉 So, basically, your other API is not UTF-8 aware. Instead of doing UTF-8 decoding of the bytestream, it is essentially just upcasting all the bytes to chars directly without any decoding.

cky18:03:21

If you can get your API to return byte arrays, you can easily use Java’s Charset class to decode that.

arohner18:03:33

I can’t fix the API. This is a 3rd party service I don’t control

cky18:03:44

Okay, is there any documentation for the API?

arohner18:03:35

kind of, but not adequate. It’s http://support.kissmetrics.com/apis/data/. They’re broken, I’ve told them they’re broken, but I still need to parse my data

cky18:03:35

Okay, it’s a Web API. Can you send me a dump of the API response including HTTP headers?

cky18:03:56

You can strip out any sensitive information, of course.

cky18:03:25

I’m basically trying to see if the HTTP headers contains a UTF-8 charset declaration in the Content-Type.

cky18:03:26

I am also trying to see if the data has double-encoding.

sveri18:03:39

Hi, I have a vec of strings and want to concatenate them via a grouping. So ['a 'b 'c 'd] becomes ["ab" "bc" "cd"], is there a nice function for that?

arohner18:03:32

sveri: (map #(str/join "" %) (partition-all 2 1 ['a 'b 'c 'd]))

arohner18:03:59

sorry, partition, not partition-all

sveri18:03:07

@arohner: Great. I missed that partition takes a step parameter, thets what I need, thank you

cky18:03:33

@arohner: I reread your question. Is your API returning actual backslash-3-4-2-backslash-2-0-0, etc.?

cky18:03:06

I did write a Ruby string parser a few years ago.

cky18:03:15

Feel free to steal the code. (Lemme hunt you my Gist.)

cky18:03:18

That will get you to a place where you can then do a UTF-8 decode.

cky19:03:56

(As an aside: “j7gs” in the package name stands for “Java 7 GolfScript”. I had intended to write a Java-based GolfScript interpreter (which uses Ruby strings) many years ago, before I realised that all the serious golfers had moved on to using CJam and Pyth. I’m currently in the process of writing a C++ implementation of CJam for fun. :-P)

cky19:03:07

(and “Java 7” refers to the use of invokedynamic for the interpreter’s mechanics)

josh.freckleton22:03:34

cider is consistently crashing emacs when I accidentally build an infinite loop. C-C C-C does nothing to cease execution. How can I stop crashing emacs? Is there a way to break out of long running loops? Or reliably terminate execution without killing emacs?

josh.freckleton22:03:16

(and just now, when I started the CIDER in emacs, you know how it gives you a little quote of the day? Mine just now was "To infinity and beyond", haha. The computer revolution is here, it knows what I'm doing!!)

bpicolo22:03:08

The reify docs don't make aaaany sense:

anmonteiro22:03:58

cross-posting in #C03S1L9DN

anmonteiro22:03:01

in Javascript, 46245 << 16 = -1264254976 in Clojure, (bit-shift-left 46245 16) = 3030712320 Is this related to JavaScript number precision being only 53 bits? anyone know how I can get the same result in Clojure?

anmonteiro23:03:17

FWIW, the solution is: (clojure.lang.Numbers/shiftLeftInt 46245 16)

anmonteiro23:03:52

clojure was using Longs

bronsa23:03:58

@anmonteiro: use (unchecked-int (bit-shift-left 46245 16)) rather than relying on implementation methods

anmonteiro23:03:58

@bronsa: cool, thanks. that looks better