Fork me on GitHub
#clojure
<
2016-04-06
>
curtis.summers01:04:48

@lvh some of the changes in yesql 0.5.x prompted me to create HugSQL: http://www.hugsql.org

joshmiller01:04:50

@lvh: I’m on yesql 0.5.2 and using a reloaded pattern; I’m not having any trouble doing (defqueries “sql/queries.sql”) and then passing the connection like (get-user {:id 2} {:connection conn})

arrdem04:04:23

@eraserhd: @bronsa: Jaunt is properly indented </plug> simple_smile

nav08:04:57

looking for someone to help me or for them to write a web scrapper

martinklepsch10:04:56

can someone think of a way to make compojure match routes that don't have an extension?

glenjamin11:04:42

plexus: that feature toggle lib looks neat, providing a cookie-toggle implementation out of the box would probably be useful for lots of people

plexus11:04:03

@glenjamin: this first release is just laying the groundwork, it's not very feature-rich yet. PR's are welcome though 😉

grav11:04:31

But why? Why is it that the backtick has two features, namespacing stuff and allowing unquote, but you have to use both?

plexus11:04:55

@martinklepsch: you should be able to do something with the regex support

plexus11:04:00

(GET ["/:path" :path #"[^\.]+"] [] ,,,)

plexus11:04:00

if I'm understanding you correctly... you want to match /foo but not /foo.xxx ?

martinklepsch11:04:14

@plexus: yeah that /:path approach helps!

plexus11:04:39

yeah regex FTW simple_smile

plexus12:04:05

@sveri: (moving conversation here) Pennon is mostly intended for features that are under development. It allows decoupling deploying to server from switching on new features

plexus12:04:37

that said it's pretty generic, you can think of it as a rule-based system for turning features on/off. How you set up the rules is up to you

sveri12:04:44

@plexus: Ah ok, I got it, thank you simple_smile

bronsa12:04:34

@grav: you're not forced to use unquote, and you can escape the auto-qualifying bit by using ~'foo

grav12:04:41

@bronsa, you’re right there. But I have to do ~’ quite a bit in eg datomic queries, if I want to use unquote

grav12:04:20

It seems to me that a non-qualifying backtick would solve this.

grav12:04:31

But it may be that I’m using the the wrong tools

grav12:04:09

@dm3 yes, that might be the way to go.

john.carnell12:04:37

Hey guys I am trying to destructure the value of map being passed into a function to a vector. So for instance if I have a map {:group1-value "abc" :group2-value "cde" :group3-value "fgh" :group4-value "ghi" :group5-value "dddd”} and I want to passed it to (defn x [destructuring here]) any ideas how I would do it

sveri13:04:35

@john.carnell: If the map contains always the same keys you could do (defn x [{:keys [foo bar baz]}]...

mpenet13:04:22

the question is not very clear tbh

plexus13:04:25

@john.carnell: what result do you want to get?

john.carnell13:04:42

I am trying to pull the values out of map into vecotr

john.carnell13:04:02

In the function I want to take the values and join them with a “-"

john.carnell13:04:14

(defn- build-pairing-token-string "Build the final pairing token string that will be returned ot the customer." [{:keys [group1-value group2-value group3-value group4-value group5-value]}] (str group1-value "-" group2-value "-" group3-value "-" group4-value "-" group5-value))

john.carnell13:04:52

I want to eliminiate the (str join) and see if I can destructure into a vector and then use the join function

john.carnell13:04:00

to join them together

mpenet13:04:14

depends if you need to have some predefined ordering

john.carnell13:04:30

I want to keep the order of the keys

john.carnell13:04:38

listed in the {:keys}

mpenet13:04:51

you could (str/join "-" (juxt [your-keys]) map)

john.carnell13:04:20

cool let me play with it

plexus13:04:43

(defn- build-pairing-token-string
    "Build the final pairing token string that will be returned ot the customer."
    [m]
    (clojure.string/join "-" (map m [:group1-value :group2-value :group3-value :group4-value :group5-value])))

mpenet13:04:45

(clojure.string/join "-" ((juxt :a :b) {:a 1 😛 2}))

mpenet13:04:50

map works too

mpenet13:04:58

but juxt is cool'er

syzer13:04:56

general question: why ppl tends to favor clojure over clojureScript ?

ok13:04:36

@syzer: Libraries, libraries, libraries

plexus14:04:27

@syzer: all depends on what you're doing. If you're not targeting browsers it makes more sense to use Clojure

plexus14:04:14

you could build server-side stuff in ClojureScript as well and e.g. run it in node or rhino, but it's not that compelling an option at the moment

plexus14:04:42

and even then your build chain still requires java

syzer14:04:35

so if i would tamper with build system i could get away without installij java?

syzer14:04:47

thanks all for answers

bronsa14:04:13

the clojurescript compiler requires the jvm

plexus14:04:09

you could run bootstrapped clojurescript without a jvm, but it's not intended for production use, and you would do without the optimizations that the Google Closure compile does (which also needs a JVM)

acron15:04:25

is there shorthand for calling a quoted fn? (let [f '(+ 2 3 4)] (apply (resolve (first f)) (rest f))) seems crufty

acron15:04:24

oh eval 😄

bronsa16:04:51

@acron: eval is usually a code smell

acron16:04:22

Fair point

plexus16:04:24

but reimplementing eval in terms of apply is probably also a code smell 😆 you'll have a poor man's eval which can evaluate functions but not special forms

donaldball16:04:25

Does anyone know how to eval a sexp where the symbols in the sexp may not be vars, but also let bindings? I seem to recall figuring this out once but can’t recall the details.

plexus16:04:46

you mean they are bound by a let form around the eval? seems tricky...

bronsa16:04:05

it's only possible from within a macro

donaldball16:04:04

That jibes with my recollection

fasiha16:04:20

Dear JVM people, please help me understand why (bit-and (byte -114) (short 0xFF)) has type Long, i.e., why bitwise-and of 16-bit and 8-bit values returns 64-bit value? I'm trying to decide if this expected (i.e., JVM internally upcasts all arguments to bitwise operators to 64-bit) or if it's something I'd doing wrong, because ideally I'd like to get 16-bits out of that bit-and but if it's always going to be 64-bit then I might as well leave it as such (unless memory becomes an issue)

bronsa16:04:51

@fasiha: the JVM only has either 32 or 64 bit numerics, short/byte/char are still 32bit. as to Why you're getting back a Long -- clojure defaults to long/doubles and has little to no support for byte/short/int/float operations

fasiha16:04:59

@bronsa: that's helpful—thanks!

grav17:04:25

My IDE just crashed, but the nrepl is still going strong. Is there a way to get the history?

jrotenberg18:04:25

is there a term for a pair of numbers that have the same absolute value but one is negative and one is positive?

jrotenberg18:04:02

i’m trying to appropriately name my (brute force) function to check

cgore18:04:29

Opposite?

cgore18:04:43

Negation?

bostonaholic19:04:31

@jrotenberg: > Two numbers that have the same magnitude but are opposite in signs are called Opposite Numbers.

arrdem19:04:49

The inverse element in the additive group?

taylor.sando19:04:55

A vector pair of additive inverses?

arrdem19:04:57

@eraserhd: yeah I'm off in crazy land over here jaunt

jrotenberg19:04:34

opposite seemed too obvious

jrotenberg19:04:42

but there you go

payal20:04:29

any idea what is this expr used for '<?' is it related to async calls

hiredman20:04:23

it could be anything without context

hiredman20:04:12

it certainly doesn't come from core.async, but there are other ways to do things async, and you could write your own thing called '<?' on top of core.async

hiredman20:04:35

it isn't in clojure.core, but the same applies

jr20:04:37

<? is usually a custom take op that will raise any exceptions put on the channel

hiredman20:04:56

provided by some library

jr20:04:30

(let [ch (chan)]
  (go (>! ch (Exception. “boom”)))
  (go (<? ch))) ;; Raises “boom” exception inside go

payal21:04:05

okay understood... thanks!

isaac_cambron21:04:58

Do most people not use go's automatically returned channel? I use them a lot but most examples I read don't, so I sometimes wonder if I'm being unidiomatic

hiredman21:04:36

well, the built in returned channel can only have one item put on it once, where most interesting stuff you do with queues, you put many things on it over time

igotmine22:04:11

So I have what might be sort of a remedial question here - if I'm in the REPL, in the directory with the relevant project, and do (use 'some-namespace.core) I should have access to all the stuff I've defined in that core.clj, correct? Assuming it doesn't grumble about not finding the namespace, at least.

igotmine22:04:46

For context, I'm trying to run though the ring documentation, and though I can get a handler running by defining it in the REPL, I get an "Unable to resolve symbol" error if I just name the handler I defined in my core.clj

isaac_cambron22:04:13

@hiredman Oh, there's totally a lot of cases where using the returned channel makes no sense. I just always use them when they would work. But even in examples with only one item I pretty much always use the built-in one. It might be that examples don't use it because it's a little less obvious. But there might be other reasons why it works but is unwise