#clojure logs

2014-08-28

00:00amalloyuh, yeah. because you made the claim you can control what happens when you divide by 0 in C
00:00ifihthttp://2.bp.blogspot.com/_Ku6SPRq8054/TGnWBQfBKJI/AAAAAAAAAvM/5bwQGaKCneo/s1600/divided+by+zero.jpg
00:00amalloywhich is obviously false: the language definition says you get undefined behavior
00:01ifihtI can't control it. 'S why I'm using clojure :)
00:01TEttingerifiht, you should define your own /
00:01ifihtwith a conditional to handle 0/0
00:02TEttingeryou can have it do whatever you want
00:02ifiht?
00:02ifihtthat's what I was considering
00:03technomancyjust doseq over all the functions in ns-map of ns-all, and do alter-var-root on them with a function that catches the divide-by-zero error.
00:03technomancyboom.
00:03TEttingerI believe namespacing should prevent it from being used by core lib functions, but you may need to make sure no one uses your custom / . it would be a good idea to change the name
00:03TEttingerand yeah try catch could be used too
00:03TEttinger(not sure if inc or dec technomancy)
00:04technomancyhttps://gist.github.com/technomancy/0568b638542bc90f32ef
00:04technomancyactually wait
00:04technomancythat should catch Throwable just to be safe
00:05sm0kenice to hear that
00:05sm0keugh not above, TEttinger the game thing
00:06technomancyno I'm pretty sure sm0ke thinks this is a great idea
00:06technomancygoing to quote you on that
00:06TEttingerthat's filthy, technomancy, but because you put some effort in,
00:06TEttinger(inc technomancy)
00:06lazybot⇒ 133
00:06arrdemTEttinger: glad I'm not the only one here who thinks this is vile
00:06arrdem(dec technomancy)
00:06lazybot⇒ 132
00:06amalloytechnomancy doesn't need your pity points
00:06amalloy(inc technomancy) have some spite points
00:06amalloy(inc technomancy) ; have some spite points
00:06lazybot⇒ 133
00:07sm0ke(inc technomancy) ; for leiningen
00:07lazybot⇒ 134
00:07TEttinger(dec dec)
00:07lazybot⇒ 0
00:07sm0ke(inc inc)
00:07lazybot⇒ 10
00:07technomancyjust juxt inc and dec =)
00:07arrdemoh gods it's only me
00:07TEttinger$karma amalloy
00:07lazybotamalloy has karma 163.
00:07amalloytechnomancy: and make you into a pair? the world doesn't have enough room
00:08arrdemamalloy: I'd inc for that but I want technomancy to catch up in karma some day
00:08technomancyarrdem: since you have the logs handy... am I the only one who says "you monster." or are there other occurances?
00:08technomancyoccurrences
00:08amalloytechnomancy: i do it
00:08arrdemtechnomancy: my logs don't go back far but I'll look
00:08amalloyarrdem: two other people have dec'd technomancy
00:09arrdemtechnomancy: maximumpanda, didi, a7a and you are the only offenders I see
00:09amalloyi prefer the phrasing "you're a monster"
00:09technomancydidi came here? cool.
00:09amalloyseangrove apparently dec'd technomancy in october just to keep his ego in check
00:09arrdemamalloy: only you and trptcolin
00:10arrdemamalloy and Raynes have more extensive logs than I do :/ mine only go back to like january
00:10TEttingerthis is why we need my insane lucene search for lazybot. with my heavily modified, messy seen plugin, you can try: `last-with-n monster 3
00:10clojurebotExcuse me?
00:10amalloyand hyPiRion actually came up with a clever way to inc+dec technomancy in 2012
00:10amalloy[15:11:27] hyPiRion: ,(list (rand-nth '[inc dec]) 'technomancy)
00:10amalloy[15:11:29] clojurebot: (dec technomancy)
00:10amalloy[15:11:29] lazybot: ⇒ 37
00:10TEttingernice
00:10arrdemamalloy: but mutual recursion on bots is no longer possible :P
00:11TEttinger,(list (rand-nth '[inc dec]) 'technomancy)
00:11clojurebot(dec technomancy)
00:11amalloyarrdem: sure, but you just need to add one extra human step
00:11amalloythe interpreter, if you will
00:11TEttingerI guess you lucked out this time, with the ignore
00:12arrdemmeh. I'd just bug Raynes for a patch that allows lazybot to "see" only inc and dec forms from clojurebot :P
00:12arrdemthat or do it myself with beer this weekend
00:12sm0ke(identity technomancy)
00:12lazybottechnomancy has karma 134.
00:12sm0kewow
00:13amalloyhey, when did that get added. that's cute
00:15sm0ke(map inc [ technomancy amalloy ])
00:15sm0ke:P too much to ask for
00:16sm0ke##(map inc [ 'sm0ke ])
00:16lazybotjava.lang.ClassCastException: clojure.lang.Symbol cannot be cast to java.lang.Number
00:17sm0keok that makes no sense
00:18arrdemsm0ke: karma isn't actually executed as clojure code. it's its own interpreter that looks like clojure for humor's sake
00:19technomancyyou can tell because it has troublesome identity/value conflation that would never actually happen in cloju--oh wait
00:20sm0ke##(prn lazybot.plugins.karma/limit)
00:20lazybotjava.lang.SecurityException: You tripped the alarm! lazybot.plugins.karma is bad!
00:25sm0kelazybot: playing
00:26sm0kei wonder how to use this https://github.com/Raynes/lazybot/blob/master/src/lazybot/plugins/rotten_tomatoes.clj
00:27sm0keplaying?
00:27arrdem$movie starwars
00:27lazybot2005 - Star Wars: Episode III - Revenge of the Sith 3D | rating: 80 | consensus: | link: http://www.rottentomatoes.com/m/star_wars_episode_iii_revenge_of_the_sith_3d/
00:28arrdem$playing
00:28sm0keradar?
00:29JumblemuddleI have a sequence of items, which I need to find a specific item where it's :name property equals a certain name. In order to get the name of the first one I do (:name (:data (first sequence))) What would be the best way to loop through these. (Recursion?)
00:30amalloyJumblemuddle: best would be to not store the things in a dang list, but in a hash-map indexed by name
00:30amalloythen you can just look it up in O(1)
00:30JumblemuddleWell, I'm getting it from neo4j (database).
00:30JumblemuddleI guess I should probably do all this work on the database side...
00:30amalloybut if you had it in a list, you could write (first (filter (comp #{"mike"} :name :data) sequence))
00:31amalloybut yes, you should let the database do this
00:32JumblemuddleI guess I'll try to find some more documentation on the database stuff. Thanks for the example though. I don't have any experience with 'filter'.
00:36ifiht,(defn trouble [a] (if-let [a (compare a 5)] (1) (a)))
00:36clojurebot#'sandbox/trouble
00:36ifiht,(trouble 5)
00:36clojurebot#<ClassCastException java.lang.ClassCastException: java.lang.Long cannot be cast to clojure.lang.IFn>
00:36sm0keneo4j is property graph right? graph.getVertices(:name,"abc") should do it
00:52blorgon,"cljbot rules"
00:52clojurebot"cljbot rules"
01:47blorgonAll Clojurians are sleeping?
01:47arrdemthe sun never sets on the clojure empire
01:49schmirgood morning!
02:07arrdemtechnomancy: http://blog.mattgauger.com/blog/2014/08/19/atreus-my-custom-keyboard/
02:10beamsois that keyboard easier or harder to use with the control keys all along the bottom?
02:18blorg,(clojurebot? 0)
02:18clojurebot#<CompilerException java.lang.RuntimeException: Unable to resolve symbol: clojurebot? in this context, compiling:(NO_SOURCE_PATH:0:0)>
02:19blorg~clojurebot?
02:19clojurebotclojurebot is the cloud
02:19lpvbdo delays ever get garbage collected after they are derefd?
02:20blorgclojurebot?
02:20clojurebotclojurebot is amazing
02:20arrdemif nothing else is holding the delay reference, then yes it should be GC'd
02:22blorg,(def x 2)
02:22clojurebot#'sandbox/x
02:23blorgHmm
03:23Kneiva,x
03:23clojurebot#<CompilerException java.lang.RuntimeException: Unable to resolve symbol: x in this context, compiling:(NO_SOURCE_PATH:0:0)>
03:38TEttinger,(def it-will-expire 2)
03:38clojurebot#'sandbox/it-will-expire
03:38TEttinger,it-will-expire
03:38clojurebot2
03:40SagiCZ1yesterday i understood how refs work.. that you always work with the snapshot of the value at some point of time, not necessarily the latest version of it.. so what is it for? lets say the ref points to a map: {:a 0 :b 1}. One thread wants to increase all values by one.. so it reads the map and starts increasing.. at the same point another thread wants to mutiply each key of the map by five.. it starts with the same version {:a 0 :b 1
03:40SagiCZ1how is that useful for anythiing?
03:43TEttingerSagiCZ1, hm?
03:44TEttingerif they're at the same point, you don't want partial updates
03:44SagiCZ1multiple threads share a ref.. and they want to propagate their changes to it..
03:44TEttingerso refs have dosync around them whenever they're updated
03:44SagiCZ1and dosync waits for other threads to finish writing?
03:45TEttingerdosync will wait for writes, not reads
03:45SagiCZ1thats the difference between a lock and dosync right?
03:45TEttingeryou can deref with @ at any point to see the value before the dosync has completed (and without its changes if it isn't done, IIRC)
03:46SagiCZ1i see.. so what about atoms which are not used inside transactions?
03:46TEttingerI only used refs a little, they aren't common in clojure unless serious concurrency is needed
03:46TEttingeratoms are thread-local if I remember it right...
03:46SagiCZ1no.. vars are
03:47TEttingerI need to pull out the clojure book :)
03:48TEttingerAtoms are an efficient way to represent some state that will never need to be coordinated with any other, and for which you wish to make synchronous changes (unlike agents, which are similarly independent but asynchronous)
03:49SagiCZ1i want to make synchronous changes but dont need it to be coordinated? does not make much sense to me
03:49TEttingercoordinated with other mutable state
03:49SagiCZ1would a use case help?
03:49TEttingeryeah.
03:50TEttinger,(let [a (atom 10)] (dotimes [n 5] (swap! a inc)) @a)
03:50clojurebot15
03:51TEttingerthey're the easiest way to handle mutable-like state in clojure
03:51SagiCZ1lets say i have this list of creatures.. each living in its own thread.. these creatures interact with their environment and as a result of that change their internal state (mood lets say). I need to have an overview of all the creatures and their moods. So they would share a ref (or something else?) and propagate their changes to the ref. What should i use?
03:52TEttingerI actually did something similar with an (atom {:cat (atom {:cat :stuff}) :dog (atom {:dog :stuff})})
03:53TEttingerwith that approach you can change the whole thing or take out one creature and pass it around, changing it, and pass it back
03:53SagiCZ1i see
03:53SagiCZ1that didnt occur to me
03:53SagiCZ1did it work fine?
03:54TEttingerthe other way is to keep state as little as possible, and only change things by returning a different list of creatures and passing it into something else that uses it.
03:54TEttingerthat's play-clj's approach
03:54TEttingerthe atoms worked fine, a bit verbose compared to the rest of clojure
03:55TEttingerplay-clj's approach is probably safer in larger programs, but needs some glue I think
03:56SagiCZ1yeah seemed a little verbose... i think i could just go through the creature-list sequentially and not use threads at all .. thus incorporating pure functional programming but this application is very suited for paralel computation as the creatures are very independent of each other..
03:56SagiCZ1two questions..1) when u used ur atom(atom thing.. was some sort of global variable? or how did you access it?
03:56SagiCZ12) what is play-clj?
03:57TEttingerpretty much everything in clojure is "global" with namespaces. play-clj is a thick abstraction over a java game library to make using it more clojure-y
03:58TEttingerhttps://github.com/oakes/play-clj
03:58SagiCZ1so global "variables" are not frowned upon?
04:00TEttingervariables in general are tried to be used less. global functions and constants are fine.
04:00SagiCZ1i understand that.. but the atom(atom structure could be considered "variable" right?
04:02TEttingerthe idea is to keep mutable state to a minimum, and use immutable things passed around with slight changes instead. atoms are as close to conventional variables as clojure gets, and they're certainly fine to start with. you may decide to try to rewrite later to take better advantage of the immutable data's persistence
04:02TEttingerthat's what I did, pretty much, for my messy clojure game
04:02TEttingerthe rewrite used play-clj, and it was much smoother
04:03SagiCZ1yeah i think my first project will be some game-y evolutionary algorithm crap and i expect it to be messy.. i dont want to use extensive libraries that would make it too easy though
04:04TEttingerok, I gotta get to bed. if you're doing a game, try NightMod! I am curious how it is but it looks good. https://nightmod.net/
04:05TEttingerbeing able to edit during a game seems ideal for repl-style clojure dev
04:05SagiCZ1thanks for the tip and the other stuff
04:06SagiCZ1see you tomorrow
05:10bcmhi
05:10bcmdo many people here use emacs
05:11mpenetyes
05:44kqrhey! rich hickey talks warmly about using queues to send messages between things rather than having them call each other directly. can anyone expand on how this works in clojure?
05:46glorbonbetter yet can rick hickey become the pope?!
05:47glorbonso we can all do ayearly pilgrimage and ask him our deepest most perplexing questions!?!
05:48schmeekqr: core.async is great for that
05:48kqrschmee, i'll have a look!
05:50schmeekqr: so instead of having A communicate directly with B, stick a channel in between and make a put thing on the chan and B take things of it
05:50schmeemake A put things on the chan, I mean
05:50kqryeah I understood that
05:50kqrI have some experience with erlang and chans in haskell so it makes sense to me
05:51schmeeahh, then you should feel right at home with core.async
05:52glorbonwow.. evry1 here knows haskell .. only i dont?
05:54schmeeglorbon: I don't know it either, I've tried it a few times but it wasn't my cup of tea
05:59SagiCZ1glorbon: i know nothing about haskell.. but some people say it's pretty
06:02SagiCZ1does having some kind of logger call inside a pure function make it unpure? since its technically a side-effect?
06:05glorbondefine : call inside
06:06SagiCZ1(fn [args]
06:06SagiCZ1 do something...
06:06SagiCZ1 log(message))
06:08kqrSagiCZ1, yes, it does
06:08kqrSagiCZ1, but if you pass the logger function as an argument to your function, it's pure enough to be testable at least
06:09SagiCZ1and is that the common way how to log something in clojure?
06:15kqrI don't know
06:19glorbonpersonaly ilek the second option more
06:19glorbon*liek
06:19glorbonbut idk about purity and such
08:07lvhHi :)
08:07lvhSome questions about being a good Clojure citizen.
08:08lvh1) Is there a serialization protocol in Clojure that I should extend instead of writing my own (defprotocol SerializationScheme ...) ?
08:08lvh2) (hash-fn msg :salt (.getBytes "xyzzy")), or (hash-fn msg {:salt (.getBytes "xyzzy")})
08:10beamsolvh: for 1, what about edn?
08:10lvhbeamso: I intend to implement it with edn, yes
08:10lvhbeamso: does edn have a generic protocol?
08:11beamsoi'm unsure what you mean by 'generic protocol'
08:12lvhbeamso: a protocol for serialization, as in defprotocol
08:17vijaykiranlvh - what do you want to serialise ?
08:18lvhvijaykiran: arbitrarily composed maps, vecs and sets with fairly simple keys and values (ints, strings, byte arrays), the usual
08:18lvhEDN seems like the natural choice :)
08:19lvhI am the only consumer/writer of this data, so I don't care if the format is poorly supported outside of clojure (nippy)
08:19beamsothere doesn't appear to be a protocol (as in defprotocol)
08:21swiHello. I'm choosing a book to read about clojure (after some blind play with language at 4clojure) to understand it's better. I'm choosing from 'Clojure programming' by Emerick and 'Programming Clojure' 2nd by Halloway. Which one is better for begin (i have a very little FP background)?
08:22beamsoi preferred emerick's book
08:22hyPiRionswi: I have heard that 'Clojure programming' is better
08:23swi:)))
08:23hyPiRionI think that's the general consensus in this channel as well
08:23beamsoa current o'reilly discount code is 'B2S4'.
08:23lvhI liked joy of clojure
08:23lvhbut tbh I liked most of those books :)
08:23lvh(maybe I just like clojure :))
08:23beamsotha discount code was for ebooks
08:24beamso*that
08:24glorbonwait.. emrick is the concensus?
08:25hyPiRionlvh: yeah, but I felt JoC is for Clojure programmers with some experience
08:25glorbon(also is it necassary or can one skip to joy of clojure without miising much?)
08:27mpenetjust read 1 and then get your hands dirty
08:27mpenetthey all repeat more or less the same stuff
08:28TimMcI don't think any of them are a *bad* choice. :-)
08:31glorbon,"want to sleep"
08:31clojurebot"want to sleep"
08:51swiThanks a lot, so let it be Emerick :)
08:56justin_smithglorbon: (Thread/sleep (* 1000 60 60 8)) ; get 8 hours of sleep
08:57glorbonu need to put a comma before that
08:57glorbonotherwise i dont respond, silly
09:11justin_smith"i dont respond" is a funny response
09:13glorbonu have defeated my logiacally. *bows*
09:13glorbon*me
09:32glorbonhttps://www.kickstarter.com/projects/1751759988/sicp-distilled
09:34virmundihello. I’m trying to embrace the dynamic typing of cloure. I have an api that allows a user to create a collection on a remote server. There are a lot of little options that can go into creation. There are other points in the api where a collection name is needed such as when a user wants to get a document from the collection.
09:34virmundiin clojure is it common to have a value in a map be either a string or another map?
09:35virmundiI was thinking {:collection “name”} for things like getting a document or {:collection {:name “name” :option1 …}
09:35virmundiIs that a good fit for the language?
09:36teslanickDepends on the details of your use case, but either is appropriate
09:36teslanickNot sure how that relates to dynamic typing, though.
09:38virmunditeslanick: Java would normally not have collection be an Object.
09:38virmundimost of the time the value would be statically typed to a string or another configuration object.
09:42kqrteslanick, in a static type system you'd want a sum type for that usage
09:43kqrvirmundi, also if you haven't seen it yet, one day this might be useful: https://github.com/cemerick/clojure-type-selection-flowchart
09:44virmundikqr: thanks. I’ve just started Clojure. I need a good driver for a db. Figured this would be the best way to learn the language.
09:44kqryeah i've just started myself
09:45kqri currently have one place where I need a sum type, and I've simply made a record out of it
09:45teslanickThings in clojure have types, they just fall into a few simple constructs rather than highly-specialized objects. The value of a highly-specialized mutable types goes away when you don't have methods on objects to call.
09:45kqrso say if I want to return either an ID string or a record, i'd return either {:id "2891378"} or {:full-record {:name "sarah" :age 27}}
09:45kqrand so on
09:46teslanickBut you can do runtime structural validation. Prismatic has a bunch of useful utilities to that end.
09:46justin_smithkqr: a protocol or interface can effectively be used as a sum type under the jvm's system
09:46ToxicFrogteslanick: I'm not sure I buy that; even with immutability and no object methods, type checking is still worthwhile to catch arg/return type mismatches before runtime.
09:46kqrthis means I don't have to dispatch on type which might be weird, but I don't know what's idiomatic
09:47kqrjustin_smith, I haven't looked into protocols yet, but I'm excited for when I do
09:47kqrjustin_smith, from the sound of it, they seem awesome
09:47justin_smithkqr: the idea is that instead of defining a sum type and enumerating in one place all it's possible values, you define a protocol, and enumerating in one place all the functions implemented on it
09:48teslanickToxicFrog: Not saying that types aren't useful, but they're less useful than a robust collection api (like the one clojure provides). It's possible to have both, but that's not where clojure is right now.
09:48justin_smiththen add the values piecemeal
09:48teslanickI'll defer to justin_smith, because he's smarter/more-experienced than I am.
09:48justin_smithkqr: all the same functionality you get with a sum type, but the specification is sort of inside out
09:49kqrjustin_smith, i've heard they are similar to typeclasses
09:49justin_smithteslanick: defer to me on what?
09:49teslanickW/R/T approaches to data typing
09:50teslanick"typing" in big scare-quote-things
09:52justin_smithI haven't tried core.typed, but one thing I miss in clojure is the ease of refactoring with a typechecker
09:52justin_smithyou just make a couple of changes, and then fix things until it compiles
09:53tbaldridgeaka, flail around until stuff works :-P
09:53justin_smithtbaldridge: well, not so much flailing as being lazy, and trusting that the compiler will point out the remaining cases that need to be updated
09:54justin_smithbut sure, it's no replacement for having a great design in the first place
09:55kqrwell, yeah. with a great design the type system is by some sort of definition useless
09:56kqrthe issue is that people suck at creating great designs from the start
09:57hyPiRionkqr: Sure, a type system is useless when you already have working software.
09:57kqrexactly
09:57mpenethyPiRion: until you need to refactor things
09:58hyPiRionmpenet: but then it's not working
09:58hyPiRionat least not as intended.
09:58mpenetwell, extending something that's working happens often !
09:59hyPiRionmpenet: right, that's what I was trying to get at :p
09:59kqrbut if the design doesn't take into account the new specs it's not a great design anymore
09:59kqrwhich is why I think "a type system is no replacement for a great design" is a trivial statement
10:00mpenethaving choice between the 2 would be nice
10:00mpenetreminds me of https://github.com/mikera/kiss
10:00kqri'm trying to understand how that'd work
10:00mpenetwho knows one day
10:01kqrah, you probably meant something other than what I think
10:01clojurebotExcuse me?
10:02justin_smithkqr: point being, yes, using a type system to drive refactoring can be seen as flailing until stuff works, but designs that start perfect are the exception, and something that drives our confusion and disorganization toward something that works again is valuable
10:03kqrah sure
10:03justin_smiththough without a type checker we can get very far with well designed tests, and hammock driven development - making sure we have a really strong mental model going in
10:04sritchiejustin_smith: the type system provides some rigor and guidance around what constitutes a strong mental model
10:04mpenetwell, even with perfect design we make errors when implementing
10:04glorbonjustin_smith: are you rick hickey?
10:05justin_smithglorbon: definitely not
10:05sritchieAND the “strong mental model” you have may not be obvious to someone else reading the code later
10:05mpenethaving warnings at compile time is definitly a +
10:05justin_smithglorbon: though I will take that as a compliment
10:05sritchieglorbon: :)
10:20vermawould >! return a non-true value when the port is closed? or just the whole go-loop just dies?
10:23vermathis is what I am doing: https://www.refheap.com/89539
10:24sveriHi, using datomic I have a lot of functions that start like this: (defn f [db-conn] (let [db-val (d/db db-conn)] (do-something-with db-val))). Is there a way to get rid of these (let [db-val (d/db db-conn)] part? maybe with a macro?
10:24vermaI do see "What is love?" printed everytime I exhaust my "messages", but I am hoping to see it when the returned channel is closed as well.
10:26vermawhen I close the chan, the program terminates but I never see the "What is Love" message
10:27tbaldridgesveri: you should only really need to call (d/db conn) in one place,
10:27tbaldridgeperhaps in a handler
10:28vermamay be I should condense everything into one loop
10:28vermanot sure how its going to help
10:29vermaI guess I could use onto-chan and wait for it to finish as well
10:29sveritbaldridge: and pass that through the entire application during a request? what If I do an update and want to read from the database the changed values, I would need to do (d/db db-conn) again then, however, it would be much more seldom
10:29kqrsveri, if you really mean to make a new connection (or whatever d/db does) every call, then yes, that's exactly what you have a macro for
10:32tbaldridgesveri: well (d/transact ...) hands you back db-after which is the DB after the transaction was applied. So you don't even need a (d/db conn) call after transact
10:32kqrsveri, or possibly just a function, depending on what you want the end result to be
10:33sverikqr: thank you
10:33sveritbaldridge: ok, that's right, I did not think of that
10:34sverithank you both very much, I guess, creating a db-val once should be enough most of the times
10:40noncom|2hello
10:58justin_smith, (apply str (map (comp char #(+ 101 %)) [3 0 7 7 10]))
10:58clojurebot"hello"
10:59vermalol
11:03borkdudelol
11:05sveri, (apply str (map (comp char #(+ 101 %)) [7 10 7]))
11:05clojurebot"lol"
11:05sverilet the bots do the talking^^
11:12justin_smith,(apply str (map (comp char #(+ 97 %)) (take 5 (map first (iterate (fn [[i p]] [(bit-and p 127) (bit-shift-right p 7)]) [7 29541764])))))
11:12clojurebot"hello"
11:13vermadafuq
11:13justin_smiththis is so much more interesting than the database migration and template metadata updates so we get proper previews on social media sites
11:14justin_smithverma: I could have done that with 5 bits per char instead of 7
11:15TimMc&(let [r (java.util.Random. 15057100)] (apply str (map #(char (+ 16r61 %)) (take 5 (repeatedly #(.nextInt r 26))))))
11:15lazybot⇒ "hello"
11:16justin_smithTimMc: OK, that's pretty awesome
11:16TimMc&(let [target (map #(- (int %) (int \a)) "hello")] (loop [seed 0] (let [r (java.util.Random. seed), result (take 5 (repeatedly #(.nextInt r 26)))] (if (= result target) seed (recur (inc seed))))))
11:17lazybotExecution Timed Out!
11:17justin_smithI figured it had to be something like that :)
11:17TimMcAnyway, that's how I got it.
11:19justin_smithTimMc: if you changed the static \a to be any target offset, and instead searched for 5 ints with the right relative difference, it would probably get a result much quicker
11:19TimMcmmm, true
11:19TimMcPatches welcome.
11:20TimMcIt doesn't take very long on my REPL as is, though.
11:20TimMc10.6 seconds
11:21justin_smithyeah, but that's exponential with length of the string
11:21justin_smitheven the relative offset checking is only a constant multiplier on that exponential basis of the algorithm
11:22justin_smith, (apply str (map (comp char #(+ 97 %)) (take 5 (map first (iterate (fn [[i p]] [(bit-and p 31) (bit-shift-right p 5)]) [7 470372])))))
11:22clojurebot"hello"
11:22justin_smith5 bit version
11:23justin_smithso much more interesting than social media friendly meta tags
11:23vermamy >! never really returns anything other than "true", when I close the channel, my go-loop blocks (I think), shouldn't >! be returning a non-true value?
11:25tbaldridgeverna: code? >! will return falsey if the channel is closed
11:26vermatbaldridge, sure, give me a second
11:26vermatbaldridge, doing something on these lines: https://www.refheap.com/89539
11:27vermainstead of the sent? stuff I just refactored stuff out into a function now
11:27vermatbaldridge, basically I get a list of IDs which I send down the channel, if the channel is closed I want to stop doing that, and not recur any further, inside the inner or the outer loop
11:28vermatbaldridge, I could have used async/onto-chan, but that doesn't really tell me if the completion was because of exhaustion or because the channel closed
11:29tbaldridgecode style looks good, I'd double check that sent? and next-token are what you are expecting
11:30toxmeisterhey guys. Can someone pls help my memory and by any chance remember the link to an (possibly not so recent) article which contained some great visualisations about various CSP/core.async transforms? e.g. merge, split, throttle, pubsub, map etc. Rings a bell?
11:30vermatbaldridge, when the list exhausts, things look good, let me post the code where I am consuming it
11:31vermatbaldridge, this is the go-loop which consumes values: https://www.refheap.com/89543
11:33vermatbaldridge, may be there are pending elements in the channel which haven't been consumed :/
11:34tbaldridgewell (>! will return false whenever the close! happens, but there could still be items in the channel.
11:35vermatbaldridge, hmm, that's what I thought, so I added (while (<! ch)) and it seems to have returned cleanly :/
11:35vermatbaldridge, is there a drain on close? :P
11:37tbaldridgeno, but feel free to write your own ;-)
11:43alandipertclojars feels down, anyone else noticing issues?
11:43Bronsaalandipert: the web ui or the whole repo?
11:44vermatbaldridge, sure thanks for your help
11:44verma(inc tbaldridge)
11:44lazybot⇒ 9
11:45noniwoowhy when I put single line (future (prn "Stop?")) into a file, then run it, clojure never ends running? should thread not end after printing value?
11:45alandipertBronsa: ui doesn’t work for me, deps have been flaky
11:45mdrogalisalandipert: Maybe we should cheer it up.
11:47Bronsaalandipert: wrt the site, that's a known bug that only affects the homepage
11:49Bronsaalandipert: https://clojars.org/login if you login, the site will be fine
11:49mdrogalisYeah, on a serious note - it seems alright to me, Bronsa / alandipert.
11:50alandipertthanks
11:50alandipertstill spotty for me but it’s likely my side
11:50Bronsahttps://github.com/ato/clojars-web/issues/235
11:57cursorknoniwoo: Try (shutdown-agents) after your (future ...) call
11:57meliponehello! I am having problems capturing the output of a java program to stdout. I tried everything I found on the web but nothing worked. What to do?
11:59llasramWow, everything?
12:00TimMcmelipone: Capturing the output of the entire JVM process, or redirecting from inside the JVM?
12:00noniwoocursork: ok, it worked. where can I read more about this, and behavior of (future)?
12:01TimMcBear in mind that shutdown-agents is permanent.
12:02meliponeTimMc: Dunno exactly. I am calling a function from a java library and it works fine but I can't capture the output from System.out.println
12:02TimMcAgain, what do you mean by capture?
12:03TimMcLike, `java -jar foo.jar >output.txt` in your shell?
12:03meliponeTimMc: I would like to write out the output to a file for example
12:03meliponeTimMc: Yes exactly
12:04TimMcIf that doesn't work, perhaps it is printing to stderr instead?
12:04meliponeTimMc: I have the source code of the program and it's printing to stdout
12:06justin_smithmelipone: what about System/setOut ?
12:06justin_smithif you want to set the target of all output from within the jvm
12:06meliponejustin_smith: Okay, I haven't tried that. how do you use that?
12:07justin_smithhttp://docs.oracle.com/javase/7/docs/api/java/lang/System.html#setOut(java.io.PrintStream)
12:07justin_smithin clojure, the syntax would be (System/setOut stream)
12:07justin_smithwhere "stream" is an apropriate output-stream object
12:08meliponejustin_smith: I'll try that and report.
12:08justin_smithor, more accurately, as the docs show, a PrintStream
12:08TimMcWhat I don't know is how one would set it back again.
12:08mpinghi guys
12:08meliponeTimMc: that's true
12:08TimMcSystem/setOut seems likea really good way to break everything.
12:08justin_smithTimMc: bind *out* before doing it, then call setOut again later?
12:08TimMcmmm
12:09meliponeTimMc: this occurs so often, I'm surprised a solution hasn't been found yet
12:09justin_smithactually - this is clojure, isn't *out* available for thread-local binding? why not use that?
12:10meliponejustin_smith: I tried that (binding (*out* ...)) did not work
12:10rstandy*out*
12:10justin_smiththe syntax is (binding [*out* ...] ...)
12:10meliponejustin_smith: whatever ...
12:10justin_smithunless that was just a typo above
12:11mpingwhat is the standard way to return json errors from a ring app? I'm using validateur, but I would prefer to do something like rails and add a errors field to every validatable attribute; but json serialization doesn't allow for this
12:11meliponejustin_smith: a lisp slip
12:11justin_smithmelipone: that feels like a line from a dr. seuss poem :)
12:12meliponejustin_smith: don't get me started :)
12:13justin_smithmping: can't you populate :errors on the applicable attributes before doing the json conversion?
12:15justin_smiththat can just be a reduce with assoc on each error, if the errors are in any kind of sane format
12:16justin_smithmelipone: I like tee for sending all output to a file, while also preserving real time console output - but that is yet again a solution from outside the jvm
12:19TimMcjustin_smith: If the output is being written directly to System.out, binding *out* won't help.
12:20mpingjustin_smith: error are sane, I was wondering if is a common way of representing errors on an obj that will be json'ified
12:21kqrwhat is wrong if when I start "lein repl" I get two nasty stack traces? (one starting with Exception in thread "nREPL-worker-0" java.lang.NoSuchMethodError: clojure.tools.nrepl.StdOutBuffer.length()I)
12:21mdrogaliskqr: Known issue, fixed on master.
12:21kqroh
12:22kqrdoes it affect anything other than being a nasty error message?
12:22justin_smithmping: right (reduce (fn [result error] (assoc-in result (get-error-path error) (get-error-contents error))) result errors) -- get-error-path and get-error-contents should be trivial to write
12:22mdrogaliskqr: I don't think so, no. Should be good to go.
12:22crelixthis is probably a silly question but why do i keep getting an unbound function error when trying to call clojure from java?
12:22meliponejustin_smith: I'm looking now at clojure.tools.logging
12:22kqrmdrogalis, the reason I'm asking is that according to (http://clojure-doc.org/articles/tutorials/vim_fireplace.html) lein repl should create a target file with information on the repl – this does not seem to happen. (and vim complains about not being connected to the repl)
12:23justin_smithmelipone: how will that help if the java code is calling System.out.println?
12:24mdrogaliskqr: Not sure, I'm not a Vim guy. technomancy, any idea?
12:24technomancykqr: that's a bug with 2.4.3 running outside a project; need to either downgrade to 2.4.2 or stay inside a project
12:25hiredmanI am sort of shocked at the number of people in here complaining about that
12:25kqrtechnomancy, ah. but you're supposed to be able to connect to a repl outside of a project?
12:25hiredmanI never use lein outside of a project
12:26meliponejustin_smith: I read that it has a way to capture *out* and redirect it to logs
12:26justin_smithhiredman: clearly many of us do though
12:26hiredmanjustin_smith: why?
12:26Bronsapuredanger: ping
12:26technomancyhiredman: if it affected regular repls I would have stayed up late to fix it despite being in the middle of a move, selling my house, etc
12:26hiredmantechnomancy: sure
12:26puredangerBronsa: eh?
12:27Bronsapuredanger: is there any interest in a fix for http://dev.clojure.org/jira/browse/CLJ-1232 ?
12:27kqrhiredman, I commonly start up a new session in a separate workspace when I want to figure stuff out that's more general and not immediately related to my project
12:27technomancyit's an easy fix, but unfortunately it disproportionally affects people who are less likely to know the fix
12:27BronsaI can write a patch, but if Rich's stance is that it's not an issue I won't bother
12:27kqrhiredman, i like blank slates
12:27justin_smithhiredman: I like having a "generic" repl for experimentation, etc., that is not tied to a particular project and its deps. Can't speak for everyone else of course.
12:28hiredmanI guess
12:28bdruthmorning ... quick question about let bindings, if anyone has a moment?
12:28hiredmanI mean, if I want a repl I java -jar clojure.jar (the actually path the clojure jar in my checkout of clojure is somewhere in my shell history)
12:28puredangerBronsa: I think Rich's opinion was clear in the comments and that was: should be fully-qualified if not in the auto-imported set
12:29kqrhiredman, does that repl play well with fireplace/vim?
12:29puredangerBronsa: perhaps a patch that error'ed on use of non-fully-qualified return type not in the auto imported set would be ok
12:29bdruthI have two functions that have to construct an identical set of let bindings ... wondering if there's a way of extracting them to another function?
12:29hiredmankqr: no, it is bare bones no editor integration, no history, etc
12:30justin_smithhiredman: fair enough, but lein repl also gives me an automatic nrepl port
12:30kqrhiredman, so that's why I don't use it for experimentation ;)
12:30technomancycave man clojure =)
12:30bdruthe.g.: (let common-bindings ...)
12:30Bronsapuredanger: I'm ok with throwing an error, I just don't like the current behaviour. It's not documented and confusing
12:31hiredmanbdruth: consider using a map instead of let bindings
12:31Bronsapuredanger: at the same time though I don't understand why letting the compiler auto-qualify the class symbol is out of the question
12:31bdruthhiredman: true, I could do that
12:31puredangerBronsa: I also find it confusing. :)
12:31bdruthhiredman: thx
12:32puredangerBronsa: in other words, I agree with you :)
12:33justin_smithbdruth: I don't know if it's really worth going so far, but flatland/useful has keyed, and that in combination with :keys destructuring could let you abstract out the common binding logic
12:33justin_smithhttps://github.com/flatland/useful/blob/develop/src/flatland/useful/map.clj#L8
12:33Bronsapuredanger: I'll make two patches then, one that auto-qualifies and one that throws on non-qualified&non-default-import
12:36hiredmanjustin_smith, bdruth: there thing is, the only reason the same set of bindings makes sense is if you are doing in the same thing, then so if you pull out the same use in to a function, you have one place for the bindings, but still need to communicate them to the function some how, so a map
12:37gzmaskhello all, how do I load an bitmap image into a 2D array in clojure ?
12:37justin_smithyes, using a map directly is probably more reasonable
12:37TimMcgzmask: Same way you'd do it in Java. :-)
12:38hiredmanwell, the jvm doesn't have 2d arrays
12:38TimMcFor most purposes you can pretend it does.
12:38gzmaski saw "clojure.core/to-array-2d" though
12:39gfredericks,(doc to-array-2d)
12:39clojurebot"([coll]); Returns a (potentially-ragged) 2-dimensional array of Objects containing the contents of coll, which can be any Collection of any Collection."
12:39TimMcWhat a funny little fn.
12:39gfredericksgzmask: it just means a nested array
12:39bdruthhiredman: justin_smith: yeah, I have a 'deploy' function that puts a bunch of stuff in certain places, and then an 'undeploy' that basically needs the same locations to know where to remove them
12:39gfredericksthus "potentially-ragged"
12:39bdruthI think a map will work
12:39hiredmangzmask: what people colloquially refer to as a 2d array on the jvm is an array of arrays
12:40gfredericks,(to-array-2d ['(hey this list has 6 items) #{:foo}])
12:40clojurebot#<Object[][] [[Ljava.lang.Object;@213dbd>
12:40TimMchiredman: What environments *do* have true 2D arrays?
12:40hiredmanTimMc: fortran maybe?
12:40hiredmanI dunno
12:40gfrederickswhat's that new language with the female name
12:40gzmasknested vector? like [[1 1 1][2 2 2][3 3 3]] ?
12:40hiredmanjulia?
12:40gfredericksyeah
12:40justin_smithit might make more sense to use an array of (* w h) size, and just write accessors that convert column / row numbers into direct indexing
12:40TimMcgfredericks: Swift. :-)
12:40hiredmangzmask: arrays and vectors are different
12:40gfredericksit either has 2d arrays or it just has 1-indexing
12:41gfredericksI know the latter is true, just not sure if I'm confusing it with the former
12:41hiredmangzmask: [] is a clojure vector, arrays are a jvm primitive
12:42gzmaski see. what are the situations that I should use array instead of vectors ?
12:42gfredericksinterop mostly
12:42hiredmangzmask: sure, I would definitely use an array instead of a vector for image data in many cases
12:42hiredmangzmask: you should google java ImageIO
12:43justin_smithgzmask: sometimes makes sense in tight loops, where the array a local that is not used by any other code (especially not any other threads)
12:43gzmaskso there is a performance difference between array and vector?
12:43justin_smithyes - just use the array that ImageIO returns to you
12:43justin_smithunless you need to do anything fancy, or share the data
12:44hiredmangzmask: yes, the big difference is generally with vectors you will end up with boxing (there are some primitive vectors but maintaining the primitiveness well performing operations can be tricky) while arrays can hold primitives very easily
12:45hiredmanjustin_smith: well ImageIO will return some class that wraps an array
12:45justin_smithgzmask: actually, iirc maybe ImageIO gives you a buffer, which you can then put into an array, or just read from and use as you go
12:45hiredmanbufferedimage
12:45justin_smithhiredman: right
12:46gzmaskhmm, so this buffer is something like an 1D array?
12:46hiredmanbut unless you are doing something very custom, the java image stuff likely has some facilities you'll want to take advantge of
12:46hiredmangzmask: what buffer?
12:46justin_smithgzmask: it wraps the act of getting the pixels left to write and top to bottom - you can then put that in an array, or just use it as you go if you don't need to persist the input
12:46hiredmangzmask: http://docs.oracle.com/javase/7/docs/api/java/awt/image/BufferedImage.html is what you will get from ImageIO
12:46justin_smith*left to right
12:46justin_smithhttp://docs.oracle.com/javase/7/docs/api/javax/imageio/ImageIO.html
12:48gzmaski see, I will look into the java stuff more I guess. sometimes just can't get myself "java-clean" :"(
12:48justin_smithwell, to be more precise - you can get a stream from a file / network socket / whatever - you can pack that stream into a bufferedimage which lets you access the data as needed, and then refer back to it as if it were a collection all along, or an iterator that lets you loop over them as they come in from the source
12:49justin_smithgzmask: the model is very flexible, but not all that intuitive at first to be sure
12:50justin_smithie. you don't need to save the network data to disk, or even have the whole thing in RAM, before you get the pixels. You don't need to load the whole thing if you just want the first pixels the file format provides to a reader. etc.
13:08gzmaskthe whole java eco-system feel so alien to me now. I think I need to relearn it
13:09gzmaskit's not like everything useful is inside *.swing back in 2005 anymore
13:10TimMcheh
13:43gzmask(javax.imageio.ImageIO/read (java.io.File. "sample_logos/superman.jpeg")) and I got an error. what's wrong with this java interop?
13:44TimMc"an error", you say?
13:46gzmask"clojure.lang.Compiler$CompilerException: javax.imageio.IIOException: Can't read input file!"
13:46vermatbaldridge, you think this is a resonable implementation for a drain close? https://www.refheap.com/89551
13:46vermatbaldridge, I realize its not clojurescript compatible
13:47vermatbaldridge, actually the docstring is incorrect
13:47vermaok, fixed, https://www.refheap.com/89551
13:47gzmask(ns day01.main-screen (:import (javax.imageIO))
13:47gzmask(ns day01.main-screen (:import (javax.imageIO))
13:48gzmask(ns day01.main-screen (:import (javax.imageIO))
13:48gzmask(ns day01.main-screen (:import (javax.imageIO))
13:48gzmask(ns day01.main-screen (:import (javax.imageIO))
13:48gzmask(ns day01.main-screen (:import (javax.imageIO))
13:48gzmask I imported it as (:import (javax.imageIO))
13:48slpsysnamespace bomb
13:48gzmasksorry, I am struggling with this lighttable and kiwiirc combo
13:49llasramgzmask: "Can't read input file!" seems like a pretty clear error to me
13:49gzmaskwhat's its default reading location? not /resource?
13:50llasramWhat? No
13:50llasramCurrent working directory of the process, just like in any other language
13:50llasramIf you want a resource from the classpath, you can use the `clojure.java.io/resource` function to get a URL
13:50TimMcgzmask: (do (slurp (java.io.File. "sample_logos/superman.jpeg")) nil) should produce a similar error
13:51TimMcllasram: "URL"
13:51gzmaskthat fixed it
13:51llasramTimMc: Yes?
13:52gzmaskimmersed myself in the framework too long and resources became my root XD thanks guys
13:54gzmaskok now I have this "java object" and it's immutable to pprint. how do I observe it?
13:54TimMcllasram: I seem to recall some escaping problems.
13:55TimMcgzmask: I don't think you mean "immutable" there.
13:56gzmaskim·mune*
13:56TimMcUse the API docs to find out how to interact with it. Find snippets online to get an idea of how people use it. The usual way. :-)
13:56justin_smithgzmask: there are methods that get values out of the BufferedImage - http://docs.oracle.com/javase/7/docs/api/java/awt/image/BufferedImage.html
13:56gzmaskawww, java, can't you just let me stay in the REPL ;P
13:57technomancygzmask: there are various inspector tools you can use to reflect on the methods of a given class
13:57technomancyfrom the repl
13:58gzmasktechnomancy: what are those nice things?
13:58justin_smithyou likely want to use getData, which gives you a Raster
13:58TimMcgzmask: I use org.timmc.handy.repl/show to reflect on classes from the command line. Doesn't give you javadocs, though.
13:58justin_smithgzmask: http://docs.oracle.com/javase/7/docs/api/java/awt/image/Raster.html
13:59justin_smiththe Raster represents a rectangle of pixels
13:59TimMcgzmask: What is your ultimate goal with this image?
13:59justin_smithso (-> image .getRaster (.getPixel x y))
13:59gzmaskTilemap from bitmap for a game
13:59technomancygzmask: the one I used was called javert, but I make no claim as to it being the best or good or anything
14:00justin_smithTimMc: he wants to get a pixel value
14:00technomancy*the one I made
14:00justin_smithgzmask: oh, that's not what you said before - but OK
14:01justin_smithin that case you can likely ignore Raster and just directly use the image as your tile via whatever API the game is using
14:01gzmaskbasically a bitmap read into an array, then use some specific color value as invisible collision bodies, some other value as other tile stuff like trees etc.
14:02justin_smithgzmask: there are classes in imageIO that have collision detection and such built in. I think you will save yourself a lot of work and trouble by exploring the javadoc.
14:02gzmaskyea, I just need to get the num value for specific pixel
14:03justin_smithgzmask: why test an individual pixel when the class already has a collision detection method?
14:03gzmaskthe collision detection is done is box2d
14:04gzmaskso the bimap are used as information storage for collision bodies
14:05gzmask[[1 1 1][1 0 1][1 1 1]] i.e this is a room
14:05gzmaskwhere 1s are the collision aabbs
14:06gzmaskanyway, I guess I just need digging into the javadoc now
14:13acaglecornspinbikeginrupafishbachbock
14:15mi6x3mhello clojure, what what you call a function as part of object's metadata which returns the source of the object
14:15mi6x3m:get-src ?
14:20arrdemwe already have the :src key...
14:21mdrogalisarrdem: How are your fingernails holidng up?
14:21mi6x3marrdem: well this is different, it's a function returning the source
14:22technomancyarrdem: we do?
14:22Bronsaarrdem: huh?
14:22Bronsa, (->> (ns-map *ns*) vals (map meta) (filter :src))
14:22clojurebot()
14:22Bronsa, (->> (ns-map *ns*) vals (map meta) (filter :source))
14:22clojurebot()
14:22arrdemapparently I'm confusing Grimoire implementation details and clojure.core
14:22arrdemI'll just go gibber in the corner
14:23mi6x3marrdem: the function you are looking for is clojure.repl/source probably
14:23Bronsatools.reader adds a :source key
14:23Bronsa(if you use the indexing reader)
14:25arrdemmdrogalis: still hanging in there
14:25mdrogalisarrdem: I share your discomfort.
15:00ed-ghello everyone. I'm having a heck of time setting up my new Emacs 24.3.1 to use cider 0.8.0 with my new clojure 1.6.0 project. it keeps telling me that "WARNING: CIDER's version (0.8.0-snapshot) does not match cider-nrepl's version (not installed)" but I can't figure out how to install cider-nrepl, it's not in MELPA.
15:01rweirdid you remove all the nrpel stuff
15:02cbped-g: cider-nrepl is a clojure repo, not emacs
15:02cbpmaybe you have an outdated version in your profiles.clj and forgot about it
15:02cbpor if it says not installed i guess you have to install it
15:03cbpin your profiles.clj in :plugins [cider/cider-nrepl "0.8.0-SNAPSHOT"] or something
15:03ed-grweir: yes I have
15:04ed-gcbp: ahh, it looks like cider-nrepl 0.8.0-snapshot does not exist. will try with 0.7.0
15:06justin_smithed-g: I would use the 0.7.0 version of both cider and the cider middleware - but I haven't been brave enough to try to upgrade yet
15:07ed-gcpb: thanks, it all makes sense now ;-)
15:07ed-gjustin_smith: ok, i'll try living on the edge and see how I fare
15:12bbloomcemerick: did something change recently with nrepl? suddenly today i noticed that https://github.com/greglook/whidbey is showing results in double quotes....
15:25grisevgSorry to bother you guys with a simple question. I'm trying to read variable "mytest" from config https://github.com/grisevg/refheap/blob/dev_tmp/src/refheap/views/paste.clj#L35 but I can't figure out what i'm doing wrong. Config loader: https://github.com/grisevg/refheap/blob/dev_tmp/src/refheap/config.clj Config itself: https://github.com/grisevg/refheap/blob/dev_tmp/config.clj
15:26hiredmangrisevg: pastebin the stacktrace?
15:27hiredmangrisevg: my guess is however your are packaging and running the app it cannot find the config file
15:29grisevghiredman: I run it with leiningen ring. There is no errors in console/ring. I'm thinking this is how I'm supposed to access the config https://github.com/Raynes/refheap/blob/4f6fe9ada70b0663935dd6cbc9fcfaaea76d997f/src/refheap/models/login.clj#L50. You think it fails to load file?
15:30trevorlandauDoes anyone know where the slides are for this prezzo from Rich Hickey? http://vimeo.com/100518968 Implementation details of core.async Channels
15:30hiredmangrisevg: yeah, I dunno what clj-configs behaviour is then, it may jsut return an empty map
15:30justin_smithgrisevg: can you slurp the file?
15:30justin_smithgrisevg: does (.getCanonicalPath (java.io.File. ".")) return the directory you expect?
15:31cemerickbbloom: 0.2.4 went out recently, but nothing that would affect printing of values IIRC.
15:31bbloomcemerick: i realized that it's caused by adding cider-nrepl 0.7.0 to my profile
15:32cemerickbbloom: sounds good to me ;-)
15:33bbloomcemerick: i realize that you prefer when it's somebody elses problem, but you're one of my favorite people to ask to fix things while i sit on my ass and do nothing
15:33bbloom:-)
15:33cemerickheh
15:33cemerickI'm largely out of that business, at least for the foreseeable future
15:33cemerickThe yaks will run free and shaggy
15:33hiredmanwasn't renaming nrepl.el supposed to cut down on that kind of thing?
15:34grisevghiredman: justin_smith: ok, clearly my clojure knowledge is not good enough to answer the questions, but thanks for your help guys. I was hoping it's something simple.
15:34justin_smithgrisevg: I pasted code you can run
15:34justin_smithgrisevg: and slurp is literally like this: (slurp "config.clj")
15:35justin_smithor whatever the file name was
15:35grisevgjustin_smith: yeah I tried, but it doesn't print anything in the console. I guess it's because it's running through "ring"
15:36justin_smithgrisevg: well, if you aren't in a repl, it won't print anything unless you print it
15:36justin_smith(println (slurp "config.clj"))
15:36justin_smithif that fails, (println (.getCanonicalPath (java.io.File. ".")))
15:36justin_smithyou can run either of those wherever you are loading the config
15:37grisevgjustin_smith: oh sweet, it works. Prints the file.
15:37justin_smithOK, so that eliminates one potential point of failure
15:37grisevgjustin_smith: is that a correct way to read a property? https://github.com/grisevg/refheap/blob/dev_tmp/src/refheap/views/paste.clj#L35
15:41justin_smithgrisevg: if config.clj has something like :mytest "language" in it, that looks abot right
15:43schmeecan someone help me extract the similarities between these two functions? https://gist.github.com/schmee/b60bb0285a3773f3c683
15:43justin_smithgrisevg: but it would probably be more helpful to see a paste of some of your code, instead of someone else's (presumably working) code
15:43schmeethey're almost the same, but the extra argument to f in the first function is throwing me off
15:43hiredmanjustin_smith: he is trying to run refheap
15:44grisevgjustin_smith: I forked the repo and pushed the code https://github.com/grisevg/refheap/tree/dev_tmp
15:45justin_smithgrisevg: OK, then if old doesn't have a :language key, or the session doesn't have a :last-lang, then "Clojure" should be the value that comes through
15:46grisevgjustin_smith: yeah, but when I run it, it's "Python" that gets through =/
15:47justin_smithand are you sure that "Python" is not coming from :language or :last-lang ?
15:47grisevgjustin_smith: yes... if I change it to "PHP" or any other, it changes
15:48grisevgjustin_smith: is import correct - https://github.com/grisevg/refheap/commit/40445a4602cc0cf532212770a6ae8955c75804fd#diff-afbf3ad3fac423146695e989f1a948f8R3 ?
15:49grisevgjustin_smith: or do I need to run/initialise the config ?
15:49justin_smithgrisevg: yeah, all that looks right. Note that config is only loaded from the file once, when the refheap.config ns is first loaded
15:49justin_smithhttps://github.com/grisevg/refheap/blob/master/src/refheap/config.clj
15:50justin_smithconfig is defined when the ns is loaded, based on the contents of that file
15:52grisevgjustin_smith: thank you! all i had to do is restart server.
15:52grisevgjustin_smith: I realise it's a bit selfish to ask for help with little understanding of the language myself. thank you a lot.
15:53justin_smithonce again "have you tried turning it off and then off again?" would have made the whole thing so much simpler
15:53grisevgjustin_smith: :D
15:53grisevgjustin_smith: I'm used to the fact that python/ruby servers run every single time without caching stuff like that in memory
15:58justin_smithoh - so a new one gets spawned for each request or something?
15:59amalloyjustin_smith: that's pretty common for python/ruby/php. a new interpreter instance for each request
15:59justin_smithI guess you would need a saner language for something like a pool to be reliable
16:08arrdemmdrogalis: ambrosebs has apparently heard
16:08mdrogalisarrdem: Ooo
16:09arrdemso emails are en route somewhere
16:10mdrogalisIm out. Booo
16:10mdrogalisGood luck arrdem!
16:10arrdemcheers! I fully expect to join the pitty party in a minute
16:11mdrogalisHah
16:12ambrosebsyep count me out too
16:12mdrogalis"No one is speaking this year!"
16:18bridgethillyerMy money says arrdem is a yes
16:19mdrogalisSi. He's held out so long.
16:19mdrogalisbridgethillyer: Big money for you?
16:19SegFaultAXTalks being accepted?
16:19bridgethillyermdrogalis: :)
16:19SegFaultAXIs that what you guys are talking about?
16:19mdrogalisbridgethillyer: Awww yis. Congrats :)
16:20mdrogalisSegFaultAX: Yeah
16:20bridgethillyermdrogalis: Oh, no
16:20ambrosebsbridgethillyer: congrats!
16:20bridgethillyermdrogalis: I have not heard yet
16:20ambrosebsoh :)
16:20mdrogalisOh, heh.
16:20bridgethillyermdrogalis: But I also haven’t been rejected yet!
16:20ambrosebshaha
16:20mdrogalisI'm just gonna start the rumor that you got in. If not, you can just show up and say you were misinformed.
16:20melipone_TimMc: I found a solution
16:21melipone_justin_smith: I found a solution
16:21SegFaultAXbridgethillyer: What was your proposal?
16:21bridgethillyermdrogalis: lol.
16:21melipone_TimMc: The problem was that *out* in the repl is not the same as System.out in java
16:21SegFaultAXOr, what *is* your proposal, since it's not yet confirmed.
16:22justin_smithmeliponeso what was the solution?
16:22melipone_TimMc: I just used System/setOut in a macro so that I restore it when I'm done
16:22mdrogalis"Immutable State is for the Weak" #rejectedconjtalks
16:22melipone_justin_smith: The problem was that *out* in the repl is not the same as System.out in java
16:22SegFaultAXmdrogalis: Was that yours?
16:23justin_smithmelipone_: well not always, at least
16:23melipone_justin_smith: I just used System/setOut in a macro so that I restore it when I'm done. Phewwww
16:23bridgethillyerSegFaultAX: I did two
16:23mdrogalisSegFaultAX: Deep dive on a platform I'm open sourcing soon.
16:23bridgethillyerSegFaultAX: data exploration with Clojure as that is what I am working on atm
16:23melipone_justin_smith: the repl does show two different print streams
16:24justin_smithmdrogalis: "process level concurrency for fun and profit"
16:24amalloyreiddraper: do you know if anyone's written test.check generators for Thrift objects? seems like they have enough metadata that you could do it without a ton of effort
16:25mdrogalis"Installing the JRE - the Hard Way"
16:25justin_smithbridgethillyer: arrdem: mdrogalis: they should use puffs of smoke like they do when selecting a pope
16:25reiddraperamalloy: i dont' know, but agree it probably shouldn't be too difficult
16:25bridgethillyerjustin_smith: That’s what will happen when Rich Hickey passes and a new Clojure pope must be elected
16:26justin_smithmdrogalis: "evolutionary algorithms via inconsistencies in randomized configuration of deploy environments"
16:26mdrogalisI think we can start our own worst-conference-ever
16:28tbaldridgemdrogalis: there are some who would like to start a conference filled with people speaking about tech that you should never use.
16:28justin_smith"arrogant evangelism, foul-mouthed mysogyny, blatant racism: pick two -- protecting your programming community from outsiders"
16:28tbaldridgethe problem would be finding speakers willing to show up.....
16:28mdrogalistbaldridge: Hah, yeah. Tough sell.
16:28bridgethillyerjustin_smith: Ha! I could totally give that talk
16:34technomancyI attended a "terrible ideas you should never do" talk at a rubyconf once and it was amazing
16:34mdrogalistechnomancy: Was it related to Ruby, or just in general?
16:34technomancyhttp://www.zenspider.com/presentations/2009-rubyconf.html
16:34technomancyruby-specific
16:34mdrogalisI think I could do an hour on the general side, for sure
16:40technomancyI think my "catch all the things" post from yesterday may have been subconsciously inspired by https://rubygems.org/gems/neversaydie
16:40shanemhansenwow. There are so many jokes to be had with a talk named "terrible ideas you should never do" at a ruby conference.
16:40technomancy"NEVER SAY DIE lets you rescue from segmentation faults. Got a SEGV, don't worry about it anymore! Just rescue an exception and get on with life. Who cares about getting a SEGV anyway? It's just memory. I mean, when I was in school, I didn't need 100% to pass the class. Why should your memory need to be 100% correct to get the job done? A little memory corruption here and there doesn't hurt anyone."
16:40mdrogalisbridgethillyer arrdem: Have you heard of anyone getting in yet? :P
16:41bridgethillyermdrogalis: Yep. A few
16:42mdrogalisbridgethillyer: :)
16:42arrdemmdrogalis: ambrosebs: not talking
16:42ambrosebsbl
16:42arrdembridgethillyer: congrats!
16:43bridgethillyerarrdem: Ha ha I did not say that I got accepted
16:43arrdemo
16:44mdrogalisbridgethillyer: My plan in action right there ^
16:44mdrogalisJust show up. Trust me.
16:44bridgethillyerTake a look at Twitter - a few people have said they are speaking
16:44bridgethillyermdrogalis: Ha haha
16:44arrdem(inc justin_smith)
16:44lazybot⇒ 68
16:45bridgethillyermdrogalis: I could totally pull it off. Just get up on stage whenever… hmmm… whose spot should I take?
16:46mdrogalisbridgethillyer: "What? You don't see my name on the schedule? But, but. Check Twitter. -Everyone- says it's my turn."
16:46mdrogalisTweeted by hundreds of users named asdf2837587
16:46bridgethillyergood stuff
16:46technomancysomeone's bound to not be able to make it
16:47arrdemtwitter based conference scheduling... interesting idea
16:53dagda1_is there anyway I can use apply with take....I'm trying to do (apply take 3 (range 10)) but obviously that is not right
16:54amalloydagda1_: you just want (take 3 (range 10))
16:54dagda1_amally I want the list split into 3 groups of 3
16:55amalloy&(partition-all 3 (range 10))
16:55lazybot⇒ ((0 1 2) (3 4 5) (6 7 8) (9))
16:55amalloytake is not really relevant to your goal; trying to use apply with it doesn't make sense
16:56dagda1_amally: I mean, I want ((0 1 2) (3 4 5) (6 7 8) (9)) is this possible with apply or what could I use
16:57amalloyi literally just showed you an expression that evaluates to that. also, your irc client will surely tab-complete usernames
17:00dagda1_amalloy: I'll never understand why people need to give responses like that. Don't answer if it annoys you
17:00justin_smithdagda1_: he answered your question already, it's fair to point that out
17:01justin_smith&(partition-all 3 (range 10)) ; dagda1_ this has the result you wanted
17:01lazybot⇒ ((0 1 2) (3 4 5) (6 7 8) (9))
17:01rhg135,(take 3 (-> (range 10) (partition-all 3)))
17:02clojurebot#<IllegalArgumentException java.lang.IllegalArgumentException: Don't know how to create ISeq from: java.lang.Long>
17:02rhg135meh
17:02rhg135my clojure is weak today
17:03justin_smith,(take 3 (->> (range 10) (partition-all 3)))
17:03clojurebot((0 1 2) (3 4 5) (6 7 8))
17:03justin_smithwhich is the same as partition would have returned
17:07kzarBest library for outputting some XML from some EDN in Clojure?
17:07TimMctechnomancy: Have you looked at the Maltron keyboard layout? (Their custom alternative to qwerty and dvorak.)
17:08kzar(Nothing fancy required)
17:12technomancyTimMc: haven't looked at it, no
17:15TimMctechnomancy: http://maltron.com//images/stories/layout_diagrams-current/USA/3D%2090/DM11N2X-US_Issue%20A.jpg
17:16technomancywild
17:16technomancyif I were starting from scratch I'd probably go the colemak route
17:16dgleesonhello all. I'm trying to rig my ring app up to an authentication service that requires me to use the java interopt. The problem is that I need direct access to the HttpServletRequest. Is there a way to do this inside compojure?
17:16technomancyI'm on dvorak now, but afaik colemak is less work to learn without being less effective.
17:17TimMcTheir idea is to have the most-used keys on the home row.
17:18justin_smithdgleeson: this is something that would be in the ring api, not in compojure, if it exists
17:18amalloyit's probably in the ring request map somewhere
17:19technomancyTimMc: yeah, dvorak and colemak shoot for that too
17:19justin_smithdgleeson: http://mmcgrana.github.io/ring/ring.util.servlet.html this looks promising
17:19technomancythere are so many things you can optimize for with a layout; it's boggling
17:20technomancyTimMc: I think basically as long as you get off qwerty you quickly get into the land of diminishing returns though.
17:20TimMcheh
17:20mdrogalisbridgethillyer & arrdem: Thought of another gem. "What Clojure can learn from PHP"
17:21dgleesonI think this is what I ended up really needing :) http://stackoverflow.com/questions/2806548/using-a-javax-servlet-filter-with-compojure
17:21dgleesonthanks justin_smith!
17:22justin_smithno problem - though it looks like you found that on your own
17:26technomancyTimMc: I read about someone who tracked his every keystroke and re-optimized his layout every week to reduce finger travel.
17:26justin_smithas opposed to the rest of us, that keep the same layout for a lifetime to reduce cognitive load
17:28amalloyi discovered recently that i usually hit the spacebacr with my right index finger, not with a thumb as i assumed
17:30bridgethillyermdrogalis: I think that is a totally valid proposal
17:30TimMctechnomancy: Madness.
17:31TimMcI'm surprised it would change much, anyhow.
17:32technomancyTimMc: https://xkcd.com/1095/
17:32mdrogalisbridgethillyer: I sort of realized that a minute later. I definitely didn't intend for it to be at useful. :P
17:34grisevgI have a friend, who never uses "Shift" key. He toggles "CapsLock" instead, every time, even for a single letter.
17:35zachtgrisevg: head asplode
17:35amalloygrisevg: how does he type ?
17:35grisevghe's a developer :D just toggles capslock all the time
17:35amalloyno, i mean the character '?'
17:36mdrogalisHeh
17:36tufti'm slowly tracking towards using my DataHand, which will hopefully make layout irrelevant =)
17:36grisevgthat's a good question... i'll take a look next time he's around :D
17:36tufttoday's task is to eliminate function key usage, as they're a pain on the DH
17:37technomancytuft: oooh how long have you had that?
17:37TimMcgive me give me give me
17:37arrdemhyPiRion: so... what HDL was your Lisp FPGA in?
17:37tufttechnomancy: months but haven't gotten fast on it yet
17:37TimMcI only learned aobut it today and alreayd I want it so bad.
17:37technomancyI only use function keys for controlling music, so I usually just use the internal kbd for that
17:37tufttechnomancy: been on the kinesis contour keyboards for years, and lately i'm training on DH, identifying what needs to change, and rebinding the kinesis to move towards it
17:38amalloydatahand looks like an incredible amount of work
17:38TimMctuft: Did you see someone is working on developing a replacement?
17:38tuftTimMc: no that's awesome -- where?
17:38technomancythe design doesn't seem very amenable to hobbyist hacking
17:38TimMctuft: http://geekhack.org/index.php?topic=41422.0
17:39TimMcAnd the thing was released in like... 1995, so maybe the patents will have run out?
17:39tuftsweet
17:39tuftyeah, last i heard they were still trying to find a manufacturer
17:40TimMcI hope they fix the "doesn't work in bright light" problem. :-P
17:40tufti guess they're hard to machine up for
17:40tufthaha i hadn't heard about that, makes sense
17:40technomancyoh wow, it's the ergodox guy
17:40tufti want a datahand injection molded to casts of my hands
17:41tuftfinger dangle isn't quite perfect on any setting
17:41tuftsettings are kinda hackish anyway
17:41technomancyor he's helping out at least
17:51vermaI have structure like this: {:parts [{:stuff "hello" :parts [{:more-stuff "hello"}]}]}, how can I get all the parts flattened out from this recursive structure?
17:52hiredman(doc tree-seq)
17:52clojurebot"([branch? children root]); Returns a lazy sequence of the nodes in a tree, via a depth-first walk. branch? must be a fn of one arg that returns true if passed a node that can have children (but may not). children must be a fn of one arg that returns a sequence of the children. Will only be called on nodes for which branch? returns true. Root is the root node of the tree."
17:52vermahiredman, nice, checking
17:54vermathat function is making my head spin
17:55vermaok, think I get it a little bit may be, caffiene overdrive is not helping
17:57rhg135,(tree-seq :parts (comp seq :parts) {:parts [{:stuff "hello" :parts [{:more-stuff "hello"}]}]})
17:57clojurebot({:parts [{:stuff "hello", :parts [{:more-stuff "hello"}]}]} {:stuff "hello", :parts [{:more-stuff "hello"}]} {:more-stuff "hello"})
17:58rhg135thats a start
17:59rhg135,(filter seq? (tree-seq :parts (comp seq :parts) {:parts [{:stuff "hello" :parts [{:more-stuff "hello"}]}]}))
17:59clojurebot()
18:01vermathanks rhg135 I feel I am getting it
18:06zenspiderhiya. helping a friend. is there a built-in or packaged clojure equiv to xexprs? google is falling short
18:06zenspidermostly pointing to irc logs, actually :)
18:07zenspidersomething like xexpr->xml or somesuch
18:07justin_smithzenspider: you mean this kind of xexpr? http://www.w3.org/TR/xexpr/
18:08zenspiderhah! ew. no. I didn't even know that existed.
18:08zenspiderxml <-> xexp <-> sexp
18:08justin_smithwe have clojure.data.xml for getting edn out of xml
18:09zenspiderhere's a racket example, afaik, almost every lisp has some equiv: http://rosettacode.org/wiki/XML/Output#Racket
18:10zenspiderthe clojure example ... prolly my lack of clojure reading skills
18:10zenspiderhttp://rosettacode.org/wiki/XML/Output#Clojure
18:10zenspiderdoesn't look equivalent, but it might be?
18:10justin_smithzenspider: https://github.com/clojure/data.xml check some of the examples here
18:10TimMcjustin_smith: OMG that had better be an April Fools post...
18:11justin_smithTimMc: inorite
18:11justin_smithzenspider: yeah, that is equivalent - it's turning standard clojure data literals into xml
18:12zenspiderok. I'm just not experienced in clojure literals I guess
18:12amalloyjustin_smith, TimMc: it says right there that this is not endorsed by the w3c, just being published by them as an acknowledgement that someone sent them this note
18:12zenspiderjustin_smith: that url is perfect. thanks.
18:13justin_smithit's actually more fluent than the racket example, since we have associative literals that map nicely to tag / value in xml
18:17TimMcamalloy: Phew.
18:18TimMcI'm used to "Status of This Document" just saying "this is a work in progress forever".
18:18justin_smithTimMc: just think how much better macros would be if they were all done in the form of xml transforms
18:20hyPiRionarrdem: VHDL
18:20hyPiRionarrdem: http://hypirion.com/pdf/igor.pdf
18:20hyPiRionI didn't do anything on that project though
18:35arrdemhyPiRion: hum okay thanks I'll check it out.
18:36arrdempicking up Verilog in the next few days for a class.
18:46hyPiRionaha
18:49hyPiRionTry to get in some lisp for me and I'll be happy
18:49hyPiRionI was unable to =(
18:51aderethtechnomancy: I haven't had access to my hackerspace since I moved a couple months ago, but I'm still committed to completing the keyboard I modeled in Clojure
18:53aderethMatt Gauger has made some progress building his own single hand chording keyboard in Clojure using my dactyl library
18:54technomancyadereth: awesome. you have free access to a 3D printer, right?
18:54technomancyseems like that makes experimenting with case layout a lot more practical
18:54aderethI did, but don't for now. Should have it back in a month.
18:54aderethYeah, I'm kinda stuck without it.
18:54technomancywhen you're paying for time, a 3D printer is way too expensive vs a laser
18:55aderethAgreed. I was shocked at the rates the Makerbot store was charging.
18:56aderethhttps://github.com/adereth/dactyl if anyone wants to play with it
18:57technomancyadereth: you're still hand-wiring everything, right?
18:57technomancyoh right; with the curved design that's the only option =)
18:57aderethYes. It's nuts.
18:57technomancyit's not so bad with only 21 switches per side =)
18:58technomancydo you have any photos of the matrix?
18:58aderethYeah, not too bad. Also, with some refactoring, I was able to easily print a few nice utility pieces for doing the wiring.
18:58beamsois it difficult to get used to the control keys being along the bottom of the keyboard?
18:59aderethhttps://twitter.com/adereth/status/463810293705883648/photo/1
18:59technomancyadereth: cutting these is the worst part ime http://p.hagelb.org/stripped.jpg
18:59technomancy(sfw)
18:59aderethhttps://twitter.com/adereth/status/460903377409675265/photo/1
18:59technomancycool
19:00technomancybeamso: it really doesn't take long
19:00aderethYes, that looks very familiar :p
19:00technomancybeamso: you get used to that part a lot faster than the columnar layout
19:00technomancyadereth: man, all those primary colors makes it look like a google office or something
19:01aderethI used the colors nobody else was interested in. Figured I'm going to spray paint or plastidip the whole thing at the end anyway.
19:02technomancyadereth: I haven't fired up any CAD myself, but I might do it soon in order to support matias switches alongside cherry.
19:02technomancybut that's a pretty simple modification to the current design
19:04aderethMy dream is to have the design fully parameterized to the point that someone could enter the dimensions of their hand and get a custom keyboard STL or SVG. Switch style as another parameter.
19:04aderethObviously leading to KaaS.
19:04SegFaultAXLike cars that adjust the seats and mirrors based on who is driving?
19:05technomancyhaha nice
19:05technomancyyeah, I'm always on the go, so I've gotta optimize for portability and sturdiness.
19:05weitransit question. trying to serialize a #uuid and get Uncaught Error: Cannot write. do I have to add that type somehow?
19:05technomancybut that'd be pretty sweet for a desk setup
19:06SegFaultAXMakes me think of the cars from Demolition Man.
19:06c3wif you regularly pair programmed with someone, with one of you taking the right-hand keys and the other taking the left-hand keys, you could finally have an ergonomic solution
19:07technomancyTimMc: you saw adereth's design, right?
19:08SegFaultAXadereth: Your dream is already a reality for mice, basically. Check out the R.A.T. 9
19:08SegFaultAXFully configurable gaming mouse.
19:09aderethThat's nuts. I wasn't going for anything adjustable. You enter the parameters and get a design that can be printed or laser cut for you.
19:10technomancyadereth: you can't laser-cut a curved design like that though, can you?
19:11aderethI have two approaches that I've tried. One is to do it layered, which gets you different heights, but not all the right angles.
19:11aderethThe other is to cut pieces that are meant to be heated and bent.
19:11aderethAlong with stencils for cutting out jigs that let you do the bending precisely.
19:11technomancyhm; interesting
19:12technomancyI could you do the jigs in acrylic too, or would it need more heat-resistance?
19:12aderethThat was what I used the analemma library for. I started with Inkscape then moved to clojure.
19:12aderethI was going to go with wood.
19:12technomancyhuh
19:12SegFaultAXThat second one seems neat, but impractically difficult to automate, no?
19:12technomancyI still <3 laser-cut wood for the case material
19:12aderethYes, no automation here. It would be a kit.
19:12technomancyI keep building these wooden boards and sending them out, and feeling mildly jealous
19:13SegFaultAXI mean automating the design based on your specifications to get an SVG or whatever.
19:14aderethI don't think so, but I may be missing something or making some simplifying assumptions that I'm not communicating.
19:15aderethA lot of trig, but it all becomes possible when you have accurate measurements of everything.
19:17aderethFor instance, the model I have for this: https://twitter.com/adereth/status/472380239881175040/photo/1
19:17technomancyadereth: is the distance of the thumb cluster similar to the ergodox?
19:18aderethThe parameters are things like how much to offset the columns for each finger in Y and Z, what the spacing should be vertically and horizontally, what the overall angle should be.
19:18technomancylooks like a bit of a stretch from the photos
19:18elarson_is there a way to create a map from a sequence using for?
19:18technomancyelarson_: no, for is lazy
19:18aderethThose versions were spaced too far. Don't have photos of the tighter versions, but yes.
19:18technomancyyou have to (into {} (for ...))
19:19elarson_technomancy: ah ok. I didn't realize it was lazy. that is very helpful, thanks!
19:22elarson_is thera simple way to time an operation in the repl?
19:23elarson_*is there a
19:23elarson_ah (time $exp) worked
19:23justin_smithelarson_: for better microbenchmarking, there is also criterium
19:40sabernethyFollow up question to elarson_'s ... Is there a shortcut way to turn a sequence 'as' into a lookup map where the key is generated by 'f' ? I find myself doing (into {} (map (juxt f identity) as) a lot
19:41sabernethy*an existing shortcut
19:42amalloysabernethy: if you write that a lot, make it a function
19:42sabernethy:) after I wrote the question I knew I was going to get that answer.
19:42sabernethyamalloy: ok. thx. :)
19:43hiredmanhave you seen group-by?
19:45justin_smithyeah, that looks exactly like group-by
19:45amalloyit's not *exactly* group-by
19:46amalloygroup-by gives you a map whose values are lists
19:46justin_smithyeah - it will replace rather than vectoring keys
19:46sabernethyhiredman: yeah. but. when the grouping function returns a single item for the whole seq... i don't want the map val to be nested in a seq
19:46justin_smithsabernethy: having two different kinds of return types increases the complexity of every caller of the code
19:46justin_smithand has very few if any advantages
19:48tuft.. and not the calculus kind
19:48turbofailit'd be something like index_by from rails activesupport
19:48turbofailwhich replaces instead of vectoring
19:48sabernethyjustin_smith: i lost you, sorry. do you mean that group-by shouldn't have two return types... i wasn't asking for that.
19:49sabernethyturbofail: yeah exactly like that
19:49sabernethyi just wondered if it was in core and i'd missed it
19:49justin_smithsabernethy: you said "when the grouping function returns a single item for the whole seq... i don't want the map val to be nested in a seq" - I took that to mean you wanted individual values under some keys, seqs under others
19:50turbofailanyway i don't think there is any shortcut like that in core
19:50justin_smithI think I misinterpreted you
19:50sabernethyjustin_smith: ok. no. no problems. :)
19:50justin_smith,(map (fn [[k v]] [k (pop v)]) (group-by int "hello world!"))
19:50sabernethyturbofail: ok. now i know what to call my custom implementation though, thx.
19:50clojurebot([101 []] [119 []] [104 []] [32 []] [108 [\l \l]] ...)
19:50justin_smith,(into {} (map (fn [[k v]] [k (pop v)]) (group-by int "hello world!")))
19:50clojurebot{101 [], 119 [], 104 [], 32 [], 108 [\l \l], ...}
19:51justin_smithoops
19:51justin_smith,(into {} (map (fn [[k v]] [k (peek v)]) (group-by int "hello world!")))
19:51clojurebot{101 \e, 119 \w, 104 \h, 32 \space, 108 \l, ...}
19:51justin_smithor you could just look at the source of group-by - it's a 6 line reduce
19:53sabernethyi think i'll stick with (defn index-by [f as] (into {} (map (juxt f identity) as))
19:59numbertenwhat's the idiomatic way of adding an optional keyword option at the end of a function, like (foo x y :bar true)
20:00amalloynumberten: don't do it, just take an optional map argument: (foo x y {:bar true})
20:00numbertenbut that doesn't look as pretty :(
20:00rhg135what i've done is to just have a map argument
20:00rhg135and a optional mapless variety
20:01amalloynumberten: the freefloating keyword args look prettier until you smash your monitor in rage because it makes your function hard to work with
20:01numbertenhaha
20:01numbertenfair enough :)
20:09elarson_I wrote some code to parse cache control headers and I'm curious if there are any obvious improvements: https://www.refheap.com/89560 I'm just learning clojure and would love any tips
20:13amalloyelarson_: that is a lot of calls to map - there's gotta be a clearer way
20:13bbloomelarson_: probably worth learning about ->, ->>, and for
20:13amalloyi also don't understand what (nth entry 1 1) is supposed to be about
20:14amalloybbloom: i'm rewriting it; i bet i end up using for but not any arrows
20:14elarson_bbloom: I'll take a look, thanks!
20:16elarson_amalloy: the nth call grabs the nth item in the list and allows setting a default. so in this case if you get a string like "public, max-age=60" you'd get a vector that looks like {:public 1, :max-age "60"}
20:16amalloyokay, i knew that's what it did, i was just surprised that 1 was a good default
20:16amalloythought you might be misusing it
20:16bbloomis that an http spec thing? or maybe you want a boolean?
20:17amalloyelarson_: https://www.refheap.com/afc396efc83810a16084c62d1 is a fairly boring rewrite
20:17amalloya and b are obviously bad names, but i don't know what to call them since you didn't give them names
20:18elarson_amalloy: ah, so if you do a for on a list and the item doesn't have enough values to fill in the arguments, it will just use nil?
20:19amalloyelarson_: no, you're not understanding what destructuring on a list does
20:19amalloy(for [[x y] [1 2 3 4]] ...) is an error, because the elements of the list are numbers, not pairs
20:19amalloyfor always goes over a list exactly one item at a time
20:20amalloy(for [[x y] [[1 2] [3 4]]] ...) would be okay
20:20bbloomelarson: is that 1 just supposed to be something truthy? in clojure, only false and nil are logical false
20:20amalloyoh, you mean if you destructure a list
20:20bbloom,(boolean 0)
20:20clojurebottrue
20:20amalloyyes, that is true
20:21elarsonbbloom: I'm porting some code I wrote in python that used a 1, but yes, a boolean is the better choice.
20:21justin_smithelarson: another option is a keyword describing what that value means
20:21justin_smithwhich would be both truthy and informative
20:22bbloomjustin_smith: iirc the cache control header has a number of flags that may or may not be present
20:23justin_smithbbloom: in that case, :present is a more informative value than 1 is
20:23justin_smithor maybe :provided
20:24bbloomjustin_smith: meh
20:24bbloomi appreciate the concern about boolean blindness, but it seems perfectly reasonable here
20:26justin_smithbbloom: I only suggested it because at least one intelligent person read the code and didn't intuit what "1" meant there, or its significance as a default
20:27bbloomamalloy: would you have been confused if it were `true` instead of `1` ?
20:27lodinIs there any way to unload a class/type once created via deftype?
20:27amalloyno. i was confused because the 1 was right next to another 1, and it looked like he was trying to do some sort of 2d indexing
20:27amalloyor possibly just typed too excitedly!!1
20:52danielszmulewiczOK, after a month of hard work (as hard as it gets with computer work, not much), I've finished a prototype for a toy project. The purpose was twofold: do something fun, do something to experiment with the "immutable stack". The result is here: http://videos.tuppu.net/
20:53danielszmulewiczYou create playlists with youtube videos.
20:53danielszmulewiczMine is here: http://videos.tuppu.net/user/daniel.szmulewicz
20:54danielszmulewiczFeel free to log in with a google account, and create your own videowall.
20:54danielszmulewiczFeedback welcome, of course.
20:57danielszmulewiczIt has been fun to do, and it's interesting to see if it goes anywhere.
21:02danielszmulewiczLessons learnt: Om was great to work with. Core.async helps a lot on the client. Datomic was probably overkill.
21:08mdeboarddanielgl_, Was it clojure front and back end
21:08caternn o i c e
21:10danielszmulewiczmdeboard: yes, the whole stack.
21:10danielszmulewiczcatern: thanks!
21:12danielszmulewiczmdeboard: REST API with Liberator, messaging with Langohr (RabbitMQ), persistence with Datomic, Om and Sente on the client-side.
21:13mdeboarddanielszmulewicz, how did you go about sorting how to organize your code
21:14danielszmulewiczmdeboard: trial and error. Lots of sweating, starting from scratch with a better design than the previous one.
21:15danielszmulewiczmdeboard: reading projects by other people and assembling the pieces that made sense to me.
21:15mdeboarddanielszmulewicz, Yeah that's a sore point in clj+cljs tooling IMO
21:15danielszmulewiczIt's new territory.
21:19danielszmulewiczmdeboard: Thing is there is a real payoff to persistence. But it's not obvious and the road can be painful.
21:20mdeboardYeah well when I'm starting a new project I don't wanna have to wrestle with how I organize the files. I'm sure someone will come up with a template for it eventually
21:24danielszmulewiczmdeboard: One thing I had to unlearn was my tendency to split up files like in OO, one per class. With functional programming, it can be counterproductive to have many files with many different namespaces. Not necessary, actually. I had to learn how to use imenu in Emacs to navigate bigger namespaces.
21:24mdeboardoh was this your first clj project?
21:25danielszmulewiczmdeboard: no, but the first web project full Clojure stack.
21:25mdeboardcool
21:32TimMctechnomancy: Thanks, I'll take a look at the design tomorrow. I think I'll just switch to dvorak for now. :-)
22:02andrewchambersanyone here played with llvm in clojure?
22:02arrdem$google halgari mjlinr llvm clojure
22:03justin_smith$google halgari mjlinr llvm clojure
22:03arrdemhttps://github.com/halgari/mjolnir/
22:03arrdemspelled it wrong anyway
22:04justin_smithclearly you have never played nethack
22:04arrdemthis is true
22:10andrewchambersarrdem: yeah read abuot mjolnir
22:10andrewchambersi wanted to convert llvm modules into an edn representation
22:10andrewchambersand was just wondering if anyone else is interested
22:11andrewchambersso its not using llvm, but allowing clojure to consume some compiler output in a friendly way
22:11andrewchambersfor analysis etc
22:11arrdemwhen would you ever be using Clojure as an analysis engine?
22:12andrewchambersumm, it has datalog and other things for running queries
22:12andrewchambersWhen would you ever use C++ for doing this sort of work :/
22:13andrewchamberswhat would you suggest then?
22:14andrewchambersI even think core.logic might be interesting for prototyping whole program analysis
22:17arrdemeh. core.logic and other querying systems won't be able to add anything to a whole AST traversal unless you flatten your AST into some {id node} representation where nodes hold each-others ids and upon which you can do indexing (say node type etc)
22:17andrewchambersum
22:17andrewchambersllvm is not an ast
22:17andrewchambersits a flat assembly
22:18andrewchamberse.g. x = add y z
22:19andrewchamberswhich is exactly what you just described
22:19andrewchambers?X where instruction ?X and opcode ?X :add
22:19andrewchambersor whatever.
22:20andrewchambers?X where Call ?X and Target ?X SQLVulnerable
22:20andrewchambersetc etc
22:21andrewchambersthen you can add more advanced rules like
22:23andrewchamberscomplex deductive rules on whether a value may have come from untrusted source
22:23andrewchambersthen query for possible buffer overflows based on that
22:24arrdemthat's just taint analysis, which is a well known whole program closure fixed point operation. no need for a fancy logic engine here.
22:24andrewchambersThe point is that it simplifies things for prototyping
22:25sdegutisHi.
22:25andrewchambersarrdem: it also makes things much easier to compose
22:25andrewchamberse.g. compose taint anaylsis with a bunch of other analysis would be easier in datalog queries than in C++ code
22:25sdegutisFor a small web store that gets a max of 4k views per day, which does mostly reads but some writes, does using SQLite3 make sense?
22:26andrewchamberssdegutis: I think sqlite3 can handle that, it really depends on your code
22:26sdegutisOh.
22:27andrewchambersYou might be better off asking the sqlite people though, they answer that in the faq
22:28andrewchamberssdegutis: "Generally speaking, any site that gets fewer than 100K hits/day should work fine with SQLite. The 100K hits/day figure is a conservative estimate, not a hard upper bound. SQLite has been demonstrated to work with 10 times that amount of traffic."
22:28andrewchambershttp://www.sqlite.org/whentouse.html
22:28sdegutisAh I read that too.
22:28sdegutisThanks :)
22:29andrewchambersI was trying to decide a similar thing myself
22:29andrewchamberssettings up an sqlserver vs just using sqlite
22:30andrewchambersarrdem: Do you work on compilers at all?
22:31andrewchambersor code anaylsis tools
22:31arrdemandrewchambers: long story short yes, but my llvm isn't especially strong.
22:32arrdemhttp://github.com/oxlang/oxcart <- my summer project
22:32andrewchamberscool
22:32andrewchambershow long did that take you?
22:33arrdemthat's more or less my whole summer. I was a GSoC student.
22:33andrewchamberssweet
22:34arrdemhttp://arrdem.com/2014/08/05/of_oxen,_carts_and_ordering/ <- end of project results post
22:35andrewchambersThats pretty cool
22:35sdegutisarrdem: neat
22:35arrdemit was a project but to be honest it's pretty trivial. All I really had to do was use set/reach set/taken as value analysis
22:36arrdem*fun project
22:36andrewchambersyou are just emitting java bytecode?
22:37arrdemyeah. I basically forked Bronsa's class AST emitter, customized it, and then used his class AST to bytecode transforms
22:37arrdemhttp://github.com/clojure/tools.emitter.jvm/
22:37arrdemwhere I left off I was forking clojure to try and purge RT.java and Compiler.java so that Oxcart programs could be entirely static
22:38arrdembut that's where I started questioning the utility of the project for myself and kinda lost inertia.
22:38andrewchambersyeah
22:38andrewchambersits easy to get burnt out
22:38andrewchambers300+ commits is a good effor
22:38andrewchamberst
22:39andrewchambersI was just thinking of working on two projects
22:40bacon198`Hey, I was wondering why i'm not seeing the right output on this https://www.refheap.com/89566
22:40andrewchambersone is a compiler
22:40bacon198`I was expecting [10 20 Object], but it's [10 null Object]
22:40andrewchambersbut not for a lisp or anyhting
22:40bacon198`(it's clojurescript)
22:44arrdemandrewchambers: if you're looking for a project and interested in language design I could use some help http://github.com/oxlang/oxlang :P
22:44justin_smith bacon198`: put your :as form in {} instead of []
22:48justin_smith,((juxt (fn [& {:keys [a b] :or {a 10 b 20} :as more}] [a b more]) (fn [& {:keys [a b] :or [a 10 b 20] :as more}] [a b more])) :a 10)
22:48clojurebot[[10 20 {:a 10}] [10 nil {:a 10}]]
22:51akjhello! is there a function for seq that is equivalent to clojure.string/split? partition-by comes close but I wonder if there is something that works just the same as split
22:52justin_smithakj: what would qualify as "just the same as split" that partition-by does not do?
22:52bacon198`thanks justin_smith
22:53akjsplit does not return the character that is used to split with
22:57akjcompare (partition-by #(= % \-) '(\f \i \r \s \t \- \n \a \m \e)) with (partition-by #(= % \-) '(\f \i \r \s \t \- \n \a \m \e))
22:57akjsorry, compare (partition-by #(= % \-) '(\f \i \r \s \t \- \n \a \m \e)) with (clojure.string/split "first-name" #"-" -1)
22:58justin_smith,(letfn [(p [x] (zero? (mod x 3)))] (apply conj (reduce (fn [[coll sub] e] (if (p e) [(conj coll sub) []] [coll (conj sub e)])) [[][]] (range 10))))
22:58clojurebot[[] [1 2] [4 5] [7 8] []]
22:59justin_smithnot quite it - but its a start
22:59justin_smithmaybe wrap it in a (remove empty? ...)
23:04akjjustin_smith: what was that looong line? Lol, I hope that wasn't addressed to me
23:06akj,:5
23:06clojurebot:5
23:09justin_smithakj: it's an expression that does what you want (almost)
23:09justin_smiththough it would be better to have a lazy version - playing with that now
23:11akjjustin_smith: would it make sense to alter the source for partition-by and create a new function
23:11akjjustin_smith: that leaves out the "separator"?
23:21justin_smithakj: yes - notice that there are no multiples of 3 in the output
23:21justin_smiththough there are some empty vectors
23:23justin_smith,(defn split-seq [pred coll] (remove #(pred (first %)) (partition-by pred coll)))
23:23clojurebot#'sandbox/split-seq
23:23justin_smith,(split-seq #(zero? (mod % 3)) (range 10))
23:23clojurebot((1 2) (4 5) (7 8))
23:23justin_smithakj: I think that's the better answer
23:24justin_smithakj: you could write a modified version of partition-by instead, of course
23:24andrewchamberslol, clojure and rust started similar times. Rust 30k + commits, clojure 2.5k commits
23:24andrewchambersone is a production ready language
23:24andrewchambers:P
23:24andrewchambersthough i guess its cheating since clojure didnt write the jvm
23:24justin_smithandrewchambers: very different development models
23:25justin_smithwell the other doesn't use a vm does it?
23:25andrewchambersthen again
23:25andrewchambersrust uses llvm
23:25andrewchamberswhich itself has 100k + commits
23:25andrewchambersfor its backend
23:26andrewchambersIt's not really a totally fair comparison, but its fun to think about