Fork me on GitHub
#clojure-uk
<
2019-07-31
>
guy07:07:18

Morning team!

guy07:07:23

😂 i meant folks but havent had my coffee yet 😭

dharrigan07:07:37

I'm on my second

guy07:07:53

Yeah i would normally be too haha

rickmoynihan08:07:41

can someone remind me how Boris is going to solve the Irish Border issue? :rolling_on_the_floor_laughing: https://twitter.com/marksugruek/status/1155957402312663041

guy08:07:06

He’s going to build a wall!

Ben Hammond08:07:38

er muckga shurley

jasonbell09:07:37

NI comes out worst regardless of what happens.

jasonbell09:07:02

As it’s mainly propped up by crossborder EU funding and all island project partnerships.

jasonbell09:07:19

Most arts and community funding was axed from 2016 so they’ve essentially closed up and it’s left the communities in a state. More than likely the rise in unrest that you don’t hear about in the mainstream news.

rickmoynihan10:07:50

a really saddening state of affairs

jasonbell10:07:12

The unrest has been on the rise for a while.

jasonbell10:07:26

I’ve already lost one really good friend.

😢 8
❤️ 8
jasonbell10:07:06

Though that was nothing to do with anything Brexit related.

jasonbell10:07:44

Some parts of the border already have Gardi and Police checks on the border. I’ve not seen that in a long time.

dharrigan10:07:40

Perhaps a fleet of drones continuously flying up and down the border with lasers?

jasonbell10:07:15

Don’t encourage it @dharrigan

guy10:07:10

Drones with Nets and like id tags i reckon

guy10:07:25

:thumbsup: :robot_face: :thumbsup:

jasonbell10:07:40

Ask any NI startup and they’ll mention #blockchain instead 🙂

😄 4
dharrigan11:07:10

AI in NI with BC

jasonbell12:07:53

Oh don’t joke……

practicalli-johnny12:07:17

Anyone using Planck - the standalone ClojureScript REPL? It's really great tool. It's just been updated to use the new cljs_bean library for transforming to/from JS and Cljs https://twitter.com/ldnclj/status/1156540053587464192?s=19

Ben Hammond13:07:11

I keep seeing the claim that Republic of Ireland has more wealth per person than Northern Ireland. Is that a reliable claim? do any of you have an opinion? I found https://sluggerotoole.com/2018/03/26/is-northern-ireland-dramatically-poorer-than-the-republic/

Ben Hammond13:07:59

I appreciate that there's a bunch of multinataional HQs in dublin that distort the figures...

maleghast17:07:29

Anyone got any ideas on how I as a Java neophyte would start to go abut using this in Clojure? https://www.unidata.ucar.edu/software/decoders/grib/javadoc/ucar/grib/grib1/package-summary.html

maleghast17:07:57

I have the maven dependency in my project.clj

maleghast17:07:15

(and it's been downloaded)

maleghast17:07:55

I know that I need to (:import ...) in my ns macro the Objects I want / need

guy17:07:29

i can try if u like @maleghast

guy17:07:34

if u send me the mvn link

guy17:07:42

i mean depenency in project clj

guy17:07:48

and ill start a fresh project and give it ago

maleghast17:07:56

Sure, hang on...

maleghast17:07:41

:dependencies [[org.clojure/clojure "1.10.0"]
                 [edu.ucar/grib "8.0.29"]]

maleghast17:07:54

You will probably need a GRIB file as well - I will find a small one to send to you...

guy17:07:05

i was gonna try making a random one haha

guy17:07:11

public Grib1Record(java.lang.String hdr,
                   Grib1IndicatorSection aIs,
                   Grib1ProductDefinitionSection aPds,
                   Grib1GridDefinitionSection aGds,
                   long offset,
                   long recOffset)

guy17:07:13

like that?

maleghast17:07:47

Here's a reasonably sized one...

guy17:07:24

ok cool so i’ve got the dep

guy17:07:29

i’ve imported the class

guy17:07:32

and the objects i think

guy17:07:35

now what do you want to do?

guy17:07:45

(ns ucar.core
  (:import
   [ucar.grib.grib1 Grib1Record
                    Grib1IndicatorSection
                    Grib1ProductDefinitionSection
                    Grib1GridDefinitionSection]))


(def my-grib (Grib1Record. ""))
(defn foo
  "I don't do a whole lot."
  [x]
  (println x "Hello, World!"))

guy17:07:48

something like this?

maleghast17:07:09

Basically I am almost completely new to Java Interop and I was looking for some pointers as to how I would work out the Class / Classes I would need in order to read a Grib file and extract feature data from it.

guy17:07:12

this isnt working code due to the constructor taking more than 1 arg

guy17:07:31

So this is how i read java libs

guy17:07:50

lets say im interested in

guy17:07:22

to import it i would look for this

guy17:07:42

then i would just do

guy17:07:59

(:import [ucar.grib.grib1.Grib1BinaryDataSection])

guy17:07:04

then i would add a space 😂

guy17:07:17

(:import [ucar.grib.grib1 Grib1BinaryDataSection])

guy17:07:27

and look at the constructor for it

guy17:07:36

further down the docs

guy17:07:57

Then i would choose a constructor and do something like

guy17:07:14

(Grib1BinaryDataSection. arg1 arg2 arg3)

guy17:07:25

whatever the corresponding args are

guy17:07:34

I would do this in the repl, get something working that looked right

guy17:07:37

then do like

guy17:07:43

(def x (Grib1BinaryDataSection. arg1 arg2 arg3))

guy17:07:51

Then i could use x and its methods

guy17:07:10

So i can see this has the getvalues method

guy17:07:16

So i think i could something lik

guy17:07:22

(.getValues x)

guy17:07:38

I think thats how it works

guy17:07:59

Once i got my java interop working, i would basically wrap up the java stuff in functions

guy17:07:05

Just so its easier to grok

guy17:07:15

Is that what you meant @maleghast?

maleghast17:07:25

Pretty much!

dharrigan17:07:53

java interop ftw!

guy17:07:58

Member access
(.instanceMember instance args*)
(.instanceMember Classname args*)
(.-instanceField instance)
(Classname/staticMethod args*)
Classname/staticField

dharrigan17:07:01

I used it with Flyway, seamless!

guy17:07:09

and the examples

(.toUpperCase "fred")
-> "FRED"
(.getName String)
-> "java.lang.String"
(.-x (java.awt.Point. 1 2))
-> 1
(System/getProperty "java.vm.version")
-> "1.6.0_07-b06-57"
Math/PI
-> 3.141592653589793

guy17:07:33

As far as getting something working with lib, i think you will have to read the docs and make sure ur sending thee right stuff

maleghast17:07:35

The only bit I don't get, is that the constructor for that ^^ needs a unidata.RandomAccessFile or something like that...

guy17:07:49

but i think u can click that?

guy17:07:51

let me check

maleghast17:07:03

And I have no idea what that is...

guy17:07:15

ah i see

guy17:07:17

ucar.unidata.io.RandomAccessFile

guy17:07:19

that one?

maleghast17:07:44

Would I need that in the :import as well..?

rickmoynihan08:08:57

Strictly speaking no. You can address a class on the classpath with its fully qualified name without an :import. :imports just allow you to alias the class to its name without needing to type its package/namespace. At a REPL when experimenting you’re often best just using fully qualified names, then :importing them once you’ve proven it works.

guy17:07:17

im looking for it

guy17:07:29

:thinking_face: mmm

maleghast17:07:40

The lein deps run grabbed edu/ucar/unidataCommon/4.2.20/unidataCommon-4.2.20.jar from central so I assume I've got it

guy17:07:44

yeah you do

guy17:07:53

Try importing it

maleghast17:07:20

OK, will do - thx

guy17:07:36

ucar.unidata.io.RandomAccessFile -> RandomAccessFile -> [ RandomAccessFile]

guy17:07:57

this might be the docs

guy17:07:00

im not entirely sure

guy17:07:30

otherwise u can go to the java code

guy17:07:32

if u use intellij

guy17:07:42

i mean, i know with intellij u can do it

guy17:07:51

not sure about emacs, but its emacs, so u probably can

guy17:07:45

anyways hopefully that helps! @maleghast good luck 🙇

maleghast17:07:14

LIke this:

(:import
   [ RandomAccessFile]
   [ucar.grib.grib1 Grib1Record
                            Grib1IndicatorSection
                            Grib1ProductDefinitionSection
                            Grib1GridDefinitionSection])

guy17:07:41

Yeah I would do it that way i think

guy17:07:47

let me check the docs

guy17:07:21

I have to say i cant remember if its [] or ()

guy17:07:45

(:import
   ( RandomAccessFile)
   (ucar.grib.grib1 Grib1Record
                            Grib1IndicatorSection
                            Grib1ProductDefinitionSection
                            Grib1GridDefinitionSection))
I think would work too

guy17:07:07

But really, if you have something working, thats the main thing. Then find out after if its [] or ()

maleghast17:07:50

The file seems to be written correctly as I can cider-jack-in, but when I try to use (RandomAccessFile. "~/Downloads/ExampleGRIBFILE.grib" "r") I get:

Syntax error (IllegalArgumentException) compiling new at (ecmwf:localhost:43023(clj)*:43:13).
Unable to resolve classname: RandomAccessFile

maleghast17:07:32

Does anyone know if I need to evaluate the (ns ...) in order to have the Class available?

maleghast17:07:58

(Emacs and CIDER)

maleghast17:07:21

I am such a REPL n00b even after all this time...

maleghast17:07:06

s'ok, sorted it - I had a typo in my ns ...

guy17:07:42

ok :thumbsup:

maleghast18:07:07

@guy - Any idea what this means in the Consructor docs:



decimalscale - the exponent of the decimal scale

maleghast18:07:44

Basically I don't think I am adding the right number as a parameter.