Fork me on GitHub
#beginners
<
2015-10-26
>
clojuregeek00:10:55

If i create a library and want to use it on another project, must I put in on clojars or can I just load from github ?

clojuregeek00:10:41

hmm the Clojure Applies book says: Clojars, Maven Central Repository or a self-hosted maven repo

xeqi00:10:17

@clojuregeek: tools like lein assume it will be in a maven repo of some kind

clojuregeek00:10:30

my boss was hoping I can grab a release of our library from github (as a jar) and use it ... but I am not sure how .... he wants to open source it at some point .. but he is not ready for me to publish to clojars yet

clojuregeek00:10:57

our http://travis.ci build is failing because one repo can't get the other one

potetm00:10:54

@clojuregeek: if the repo is a dependency of the project you’re trying to build, a self-hosted maven repo is the way to go. If you’re feeling lazy, you can check it out from source on the CI box and run lein install.

clojuregeek00:10:18

there is no way to say bundle the jar file of the dependancy with the project that needs it, so http://travis.ci can run the tests ?

potetm00:10:16

I believe lein uberjar does that for you. But I assumed you were trying to build from source.

potetm00:10:28

If all you need is an artifact, then uberjar is your friend

clojuregeek00:10:50

i make a jar file and run it as a lambda on aws

clojuregeek00:10:16

but thats how I use it now

clojuregeek00:10:25

so the clojure project can't say "get this dependency from a git hub release zip file, here's the url"

potetm00:10:34

You know, I’ve never tried it. Only things I know are local repo and private maven repo. I’ll snoop around for a bit.

clojuregeek00:10:19

ok .. i can't find anything about it so far.. and nothing in Clojure Applied book .... thanks!

xeqi00:10:12

one option is to make the .travis-ci.yml file have an install that wgets the file and adds it to the local maven cache

clojuregeek00:10:33

ok the jar file to wget .. would be in a private repo..

isaac_cambron02:10:25

you could also add it to your project as a git submodule and have travis check out the whole shebang

isaac_cambron02:10:29

would save you the wget

isaac_cambron02:10:42

then cd in and lein install. cd out and build

thedavidmeister09:10:37

[foo.bar :as bar] [foo.bar.baz :as baz]

thedavidmeister09:10:41

why can’t i do

xeqi10:10:44

@thedavidmeister: I'd guess performance. With the namespace portion of the symbol being complete on its own, then a hashmap lookup can be used. Otherwise you get into slower string substitution and multiple match possibilities

thedavidmeister10:10:35

wouldn’t that just be something a dev could do themselves if they profiled and found that level of micro optimisation is needed?

thedavidmeister10:10:04

also, if it worked, you could always run a tool over your code to “expand” all the namespaces

xeqi10:10:57

for every namespace lookup/callsite in the app?

thedavidmeister10:10:15

bar.baz would expand to foo.bar.baz

xeqi10:10:40

oh, I missed the obvious one about require actually loading the namespace and running the top level forms

chipf0rk10:10:47

I mean, that would kind of defeat the purpose of fully qualified symbols - being guaranteed to refer to only one thing. If you require foo.bar as bar and then expect a child namespace baz to be referrable through bar - how could you possibly refer to something in a namespace that is actually called bar.baz?

thedavidmeister10:10:38

the :as is the bit i control

thedavidmeister10:10:57

isn’t that the same issue with aliases in say, SQL?

rauh10:10:18

Note the point: An alias (which require does) can contain a dot.

rauh10:10:31

[clojure.data.xml :as data.xml]

rauh10:10:59

A namespace must be either an alias or a FQN.

rauh10:10:29

If you need the actual "why" then you'd have to dig into Compiler.java. Especially the maybeResolve...

thedavidmeister10:10:32

yeah so, i’m not sure why you can’t alias a part of a FQN

thedavidmeister10:10:51

not the “why” as in “where in the code"

thedavidmeister10:10:07

but “why” as in “what’s the tradeoff here? what do we gain by not being able to do it?"

thedavidmeister10:10:17

“what would we lose if we had it?"

thedavidmeister10:10:02

like, a namespace is strictly a heirarchy

thedavidmeister10:10:06

as i understand it

thedavidmeister10:10:14

i should be able to alias to any level of that heirarchy

thedavidmeister10:10:40

just like a part of a file system path

rauh10:10:47

I'd say that it's very bad form, technically it'd certainly be possible. But I would hate reading a source that uses that kind of referencing

thedavidmeister10:10:58

well, i’m using hoplon

thedavidmeister10:10:07

so i’m making html elements in a folder

thedavidmeister10:10:11

i’m getting down to

thedavidmeister10:10:16

elements/form/atoms/textfield

thedavidmeister10:10:25

actually i’d love to be able to require

thedavidmeister10:10:36

elements/form/textfield

thedavidmeister10:10:39

it doesn’t really matter

thedavidmeister10:10:44

the point is that it would be nice to get

thedavidmeister10:10:49

elements/form mapped to something

thedavidmeister10:10:52

then have folders within that

thedavidmeister10:10:59

and know i’m dealing with form elements

thedavidmeister10:10:17

without needing to require every single element at the top of the file

thedavidmeister10:10:30

makes refactoring the DOM structure more work

thedavidmeister10:10:00

and I come from PHP, so you might hate a lot of source that I work with all the time @rauh 😉

rauh10:10:49

Often people use ztellman/potemkin to collect vars into a single namespace from a structured implementation. If that's what you're looking for

thedavidmeister10:10:15

i’m not 100% sure what i’m looking for

thedavidmeister10:10:37

i’m just used to being able to use namespaces like directory structures

thedavidmeister10:10:04

rather than needing it to be FQN 100% of the time, or a FQN shorthand

thedavidmeister10:10:27

i don’t know enough about clojure to understand the problems that might cause

xeqi10:10:58

so the things that you lose are performance, and knowing require has already been loaded the namespace and ran the top level forms. (think defs, multimethods, etc)

rauh10:10:34

If you're new then I'd just recommend you to stick with the verbose method of importing the stuff you want. You could def. "script" this with clojure, maybe adapting this code: http://stackoverflow.com/questions/21634507/require-child-namespace-as-shorthand-in-clojure

thedavidmeister10:10:50

yeah, so basically i just have to write lots of requires

thedavidmeister10:10:53

not the end of the world

xeqi10:10:08

its possible to build your own lookup implementation around the one in clojure using string concatination, resolve, and load, but it wouldn't be easy/normal

thedavidmeister10:10:31

which seems like it might do some of the work for me

thedavidmeister10:10:34

but in the other direction

xeqi10:10:06

what are you using as an editor?

rauh10:10:15

Do you use Cursive? It can import (and :as xyz) for you

rauh10:10:30

Well, then use Cursive as first step simple_smile

thedavidmeister10:10:36

no idea what that is

rauh10:10:58

Best editor we have in clojureland (arguable)

thedavidmeister10:10:47

yeah that might help a bunch

rauh10:10:09

There is also #C0744GXCJ 😉

thedavidmeister10:10:08

kk, getting the ide now

thedavidmeister11:10:51

ok, opened cursive

thedavidmeister11:10:31

i feel like i just stepped into a plane cockpit

thedavidmeister11:10:08

so, i put in (textfield)

thedavidmeister11:10:35

how do i make it require my-project.elements.form.textfield

comma11:10:58

thedavidmeister: make sure to check out the introduction to cursive, the very first steps detail how to strip away all those “plane cockpit” details

thedavidmeister11:10:48

hmm, anyone else had problems with the “emacs tab” thing?

comma11:10:40

not personally, though it might be worth asking in #C0744GXCJ

thedavidmeister12:10:06

so, not sure if it’s me or cursive or hoplon or whatever

thedavidmeister12:10:18

but i just get lots of “foo cannot be resolved"

thedavidmeister12:10:22

even though it compiles fine

thedavidmeister12:10:59

soz, going back to sublime >.<

thedavidmeister12:10:04

too much “magic” going on in cursive

colin.yates14:10:58

@thedavidmeister: ping @cfleming in #C0744GXCJ - he is the author of cursive and a great and helpful guy. I do know that Cursive struggles sometimes to grok macros...

comma14:10:14

i’m trying to figure out a better way of writing

(defn back-and-forth-translation [text url api-key]
  (let [lang "en-ja"
        params {:lang lang :text text :key api-key}
        first-translation (run-translation url params)]
    (run-translation url (assoc params :lang (reverse-lang lang) :text first-translation))))
basically i build up some params, run a function, take that result and then run that same function with new params. i suppose i could use -> to be a little neater but is there a better way?

jeremyraines16:10:20

if you do lein jar does it use the branch you are on, or always master?

ordnungswidrig16:10:41

it uses what is in you working directory

jeremyraines16:10:13

a little context and follow-up question:

ordnungswidrig16:10:03

@comma: -> doesn’t quite fit because you need to wrap the text parameter in a hash

comma16:10:34

ordnungswidrig: yeah i noticed that shortly afterwards when i decided to implement it myself 😕

jeremyraines16:10:36

how do people generally work on forks? What I’m doing is forking a project, making my changes and creating a jar. Then I install that with lein-localrepo, and change the deps of the project where I’m testing it to (attempt to) use the localrepo version

jeremyraines16:10:03

I’m missing my gem “foo”, github: “bar/baz” simple_smile

ordnungswidrig16:10:16

I guess most will rename the project to „bar/baz“ locally and increment the revision in a sensible way

shaun-mahood16:10:35

@jeremyraines: I rename the project, install it using lein install, and then include that version in the project I want to use.

jeremyraines16:10:56

hmm. But still do the localrepo stuff? What does the rename & version bump accomplish? If I change, for example [michael-blume/lein-marginalia “0.9.0”] to [lein-marginalia “0.9.0”] that it would only find the local version

jeremyraines16:10:35

*I assume that it would find only the local version. But I didn’t see any install messages, so I don’t know. Would expect an error at least if that were wrong

ordnungswidrig16:10:52

oh, you should change it to „jeremyraines/lein-marginalia“ and lein install it.

ordnungswidrig16:10:15

then the dependency on [„jeremyraines/lein-marginalia „0.9.0“] should find it locally

ordnungswidrig16:10:18

(or even on clojars when you release if)

jeremyraines16:10:47

I see that the difference between lein jar and lein install is that it generates the pom.xml and installs it into local repo

jeremyraines16:10:04

is the difference between what I did and that just the generation of the pom.xml?

jeremyraines16:10:24

which I think lein-localrepo attempts to do if it isn’t provided

ordnungswidrig16:10:43

need to go, be back later, sorry 😞

jeremyraines16:10:02

ok, thanks to you both. Gives me some more avenues to explore and hopefully a faster process

roberto17:10:19

what sql libraries would ppl recommend?

roberto17:10:35

I’d prefer a sql library and not an orm.

colin.yates17:10:27

honeysql is great as is yesql. There was a newer lib which some people preferred over yesql - cannot recall - let me search...

roberto17:10:51

oh, I saw squee but it doesn’t seem to be available in clojars

roberto17:10:51

awesome, thank you @colin.yates

colin.yates17:10:13

no, I can’t find it - darn.

colin.yates17:10:51

if you have the use-case it addresses then I really can’t recommend honey-sql enough.

roberto17:10:45

honey-sql looks interesting, but the docs are lacking. It doesn’t seem to specify how to connect to a db.

donaldball17:10:11

honeysql allows for composable queries, while yesql is fine if your queries are defined completely ahead of time

colin.yates17:10:26

it doesn’t - you construct a map and then ‘render’ it effectively which produces a vector of [sql params] which you then pump into the standard jdbc lib

roberto17:10:43

yeah, I tried yesql before, but was turned off by lack of composability.

roberto17:10:02

oh, so honeysql just constructs the sql, gotcha.

colin.yates17:10:47

it’s the usual success you get when it is just data simple_smile

roberto17:10:17

yeah, having just data is so nice.

roberto17:10:37

recently had to implement a web scraper, and used Enlive for the first time. It was so nice compared to using Geb.

donaldball17:10:49

I hack on honeysql a little, so if there’s something you think it should be able to do but isn’t, feel free to ping me as well

roberto17:10:12

awesome, will do

roberto17:10:46

I think I’ll go down the honeysql route + the official jdbc lib.

jeremyraines19:10:34

thanks, I’ll check that out

jeremyraines19:10:49

here’s what I was working on, but failed. (The deps part was OK thanks to the help above). If anyone would like to hack on this, either online or at the conj, I’d be really interested

jeremyraines19:10:31

and that was a side effect of producing this: http://jeremyraines.com/noise.html . . . was going mad that I couldn’t document things inside of a let block

jeremyraines19:10:38

ah crap, uploaded the version produced by my failed attempt. oh well, will fix it later.

jeremyraines19:10:38

hmm, apparently I now need something like “lein uninstall”. When I was working on those forked repos, and did lein install, now my main project will only use those as deps. I think I now understand why I was told to bump the version numbers ...

xeqi19:10:18

@jeremyraines: rm ~/.m2/repository/marginalia -rf

xeqi19:10:52

will wipe all the versions from the local cache, and will redownload next time you need it

jeremyraines19:10:38

awesome, thanks