Fork me on GitHub
#beginners
<
2023-05-07
>
Peter Tonner15:05:49

what is the correct way to access data that is stored in a path specified in deps.edn ? E.g. I'm trying to put some data used during testing in the resources folder. E.g. my deps.edn looks like:

{...
 :test :extra-paths ["test" "resources"],
 ...}

Peter Tonner15:05:50

but I don't know what the path should be when writing test code to use data in resources

Bob B15:05:12

those paths get added to your classpath, so you can use (for example) to access those files as relative to the classpath

Peter Tonner15:05:13

ah okay thanks! I'll try that. figured it was something simple

mister_m16:05:16

Maybe more of a java question - but if I have a byte array - how can I turn this into a long/hex so I can do bitwise operations on it

phronmophobic17:05:39

There's more than one way to do it with different tradeoffs. One reasonable way is to use BigInteger, https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/math/BigInteger.html#%3Cinit%3E(byte%5B%5D)

jpmonettas11:05:25

if you have a byte array of size <= 8 (so it fits into a long) you can do like this also :

(let [arr (byte-array [1 0 0 0 0 0 0 0])
            l (bit-or 
                (bit-shift-left (aget arr 7) 0)
                (bit-shift-left (aget arr 6) 8)
                (bit-shift-left (aget arr 5) 16)
                (bit-shift-left (aget arr 4) 24)
                (bit-shift-left (aget arr 3) 32)
                (bit-shift-left (aget arr 2) 40)
                (bit-shift-left (aget arr 1) 48)
                (bit-shift-left (aget arr 0) 56))]
        (format "%x" l))
depending on the endiannes you want to change the numbering on the first row