Fork me on GitHub
#off-topic
<
2018-11-03
>
slipset14:11:23

@rgb.ide I’d start by asking myself is REST really what I want, and independent of the answer, start looking at the architecture behind https://github.com/capitalone/cqrs-manager-for-distributed-reactive-services/blob/master/doc/architecture.png and the talks @bobbycalderwood has given on the subject. Then I’d think about why GraphQL or its likes are not a better fit than REST.

hmaurer23:11:21

Not to start a debate but in which context would you say GraphQL is not a better fit than REST?

rgb-one15:11:23

@slipset nice approach. I have already started building out a "Restful API" without really understanding much about it. I think I may need to take a step back learn a bit more about RESTful API's and other approaches like GraphQL and how well they suite my usecase. Thanks @slipset, @dominicm.

slipset16:11:12

If the purpose of your api is to serve an SPA, I’d say REST is the wrong approach.

👍 4
quadron17:11:02

how do i convert a byte array to binary representation?

andy.fingerhut17:11:19

Not sure what you mean. Do you mean write it to a file?

andy.fingerhut17:11:05

In memory, a byte array is in a binary representation, is one way of thinking of it, hence my question back to you.

andy.fingerhut17:11:42

or maybe you want to print it out for debugging as a sequence of 1s and 0s?

quadron19:11:25

I want a sequence of 1s and 0s

quadron19:11:14

this has a lot of calls!

andy.fingerhut19:11:27

So if you have a way to take a single integer and convert it into a sequence of 0s and 1s, then you can see how to build that up for a byte array, I hope?

andy.fingerhut19:11:26

And there are many ways to do it, so a question would be: do you need a way that will have the highest performance among all possible ways (or close to it), or you just need some way that is correct? (e.g. maybe performance is a secondary or lower concern because this is for debugging)

andy.fingerhut19:11:42

For example, here is a way to get a Java/Clojure string of "0" and "1" characters, which could then be converted into a sequence of integers 0 and 1, but that isn't going to be the highest performance way to get a sequence of integer 0s and 1s: (Integer/toBinaryString 148) returns "10010100"

andy.fingerhut19:11:52

(Integer/toBinaryString 5) returns "101", so if you want the sequence to always contain 8 integers, you need to pad 0s on the left side for small values.

quadron19:11:35

I was wondering if there was a way to bypass integer representation; still it's not a big problem, the above code is correct

andy.fingerhut19:11:09

There is also a Java class BitSet that you can call java.util.BitSet/valueOf and pass it a byte array, and it will create an object that you can then get the value of each bit one at a time given its index.

andy.fingerhut19:11:29

That may be faster than creating an intermediate string, but I haven't measured.

✔️ 4
andy.fingerhut19:11:51

Example: (def b1 (java.util.BitSet/valueOf (byte-array [148])))

andy.fingerhut19:11:08

Then: (map (fn [idx] (if (. b1 get idx) 1 0)) (range 7 -1 -1)) returns (1 0 0 1 0 1 0 0)

quadron19:11:43

thanks, BitSet/valueOf seems to be it