Fork me on GitHub
#beginners
<
2017-12-17
>
Drew Verlee00:12:30

I have a set of functions used just for testing, I would think it would be a bad idea to keep them under src, I would rather nest then under a test namespace to be more clear. What's the recommend way to handle that

seancorfield00:12:25

@drewverlee Sure, if they're test-only functions, they go in test, not src.

seancorfield00:12:13

Not everything in test has to be an actual test 🙂 We have test versions of our Components under test and some utility code (esp. around WebDriver stuff).

Drew Verlee00:12:55

Ill need to figure out how to tell my repl to find the file, I'm probably missing something obvious

seancorfield03:12:27

@drewverlee Not sure whether you're using Boot or Leiningen, but however you tell it find your tests, any code under test should then be visible -- your tests aren't special: alll code under test would be accessible.

noisesmith05:12:31

also, I have a library that puts transit formatted runtime data into files under test/data/

noisesmith05:12:10

(since I want to use the data to recreate specific conditions for unit tests, so it seems like a natural place for it)

sb12:12:58

Possible load in repl or single .clj (without project.clj or boot) Clojure repositories? Like in other languages, direct loading in the clj file?

noisesmith16:12:23

If you have no external deps you can load a single file with load-file - that's literally what it does.

sb17:12:36

Thanks the infos. Yes, there is external deps. @U07TDTQNL @noisesmith

sb18:12:51

Yes, 1.9 cli and deps > sounds very interesting 4 datascience projects

zignd12:12:33

how do i get the index of a map value inside a vector of maps? considering i have one of the maps at hand

zignd12:12:24

nvm, i was using .indexOf wrong xD

Clepseedra15:12:31

hi! I have namespace in separate file: '(ns other) (print '3)' it is in my classpath. how can I load it from repl so it does the print function?

Clepseedra15:12:29

I tried '(require 'other)' but it did not run the function...

Clepseedra16:12:11

found it '(use 'antras :reload-all)'

Clepseedra16:12:14

but still did not print...

Sabbatical201716:12:33

I have a super basic question about datascript / datomic. I am assuming this is discussed somewhere but I don't even know what words to search for to lead me to the information. Assume that I want to keep track of how much various people like various kinds of foods (on a scale of 0 to 10). E.g., let's say I want to record that Joe's liking for ice cream is an 8. I am assuming that I am asserting a fact about the entity which is the pair (Joe, ice cream), right? What's the recommended way to do this so that I can do queries like "what are all the foods that Joe likes at least 5?" Thank you!

Sabbatical201716:12:59

After spending a few minutes in my hammock I decided that the entity that I am asserting stuff about has got to be (Joe, ice cream). In addition to asserting :liking 8, I should also assert something like :liking-person :Joe and :liking-food :ice-cream. Doing it like this will make it easy to compose a query to answer "what are all the foods that Joe likes at least 5?"

Nondv16:12:27

Hi guys! I cant figure out how I include css from cljsjs libraries. Specifically this one: cljsjs.rc-slider https://github.com/cljsjs/packages/tree/master/rc-slider

Nondv16:12:11

I tried cljsjs-ring but it seems like it's not the tool for the job

noisesmith16:12:20

to serve css out of a jar via ring, you'll want the wrap-resource middleware

Sabbatical201716:12:14

For my previous question, the "right" solution I describe above raises the further question of how to make the combination of :liking-person and :liking-food attributes unique, so that I can easily retract facts by just asserting a new one. Any hints would be greatly appreciated!

Nondv16:12:16

I dont have this css. I have installed via lein library cljsjs/rc-slider. And it should come with styles but I dont see them

noisesmith16:12:00

cljsjs/rc-slider adds a jar to your classpath, wrap-resource lets you serve css to a client out of a jar

noisesmith16:12:25

if it doesn't come with the css you need, ... I have no idea how to help you with that, are you just supposed to figure out on your own how to find and include the css?

Nondv16:12:20

I am not sure if I understood you. Can you elaborate on wrap-resourse? Ring already serves MY resources from /resourses/public. How is it related to external library?

noisesmith17:12:35

wrap-resource isn't about resources/public

noisesmith17:12:53

it's about things that might be in a jar (including your resources/public if you create and run an uberjar)

Nondv17:12:10

The problem is that in JS imports would be like:

import Slider, { Range } from 'rc-slider';
import 'rc-slider/assets/index.css';
But since Im using clojurescript I can only require [cljsjs.rc-slider] and it works (html is generated). But what about css?

noisesmith17:12:14

it means that you can serve any item inside any jar used by your project to a client

noisesmith17:12:12

@non.dmitriy yeah I have no idea where index.css is - all I was saying is that I would expect cljsjs to be sane and include index.css in its artifact, and if it does that, you can serve index.css from ring via wrap-resource

noisesmith17:12:42

that's what wrap-resource is for

Nondv17:12:15

ok, what would be arguments for wrap-resourse in this case? (wrap-resource handler <???>)

noisesmith17:12:45

the path to the index.css inside the jar - I'd think they would be documenting this stuff though...

noisesmith17:12:41

so if the jar has "public/rc-slider/assets/index.css" you could use (wrap-resource handler "public/rc-slider") then ask for "assets/index.css" in your html shell

noisesmith17:12:10

a jar is a zip file, and you can use lein cp to see all the jars you use

noisesmith17:12:19

you should be able to go in and see what's in that jar

Sabbatical201717:12:26

For the record, after some more time in the hammock I realized that adding :liking-person-food [:Joe :ice-cream], and marking the :liking-person-food attribute unique, seems to provide a solution to my problem. Using more conventional database terminology then, what I want is to assert {:person-food [:Joe :ice-cream] :person-fk :Joe :food-fk :ice-cream :liking 8}, with the :person-food attribute having been marked unique.

Nondv17:12:50

@noisesmith thank you for your help. I guess it really is not in the jar 😞

noisesmith17:12:22

OK - yeah, I wonder what they actually expect people to do?

Nondv17:12:47

same here. As for me I am gonna go cry til the end of the day:D

sova-soars-the-sora21:12:10

@sabbatical2017 when you add an entity to the database it gets an internal eid (entity id)

sova-soars-the-sora21:12:23

you can add an entity like [ :person/name "Joseph" :food/type "icecream" :food/rating 8]

sova-soars-the-sora21:12:05

when you do a search against the database, then you'll do a quantum balancing act: give me the EID where my queries are satisfied [?eid :person/name "Joseph" ?eid :food/type "icecream" ] if you want to write more facts to the database, you can just use one attribute to tie in a new value to your what-the-heck-is-this-entity-chain , say you want to add another food that joseph likes: [:person/name "Joseph" :food/type "veggie burger" :food/rating 10] now when you do a search in the db for all entities that have :person/name "Joseph" it'll actually return 2 EIDs, in a query: [ ?eid :person/name "Joseph" ?eid :food/rating > 5 ] would also return two EIDs (my syntax is not datomic proper here)

Quan Nguyen23:12:18

Anyone know if there's a standard lib function that does something like (foo f g [a b]) => [(f a) (g b)]?