#clojure logs

2014-06-03

00:57rs0i just noticed something else about the Clojure 1.6.0 Java API
00:57rurumateoi clojure, when doing (binding [*snowflake* "special"] (do-things)), and do-things does concurrent things like starting threads, will the binding of *snowflake* to "special" be visible in these threads?
00:57rs0the public API supposedly consists *solely* of IFn and clojure.java.api.Clojure
00:57rs0however, IFn in turn depends on ISeq, which depends on IPersistentCollection...
00:58tolstoyrurumate: I got the impression that bindings are thread-local.
00:58rs0so the transitive dependency closure of those two classes contains more than just those two classes
00:58rs0rurumate: that binding will not be visible in separate threads. however, there are cases where tasks will run in the *same* thread, and therefore will see the bound value. for instance, new Thread().run() will not create a new thread; it will directly invoke the Runnable in the current thread
00:59rs0rurumate: another example is a ThreadPoolExecutor with a CallerRuns saturation policy. that can cause tasks to run in the submitter's thread, with the submitter's bindings
00:59rs0rurumate: there's apparently an InheritableThreadLocal type since Java 1.2, but Clojure doesn't appear to use it
01:00rurumatewhat about pmap or fork/join things like reducers?
01:01rs0unless the API makes a specific guarantee, you'd have to read the source code to find out. generally you should assume that dynamic bindings will not propagate across thread boundaries
01:02ambrosebsrs0: every API has an implementation
01:03rurumateexperimentation now
01:03rs0ambrosebs: that's not really my point
01:03rs0ambrosebs: the actual IFn interface makes mention of ISeq
01:03rpaulotrying to use seesaw and getting: Exception in thread "AWT-EventQueue-0" java.lang.IllegalArgumentException: No matching ctor found for class com.jgoodies.forms.layout.FormLayout. This is on (forms-panel)
01:03rs0ambrosebs: which makes ISeq part of the public java API, unless the contract is "you can expect ISeq to exist, but you can't expect any particular methods on it to exist"
01:04rurumateif bindings are not inherited, using them seems brittle because concurrency might be added to the program later on
01:04ambrosebsright? you still use the `seq` Var to get an ISeq
01:04ambrosebsyou don't actually use ISeq
01:05tolstoyrurumate: I think the pattern is that you rebind for a single thread so that you can "customize" that value JUST for a thread. Atoms make better "shared state" for threads.
01:05rurumateyeah but atoms are not automatically reset to root binding after the work is done
01:06tolstoyMaybe a macro?
01:06rhg135tolstoy, wouldn't it mess up any concurrent ops?
01:07rurumatealso atoms are automatically shared between *all* threads which might be more than I wanted
01:07tolstoy(defmacro with-reset [some-atom] `(let [orig# @some-atom] ~@body (reset! some-atom orig#)).... blua blah.
01:08tolstoyrurumate: Ah, well. "Depends on the problem you're trying to solve." ;)
01:08rs0i've got my library virtually 100% compliant with the public java API, although i'm fudging a bit by including AFn in a few places because I didn't feel like reimplementing all that invoke() boilerplate. however i'm also evoking clojure.core/eval in order to define multimethods, and i'd really really prefer to do that through a Java API
01:10rhg135rs0, am indurstanding correctly that it's in java using the api to add functionality?
01:10rhg135if so i'm in awe
01:10rs0rhg135: ?
01:10ambrosebsrs0: can you write the boilerplate in a real clojure file?
01:10rhg135rs0, a jav app basically using clojure as a tool?
01:11ambrosebsI guess I mean the calls to eval
01:11rs0ambrosebs: i'll probably investigate that route next
01:11mangerurumate: Take a look at bound-fn for maintaining bindings in different threads
01:11rs0ambrosebs: it's easy to invoke remove-method, which is an actual function
01:11rs0ambrosebs: not sure how much it will help to write a function wrapper around a macro
01:12ambrosebsrs0: mm
01:12rs0rhg135: i'm writing a java library that makes it possible to use clojure maps from java code without ruining them https://github.com/rschmitt/dynamic-object
01:13ambrosebscool
01:13rs0it's a bit like defrecord ported to java
01:13ambrosebswhere's the eval calls?
01:13rhg135uh, why can't it be in .clj and gen-class a java api?
01:13rs0ambrosebs: i haven't pushed them yet =)
01:14ambrosebsor even better just write the interface in java and do everythign else in clojure
01:14rurumatemange: nice find, thanks
01:14ambrosebsis thatpossible?
01:14rhg135yes
01:15rhg135reify ftw!
01:15ambrosebslooks like you're using generics..
01:15rhg135generics are only hints for the compiler
01:15rs0ambrosebs: okay, *now* it's pushed
01:15rhg135they don't exist in bytecode
01:16rs0i could look at reimplementing this in clojure, but i doubt i will... it's already working
01:16rhg135ahh
01:16rs0i'd rather add new features than rewrite old ones. it's the same reason the Clojure compiler is still written in Java
01:16ambrosebsDon't the generics exist for the Java user? seems like we're throwing them out.
01:16amalloyambrosebs: yeah, writing an interface in java and reifying it from clojure is a great interop plan. it's what i do when i need to put a java-friendly face on some clojure code
01:16rs0besides, i'm relying on a lot of JDK8 features, like default methods
01:17rs0ambrosebs: the generics are basically so that the static methods in DynamicObject return the correct types without requiring the user to downcast, which wouldn't be idiomatic
01:17Jaoodabandon ship, swift is here
01:17rs0ambrosebs: within the library, it's complete downcasting anarchy and dynamic typing
01:18rhg135just use Objects and reflection
01:18rhg135performance may suffer but freedom goes up
01:19dissipateJaood, yeah, i'm going to totally abandon ship for swift!
01:19rs0rhg135: can you be more specific?
01:21dissipateBTW, what's with all these programming language names that it's impossible to do a proper search for, like 'go'
01:21rs0dissipate: the convention is to use the term 'golang' instead of just 'go'
01:21rs0dissipate: it's funny that people have to manually SEO the name of a programming language that came out of a web search company
01:22dissipaters0, that is pretty ridiculous
01:25rs0i remember that people made the same criticism of C# when it first came out
01:25rs0because back in those days search engines would just drop all the weird symbols
01:25rs0apparently
01:26ambrosebsrs0: is there much of a performance difference with generics?
01:26dbaschrs0: I worked at a search engine in the late 90s, and we had to create special tokens like AT&T
01:27rurumate"quoting may work when searching c#"
01:27dbaschwe had a bunch of one-off special cases in the indexer parser
01:28rs0ambrosebs: the generics are purely a programmer convenience thing for users of the library, who are going to be accustomed to static typing and OO
01:28taliosrs0 - mmm, dynamic-object looks damn squishy! I like.
01:28rs0talios: squishy?
01:28rurumatedbasch: I'm in the search business too, bro :3
01:28taliosso huggable :) nice a nice plush toy
01:28ambrosebsrs0: ah ok
01:28ambrosebsyea looks like fun
01:29dbaschrurumate: I’ve been out of the search business for a while myself :)
01:29rurumatesad to hear it
01:29dbaschrurumate: 14 years, it was time to try something else
01:29talioshey ambrosebs!
01:29rs0ambrosebs: the strategy here is to bring Clojure's strengths to Java development in the most inconspicuous way possible. we lie low for a while, as the user base of dynamic-object grows steadily. eventually, clojure.jar is part of every Java deployment. then we begin Phase Two
01:29ambrosebstalios: hi!
01:30taliosambrosebs - was thinking we should get you back on the show for a 3rd round state of typed-clojure ;)
01:30rs0this is all explained in http://www.youtube.com/watch?v=2WLgzCkhN2g
01:30ambrosebstalios: oh yea sure :)
01:30ambrosebstalios: let's try July sometime
01:31taliossounds goodo
01:32taliosambrosebs - will schedule something and get back to you
01:32ambrosebstalios: thanks
01:32dissipaters0, i doubt that is going to happen
01:33ambrosebsrs0: improved startup time should be phase zero :)
01:33rs0ambrosebs: it's really easy, just use nailgun. nothing solves everything forever like nailgun
01:33rs0(not actually)
01:34rs0i guess improved startup time could also be realized through the use of clojure-scheme, which compiles to native code by way of Gambit Scheme
01:35rs0dissipate: i'm not being completely serious; i mainly just wanted something that would make java development easier at my dayjob. in particular, i really wanted to get away from object serialization libraries. object serialization is a complete scam
01:36rs0dissipate: however, widespread availability of the Clojure runtime couldn't hurt adoption
01:39dissipaters0, well, you shouldn't be doing Java development at your day job... that's a problem right there
01:43rs0dissipate: at least i'm not doing Scala development at my day job
01:43rs0dissipate: or, like, C++
01:44dissipaters0, *shiver* yeah, that's pretty bad too
01:47dbaschrs0: you know, there are Clojure jobs
01:50dissipatedbasch, i think i could only do the remote ones
01:50rs0dbasch: is the Clojure job market a buyer's market or a seller's market?
01:51rs0dbasch: or is it too illiquid to say?
01:54dissipaters0, probably a lot like any other job market for a niche language
01:54rs0dissipate: i'm not really familiar with them, or with the general experience of hunting for jobs based on language
01:57beamsoi've seen clojure job ads locally, but clojure is typically listed as one of several languages you're required to be familiar with
01:57dissipaters0, for a niche language, there are fewer jobs, but the employment tends to be a bit longer term with more loyalty on both sides. not always, but more so than 'big tent' languages.
01:58dissipaters0, the flip side of that, is that there can end up being a lot more tasks for dealing with legacy code.
02:01dbaschrs0: I think it’s too illiquid to say
02:01dbaschfor my last contract gig I wanted to use Clojure in a Java shop. The compromise was Scala, and it didn’t work out too well
02:02dbaschScala/Java interop is type hell
02:18rs0dbasch: Scala is basically C++ for the JVM
02:19bob2that's unfair
02:19bob2it's even more complicated than c++
02:19rs0dbasch: different versions of Scala aren't bytecode-compatible forwards or backwards, which means that Scala and Java interoperate better than Scala and Scala
02:23rs0bob2: i think that Scala and C++ are both examples of very solid technical competence pursuing exactly the wrong principles
02:23rs0bob2: those languages weren't just built by incompetent amateurs like PHP was
03:41hellofunkDoes anyone know how to specify that a route in Compojure is an HTTPS (secure) route?
03:57blur3dhellofunk: you could try https://groups.google.com/d/msg/compojure/XWluMvf4CBs/OJVc_IVPsxUJ
03:57hellofunkblur3d thanks I found that as well.
03:58blur3dI dont think it handles it any other way… you just have to add handlers for it
04:01ddellacostahellofunk: this is basically what you want to do: https://github.com/noir-clojure/lib-noir/blob/master/src/noir/util/middleware.clj#L59-L68. You could probably just use that with a subset of your routes too
04:04hellofunkThanks ddellacosta. I may have another question for you in a while once I exhaust my current attempts to get a user's email address from the Google access token.
04:05ddellacostahellofunk: sure thing
04:20hellofunkddellacosta you used drawbridge much? I'm starting to the feel the pain of remote development. every little change I must push to heroku. I can't do it on localhost since there are URI that requests must come from to google
04:21ddellacostahellofunk: what is the google requirement, is that for openid or oauth2?
04:21hellofunkoauth2
04:23ddellacostahellofunk: assuming you are using mac os x or linux to develop, just change the url to be localhost in your /etc/hosts
04:24beamsoi've done oauth work where the URL i used was localhost :/
04:24ddellacostahellofunk: ^ that's the other alternative, just create an alternate app in the google settings using localhost. That's how I test oauth2 anyways
04:24hellofunkah ok, that would probably do it.
04:42noncomis it ok to have a package and ns with a same name, on the same level?
04:42noncomsay i have "core.clj" and package "core" on one level
04:42noncomwon't there be any problems with requiring or other ns-related management?
04:44clgvnoncom: that's fine, I have seen an idiom several time where the implementation details were in such a namespace, e.g. my.lib as API namespace and my.lib.* with implementation namespaces
04:45noncomyeah, that seems like exactly my case :)
04:45clgvnoncom: the folder name is only the last but one package in the fullqualified package name
04:46noncomoh, thanks for the correction
04:46noncomclgv: do you work with ccw?
04:46clgvin java that's different. there the fullqualified package consist of all the folders below the root source folder.
04:46clgvnoncom: yes
04:46clgvall the time^^
04:47noncomclgv: ummm.. could you give a little example on difference between java and clojure package concept?
04:49clgvjava: src/my/lib/MyClass.java => package "my.lib", clojure: src/my/lib/myns.clj => package "my.lib.myns" where function in the ns are classes with that package
04:50noncomaah, that's what
04:50clgvhence src/my/lib.clj => my.lib and src/my/lib/impl.clj => my.lib.impl
04:52noncomso that in the case that i first mentioned, with "core" and "core.clj", the compiled contents of the core.clj get laid together with the "core" folder contents ?
04:52Glenjamindoes it help to think of clojure functions as java classes?
04:52noncomGlenjamin: i suppose it depends on the context of your thinking
04:53Glenjaminit's always package.package.package.Class
04:53noncomyeah
04:53Glenjaminbut in java only the Class has a file, but in clojure the namespace (which is the last 2 bits) has a file
04:54Glenjamini'm unsure if that helps, but i think i get what clgv is saying - and it had never ocurred to me before
04:57clgvnoncom: no in your case ...core.clj and ...core/some.clj have different namespaces, in that concrete examples the difference is an additional "some" package at the end
04:57hellofunkddellacosta just to confirm, while most Friend credential functions take a map, the cred fn to your oauth2 workflow just takes the actual access token, not a map
04:58clgvnoncom: though it depends which kind of clojure constructs you consider. since there is a difference between functions and deftype/defprotocol/defrecord
04:59clgvnoncom: just AOT compile your whole project and investigate where the implementation ends up
04:59ddellacostahellofunk: yes, you can see a simple example here: https://github.com/ddellacosta/friend-oauth2/blob/master/test/friend_oauth2/test_helpers.clj#L65-L67
05:00noncomokay, i will experiment more into this field. really, i saw all thsese things, but did not pay much attention, but now you got me interested
05:00noncomclgv: but ok, back to ccw
05:01clgvnoncom: conclusion: your namespace layout is just fine ;)
05:01noncomhave you ever tried to generate namespaces from templates? like have a command in your repl that creates a namespace in your project, filling it with a template? the problem i get is that eclipse does not recognize the created stuff..]
05:02clgvnoncom: also after refreshing the project?
05:02noncomclgv: here is my q on so: https://stackoverflow.com/questions/22784284/creating-a-source-package-folder-in-a-counterclockwise-project-programmatically
05:03noncombut the last statement about eclipse recognizing extensions is i am *not sure of*
05:03noncomyes, refresing does not elp
05:03noncomi though just maybe you've tried that
05:04noncomit does not really always recognize the created structure of folders and source files, be it .java or .clj
05:04clgvnoncom: does "leiningen->reset project configuration" help?
05:04noncomand sometimes does
05:05clgvdoes that actually have consequences on a freshly started REPL?
05:08noncomclgv: i do not remember.. it was some time ago, and now i'm coming back to the issue. i can't find that test project. i think i have to re-create the situation and test what you suggested..
05:08noncomthis will only be possible much later in today, so i will try and then, maybe tomorrow, write back..
05:08clgvok np.
05:09clgv"reset project configuration" should reset the classpath settings to what they need to be
05:09hellofunkddellacosta it is rather interesting that the oauth2 callback URL is taken out of the equation when integrating with Friend which instead specifies the landing-uri. someday I should pour through the source to figure out how that works.
05:10ddellacostahellofunk: what do you mean?
05:11hellofunkddellacosta i mean once you get through the google login form, you are taken back to the site landing page specified in the :default-landing-uri part of the friend/authenticate rather than the callback url specified with Google
05:12beamsoare you sure you haven't noticed it redirect from the callback url to the default landing uri?
05:12beamsoit could just be very quick
05:12hellofunkbeamso well perhaps it is, but that's nifty that Friend manages to override that
05:13beamsoisn't it more that google redirects to your specified uri, your app takes the tokens out and links them to a user's session then redirects to the default landing uri?
05:14beamsoi have to admit i did the oauth stuff with a phonegap app
05:14hellofunkbeamso well that depends on the library you are using. i tried another oauth2 library and it just honored the google callback url, you do what you want on that page.
05:15ddellacostahellofunk: try turning off https://github.com/cemerick/friend/blob/master/src/cemerick/friend.clj#L152
05:17ddellacostahellofunk: but you do certainly land on the callback before being redirected: google certainly doesn't know anything about your site other than what you tell it
05:18hellofunkddellacosta ok, it's just really fast and I find rather interesting that Friend takes over there. I don't mind it, just shows the extent of operation that chas did.
05:18ddellacostahellofunk: yes, it's a nice feature to have it redirect back to the page you intended to go to, agreed
05:18hellofunkddellacosta which would work regardless of the workflow in action
05:19ddellacostayep
05:19hellofunkunifies them
05:55hellofunkwhen you have a mutable atom in a ring server page, does each separate visitor to the server get only the initial state for the atom, or are changes to that atom visible to all visitors?
05:56justin_smithhellofunk: atoms are synchronized in state across threads
05:56justin_smithso changes made in one request should be visible to another
05:56hellofunkok, thanks.
06:17hellofunkso ddellacosta, i'm using this guy's little fn to pull the email from google from access token: https://coderwall.com/p/y9w4-g
06:18hellofunkddellacosta that fn uses a different oauth library. i tried to use his function with the access token returned from your oauth2 but that google user email fn seems to depend on the additional parts of the access token that your oauth2 strips out
06:20hellofunkddellacosta for example your returns a nice and clean map with just :access-token. google returns a larger map that also includes expiration time, and :id_token and more. so whatever reason, those seem necessary when using the google email fn mentioned above.
06:21ddellacostahellofunk: as I said previously, friend-oauth2 does not collect or use this information as it is not part of the oauth2 spec. If you want to use *all* the data google returns you'll need to patch friend-oauth2 yourself
06:22ddellacostahellofunk: otherwise, you'll have to use clj-http w/ the default way of accessing Google APIs via oauth2, what I linked you to yesterday
06:22ddellacostahellofunk: https://github.com/dakrone/clj-http, https://developers.google.com/accounts/docs/OAuth2?hl=en
06:23hellofunkddellacosta ah ok, so Google is returning things in its oauth2 that are not actually oauth2-specific?
06:23ddellacostahellofunk: yes, although I guess they may be part of the OpenID connect spec which I have not implemented as of yet
06:24ddellacostahellofunk: in any case, to save yourself some pain you may want to just patch friend-oauth2 for the time being to intercept what Google is sending you back, that will be simpler than doing a separate api call
06:24hellofunkddellacosta ok; it is a bit confusing that OpenID Connect seems to be a part of the OAuth2 process, as if they are synonymous
06:25ddellacostahellofunk: it is an extension to oauth2, and I was not aware of it (and may not have been around) when I started working on this
06:26hellofunkddellacosta when patching a library such as yours, I suppose that instead of linking to clojars i'd just download the source and place it along with mine?
06:28hellofunkapologize for how green I am with some of this stuff, general dev workflow, etc
06:29ddellaco_hellofunk: sorry, got disconnected
06:29hellofunkno prob ddellaco_ did you see my question?
06:29ddellacosta_hellofunk: the simplest way is just to include the workflow itself in your codebase
06:29ddellacosta_hellofunk: and replace it at such a point that the openid connect flow is supported
06:30ddellacosta_hellofunk: which will be Real Soon Now
06:30hellofunkddellacosta i've often wondered how github users collaborate; if multiple people are manipulating the same code base, I guess none of them would be using project.clj to specify dependencies, they'd just have the code in the src/ folder
06:31ddellacosta_hellofunk: ...most of the time if you are building a production app this is not an issue, in terms of dependencies
06:31ddellacosta_hellofunk: but it sounds like you need this ASAP so this is the best thing I can suggest
06:32hellofunkddellacosta when i look at a repo and see many contributors to it, i assume this means that most of them would have the entire source mirrored in their project rather than using a lein dependency, is that sorta right?
06:34ddellacosta_hellofunk: I'm not sure I follow; if there are many contributors to a clojure project, it just means folks have patched it and submitted a pull request/committed at some point. It doesn't indicate anything about how the contributors have used it. Perhaps they used checkouts to test it in the context of another project, or just ran lein install...if that's what you mean.
06:36ddellacosta_hellofunk: you don't necessarily even need to be running that project in the context of another one to test and make changes, if that's what you were getting at--but I'm not entirely sure where you were coming from with that question, sorry.
06:36hellofunkddellacosta, thanks -- having nor formal or institutional training or education in modern development workflows, and working mostly by myself, i'm often frustrated by how little i know about the general process that everyone takes for granted
06:36ddellacosta_hellofunk: ah, gotcha. Don't feel bad about asking questions, and sorry if I'm not always giving you the best responses.
06:37ddellacosta_hellofunk: just be patient and it'll become more clear
06:38ddellacosta_hellofunk: on that note, unfortunately I have to get going, but ping me again if you have questions. Hopefully some of the info I gave you will get you on your way.
06:38hellofunkddellacosta_ thanks again!
06:38ddellacosta_hellofunk: np, cheers. :-)
06:59cflemingHi everyone - I'm wondering how :refer-clojure :exclude works in cljs. Does it exclude symbols from cljs.core, macros, or both?
07:16ambrosebs*checks the source*
07:17cflemingambrosebs: I tried that, but still wasn't sure :-)
07:18ambrosebslooks like it excludes everything.
07:19ambrosebstry it: (ns my.ns (:refer-clojure :exclude [for])) (for [a [1]] a)
07:19ambrosebs:)
07:19cflemingSo for a given name, it'll exclude it from both? That was what I suspected, but couldn't tell.
07:19cflemingHehe
07:19ambrosebsyea I think the core-name? predicate in cljs.analyzer resolves core vars/macros
07:19cflemingThe problem is I need a symbol defined as both a macro and a sym - I could set up a test case but I'm lazy :-)
07:19ambrosebsand that takes :excludes into account
07:20cflemingOk, thanks - I'll assume that for the moment.
07:20cflemingThere's not much doc about a lot of these cases in cljs
07:20ambrosebsI'm sure we'll get to 0.1 one day.
07:21cflemingI'm working on indexing cljs now, it's surprisingly tricky
07:22ambrosebswhat does that mean?
07:22cflemingI'm working on indexing cljs for Cursive.
07:23cflemingIt's tricky because the same name can and frequently does refer to two things.
07:23ambrosebsoh. hi colin :D
07:23cfleming:)
07:23cflemingHi Ambrose
07:23ambrosebs(thought your name looked familiar)
07:24cflemingOf course, it's additionally tricky because there's no doc about how this stuff actually works, and I'm not familiar enough with the code yet.
07:24ambrosebsand you're getting lazy
07:25cflemingFortunately Clojure smiles on laziness.
07:25ambrosebsagreed
07:25cflemingThat's my excuse, anyway
07:25ambrosebsI always look up cljs.analyzer instead of running cljs code :P
07:25cflemingYeah, the code is actually really nice, it's very easy to understand in general.
07:26cflemingIt definitely looks like a v2 of the Clojure code :)
07:29ambrosebsyea. Looking forward to v3 with tools.analyzer.js
07:31cflemingNice.
07:31cflemingI must admit I'm a little lost with all the analyzers - I'm going to investigate them soon to get it all straight in my head.
07:32cflemingExciting things happening with clj compilation though, the GSOC projects look great.
07:38ambrosebsyea loving the foundation our students are building.
08:00noncomhey what's up with core.async?
08:00noncomso many talks were here
08:00noncomsuddenly all is gone
08:01noncomdid everyone finally understand everything about it/
08:01noncom?
08:02ambrosebsall gone?
08:03noncomwell, no more talks..
08:03noncomi loved reading them since that let me learn many new things
08:03noncomnow however i am here, there is not much of them...
08:03noncomor maybe i am here at wrong times...
08:05ambrosebsI think #clojurescript discusses it every so often
08:06noncomah, that's what - they moved to a separate channel
08:10centraphetaHey all, so I thought of a programming challenge: Given 7 9 8 7 6 5 4 3 2 5 6 7 3 4 2 4 5 8 7 = 476 Goal: find out what mathematical operators (minus, multiply, divide, add) satisfy that solution (476)
08:10centraphetaOrder of operation is variable.
08:10centraphetaDynamic programming :)
08:10centraphetaExample output: http://pastebin.com/yDpS3Na4
08:17centraphetalocks, :o how?
08:17centraphetalocks, Using dynamic programming?
08:26clgvcentrapheta: is there a dp strategy, i.e. does the bellman principle apply?
08:27centraphetaclgv, dp[i][j][k] = Can I make the number k using the numbers a[i ... j].
08:28clgvah right. that trick. large table then, exponential in the result size (476)
08:30centraphetaJust curious to see some clojure dp solutions :)
08:31clgvcentrapheta: well if they shall be really fast, it's only almost imperative with clojure syntax
08:32clgvdp is just nested loops anyway ;)
08:33mdrogalisJust Wiki'ed the Bellman principle. That was too much before coffee.
08:33clgvmdrogalis: will get much easier after the coffee ;)
08:34mdrogalisAs do most things. :)
08:35clgvmdrogalis: hm well, the wikipedia page does not have an easy top level explanation it seems ;)
08:36mdrogalisclgv: I didn't want to call you a liar, but.. :P
08:36centraphetaIf I want to make X with the numbers A[i ... j], then I find a position v such that A[i ... v - 1] can make Y, A[v ... j] can make Y', and either Y + Y', Y * Y', Y - Y', or Y / Y' is equal to X.
08:36centraphetaThat is how you compute A[i][j][X].
08:37centraphetaIf you want to find some sequence that does, then in A[i][j][X] you store the position at which you split (v) and the operator you chose.
08:37centrapheta_Every_ expression that you can form using the numbers in A[i ... j] is of the form (Y) op (Y'), where Y is an expression obtained from A[i ... v - 1], Y' is an expression obtained from A[v ... j], and op is either +, -, *, or /.
08:38mdrogalisWhat is happening. D:
08:38centraphetaIf I'm trying to find several, I'll store the several v, but that (since the number of answers is already exponential) will be exponential in space and time.
08:38mdrogalisMake it stop D:
08:38clgvmdrogalis: there are easier problems to learn DP ;)
08:38mdrogalisHa. I'm just kidding, at any rate. Carry on :P
08:39clgvin fact a trivial on is the Fibonacci sequence. a more representative but still simple one is binomial coefficients
08:40clgvso back to linear algebra and matrices ^^
08:41mdrogalisHah
08:59adsiscoany good library to connect to mysql besides sqlkorma?
09:02beamsoadsisco: clojure.java.jdbc?
09:05adsiscobeamso: which is better?
09:07alexherbo2Hi
09:08beamsoadsisco: i've only used clojure.java.jdbc
09:10ddellacostaadsisco: clojure.java.jdbc is lower level. You can use DSLs on top of it like HoneySQL or the more basic one available with clojure.java.jdbc (java-jdbc/dsl)
09:10dabbelingCljHi there! I got a complex JSOn document/file, which clojure lib fits best to drill in and extract data from JSON?
09:10ddellacostaadsisco: korma is a bit more magical and higher level, and wraps up more functionality in its DSL
09:12ddellacostadabbelingClj: take a look at https://github.com/clojure/data.json and https://github.com/dakrone/cheshire and see which one you like better
09:13dabbelingCljddellacosta: thanks, i have alook!
09:13alexherbo2How list all functions ?
09:13cshellIs there a way to build regex patterns by referencing other regex patterns in clojure?
09:14alexherbo2I’m writing syntax highlighting for Kakoune; i need the list of function names.
09:14cshellalexherbo2: http://clojure.github.io/clojure/
09:15ddellacostacshell: you're talking about somehow composing regexes? Haven't heard of anything like that in Clojure
09:16cshellddellacosta: Yeah, I’m writing a GC log parser and there are a lot of repeating patterns that happen so I was hoping to leverage some reuse
09:16shep-homecshell: sounds like you want a real parser :-)
09:16Glenjaminhttp://clojuredocs.org/clojure_core/clojure.core/re-pattern perhaps?
09:16shep-homehttps://github.com/Engelberg/instaparse
09:17shep-home"there may be times when it is useful to build parsers with parser combinators."
09:17alexherbo2cshell: is there a function to get this list?
09:17cshellshep-home: haha, yeah
09:18cshellGlenjamin: thanks - that might work actually
09:18alexherbo2or i have to wget the page and parse it
09:18ddellacostaalexherbo2: try (map first (ns-publics 'clojure.core)) for example
09:18cshellGlenjamin: I was using the #”…” syntax but that might not work for what I’m doing
09:19alexherbo2ddellacosta: thanks
09:19alexherbo2^^
09:19ddellacostaalexherbo2: np
09:36broquaintIf cshell was still about I would've suggested seqex - https://github.com/jclaggett/seqex
09:41ddellacostabroquaint: cool stuff
09:58eflynnis there anything wrong with a collection of atoms?
09:59ddellacostaeflynn: needs more context, but if you have a collection of atoms it begs the question of why you don't have an atom of a collection instead
10:00eflynnddellacosta: because the atoms would be shared in other collections, but yeah the same thought occurred to me too
10:01eflynnddellacosta: writing a scheme interpreter in clojure
10:02ddellacostaeflynn: what part of the interpreter is this?
10:02Glenjaminthe purpose of the atom-collections is some sort of reference lookup?
10:02clgveflynn: well if you never need to coordinate between the atoms to have some consistent operation on that collection that might be fine
10:04eflynnddellacosta: the environment part. you can see something like what i have here: https://github.com/gregsexton/SICP-Clojure/blob/master/src/sicp/ch4.clj this is not my code
10:05eflynnddellacosta: if you make scheme without set! or define it’s pretty easy
10:08ddellacostaeflynn: I'm not totally following what that code is doing, but if you needed an analogue to set!, could you just have something that looked up a value in a table inside (a collection in) an atom?
10:08ddellacostaeflynn: swap!-ed it, to be clear
10:09ddellacostaeflynn: sorry, that may not be too helpful...but good luck. Very cool project. :-)
10:12eflynnddellacosta: yeah it’s hella confusing. an environment is represented as a collection of ‘frames’ and if a frame is changed, other environments that share that frame need to see it.
10:13ddellacostaeflynn: I see, so that code actually does what you're talking about, huh--I see it makes a frame via creation of a new atom. Hrm
10:14eflynnddellacosta: it was converted from a scheme version so maybe it’s not very clojure-y
10:26dabbelingCljHow do I get the "type" of a clojure expression?
10:26cbp(type expr)
10:26dabbelingClj!
10:26dabbelingCljthanks i tried :type
10:28cbpdabbelingClj: that would work like this: (:type (meta expr)), but only for clojure values with that metadata added
10:29dabbelingCljcbp no its fine it works liek expected
10:54dabbelingCljI'm trying to acces data from a clojure Map, usually i use: (keys {:a 1, :b 2}), which gives: (:a :b), which is fine but Cheshire returns also keys which are not :keywords? how do i access those?
10:55llasram`,(let [m {"a" 1}] [(m "a") (get m "a")])
10:55clojurebot[1 1]
11:02dabbelingCljllasram`: why i need the let?
11:03sluukkonenyou don't, it's just for demonstration purposes
11:03sluukkonen(m "a") and (get m "a") where m is the map are the important bits
11:04dabbelingCljSo this is my code: (keys (parse-stream (clojure.java.io/reader "data.json"))) which gives : ("entities" "in_reply_to_status_id_str" "place" "user")
11:05mpenetdabbelingClj: cheshire can keywordise the keys btw
11:06dabbelingClj(get "user" (parse-stream (clojure.java.io/reader "C:\\Temp\\tweedlsclj2\\resources\\tweedls_data.json"))) <- nil
11:06mpenet,(doc get)
11:06clojurebot"([map key] [map key not-found]); Returns the value mapped to key, not-found or nil if key not present."
11:06dabbelingCljI dont get it should be dead simple...
11:06mpenetyou're inverting the parameters
11:06dabbelingCljah!
11:06mpenet,(get {"a" 1} "a")
11:06clojurebot1
11:06llasram`And Clojure takes a pretty extreme "garbage in, garbage out" stance
11:07dabbelingCljmakes sense!
11:09hyPiRionThere should be a clojure variant with support wheels for such mistakes.
11:09hyPiRionAnd I don't mean core.typed here
11:10dabbelingCljno its fine its an "ovious" API mistake on my side
11:11dabbelingCljcan I put that (parse-stream (clojure ...) in a def ?
11:12dabbelingCljha ok I always forget that i have to evaluate "every *new" expression in LT
11:13dabbelingCljnested gets I see a use case for -> and ->> :D
11:13Glenjaminif i have some related things i sometimes wrap in a (do)
11:13Glenjaminor just shift+cmd+enter to re-eval the whole file
11:14Glenjaminand i've got a keybinding for "save all + (tools.repl.namespace/refresh)"
11:16clgvdamn, I thought I could use "balagan". but it seems it extracts all possible paths from the given data and then filters those that match the query. that is not really usable with a data structure of 2GB and lots of arrays in it
11:16hhenkelHi all, I'm trying to cummulate the result of a for loop into a let binding. That works so far, only issue is, that I only get the last return value of the for loop: https://www.refheap.com/86232
11:17Glenjaminhhenkel: it's generally best to not think of for as a loop
11:17Glenjaminit's a list comprehension
11:17hhenkelI used trace to see that the for loop is executed two times and give me a result two times.
11:18hhenkelGlenjamin: yes, good point, thanks for the clarification.
11:18Glenjaminalthough this looks sort-of right
11:18clgvhhenkel: does config/substitute-all-the-vars return different keys?
11:18Glenjaminthe ->> is actually making it trickier to read though imo
11:18gfredericks(defmacro throw-data [s m] `(throw (ex-info ~s ~m)))
11:20mpenetgfredericks: should be in core, dunno how many times I wrote this
11:20hhenkelclgv: yes, I would say so. Every execution gives me a map.
11:20mpenetgfredericks: throw-ex-info, or throw+ or whatever
11:20gfredericksthrowx
11:21gfredericksthroan
11:21gfredericksthroat
11:21Glenjaminhhenkel: if every execution gives a map, you probably want (reduce merge) instead of into
11:21gfredericksthrone*
11:21mpenetfeel free to add this to catch-data, wouldn't hurt
11:21Glenjaminthen you basically have slingshot though, no?
11:21clgvhhenkel: huh? a map? well then "into" will use "merge" since you use "into" with a map as target. I thought it returns key-value-pairs
11:21mpeneta slim, slingshot
11:21gfredericksGlenjamin: without unnecessary features
11:22hhenkelclgv: Glenjamin: It gives me a datastructure descibing attributes of a server.
11:23Glenjamin,(into {} [{:a 1} {:b 2}])
11:23clojurebot{:a 1, :b 2}
11:23Glenjamin,(into {} [{:a 1} {:a 2}])
11:23clojurebot{:a 2}
11:23clgvGlenjamin: that's what I meant ^^
11:23Glenjaminhhenkel: can you give an example of what you want the input and output to be?
11:23clgv,(into {} [[:a 1] [:b 2]])
11:23clojurebot{:a 1, :b 2}
11:24clgvhhenkel: and that's what I thought your code does ^^
11:25hhenkel,(into {} ({:a 1 b:2} {:a 3 :b 4}))
11:25clojurebot#<RuntimeException java.lang.RuntimeException: Map literal must contain an even number of forms>
11:25clgvhhenkel: why do you use "into" if your "for" does not contain key-value pairs?
11:27PigDudeclojure has no notion of package privacy which means i need to make a huge namespace to share private functions between my code?
11:27hhenkelGlenjamin: I updated https://www.refheap.com/86232
11:27clgvPigDude: I would make them public.
11:27PigDudeif my code can require foo.util, so can anybody else, it seems like a clean API is more difficult to achieve in clojure unless you write very large namespaces
11:27PigDudethat's what i do now clgv
11:28cbp,(apply merge '({:a 1 :b 2} {:c 3 :d 4}))
11:28clojurebot{:d 4, :c 3, :a 1, :b 2}
11:28llasram`PigDude: You can annotate namespaces as :private. It's just a hint to the library user, but is an explicit one
11:28clgvusually it is a bad idea to make functions private anyway. there are some examples for that in clojure.core as well
11:28hhenkelclgv: I simply tried to adopt some code I was using at a different point and did not think about the datatype in the first place.
11:28PigDudellasram`: when would a code user see the :private metadata?
11:29llasram`PigDude: When the generated/manully-written documentation?
11:29clgvPigDude: how about an "api" namespace that contains only the functions a regular user is supposed to use?
11:30llasram`PigDude: It sounds like you expect people to just randomly depend on random namespaces, then burn down your house if you change anything they can access :-)
11:30clgvhhenkel: you want a vector or sequence of all the configs?
11:31clgvhhenkel: but you want to force immediate evaluation?
11:31clgvhhenkel: then use "doall" or "vec"
11:31clgvhhenkel: (into {}...) merges all your distinct maps together to one
11:32hhenkelclgv: okay, so I do "vec" instead of "into {}" then, right?
11:32clgvyes
11:33llasram~tias
11:33clojurebotTry it and see! You'll get results faster than asking someone in #clojure to evaluate it for you, and you'll get that warm, fuzzy feeling of self-reliance.
11:33llasramMmmmmm.... fuzzy....
11:34gtrakI like my peaches a bit cold.
11:34devnmushy peas, please
11:35hhenkelclgv: Thanks, that works like a charm.
11:36clgvhhenkel: better build up from scratch next time ;)
11:37hhenkelclgv: Yes, definitely.
11:39PigDudellasram: yes? :)
11:40PigDudellasram: this is honestly how i often see my relationship with code users when i work on a library
11:40PigDudellasram: you're probably right
11:40PigDudeclgv: that is what i do now, the API is in core
11:40PigDudeclgv: llasram thanks for the advice!
11:45clgvPigDude: http://steve-yegge.blogspot.de/2010/07/wikileaks-to-leak-5000-open-source-java.html
11:45PigDude:P
11:46PigDudeclgv: *I* have yet to see the case where java's security is useful, but i understand that in practice it's very important, and allows you to run untrusted code
11:47PigDudeclgv: (thinking of package privacy and such)
11:47PigDudeclgv: funny post bw
11:47PigDude*btw
11:48PigDude'The Agile Java community has denounced the Wikileaks move as a form of terrorism. "It was probably instigated by those Aspect-Oriented Programming extremists," speculates Agile Java designer Claudia Hewitt, age 29. "I always knew they wanted to use my code in ways I couldn't predict in advance," she added.'
11:49gtrakPigDude: steveyegge?
11:49clgvgtrak: yes ^^
11:49PigDudeyea clgv sent me the link
11:49gtrak:-)
11:49gfredericksVeyeg Geste
11:50gtrakthat was a much better age of his rants.
12:27shriphanihi. anyone here used quil? I have a question about images.
12:28dbasch~anyone
12:28clojurebotJust a heads up, you're more likely to get some help if you ask the question you really want the answer to, instead of "does anyone ..."
12:28shriphaniI am performing some animation using the standard routines and at the end I want the image to be displayed on top the animation one
12:28shriphanidone *
12:28shriphanithe image call seems to put the loaded image in the background
12:30nbeloglazovshriphani: can you show your code?
12:30shriphanisure one sec.
12:30shriphaninbeloglazov: https://www.refheap.com/86236
12:31shriphanisee the draw routine and the call to image at the end
12:33shriphaninbeloglazov: and that does this: http://shriphani.com/pics/bug.png
12:33shriphaniI want the image to lie on top of the animation. Is that not possible ?
12:36nbeloglazovout of curiosity, what happens if you switch renderer to :java2d or :p2d/:p3d?
12:37shriphaniyup that works !
12:37shriphaniwee !
12:41nbeloglazovwhich renderer works?
12:41nbeloglazovjava2d and p2d/p3d or only java2d?
12:43justin_smithshriphani: I think this has to do with how opengl handles identical z indexes
12:43justin_smithie. it handles them kind of indeterminately
12:51shriphaninbeloglazov, both java2d, p2d and p3d
12:51shriphanis/both/all/
12:54nbeloglazovshriphani: cool. Actually opengl renderer is not recommended to use in processing/quil anyway :)
12:55stompyjJust a poll, do people use jetty, tomcat, other app servers?
12:56justin_smithon aws I have used tomcat (via beanstalk)
12:56justin_smithbecause the was the mandated platform
12:56gtrakall the lein-ring stuff uses jetty, which means a lot of people use jetty
12:57justin_smithreally, http-kit (maybe a few instances) behind nginx/varnish is simpler to set up, and performs much better
12:57cbpI just use http-kit behind nginx
12:57justin_smithgtrak: at dev time, sure
12:57justin_smithlein-ring in production is not a good idea
12:57stompyjmy lein ring uberjar works find, but lein ring uberWAR is failing, with a very ambigious error
12:57stompyjI figured most people are using jetty (that what I’m currently trying to do)
12:57gtrakstompyj: we opted for dropping lein-ring and building a custom servlet.
12:58gtrakit's easy.
12:58gtrakstill using jetty though.
12:58stompyjwell, I’m just trying to checkout from git, lein ring uberwar, copy to jetty and bounce server. That should be super easy too
12:58stompyjbut ok
12:58stompyjenough people are using jetty that I shouldn’t necc. avoid it
12:59stompyjhas anyone seen when uberjar works, but uberwar fails?
12:59stompyjI’m just getting a NullPointerException, but nothing else relating to my project
12:59hiredmanstompyj: when are you getting the error?
13:00stompyjhiredman: immediately after running “lein ring uberwar"
13:00stompyjException in thread "main" java.lang.NullPointerException, compiling:(util.clj:90:1)
13:00stompyjoh geez
13:00stompyjI’m a moron
13:01stompyjignore me. :)
13:01cbplein profile.clj errors are ze worst
13:13bbloomdnolen_: i just discovered another use case for specify
13:13bbloomon the jvm side that is
13:13bbloomi have two different protocols in two different namespaces, but they have a common method name.... i can't use reify b/c then the names conflict as methods on the generated type
13:13bbloomoh well. i'll just need to use a deftype
13:13bbloomand extend
13:14bbloomor rename
13:15dnolen_bbloom: I thought that shouldn't matter, two different protocols in two different namespaces
13:15bbloomdnolen_: reify only creates class methods, not protocol methods
13:16dnolen_oh huh, did not know that - that seems like the real issue
13:17bbloomi guess so, but i don't know how you'd address it without changing the interop characteristics of reify and/or making it inconsistent with deftype
13:17bbloomdeftype has the same issue, of course
13:19Bronsabbloom: maybe making the method names for protocol interfaces include the namespace segment could fix it?
13:19dnolen_cool stuff http://rigsomelight.com/2014/06/03/devcards-taking-interactivity-to-the-next-level.html
13:19bbloomBronsa: would be a seriously breaking change for interop
13:21Bronsabbloom: yeah, that sucks
13:23bbloomdnolen_: video is a bit long so i just clicked through it. seems neat
13:40bhaumanbbloom: I suck at videos, it took me forever to get that stupid thing dome
13:41bbloombhauman: for introductory videos, the 60 second rule applies :-)
13:42bhaumanbhauman: I hear you, but way beyond my skill level
13:42bbloomwhen i saw "14:10" i immediately said "not gonna watch this" and only bothered to press play b/c david mentioned the thing
13:42bbloombhauman: designing videos is just like designing code: it's done not when there is nothing left to add, but when there is nothing left to take away
13:44bhaumanbbloom: yeah it’s a hard sell but, its something that IMHO was hard to express.
13:45bhaumanbbloom: Although apple did it in like 3 minutes
13:45bbloombhauman: you mean the playground demo? heh
13:51arrdemBronsa: t.a.jvm can't express the class method reach set of an expression in the general case, right? I'm pondering if there's static analysis I can do to prove out clojure.lang.Var/alter* or warn if present.
13:53seangrovebhauman: I feel you, you always want to spend time emphasis/explaining parts that you feel are important. Hard to resist that
13:59stompyjvideos are particularly tricky, we can scan text, so it’s easy to skim and find the good parts/parts we’re interested in, or scan quickly and figure out if the writing is worth reading
13:59stompyjvideos are a blind investment.
14:00Bronsaarrdem: well, if you require that all the dependencies must be analyzed by t.a.j, you might be able to write a pass that does that I
14:01gtrakthere needs to be like a clojure video feed.
14:01gtraktwitter acct
14:01gtrakit's hard to find good ones if I just go look for them, but sometimes that's what I want.
14:01gtrakfor working out or something.
14:02cbphow do you get the doc for a namespace?
14:02bhaumanseangrove: yeah its like when you try to talk a client down from adding music to there website.
14:03arrdemBronsa: okay, I'll play with it some. I think the answer is that you generally can't, but the hinting requirements on methdo invocations may enable the cases that I care about.
14:03arrdemthat or you can if you're willing to implement and eat an expensive pointer analysis.
14:04Bronsaarrdem: uhm derp. I assumed you were talking about static methods, not instance methods.
14:04arrdemBronsa: oh static methods are what I care about, instance methods are hard to impossible.
14:05arrdemso I should be alright.
14:08seangroveTime to meet the community
14:09bhaumanseangrove: good luck man
14:09TimMcFoley: Sounds of pots and pans hitting the wall, pottery breaking.
14:12aperiodicdakrone: is it a conscious choice that there is no way to set a default key-fn in cheshire?
14:12Jaoodseangrove: you gave up on cljs? :)
14:13seangroveJaood: Oh, of course not :) But we have some reasons for dealing with meteor
14:26dbaschwhy the rage seangrove?
14:27seangrovedbasch: Bad decisions winning again and again
14:27bbloomdbasch: dnolen_ myself and seangrove have all trashed shadow dom a bunch in this room, check the logs :-)
14:28dbaschbbloom: but why? I don’t know shadowdom but I’m sure it’s web scale :P
14:29seangrovedbasch: It's definitely web-scale, where web-scale means as horrible as everything else on the web :P
14:29bbloomdbasch: it's a very complex non-solution to the modularity problem of web pages
14:30dbaschwhy can’t we go back to the 80s, when screens were represented as grids instead of trees?
14:31justin_smithwhy not upgrade from trees to graphs? then we get fully fractal page rendering for free
14:31hiredmanemacs still does that
14:32hiredmanI was looking at the source for the mac gui for emacs and all the rendering code still treats the screen as a matrix of characters
14:32dbaschjustin_smith: then we can have turing-complete web pages
14:33TimMcDo everything in LaTeX.
14:33bbloomLaTeX, it's a lisp with fexprs! :-P
14:37dbaschI don’t even. http://stackoverflow.com/questions/24015415/clojure-defining-a-macro-that-uses-the-carret-metadata-syntax
14:39justin_smiththe dude seems to have a fundamental misunderstanding of what metadata is for (based on that and his other SO questions)
14:40amalloyi saw that one this morning, dbasch. didn't you comment on it? did it get removed, or am i inventing memories?
14:40dbaschamalloy: I removed my comment after reading the other question
14:40dbaschamalloy: I have no idea what that person is trying to do
14:41Rayneswhat is this i dont even
14:42dbaschI also don’t understand why people are so fascinated with macros, or think they are the solution to random problems
14:42dbaschit’s like regular expressions
14:43amalloy*shrug* the new, novel thing you don't understand always seems like it must be the easy solution to all your hard problems
14:43ToxicFrogdbasch: because after using a language that has them for a while, you really miss them when you go to a language that doesn't.
14:43ToxicFrogMuch like regular expressions.
14:44RaynesI actually don't really ever miss macros in other languages.
14:44ToxicFrogOh. I do.
14:44RaynesMost of what I've used macros for that actually required macros has been relatively superficial syntactical things.
14:44dbaschToxicFrog: you reminded me of that famous question about parsing html with regular expressions
14:44ToxicFrog(no, cpp does not count)
14:45ToxicFrogRaynes: well, yes, macros are syntax transforms, their most obvious application is making new syntax for things that are inconvient to do "plainly".
14:45hyPiRionRaynes: You have never tried to perform a variadic loop unroll through #define in C, it looks like
14:45amalloydbasch: it's really more of a famous *answer*. the guy didn't even ask to parse html with regular expressions, he was just looking for a particular tag
14:45bbloomi much prefer eval over macros
14:45bbloomi'm guilty of (doseq [...] (eval `(...)))
14:45amalloywat
14:45bbloomworks great, much easier to reason about & write than macros
14:46dbaschamalloy: yes, this one http://stackoverflow.com/a/1732454/586880
14:46amalloybbloom: that's madness. you can just use a local macro
14:46bbloomamalloy: but then i have to NAME the macro :-P
14:46amalloybbloom: pull in macrolet, man
14:46amalloyor any utils library with a cousin of it
14:46sbi_lol :D
14:47RaynesToxicFrog: Sure, but I just don't often find places where a macro makes things objectively better.
14:47dbaschI assume that the maintainer of my code will be an idiot, and that’s true even if I’m the only person to ever see my code
14:47justin_smithmost of the time if I need to use a macro it is because I am using a macro and need a macro to compose functionality with it
14:47bbloomhow is it any different to do (defmacro m [args] `(...args...)) (m a b c) rather than (doseq [x [a b c]] (eval `....
14:47dbaschespecially if I’m the only person to see my code, as I get dumber with age
14:47RaynesIt's certainly an important and amazing feature of lisps.
14:47RaynesBut I can live without it in other languages.
14:47justin_smith"if I need to write a macro" that is
14:48bbloomi may be a crazy person, but i no longer feel that eval is evil :-P
14:49Jaood you are evil ;)
14:49RaynesYou're pretty screwed up, man.
14:50Jaoodwe should be talking about swift
14:50bbloomi find that i need a lot less syntax-quote and unquote to do simple top-level eval usage
14:51dbaschJaood: swift is so yesterday, nobody cares anymore :P
14:51dbaschI looked at it and my first impression was that it looked like a proprietary version of go. Not interesting unless you need to do iOS development.
14:54Jaooddbasch: and OS X
14:55dbaschJaood: well, you have more choices if you’re sticking to OSX
14:59amalloyhaha, excellent. google's first autocomplete suggestion for "printstacktrace s": "should be removed"
15:00bbloomhaha
15:01TimMcamalloy: "clojure is |nil"
15:01amalloyit turns out to be not quite as funny: apparently that's the warning message netbeans gives you if you have "e.printStackTrace();" as the body of an exception handler
15:02bbloomsome IDE decided that was as good enough as any codegen default
15:02bbloomand people leave it there
15:02dbaschjust like FIXME in clojure projects :P
15:06TimMcI had to add this to a java project to be able to use some of the Clojure persistent data structures and I don't know why. :-( https://github.com/timmc/johnny/commit/340a217e4554ca296351affbc20911aeb805d85a#diff-c6d534713fa591414088043313740566R18
15:07TimMc(If this sounds familiar, I'm revisiting a project from a while back: http://clojure-log.n01se.net/date/2013-10-25.html#17:15)
15:07TimMcApparently there's something weird with the order in which Clojure classes have to load.
15:09hiredmanyeah, RT really wants to be loaded first
15:09TimMcRT.init() yells at you if you call it.
15:09hiredmansure
15:10hiredmanyou just need to load the class, not call any methods
15:10hiredmansimilar to jdbc driver kind of things
15:10hiredmanClass.forName("clojure.lang.RT");
15:11TimMcYeah, I suppose that would be more clear to the reader.
15:11TimMcThe error I get if I don't preload it is really bizarre though.
15:12TimMcSomething about contains? not supporting PersistentList -- but this occurs during PersistentTreeSet's class init.
15:14hiredmanTimMc: is the java app multithreaded at all?
15:14hiredmanit could be some kind of concurrent classloading issue
15:15TimMcNah, I'm just running the JUnit tests.
15:18l1xguys, what is your take on dealing with files in Clojure? Should I use java.io.File to pass in to functions dealing with files or just string and convert it locally to a File type? both cases how would you deal with the different path element separators (windows
15:18l1xand macos)
15:18amalloy$google raynes fs
15:19lazybot[Raynes/fs · GitHub] https://github.com/Raynes/fs
15:19justin_smithl1x: also, the existing java libs already abstract over that stuff, and it is not hard to interop with them
15:21justin_smithl1x: a project I contributed to once tried to account for the separator used by each OS, but it turned out that broke things and the right way is to use '/' everywhere and let java.io.File decide when that needs translating
15:21l1xjustin_smith: i was thinking having a function that reads files, but i am not sure if i should pass in a [] with the path so it can construct the platform specific File of it or should i pass in a File from each function i have
15:21cbplix File can take multiple strings and will automatically add the separator no?
15:22l1xcbp: exactly
15:22justin_smithcbp: sure, but if you use '/' it turns that into the right separator for the platform
15:26cbpyou see my sick pr sdegutis, i got you 2 stars
15:26cbper
15:26cbpignore that
15:28justin_smith /ignore that
15:46johnwalkerwhy doesn't (.start (Thread. #(println "print"))) print "print"?
15:47johnwalkero_o
15:49cbpjohnwalker: it does
15:50cbpjohnwalker: if you're using cider it's not consistent with where it shows you your prints
15:50johnwalkeroh what the fuck
15:51cbpwhen you use multiple threads
15:51johnwalkerthat explains a lot actually
15:51johnwalkerbecause using .run gave me some output
15:51johnwalkerthanks cbp
15:52dbaschjohnwalker: check your *nrepl-server* buffer
15:54johnwalkerright on dbasch
15:55johnwalkerthanks :)
16:09fifosineIs there a way I can define a set but not generate its contents (because it is very large) and ask for a random member of that set?
16:10bbloomfifosine: clojure's collections are extensional
16:10fifosinebbloom: What does that mean?
16:10bbloomfifosine: mathematical term for the opposite of another mathematical term: intentional
16:10bbloomextensional means the collections list all the members
16:11bbloomintentional means it lists the criteria to be a member
16:11ystaelbbloom: inten_s_ional
16:11bbloomystael: dur, you're right
16:11bbloomystael: amalloy can tell you that my spelling sucks
16:11bbloomfifosine: anyway, the point is: you can just define a function for membership testing & pass that function around
16:12bbloomfifosine: you don't need it to be a clojure set
16:12fifosinebbloom: In the end, what I'd like to do is be able to query a random color (from the 256^3 space of colors) that is not in the given set of colors. What I don't want to do is have to make that entire color space.
16:12bbloomjust use a predicate directly
16:12l1xis there an easy way to pass in a list of a function that calls an another function and puts the list elements as parameters?
16:12bbloomfifosine: what's wrong with simply creating a random-color function?
16:13bblooml1x: your explaination is not clear, please give an example
16:13fifosinebbloom: So, inside this random-color function I generate a random color, then check that it doesn't exist in the given set. If it does, then what, call random-color again? I don't want the stack to explode as the given set grows
16:14l1x(defn test [&params] (test2 param0 param1 param2....paramN))
16:14PigDudei noticed lein taking longer and longer, with all plugins removed it take 10s to start, without them it was taking 30+s. what do you do about this?
16:14fifosinebbloom: I want a random and unique color
16:14Bronsal1x: I think you're talking about apply
16:14l1xBronsa: hmm maybe
16:14PigDudeoh sorry wrong channel
16:14Bronsa,(apply + [1 2 3])
16:14clojurebot6
16:14ystaelfifosine: the algorithm you give is tail recursive, so if you use `recur` you need not worry about the stack
16:14fifosineystael: You're right, didn't realize
16:14ystaelthis is a common way to generate random elements when the excluded set is small
16:15bbloomfifosine: how many colors are you generating?
16:16fifosinebbloom: At some point, up to half of all colors
16:16fifosinebbloom: Would a set difference make more sense in this case?
16:16bbloomfifosine: setting aside that i feel like you've got a serious design problem that i don't understand yet... you'd need a custom data structure to do this efficiently
16:17bbloomyou have a total ordering of colors, so you can create an extent map
16:17bblooman extent map is a sorted set of ranges of used colors
16:18bbloomthere are many extent map data structures, such as bitmap trees and stuff like that
16:18bbloombut really, i think this is totally crazy... so please explain what you're actually trying to accomplish
16:18bbloomi'm sure there is a much simpler solution
16:18fifosinebbloom: I'm trying to paint a canvas with 1 pixel per unique color
16:19bbloomfifosine: as like an art project? or what?
16:19fifosinebbloom: For fun
16:19bbloomyeah, that's what i meant
16:19bbloomok
16:19bbloomwell, if it's for fun, go crazy :-P
16:19fifosineI still want it to be fast
16:20amalloyfifosine: so just loop over all colors, in order, right? do you need it to be random?
16:20fifosineamalloy: I want it to be random
16:20ystaelfifosine: so essentially your problem is: generate an initial segment of length canvas-pixel-count, of a permutation of the vector of all 2^24 colors, where that permutation is chosen uniformly at random over all permutations of the color space?
16:21bbloomystael: that's an interesting way to reason about it
16:21fifosineystael: See the top answer here: https://codegolf.stackexchange.com/questions/22144/images-with-all-colors
16:22fifosineI wanted to do this in clojure
16:22fifosineSo I'm curious to find a fast way to query a unique color
16:22fifosineYes, the colors are a permutation, but a specific permutation
16:23ystaeloh. if you don't want a _random_ permutation, it's much easier, you just have to prove that your generator does not visit the same tuple twice
16:24ystaelwhich is easier to do by static analysis than by choosing a clever data structure to make that fact manifest in the code
16:24fifosineystael: What static analysis is available?
16:25bbloomhe means simply reasoning about your code
16:27fifosineystael: The solutions I see are: generate the color space, select a random color, and remove it one-by-one; perform a set difference between all colors and all used colors and select a random one; or recursively select a random color until we find one that has not been chosen.
16:27amalloyfifosine: for example, you can use the chinese remainder theorem to generate an ordering that appears random and is guaranteed to not repeat
16:27fifosineNone of these seem like the best approach
16:28ystaelfifosine: You're going back and forth on whether you want the colors to appear in a random or deterministic order
16:28bbloomfifosine: do you have something slow working yet?
16:28bbloomstart there!
16:28amalloythink of each color as a number from 1 to N (where N is a prime number somewhere near 2^24). pick another prime P, and a "seed" color X. compute X*P, X*P*P, X*P*P*P, all mod N
16:29fifosinebbloom: I do, but it's written in python, so I'm trying to convert it
16:29amalloythose are guaranteed to not repeat until you've exhausted all choices
16:29bbloomamalloy: that's neat!
16:29fifosineamalloy: This is the chinese remainder theorem?
16:29amalloyas i remember it, anyway. number theory was ten years ago; the details may be a smidge off
16:30fifosineShould N be larger than 2^24?
16:30amalloyif you want all possible colors available, then yeah, pick the smallest prime larger than taht
16:30amalloy(and ignore any results which are too large to be rendered as a color)
16:32ystaelamalloy: I don't think that's good enough; you need P to be a primitive root modulo N (generator of the multiplicative group of Z/NZ).
16:32amalloy,(let [n 13, x 5, p 7] (for [i (range n)] (mod (apply * x (repeat i p)) n)))
16:32clojurebot(5 9 11 12 6 ...)
16:32amalloyystael: i don't know what that means, but i think i'm right as long as P and N are both prime (as i stipulated)
16:32amalloy&(let [n 13, x 5, p 7] (for [i (range n)] (mod (apply * x (repeat i p)) n)))
16:32lazybot⇒ (5 9 11 12 6 3 8 4 2 1 7 10 5)
16:33fifosineystael: amalloy's conditions are more strict than yours, I think
16:34ystael&(let [n 13, x 7, p 5] (for [i (range n)] (mod (apply * x (repeat i p)) n)))
16:34lazybot⇒ (7 9 6 4 7 9 6 4 7 9 6 4 7)
16:34ystaelamalloy: Nope.
16:35fifosinenice example
16:36amalloyhuh. well, i don't see what's wrong, ystael, and your objection was beyond my vocabulary. can you explain in baby-talk for me?
16:37ystaelYou're asking for (1, p, p^2, ...) to visit all the nonzero (multiplicatively invertible) entries of Z/nZ.
16:38ystaelThis does happen for some p, but not all p, and it's not directly identifiable with whether or not p is prime.
16:39ystaelIf p does generate all of the nonzero entries of Z/nZ in this way, it's called a primitive root modulo p. The number of primitive roots modulo p is Phi(p - 1) (Euler Phi function) which can be proved with a little bit of group theory.
16:40GFREDERICKSdotCOcemerick: ping
16:40ystaelSorry, some wrong letters there; every 'p' after "it's called a primitive root modulo" in that last line should be an 'n'.
16:42ystaelIf you know about cyclic groups, this is rooted in the fact that the multiplicative group of Z/nZ (n prime) is a cyclic group of order (n - 1). For n = 13, this means a cyclic group of order 12.
16:44ystaelBut that has a bunch of proper subgroups -- 7 happens to be a primitive root, but neither 7^2 = 10, 7^3 = 5, or 7^4 = 9 is one.
16:44ystael(because (7^2)^6 = (7^3)^4 = (7^4)^3 = 7^12 = 1)
16:45gfredericksystael: because 2 and 3 and 4 divide 12 amirite?
16:45ystaelgfredericks: precisely
16:45amalloyyeah, i'm afraid introductory number theory was the furthest i got in that direction. i'm now just wondering what it is i misremembered, and particularly puzzled that i gave an answer that was *close* to being right
16:47gfredericksI've thought a lot about how to visualize groups as anything other than a multiplication table and never came up with anything promising
16:47ystaelamalloy: It's a beautiful idea and I'm going to steal it if that's OK, but for it to work you need to check that p is a primitive root
16:49amalloyyes, feel free to steal it. it's not like a groundbreaking number-theory result i invented myself
16:49amalloyystael: there's guaranteed to be (at least) one p that works for any given n, right?
16:50amalloybut you can't just pick any prime p like i suggested
16:50gfredericksclojurebot: this thing with N and P and some colors is a groundbreaking number-theory result that amalloy invented himself
16:50clojurebotOk.
16:50ystaelamalloy: Yes, in fact there are Phi(n - 1) of them (and most of them may not even be prime when reduced modulo n)
16:50ystaelFor n = 13, they are 7^j, where j is relatively prime to 12
16:51ystael(and that's true in general -- if you find one root p, the rest are p^j, where j is relatively prime to n)
16:51amalloyrelatively prime to n-1
16:51ystaelyes, right, sorry
16:52amalloythat sounds familiar now. at least i'm glad i didn't completely misremember
16:55gfredericksclojurebot: what is your favorite number
16:55clojurebotAlles klar
16:56edlothiolbtw, this is basically a (special case of a) linear congruential generator
16:58edlothiolor, according to wikipedia, a Lehmer RNG
16:58pbostromI have a ~50MB text file that I read into a byte-array, I want to do a search and replace on the file now, would you just shell out to sed, or stay in the JVM and try to do some stream processing?
16:58pbostrom
17:02Glenjamingenerally i believe the advice is once you're in the jvm - stay there
17:03noncom|2jvm for sure
17:03amalloywhy byte array? text isn't bytes, it's characters
17:03pbostromI read it from a zip file
17:04noncom|2is there a way to merge two {} but where matching keys values won't be replaced, but merged too
17:04noncom|2?
17:04Glenjaminmerge-with
17:04Glenjamin(doc merge-with)
17:04clojurebot"([f & maps]); Returns a map that consists of the rest of the maps conj-ed onto the first. If a key occurs in more than one map, the mapping(s) from the latter (left-to-right) will be combined with the mapping in the result by calling (f val-in-result val-in-latter)."
17:04noncom|2cool! is it deep?
17:05bbloomnoncom|2: no, but you can make it deep
17:05noncom|2,(merge-with {:a 1 :b {:c 2 :e 3}} {:b {:k 2}})
17:05clojurebot{:b {:k 2}}
17:06noncom|2ummm, it killed :a ... ?
17:06bbloomnoncom|2: you didn't pass it a function
17:06noncom|2and lost the original :b
17:06noncom|2ah
17:06amalloynoncom|2: you just merged {:b {:k 2}} with itself
17:06bbloom,(merge-with merge {:a 1 :b {:c 2 :e 3}} {:b {:k 2}})
17:06clojurebot{:b {:k 2, :e 3, :c 2}, :a 1}
17:06noncom|2wow!
17:07bbloombut "deep" is ambiguous, so you have to give it the merge function you want, which can be recursive in however you need it to be
17:08noncom|2yeah, gotta figure it out.. words are easy: i want to combine two maps so that nothing is lost. but the code...
17:09noncom|2oh i can just see if the arg is a {} then, repeat this again, else just return the arg
17:09noncom|2i guess..
17:09noncom|2gotta try
17:09bbloomconsider: what happens if you combine a {:x 1} with {:x {:y 2}}
17:09noncom|2hmmm... well, according to the current task, the second should be taken..
17:09noncom|2nice, one more case to watch for :)
17:10noncom|2oh no, wait, i am wrong
17:11bbloomlike i said, deep merge is ambiguous, you may be better off just writing a recursive function by hand to cover your particular needs
17:11noncom|2according to the task, :x must either both be maps which are to be combined, or a value (int/double/[]) which is to be replaced
17:11noncom|2bbloom yeah..
17:11amalloynoncom|2: i mean, one reasonable interpretation of "deep merge" is in flatland.useful.utils/adjoin
17:12amalloythe implementation of which is a bit hairier than you might like, if you wanted to use it as a base to write your own; but its behavior is pretty nice
17:12Glenjaminmy general on opinion on deep-merges is try not to have a general deep merge if you can
17:12Glenjaminlet them be specific to whatever it is you're merging, including appropriate semantics
17:13bbloomyeah, i find that general-purpose recursive combiners don't exist that much in practice
17:13amalloysure. adjoin only behaves as it does because that's what protobufs do when you concat them together; other reasonable options exist
17:14noncom|2cool, looked at flatlands adjoin.. it's giving thoughts
17:14noncom|2yeah, i will tailor things for the particular task. this is not an abstract supermerger haha, i got a very exact case
17:59yeoj___I have a long-running clojure data migration app, moves about 50 million rows. For the first 10 million performance is great, and then it just slowly drops off from there.... what should i be looking for? I see no telling reflection, and have blindly been messing with my jvm options... any tips?
18:00Glenjaminyeoj___: you probably want to profile it
18:00Glenjamincheck out jvisualvm
18:00yeoj___ok, but i would like to run it on the sever... so i'll need to proflie from my laptop to this server i think
18:00yeoj___if i run on my laptop through lein it's not the same i don't think
18:01Glenjaminthat is doable
18:01Glenjaminalthough a smaller reproducible test case will make it easier to measure and test hypotheses
18:01yeoj___Glenjamin: ok thanks i'll read up on it
18:09justin_smithyeoj___: you can use an ssh tunnel (ssh -L ...) to access the dt_port of the server jvm process from your local machine
18:09justin_smithso the job is done on the server, and the profiling can happen locally
18:10yeoj___justin_smith: ok... i'm reading up jstatd now and it has me setting up a security policy and port/etc. with ssh would jstatd run locally on laptop? What is the dt_port?
18:12justin_smithyeoj___: actually I meant the transport=dt_socket option to the jvm
18:12justin_smithsocket, not port
18:12justin_smithhttp://blog.javachap.com/index.php/debugging-in-java/
18:12amalloy<3 ssh -L
18:13justin_smiththat link above describes how to tell it what port to expose etc.
18:13justin_smiththen ssh -L will expose that remote protected port on your local machine (without exposing it to the rest of the world)
18:14yeoj___ok i'll give it a shot
18:14justin_smithamalloy: yeah, one of those little things that has pretty much totally changed my computer using life
18:14yeoj___so i'm thinking i probably need to stop the running job and plug in some debug options
18:14justin_smithyeoj___: once you have the port forwarded from remote, and the remote process is running, jvisualvm will give you the remote process as a clickable thing to interact with
18:15justin_smithyeoj___: yeah, unless you had it open a socket, probably
18:15yeoj___i'm hoping UseLargePages and AggressiveOpts doesn't confuse the debugger or anythnig
18:15dbaschyeoj___: running jvisualvm over ssh requires patience though, I’d exhaust other options first
18:15justin_smithyeoj___: anyway, you get better info if you profile from the beginning of the process (when the performance is OK)
18:15yeoj___ok sounds good
18:16amalloydbasch: really? i've never had any trouble running yourkit over ssh; is jvisualvm worse, or is yourkit bad too and i'm just not picky?
18:16justin_smithI am sure it is linear with the amount of data you are trying to crunch in either case
18:17dbaschamalloy: I didn’t have any trouble with jvisualvm, it’s just that I usually ran it on aws servers and it was a bit slow for interactive sesions
18:17justin_smithso in depth profiling is one thing, quick snapshots are another, etc.
18:17dbaschsession
18:17dbaschs
18:17arohnerI remember seeing a blog post a few months ago /join #clojurescript
18:17arohnergah
18:17arohner^^ that's ADD, folks
18:17justin_smithdbasch: so was jvisualvm being run remotely with X forwarding, or jvisualvm locally with forwarded dt_socket port?
18:18amalloyoh god, surely not x forwarding
18:18dbaschjustin_smith: X forwarding
18:18justin_smithyeah that is not what I was suggesting at all, X forwarding is a pain
18:18justin_smithunless you have a very fast connection
18:18amalloyi've learned my lesson about x forwarding: never do it to anyplace outside of the building you're in
18:18justin_smithexactly
18:18amalloyit's so, so much worse than vnc. x11 assumes a fast connection to the display
18:19justin_smithdbasch: next time try using ssh to forward the dt_socket, it will be worlds better
18:19awwaiideh. just do it over ssh -CX
18:19awwaiidand make your window small
18:19awwaiidvery small
18:19dbaschjustin_smith: you’re right. We were doing other things that required X forwarding so just went with the usual
18:19llasramHuh. I've never had any big problems with X forwarding, at least within the same city
18:20dbaschI’ve run firefox over X forwarding from a different continent because I had no choice
18:20llasramjustin_smith: Oh man, if you think `ssh -L` is awesome, check out `ssh -D`
18:21justin_smithllasram: oh, very nice
18:21amalloyi don't understand what -D does
18:22llasramamalloy: Creates a SOCKS proxy tunneling from your local system out the remote SSH endpoint
18:22justin_smithhttps://help.ubuntu.com/community/SSH/OpenSSH/PortForwarding
18:23justin_smiththat tries to describe the various distinctions of forwarding types
18:24justin_smith"For example, dynamic port forwarding lets you bypass a company firewall that blocks web access altogether."
18:26yeoj___so with ssh -L , i have the app running (waiting for debugger) remotely with 1100 as the "address" with dt_socket
18:26yeoj___so can i still ssh over port 21 with a different user?
18:27dbaschyeoj___: if you mean port 22 yes, sure
18:27sbi_sure you can
18:27yeoj___ah, right 22
18:27justin_smithwell -L can link up any two arbitrary ports
18:27yeoj___i'm confussed over the manpage then, where do i reference port 1100 (the dt_transport socket) ?
18:28yeoj___ssh -L 1000:remotehoste:1000
18:28yeoj___(i don't put 22 in there anywhere? )
18:28justin_smithno
18:28justin_smithssh uses 22 implicitly
18:28justin_smithalso the port numbers are arbitrary as long as they are accessible - visualvm just does a linear search for sockets that are serving dt_sockets
18:29justin_smith(I checked the source because I was working on something related)
18:29yeoj___ah ok
18:29llasramThat's uh, weird (the localhost port scan)
18:29justin_smithalso don't specify remotehost
18:29amalloyyeoj___: the idea with -L is, for example, `ssh -L xyz:localhost:abc someserver` - this says "ssh to someserver, and additionally start a server on my current machine's port xyz. if i try to connect to that port, then forward me through the ssh session to localhost:abc instead"
18:29justin_smithllasram: well the jvm has no "registry"
18:30justin_smithinstead of remotehost specify "localhost" or "127.0.0.1"
18:30yeoj___ohhh i see ok i thought the "host" bit in the man page was remote
18:30clojurebotPardon?
18:30justin_smithyou are telling remote who to connect to
18:30justin_smithin case you are using it proxy style
18:30justin_smithit really should have a "localhost" default mode I think
18:31yeoj___ok so to jvisualvm it thinks it's localhost, and doesn't care on the port,
18:31justin_smithright
18:31yeoj___i see in the console "Debugger failed to attach: recv failed during handshake: Resource temporarily unavailable"
18:31justin_smithhmm
18:32justin_smithusing "localhost" or "127.0.0.1" as the remote?
18:32justin_smithbecause dt_socket is opened for local access only for obvious security related reasons
18:32visof,(map (fn [k v] (format "%s -- %s" v k)) {"Hello" "World"})
18:32clojurebot#<ArityException clojure.lang.ArityException: Wrong number of args (1) passed to: sandbox/eval25/fn--26>
18:32yeoj___i did this at bash: ssh -L 1100:localhost:1100 remote_user@remote_server
18:33visof,(map (fn [k v] (format "%s -- %s" v k)) ["Hello" "World"])
18:33clojurebot#<ArityException clojure.lang.ArityException: Wrong number of args (1) passed to: sandbox/eval51/fn--52>
18:33visofwhy this don't work?
18:34justin_smithyeoj___: ok, the should work if there is a dt_socket on that thread remotely
18:35justin_smithyeoj___: and visualvm does show that app as being there?
18:35justin_smith*that process
18:35yeoj___trying again with 127.0.0.1
18:35yeoj___i hope this is not a windows/cygwin thing. ugh.
18:35justin_smithvisof: try an extra pair of [] - fn is only getting one arg right now - the thing mapped over should be pairs of things for that code to work
18:36amalloyhe'll need more than one extra pair of []s to make that weird code work, justin_smith. he perhaps means apply, not map
18:37justin_smith,(map (fn [k v] (format "%s -- %s" v k)) [["Hello" "World"] ["gimme" "beer"]])
18:37clojurebot#<ArityException clojure.lang.ArityException: Wrong number of args (1) passed to: sandbox/eval77/fn--78>
18:37amalloyfor the vector version, anyway. i guess for the {} version, extra []s in the arglist would do it
18:37justin_smith,(map (fn [[k v]] (format "%s -- %s" v k)) [["Hello" "World"] ["gimme" "beer"]])
18:37clojurebot("World -- Hello" "beer -- gimme")
18:37justin_smiththat is what I had in mind
18:38amalloyi'm imagining an alien has just landed his spacecraft and is trying to communicate using a phrasebook, and the best he can come up with is "world, hello. beer, gimme"
18:38yeoj___yeah, its still giving me this: Debugger failed to attach: recv failed during handshake: Resource temporarily unavailable and i see two local apps in jvisualvm but i don't think they are my remote app... it also says "not supported for this jvm" in the details.
18:39justin_smithyeoj___: do you see the list of processes to connect to change if you start / stop the server on the other end?
18:41yeoj___justin_smith: no
18:41yeoj___same two on the laptop
18:41yeoj___it's not getting hooked up; i'm googling this Debugger failed to attach: recv failed during handshake: Resource temporarily unavailable
18:42justin_smithyeoj___: is jvisualvm giving this message, or ssh?
18:42yeoj___ssh
18:43justin_smithhmm
18:43yeoj___it's a console application (the clojure one) and it's actually stdout from that console app. the one that moves 50 million rows.
18:43yeoj___(the one i changed the java debug options/dt_transport/etc. stuff)
18:43yeoj___the ssl -L one logs me into another terminal (through cygwin/bash) and then just sits there
18:43yeoj___no idea
18:44justin_smithyeoj___: you mentioned windows, this looks relevant: https://netbeans.org/bugzilla/show_bug.cgi?id=48170
18:44justin_smithyeoj___: it could be permissions on your local side for creating that port?
18:45yeoj___ah, maybe.
18:45justin_smithyeoj___: maybe relevant "if I add "server=y" to the runjdwp option, everything works"
18:46amalloyyeoj___: ssh -L will open an ssh terminal, just as if you didn't include -L
18:46amalloybut it also opens a local socket, which persists until you close that ssh session
18:46yeoj___justin_smith: i tried the server=y bit as well. :/
18:46yeoj___i wish jvisualvm was an ncurses app
18:47yeoj___i wish everything was an ncurses app.
18:47amalloyor an emacs major mode
18:47sbi_unicorns!
18:49arrdemBronsa: ping
18:54justin_smithyeoj___: this is a command line app http://jrat.sourceforge.net/
18:54justin_smith(with a separate viewer that can run locally after importing the dump, it seems)
18:55Bronsaarrdem: pong
18:55arrdemBronsa: sorry it's late, what would you like in terms of a patch for making t.e.jvm check *compile-files* to write .classfiles?
18:56arrdemI'm looking at emit.clj:1336 (emit-class) as the obvious candidate, but I need to read this more carefully I suspect.
18:56yeoj___justin_smith: found this: Oracle/Sun changed the JVM debug connection handshake in the 1.7 JVM series; somewhere after update 2.
19:01Bronsaarrdem: I don't think dumping the bytecode to a classfile is all it's going to take to add AOT compilation to t.e.j, it should probably compile a loader class too
19:01justin_smithyeoj___: oh, so you may need matching jvms
19:02Bronsaarrdem: see https://github.com/clojure/clojure/blob/master/src/jvm/clojure/lang/Compiler.java#L7235
19:04arrdemBronsa: yep okay so this is going to have to be a separate emitter that tracks & registers all emitted classes for load class generation. I'll fool with this tomorrow then.
19:04arrdemthanks as always
19:05dbaschyeoj___: it might be easier to just do it with X forwarding at this point. It would be slow though
19:05yeoj___dbasch: yeah. i wonder if profiling locally on this laptop through lein would yeild anything interesting at this point too.
19:06dbaschbut if it’s a one-off, it’s not *that* horrible
19:06yeoj___i don't even have x install on t he server
19:06Bronsaarrdem: np. I haven't really looked into what's going on with the __load/__init methods there but feel free to ask for help if you need any
19:07PigDudedo [patterns to re-matches have to be anchored?
19:07PigDudei'm finding that unanchored patterns only match .. in the repl, !
19:07dbaschyeoj___: you don’t need it on the server, you do need it on the client side
19:07PigDudethis is really strange
19:09PigDudethis is nil: (prn (re-matches #"0" (first (get-keys *store*)))), but is a match: (prn (re-matches #"^0##.*$" (first (get-keys *store*))))
19:09PigDudethe regex "0" is less specific than "^0##.*$" so what gives?
19:10amalloyre-matches checks for a complete match
19:10amalloy&(doc re-matches)
19:10lazybot⇒ "([re s]); Returns the match, if any, of string to pattern, using java.util.regex.Matcher.matches(). Uses re-groups to return the groups."
19:10amalloyif you want to find substring matches, that's re-find
19:10amalloy(or re-seq)
19:10PigDudei just want a fast LEFT() test
19:11PigDudeaka startswith
19:11dbaschPigDude: then use startsWith :)
19:11PigDudeah ok
19:12PigDudethanks dbasch
19:35PigDudedo you use :refer [s] or :refer (s)?
19:37technomancyPigDude: use [s]
19:39technomancyclojurebot: import indent is brackets imply all entries are peers, while parens imply that the first entry is different from the rest: http://p.hagelb.org/import-indent.html
19:39clojurebotAlles klar
19:39technomancyclojurebot: who's a good little bot?
19:39clojurebotHuh?
19:40PigDude() just looked weird to me
19:44gfrederickstechnomancy: I'm not sure normal usage is entirely consistent with that
19:45technomancygfredericks: if all your friends jumped off a cliff...
19:45TEttingeryou'd be lonely
19:45jonhhehe
19:46TEttingeralternatively, you'd be a cliff diving competitor
19:48amalloytechnomancy: i'd worry he learned the wrong |is|
19:48amalloyclojurebot: import indent
19:48clojurebotimport indent is brackets imply all entries are peers, while parens imply that the first entry is different from the rest: http://p.hagelb.org/import-indent.html
19:48amalloyokay, fine
19:49gfrederickstechnomancy: alright, I'm gonna go check the leiningen source
19:49TEttingerclojurebot: technomancy is the lord of lein
19:49clojurebotYou don't have to tell me twice.
19:49gfrederickstechnomancy: how would you apply this standard to (:require [leiningen.core.user :as user])?
19:49technomancyamalloy: whew; that's like impossible to correct if you get it wrong iirc
19:49TEttingerclojurebot: technomancy
19:49clojurebottechnomancy is the lord of lein
19:50gfredericksclojurebot: leiningen?
19:50clojurebotleiningen is better at starting clojure than amalloy is
19:50technomancygfredericks: arguably irrelevant since you know it's not going to wrap?
19:50gfrederickstechnomancy: huh? wrap?
19:50amalloygfredericks: it should be (:require (leiningen.core.user :as user)) according to that rule, except that ns doesn't let you do that
19:50technomancygfredericks: since it's a question of indentation
19:51amalloytechnomancy: i've had it wrap, like (:require [leiningen.core :as user :refer [a b c d e f g]])
19:51gfredericksoh I thought we were discussing [] vs ()
19:51amalloyoh, but that wrapping happens inside the refer
19:51amalloygfredericks: we are
19:51technomancyamalloy: right
19:51gfredericksI GIVE UP TALKING
19:51amalloytechnomancy's point is that the ()/[] distinction only matters because it changes how emacs indents in the case of line-wrapping
19:51technomancynot just emacs
19:51amalloys/point/claim
19:51technomancybut yeah
19:52bhaumanIs there a way to check what version of cljs is running in the leinigen environment?
19:52technomancyit's relevant when considering collections of arbitrary length
19:52gfredericksokay I think I understand all of the various viewpoints involved in this discussion now
19:53amalloyi'll start writing (:require [leiningen.core.user :refer [a b c d e f g] \n :as user]) just to spite technomancy
19:53nullptrbhauman: lein deps :tree | grep clojurescript
19:54amalloyit'll indent terrible and i'll hate him for it
19:54bhaumannullptr: thanks, I phrased the question wrong I meant from a plugin.
19:54technomancyamalloy: I forget where you stand on the when/if issue
19:55amalloytechnomancy: my viewpoint is that you are a lone madman
19:55amalloybut one whose opinion is reasonable
19:55gfredericksamalloy: let's start a social media grassroots organic campaign using the power of our brand to get other people to do this too
19:55technomancyamalloy: then I'm likely to be too annoyed by your whens to notice the ns indentation crimes you commit
19:55gfrederickstechnomancy: not once we make up for it in volume
19:55amalloyreally, technomancy, i think your when/if opinion is better than the mainstream one, but it's more important to conform than to be right, for minor issues like that
19:56technomancyamalloy: well I appreciate the thought
19:56technomancyI'm just over here shifting the overton window
19:57gfrederickslet's start a library called when-with-side-effects
19:57technomancyit's a tough job, but someone's gotta do it
19:57metelluswhat's the when/if issue?
19:57gfredericksmetellus: when to use when
19:57amalloyby the way, everyone, here's your yearly reminder to run the commands at https://www.refheap.com/0bccc08fbe2924fd38fa38b88
19:57amalloypretty up your git-diff hunk headers
19:57technomancymetellus: some people think it's a mistake that clojure.core/if allows you to omit the "else" branch
19:58gfredericksamalloy: what what?
19:58amalloygfredericks: last march i pasted that and suggested everyone run it. i just remembered to do it again
19:58technomancymetellus: they mistakenly argue that you should always use clojure.core/when if you don't have an else branch
19:58gfredericksamalloy: I'm wondering exactly what "pretty up your git-diff hunk headers" means
19:58metellustechnomancy: is there a more important difference between when and the elseless if?
19:59technomancymetellus: rather than using c.c/when to indicate side-effects, given that it has an implicit do
19:59amalloy[15:43:13] amalloy: if anyone is interested, https://www.refheap.com/paste/0bccc08fbe2924fd38fa38b88 sets up git to provide custom hunk headers for clojure files in diffs. so the diff header tells you what function the diff is in the middle of
19:59gfredericksooooooooohhh
19:59Bronsaomg that's awesome
19:59gfredericksfor a minute I was hoping this had something to do with diffing sexps
19:59technomancymetellus: this is an ancient tradition we inherited from elisp and CL
19:59gfredericksseemed too short for that :)
19:59technomancymetellus: and my argument is that if you're less concerned about side-effects than a common lisper, it's time to re-evaluate your life choices.
20:00amalloyyeah, i think the best you can do is git-diff -b, gfredericks
20:00amalloyhide the irrelevant whitespace changes, at least
20:00gfredericksgood tip
20:01amalloygfredericks: ready for a better tip? you can do that on github too! add ?w=1 to the url for a diff view, and the whitespace changes are hidden
20:01gfredericksthis has to go in the .config/git directory?
20:01gfredericksamalloy: if I keep sitting here will the tips get indefinitely better?
20:02amalloygfredericks: you're talking about the -b flag to diff? i dunno, i don't usually pass it; there's no amazing way to pass it by default, i think
20:02gfrederickss/indefinitely/arbitrarily/
20:02technomancyonly logarithmically better
20:02gfredericksamalloy: no the hunk headers
20:02amalloygfredericks: just paste the refheap's contents into your shell
20:02gfrederickslogarithm is such a funny word
20:02amalloyit puts stuff in the right place
20:02gfredericksamalloy: yes but I want this in my dotfiles repo
20:02gfredericksso now I have to worry about how my symlinks all orchestrate themselves
20:03amalloyso isn't .config/git in your dotfiles repo?
20:03gfredericksnot yet; I've never put anything in there before
20:03amalloyanyway, i don't think it has to go there. you can set your gitattributes file to be any file you want
20:03gfredericksbut that's different from .git/config?
20:03gfrederickser
20:03gfredericks~/.gitconfig I mean
20:03clojurebotI don't understand.
20:04technomancyI saw a trailer for the movie Gravity (without sound) and my only thought was that the movie looked like most of the tense scenes would consist of astronauts doing math in order to calculate force trajectories in order to not drift forever through space.
20:04amalloyyes, it's a separate file
20:04amalloysadly. i have no idea why
20:04amalloybut it can't be the same one
20:04technomancyamalloy: I guess because you can't check anything in .git/ into the repo?
20:04amalloytechnomancy: no, this is ~/.gitconfig
20:04technomancyhuh
20:05amalloyyou can set it repository-local, by putting it somewhere in .git, but i've never wanted to
20:06gfredericks"Attributes that should affect all repositories for a single user should be placed in a file specified by the core.attributesfile configuration option"
20:06gfredericks"Its default value is $XDG_CONFIG_HOME/git/attributes. "
20:07arrdemBronsa: thanks for the comment, there's a huge bug in that code I just noticed because of it :P
20:08gfredericksoh I see amalloy's script was already dealing with this nonsense
20:09arrdemBronsa: the reason load isn't in that list is theoretically check-vars looks at the reach set of the declared vars, not at the declared vars. so if you use c.c/load, c.c/load -> c.c/eval which is banned ∴ c.c/load is banned.
20:10gfredericksI'm not sure this is working
20:10gfredericksI would expect to see the function name on the line that looks like "@@ -73,10 +73,10 @@"?
20:10amalloyyeah
20:10Bronsaarrdem: uh? c.c/load calls Compiler/load IIRC
20:11amalloygfredericks: do you have a particular repo+commit that this fails on, or is it all of them? so far this has worked for everyone who's tried it
20:11arrdemBronsa: well either way I have that bug, and yeah load should be on the list.
20:11gfredericksamalloy: repo+commit for the sake of having you try it?
20:11amalloyyeah
20:11arrdemBronsa: yeah calls clojure.lang.RT/load.
20:12gfredericksamalloy: definitely more than one repo
20:12Bronsaamalloy: FWIW it worked fine for me
20:13gfredericksamalloy: oh nevermind
20:13gfredericksyour side effecting script thwarted my efforts
20:13amalloygfredericks: you were hoping for a pure function that doesn't modify your filesystem?
20:13gfredericksamalloy: it works now
20:13amalloycool
20:13gfredericksthxman
20:15andyf_technomancy: Thanks for metaverse advice a few days ago. I went with creating namespace-renamed local copies of Clojure contrib libs in Eastwood, and works like a charm^H^H^H^H^Hblunt hammer. Effective
20:16andyf_I even get to fix things in the libs that I don't like without waiting on anyone :-)
20:17technomancynice =)
20:22andyf_Bronsa: core.typed uses (alias 't 'clojure.core.typed) followed later by ::t/fn in the same file. I guess tools.reader can only handle this if I eval the first before continuing to read?
20:23Bronsaandyf_: correct
20:24andyf_One learns about the dynamicity of a language by trying to do "static" analysis on it. At least I do
20:24Bronsaandyf_: does eastwood read the whole file at once & then analyze form by form? I don't remember
20:25andyf_Double checking...
20:27andyf_It does read, analyze, emit-form, eval for each top level form in turn. I guess the eval is not done in a way that affects tools.reader properly
20:27Bronsaoh.
20:29Bronsahm, weird, that should work
20:30andyf_Not a big deal, since core.typed source is the only project out of about 50 that I have seen this. I may dig into it some time
20:30Bronsaandyf_: I'm going to bed now, I'll look into it tomorrow if I remember :P
20:31andyf_Forget .... :-)
20:36jballanc_let's say I have a map "foo" whose keys are a subset of the keys in map "bar", and I want to know if the values in "foo" and "bar" are equal but only for the common subset of keys in both...any quick way to do that?
20:38andyf_(= m1 (select-keys m2 (keys m1)))
20:39jballanc_hmm...is that quicker than (reduce (fn [match [k v]] (and match (= v (k bar)))) true foo) ?
20:41andyf_You mean faster execution time? I'd recommend some experiments using criterium to benchmark
20:41ivanthis clojure fastload branch sure does start faster
20:41jballanc_andyf_: yeah, that's what I was thinking
20:42justin_smithjballanc_: probably, also that screams for reduced (reduce (fn [_ [k v]] (if (not= v (k bar)) (reduced false) true)) true foo)
20:42jballanc_yeah, there's definitely an advantage to being able to use reduced
20:43justin_smithbut the equality check for maps probably uses short circuiting too
20:43jballanc_that's what I was wondering
20:44justin_smithif the two are actually the same object, the (= foo bar) call should return immediately (it should check object identity before anything else more expensive I would think)
20:44amalloyjustin_smith: it does
20:45andyf_The select-keys method creates a new map, so seems unlikely to be faster than a solution that allocates no mem
20:45amalloybut you can't really short-circuit on equality because select-keys builds a big old map anyway
20:45amalloyyou don't want reduce, though, you want every?
20:46amalloy(every? (fn [[k v]] (= (get m2 k) v)) m1)
20:46jballanc_amalloy: ah, true...I tend to run toward reduce
20:46amalloyjballanc_: reduce is lovely, but for anything where you want laziness or short circuiting it's not so hot
22:09yeoj___hi, how do i run my development ring server, so that remote connections can be made from co-workers?
22:10yeoj___i know i can allow for remote repl connections by listening on 0.0.0.0 but not sure about ring on say port 3000
22:12justin_smithyeoj___: allowing remote repl connections is a bad idea, you should have something secure in between
22:12yeoj___it's all on my lan, i just wanted to let someone see my internal/intranet ring app... entirely dev stuff.
22:12justin_smithyeoj___: also, the right way to expose ring to the public is to put it behind something like nginx (which will put it on port 80), or in a container like tomcat or jetty
22:13blrjustin_smith: probably overkill for just making your dev server lan accessible for a co-worker
22:13justin_smiththey should be able to access http://yourhostname.local:3000
22:13justin_smithblr: I typed that before he mentioned it was local only
22:14yeoj___yeah ok
22:14blrright
22:14justin_smithas long as everyone's box understands bonjour / avahi
22:14yeoj___i think i'm having goofy crap firewall problems. second problem today that has to do with connections to this thing. my work might have some firewall thing i don't know about on here.
22:14justin_smithotherwise http://your.local.ip.quad:3000
22:14justin_smiththat always works for me on a lan
22:15justin_smith(modulo getting the specific port right of course)
22:15yeoj___yeah, i thought that would work too. there is something up with this windows laptop.
22:16yeoj___thanks, sorry to bug with another stupid windows port on my laptop issue (just like ssh -L)
22:16justin_smithcould be you have an agressive firewall installed, which would be compatible with your previous errors as well
22:17justin_smithnow I wonder how much security theater is going on in windows land
22:18yeoj___it's not serucity thats the issue... its the lack of transparency
22:19yeoj___i have no idea what is on what isn't and how it works
22:19yeoj___causing me to mess with it... and probably making it less secure (as a workstation)
22:19justin_smithwell oustensibly the reason for these kinds of issues is preventing takover of your machine by some remote control botnet process I think
22:19yeoj___yeah i won't have it long i'm going to wipe it as soon as i get the ok from my boss
22:39amalloyit occurs to me that, for work, i've never had a clojure process running on a machine that's reachable from the outside web. so it's always been viable for me to just throw in a super-insecure swank/nrepl server
22:40amalloyand yet i always listen on localhost anyway, and connect via ssh tunnels
22:54Jaoodamalloy: you are paranoid!
22:54amalloyit's just good hygeine, Jaood
22:57right1what are people doing for relational persistence nowadays in here? i've only used korma but that seems pretty dead to me
22:57Shaun__How do I kill a go-block in core async in cljs?
22:57Shaun__Is there some hacky way to kill all go-blocks even?
23:02amalloyunplug your computer
23:03amalloy(the joke doesn't work as well now that everyone uses laptops, but i worry that "submerge your computer in vinegar" might get tried one day)
23:07Shaun__hahah, I like that solution
23:10p_lmeh
23:10p_lthermite!
23:13Shaun__looks like this is the way do it: http://golang-examples.tumblr.com/post/64474189870/stop-goroutine-by-closing-a-quit-channel
23:15amalloyi was really hoping that was a youtube video of using thermite on a laptop
23:16amalloyfor anyone who shares my hopes and dreams: https://www.youtube.com/watch?v=S7CnVH6cobU is the top youtube hit
23:22blrright1: some people seem to be enjoying https://github.com/jkk/honeysql
23:23amalloyright1: just write sql
23:23right1i've been thinking of just using JDBI with java and then just use that from clojure code
23:24right1yeah, basically just writing sql
23:24amalloyJDBI? just use jdbc
23:24blryeah you can just use raw clojure.java.jdbc
23:24blrworks fine
23:25amalloyjdbi looks like another wierdo meta-language you'd have to learn for no reason
23:25right1jdbi is pretty ridiculously simple
23:26amalloyc'mon, `.map(StringMapper.FIRST)`
23:26right1you just map resultsets and you get your result
23:26amalloywhy would you want that
23:26right1i'll read into clojure jdbc though
23:26alandiperti wonder about a stored procedure lisp interpreter to solve the SQL problem definitively
23:27blrand here I was hoping stored procedures were dead
23:28amalloyblr: they still are. lisp is dead, and transitivity...
23:34Shaun__amalloy: nice thermite video, I'll use that to stop the go-blocks :)