Re: with-open and for

2013-06-08 Thread Thomas Heller
Hey, for produces a lazy sequence (as does flatten) which is hurting you here. You could wrap everything in a doall but I'd recommend using reduce since thats technically what you want here. I'd probably go for something like: (defn filter-file [filename] (with-open [rdr (io/reader filename)

Re: with-open and for

2013-06-10 Thread Thomas Heller
On Sat, Jun 8, 2013 at 7:16 PM, Steven D. Arnold < > thoth.amon.i...@gmail.com> wrote: > >> Thanks for the responses! As suggested, wrapping in 'doall' does work. >> >> >> On Jun 8, 2013, at 3:28 AM, Thomas Heller wrote: >> >> (defn filter-

Re: ANN: core.match 0.2.0-rc1

2013-06-24 Thread Thomas Heller
Hey David, I wanted to try core.match for a while and fiddled around a bit to see what kind of code is generated by match, in doing so I found a potentially "dangerous" bug. See: https://gist.github.com/thheller/5850693#file-match-clj-L67 If a match has no :else clause an IllegalArgumentExcept

Re: [ClojureScript] Re: ANN: core.match 0.2.0-rc1

2013-06-24 Thread Thomas Heller
e > same as `case` with respect to the no match exception. > > David > > > On Mon, Jun 24, 2013 at 11:10 AM, Thomas Heller > > > wrote: > >> Hey David, >> >> I wanted to try core.match for a while and fiddled around a bit to see >> what kind

Re: ANN: cljson, for faster browser deserialization

2013-06-24 Thread Thomas Heller
Hey, this looks pretty sweet! I stuck with EDN for now but its way too slow, so I'm gonna give this a shot. One thing: I'm don't think its the best idea to fall back to *default-data-readers*, would you be open to adding a second argument to 'cljson->clj which takes a map specifying readers? e

Re: core.async

2013-06-29 Thread Thomas Heller
Hey, this looks very interesting. However I'm a little concerned about the semantics of >! and https://gist.github.com/thheller/5890363 (ns thheller.async-test (:use clojure.test) (:require [clojure.core.async :as async :refer (go >! !! ! reply-to reply) (recur (inc work-done))

Re: Sequential conditional transforms of an argument

2013-07-05 Thread Thomas Heller
Hi, you could use a macro, but a simple function should suffice. I use something along the lines of (defn cond-transform [x & pairs] (reduce (fn [x [test-fn transform-fn]] (if (test-fn x) (transform-fn x) x)) x pairs)) ;; example

Re: Ring's session cookie-store

2013-07-06 Thread Thomas Heller
Hey, cookie-store does not expect a string but a map like (cookie-store {:key your-key}) otherwise it will generate a random new key each restart, which you observed. You can also set some options for the cookie itself, see :cookie-attrs (http://clojuredocs.org/ring/ring.middleware.session/wra

core.async pub/sub

2013-07-09 Thread Thomas Heller
Hey, I'm doing some core.async tests and want to create a basic pub/sub model. Messages are >! on one channel and >! to many others. (deftest ^:wip async-test2 (let [subscribers (atom []) events (chan 100)] (go (loop [] (when-let [ev (! events i) (r

Re: core.async pub/sub

2013-07-11 Thread Thomas Heller
> on it. > > Alex > > On Tuesday, July 9, 2013 6:46:21 PM UTC-5, Thomas Heller wrote: >> >> Hey, >> >> I'm doing some core.async tests and want to create a basic pub/sub model. >> Messages are >! on one channel and >! to many others. >>

Re: cljx 0.3.0 released

2013-07-11 Thread Thomas Heller
This is awesome, thanks a ton. Solved all the issues I had with 0.2 Cheers, /thomas On Wednesday, July 10, 2013 8:26:03 PM UTC+2, Chas Emerick wrote: > Earlier today, we released [com.keminglabs/cljx "0.3.0"], which brings a > bunch of significant changes and improvements: > > > > https

Re: Things get slow if hashmap has 1000 Elements

2013-07-17 Thread Thomas Heller
One side node, *repeatedly* produces a lazy-seq. Since the REPL forces that seq when it tries do print everything you get the desired results, but if you were to (def x (repeatedly 1000 addmod) and then inspects mobs it would be empty, since no one forced the seq. If you want to force side-eff

Re: ClojureScript: Keyword Breaking Change Around the Corner

2013-08-29 Thread Thomas Heller
Hey, this sounds interesting. I just tried it on my project but it seems to be missing several keywords in the constants_table.js. Dumb example: the code tries to use cljs.core.constant$keyword$1064 , which does not exist. Will try to investigate, just a heads up. /thomas On Wednesday, Augus

Re: ClojureScript: Keyword Breaking Change Around the Corner

2013-08-29 Thread Thomas Heller
y, August 29, 2013 10:51:56 AM UTC+2, Thomas Heller wrote: > > Hey, > > this sounds interesting. I just tried it on my project but it seems to be > missing several keywords in the constants_table.js. > > Dumb example: the code tries to use cljs.core.constant$keyword$1064 , > w

Re: ClojureScript: Keyword Breaking Change Around the Corner

2013-08-30 Thread Thomas Heller
> > For #2, we can't intern the keywords like Clojure does on the JVM because > JavaScript does not provide weak references. If we interned dynamically > created keywords, then we'd have an exploitable memory leak. This may actually be a non-issue for Browser Environments since you would not

Re: Properly parse clojure source code?

2015-01-15 Thread Thomas Heller
https://github.com/clojure/tools.reader is probably your best bet. On Friday, January 16, 2015 at 12:13:22 AM UTC+1, zirkonit wrote: > > I'm thoroughly confused. If I want to parse clojure code from string > without evaluating or caring a lot about its context, I'm out of luck. > > EDN tools chok

Re: Clojurescript :advanced compilation extern only partly working.

2015-01-28 Thread Thomas Heller
I just have a guess for you. AudioContext.decodeAudioData parameters are declared as ArrayBuffer, Function, Function but you are passing "data" which is a String not an ArrayBuffer. Maybe the type inference thinks you are calling a method that is not defined in the externs? Maybe it will work

Re: Clojurescript :advanced compilation extern only partly working.

2015-01-30 Thread Thomas Heller
>>> >>>>> No, that's not it. So I tried: >>>>> >>>>> (def audio-context (js/AudioContext.)) >>>>> (.decodeAudioData audio-context (js/ArrayBuffer. 256) #(println "ok" >>>>> %) #(println "error&quo

Re: Reducers question

2015-02-09 Thread Thomas Heller
Cat is just missing a print-method entry. Try (into [] (r/fold 1 r/cat r/append! [1 2 3])), the result is what you'd expect. The n parameter isn't actually about parallelism but partition size. Fork/Join will decide the parallelism. In the case of n=1 the input will be split into 3 partition of

Re: Clojure web server capacity

2015-04-22 Thread Thomas Heller
Hey, I'm curious what you are trying to measure in regards to Clojure. As far as I know there is not a single Web Server actually written in Clojure, they are all written in Java and we just use them. The Compojure benchmark you linked uses the default Jetty Adapter for Ring (like Rack in Ruby

Re: Clojure web server capacity

2015-04-22 Thread Thomas Heller
You should check your sources. http-kit is not written in Clojure and does not use netty. On Wednesday, April 22, 2015 at 11:40:21 PM UTC+2, François Rey wrote: > > On 22/04/15 20:22, Thomas Heller wrote: > > As far as I know there is not a single Web Server actually written i

Re: Making Java serializables transparently printable and readable

2015-06-17 Thread Thomas Heller
Hey, the issue is not in clojure.core. It is with ring in this case, it uses clojure.tools.reader.edn/read-string which supports an optional {:readers {...}} argument but there is no way to specify those in ring. Should be a fairly simple fix though, doing anything to clojure.edn won't help as

Re: Making Java serializables transparently printable and readable

2015-06-17 Thread Thomas Heller
. > > > it uses clojure.tools.reader.edn/read-string > > Ugh, thanks. I forgot about that one as well. > > On Wednesday, June 17, 2015 at 5:10:24 AM UTC-4, Fluid Dynamics wrote: >> >> On Wednesday, June 17, 2015 at 4:52:00 AM UTC-4, Thomas Heller wrote: >>>

Re: Making Java serializables transparently printable and readable

2015-06-17 Thread Thomas Heller
On Wed, Jun 17, 2015 at 9:50 PM, James Reeves wrote: > On 17 June 2015 at 09:51, Thomas Heller wrote: >> >> On another note: Sessions in cookies should be VERY VERY small. >> java.io.Serializable usually isn't small and especially if you go java >> object -&

Re: ring - setting no-cache for everything?

2015-06-19 Thread Thomas Heller
> > > Cache-control is evil. Users concerned with seeing the most up-to-date > information know to hit reload (and probably do anyway, just to be sure), > and there's also the option of AJAX polling for that (or whatever precisely > sites like Facebook do). > > I don't even a wrong Cache

Re: [ANN] Introducing Yo-yo, a protocol-less, function composition-based alternative to Component

2015-06-29 Thread Thomas Heller
Hey, interesting approach but I don't like the nesting and "manual" wiring of dependencies. I don't quite like that every with-* function remains on the stack as well, but it shouldn't hurt that much. An uncaught exception will also take down your entire system, but I guess you'd have a try/cat

Re: [ANN] Introducing Yo-yo, a protocol-less, function composition-based alternative to Component

2015-07-03 Thread Thomas Heller
while but never get around to it. I might do that some day to create an actual example I can refer to. Cheers, /thomas On Friday, July 3, 2015 at 9:39:24 AM UTC+2, James Henderson wrote: > > Hey Thomas, thanks for your e-mail :) > > On Monday, 29 June 2015 11:25:44 UTC+1, Thomas He

Re: [ANN] Introducing Yo-yo, a protocol-less, function composition-based alternative to Component

2015-07-03 Thread Thomas Heller
That article makes it sound like an OOP beast, it is really much simpler than that. -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please

Re: restarts

2014-06-20 Thread Thomas Heller
be a good idea to use restarts. IMHO its not a good idea in clojure, especially coupled with lazy-seqs. But we are getting off-topic ... Regards, /thomas On Fri, Jun 20, 2014 at 9:04 AM, Stefan Kamphausen wrote: > On Thursday, June 19, 2014 11:05:07 PM UTC+2, Thomas Heller wrote: >> >>

Re: How to access record in a hashmap

2014-07-09 Thread Thomas Heller
Short and simple answer: NullPointerException (def object-locations nil) (object-locations 'bucket) will throw ('bucket object-locations) => nil HTH, /thomas On Wednesday, July 9, 2014 3:48:53 PM UTC+2, Cecil Westerhof wrote: > > When you have: > (def object-locations { > 'whiskey 'livin

Re: How to access record in a hashmap

2014-07-09 Thread Thomas Heller
Oh and its rare (outside of macros) to use symbols like that. Usually you'd use keywords. (def object-locations {:whiskey :living-room}) On Wed, Jul 9, 2014 at 5:03 PM, Thomas Heller wrote: > Short and simple answer: NullPointerException > > (def object-locations nil) > &g

Re: How to access record in a hashmap

2014-07-09 Thread Thomas Heller
Don't know Land of Lisp, but if you print it you can use (name :whiskey) to get "whiskey" (as a String), also works on (name 'whiskey). On Wed, Jul 9, 2014 at 5:28 PM, Cecil Westerhof wrote: > 2014-07-09 17:18 GMT+02:00 Thomas Heller : > > Oh and its rare (outs

Re: 101 on simple and flexible graph query/update?

2014-07-10 Thread Thomas Heller
I usually just give every ENTITY in my system a primary id and structure everything in a nested map. {:people {1 {:id 1 :type :student :name "Ben" :taking-classes #{1 2}} 2 ...} :classes {1 {:id 1 :name "Clojure 101"} 2 ...}} This basically looks like a database table. You

Re: How to return a value from catch block

2014-07-13 Thread Thomas Heller
catch returns the value of the last statement, so instead of the (str) you could just return 0.0. Also don't use read-string if you only expect floating point numbers, otherwise (convert-to-float ":hmm") returns :hmm, not exactly a float. Since closure uses Double as the default floating point

Re: Leiningen resource-paths

2014-07-24 Thread Thomas Heller
Hey, I had this problem with a jar from Bing which is not available on maven. You can use a local repo without any plugins or extra work for "others". Try this: Pick a directory for your local maven repo, should be inside your git repo. I'm using "maven". Take your jar and run mvn deploy:dep

Re: Leiningen resource-paths

2014-07-24 Thread Thomas Heller
o just copies them INSIDE the uberjar so you'll have jar in a jar which java doesnt understand. /thomas On Thursday, July 24, 2014 3:22:37 PM UTC+2, Yura Perov wrote: > > Dear Thomas Heller, > > Thank you very much for your reply. > > As I mentioned in my initial post (sorr

Re: ANN: ClojureScript 0.0-2277

2014-07-26 Thread Thomas Heller
Hey David, CLJS-826 is only partly resolved in this release since it only takes effect with a new closure-third-party release since the current jar is causing the problem. Would be nice if you could build a new closure release and bump the dependency in clojurescript. Thanks, /thomas On Fr

Re: Leiningen profile problem

2014-07-28 Thread Thomas Heller
Your issue is probably due to AOT compilation, uberjar aot compiles everything and leaves alot of class files in your target directory (aka classpath). When you run your app afterwards the class file is used instead of the clj file since the .class file is "newer". When you run lein clean those

Re: [ClojureScript] Re: ANN: ClojureScript 0.0-2277

2014-07-29 Thread Thomas Heller
Uhm small hint on how I'd do that? My maven-fu is weak. But given that https://oss.sonatype.org/content/repositories/orgclojure-1311/org/clojure/google-closure-library-third-party/0.0-20140718-946a7d39/google-closure-library-third-party-0.0-20140718-946a7d39.jar does not contain a goog/base.js o

Re: [ClojureScript] Re: ANN: ClojureScript 0.0-2277

2014-07-29 Thread Thomas Heller
0.0-20140718-946a7d39"] Confirmed to resolve CLJS-826. On Tuesday, July 29, 2014 10:30:21 PM UTC+2, David Nolen wrote: > > Just add sonatype to your :repositories project.clj entry > https://github.com/technomancy/leiningen/blob/master/sample.project.clj#L79 > > David >

Re: [ClojureScript] Re: ANN: ClojureScript 0.0-2277

2014-07-30 Thread Thomas Heller
David its probably best to hold off on that release. It seems the closure-library HEAD version depends on a newer closure compiler version than the one available via maven. At least I'm seeing some renaming issues for advanced compilation. -- You received this message because you are subscribe

Re: ANN: ClojureScript 0.0-2277

2014-07-30 Thread Thomas Heller
Sorry, I would be if I could. Trying to track it down, but debugging an optimized build is not exactly easy. :( When using 2277 I have no errors, when using 2277 with the new closure lib release I have some "undefined" errors. That usually means some sort of renaming gone wrong. Error: Cannot

Re: ANN: ClojureScript 0.0-2277

2014-07-30 Thread Thomas Heller
Geez, 2277 actually works just fine. 2234 doesn't work, but it actually doesn't work with either closure-library version. Forgot that I reverted to 2234 due to the keyword issue. 2277 + [org.clojure/google-closure-library "0.0-20140718-946a7d39"] seems fine, except for that keyword issue. Sorr

Re: [ClojureScript] Re: ANN: ClojureScript 0.0-2277

2014-07-30 Thread Thomas Heller
affected. > > David > > On Wed, Jul 30, 2014 at 11:11 AM, Thomas Heller > wrote: > > Geez, 2277 actually works just fine. 2234 doesn't work, but it actually > doesn't work with either closure-library version. Forgot that I reverted to > 2234 due to the ke

Re: CLJS Function clobbering js function of same name

2014-08-04 Thread Thomas Heller
FWIW I was not able to reproduce this behavior? What exactly does your code look like? See the source and the compiled version: https://gist.github.com/thheller/4731f682665d38b1053c Seems to me the shadowing kicked in correctly. "eval" seems to be missing in :js-globals though. https://github.c

Re: CLJS Function clobbering js function of same name

2014-08-04 Thread Thomas Heller
I was not able to reproduce Sam's initial problem. "eval" as I said does not appear in the :js-globals which seems like a mistake. -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note tha

Re: CLJS Function clobbering js function of same name

2014-08-04 Thread Thomas Heller
https://gist.github.com/thheller/4731f682665d38b1053c On Monday, August 4, 2014 3:34:33 PM UTC+2, Nicola Mometto wrote: > > > Try with (fn document [] js/document) > > Thomas Heller writes: > > > I was not able to reproduce Sam's initial problem. > > >

Re: Why does this not give output

2014-08-05 Thread Thomas Heller
If you don't need the result of the for loop (which you don't in your example) use doseq. Same syntax as "for" but not lazy and no return value (well, nil to be exact) (doseq [i (range 10)] (aset intArr i (int 0))) ... On Tuesday, August 5, 2014 5:41:08 PM UTC+2, Cecil Westerhof wrote: > >

Re: Why does this not give output

2014-08-06 Thread Thomas Heller
dotimes is for doing things n times. doseq is for seqs. Use dotimes when you can, doseq when you can't. On Wed, Aug 6, 2014 at 12:13 AM, Cecil Westerhof wrote: > 2014-08-05 19:04 GMT+02:00 Thomas Heller : > > If you don't need the result of the for loop (which you don't

Re: Transducers are Coming

2014-08-07 Thread Thomas Heller
Looks nice, although I still need to wrap my head arround it. I don't believe in micro-benchmarks but I did one anyways cause I was curious how transduce would stack up against reduce (not reducers). https://github.com/thheller/transduce-bench transduce Evaluation count : 2220 in 60 samples of

Re: Write/reading java maps and lists using fressian/transit

2014-08-07 Thread Thomas Heller
Both Transit and fressian take a Handler map as arguments to the reader/writer functions/constructors. So its pretty straightforward to replace the default handlers with handlers that do what you want. I have no example handy but it should be documented in both libraries. Transit has something

Re: Newbie: adding items to a global vector in doseq

2014-08-14 Thread Thomas Heller
Hey, it's not how you'd usually do things in Clojure and I'd consider the use of an atom in this place as "wrong". I was struggling with Clojure in the beginning too and my code looked pretty much like yours, but the faster you get into the Clojure mindset the easier it will be. This might be

[ANN] shadow-pgsql: PostgreSQL without JDBC

2014-08-21 Thread Thomas Heller
Hey Clojure Folk, I'm close to releasing the first alpha version of https://github.com/thheller/shadow-pgsql a "native" interface to PostgreSQL I wrote. Its an implementation of the native binary protocol without any intent to ever support JDBC. Mostly because that provides a bunch of features

Re: [ANN] shadow-pgsql: PostgreSQL without JDBC

2014-08-23 Thread Thomas Heller
/thomas On Saturday, August 23, 2014 5:12:30 PM UTC+2, Kyle Cordes wrote: > > On Thursday, August 21, 2014 at 1:00 PM, Thomas Heller wrote: > > Hey Clojure Folk, > > > > I'm close to releasing the first alpha version of > https://github.com/thheller/shadow-

Re: [ANN] shadow-pgsql: PostgreSQL without JDBC

2014-08-23 Thread Thomas Heller
jure and Postgres. > > Jason > > On Sat, Aug 23, 2014 at 11:23 AM, Thomas Heller > wrote: > > Hey Kyle, > > > > thanks for the Feedback. Appreciate it. > > > > I think you misunderstood the meaning of a "type" in shadow-psql. A > "type&quo

Re: [ANN] shadow-pgsql: PostgreSQL without JDBC

2014-08-25 Thread Thomas Heller
ks, > Shashy > > On Saturday, August 23, 2014 8:05:37 PM UTC-4, Thomas Heller wrote: >> >> EDN/Transit on the backend might be nice, but a little much for me. I'll >> take it if you feel like a lot of C. jsonb in 9.4 will have to do for now. >> >> Transpa

Re: Resolve function or object by name in ClojureScript

2014-08-25 Thread Thomas Heller
It is possible, the question is WHEN? You can make a function callable by name if you export it. (ns myns) (def ^:export testfn [] :foo) can be called like so, must be careful with name munging though: (let [the-fn (aget js/window "myns" "testfn")] (the-fn)) which also works with advanced

Re: Using an atom for a caching map

2014-09-01 Thread Thomas Heller
As much as I like Clojure and atoms, I do not think they are a good fit for caching. Not only is it impossible to address the concurrency issues related to multiple threads loading the same object, but you also have to do expiration and size management yourself. Immutability doesn't help much f

Re: Using an atom for a caching map

2014-09-01 Thread Thomas Heller
ealise that my original solution was actually sufficient for my > somewhat strange use case, which is nice :-). For more typical server side > caching, I agree that Guava would be a great solution. > > Cheers, > Colin > > > On 1 September 2014 20:54, Thomas Heller > >

Re: [ANN] shadow-pgsql: PostgreSQL without JDBC

2014-09-03 Thread Thomas Heller
> Ludwik. > > > On Thursday, 21 August 2014 19:00:11 UTC+1, Thomas Heller wrote: >> >> Hey Clojure Folk, >> >> I'm close to releasing the first alpha version of https://github.com/ >> thheller/shadow-pgsql a "native" interface to PostgreSQL

Re: Is this a reasonable use of core.async?

2014-09-17 Thread Thomas Heller
core.sync is more about coordination and communication than about doing things in parallel, thats just a pleasant side effect. In your case you don't need anything core.async provides. You could either use reducers or java.util.concurrent.ExecutorService. (let [exec (Executors/newFixedThreadPoo

Re: Is this a reasonable use of core.async?

2014-09-17 Thread Thomas Heller
Uh forgot to .shutdown the exec, proper cleanup is important otherwise the threads might hang arround a bit. On Wednesday, September 17, 2014 1:26:00 PM UTC+2, Thomas Heller wrote: > > core.sync is more about coordination and communication than about doing > things in parallel, tha

Re: Deploy best practices

2014-09-18 Thread Thomas Heller
I use http-kit as a web server as well. My deployment basically looks like this: My main function starts my "app", once I have an app instance I attempt to start the http-kit server on a specific port. I do this in a loop, catching all socket already bound exceptions and retrying. Additionally

Re: [ANN] shadow-pgsql: PostgreSQL without JDBC

2014-10-17 Thread Thomas Heller
I meant to do a proper release announcement for quite some time now but simply don't have the time to do it properly. That being said I have now been using shadow-pgsql [1] in production for well over a month and it has been working as expected and "stable". A couple million Queries were execut

Re: io/writer + map/recur

2014-11-01 Thread Thomas Heller
The way you wrote your loop it will only ever run once which means you could take it out. 1> res = take from queue 2> if res nil? terminate 3> if res recur with result from with-open (always nil) 4> back to 2 and terminate Not sure if this is intended but the way it is written it does not make

Re: Mutable local variables

2014-11-10 Thread Thomas Heller
@Jacob: If you get too many arguments in a loop I found it best to use a map. (loop [{:keys [a b c] :as state} a-map] (cond (and (= a 1) (= b 2)) (recur (update state :a inc)) ;; 1.7+ only, otherwise use update-in ...)) Working with named arguments (vs. positional) is a lot more user-

Re: Idiomatic way to return a single value from an async function

2014-11-11 Thread Thomas Heller
Hey, what is your definition of an async function in Clojure? I imagine something something that starts a (go ...), if appropriate you can use the result of (go ...) as the result of the function since that is a channel that will receive the return value of the go block when it dies. (defn sta

Re: Ring and Compojure with Node.js via Clojurescript

2014-12-09 Thread Thomas Heller
Due to significant platform differences from the JVM to Node.js (no real threads, everything needs callbacks) you'd probably be better off writing something more javascript-y. Porting Ring is probably not likely since everything is async and Ring is not. Same goes for Compojure but that is most

Re: Handling increasingly-intensive processes

2014-12-15 Thread Thomas Heller
Hey, without knowing much about your application/business needs its hard to speculate what might be good for you. The root of your problem might be CouchDB since it was never meant for "Big Data" and since we are talking tweets I generally think "a lot". I'm not sure how your map value looks bu

Re: Using dev/user.clj breaks java compilation

2015-01-02 Thread Thomas Heller
I had a similar problem some time ago. The analysis is correct that Clojure will always load user.clj. As a workarround I just moved the require out of the ns form. (ns user (:require [mdg.meat2])) becomes (ns user) (defn start [] (require 'mdg.meat2 :reload-all) (do-something-useful))

Re: Creating Hiccup From Code Keeping Formatting and Comments

2015-01-04 Thread Thomas Heller
Here is a crazy idea I had. https://gist.github.com/thheller/ad7dc6234f205cf4a53f Basically it slurps the .clj file of the current namespace, then looks at the form metadata to skip to the line where the (example ...) starts. It then takes the next row as the title, then reads all rows until it

Re: Creating Hiccup From Code Keeping Formatting and Comments

2015-01-04 Thread Thomas Heller
Oops, simplified a little. We already have access to the title. ;) On Monday, January 5, 2015 1:09:24 AM UTC+1, Thomas Heller wrote: > > Here is a crazy idea I had. > > https://gist.github.com/thheller/ad7dc6234f205cf4a53f > > Basically it slurps the .clj file of the current nam

Re: A (foolish) plan to re-invent IO on top of core.async

2015-01-05 Thread Thomas Heller
I built a PostgreSQL Java client from scratch recently. Since it was not a goal to support JDBC ever I thought about writing it with non-blocking async IO. I played with some ideas but ultimately I decided not to. The reason is quite simple. Async IO works well if you do enough IO to keep one a

Re: camelize-dasherize - reinventing the wheel?

2015-01-06 Thread Thomas Heller
If you want to boost performance a bit just memoize the conversion functions. Memoize makes you vurnable to exploits though, better use something with WeakRefs if you convert anything from untrusted sources (eg. guava CacheBuilder). But given your usecase this will probably be the biggest gain,

Re: Classpath bug re Clojure 1.10.1.645 when using Figwheel.Main

2020-08-11 Thread Thomas Heller
This might be a good incentive for people to keep their published .jar files clean. Unfortunately many published CLJS libs contain the rather common "public" folder with "public/index.html" and often compiled .js artifacts which aren't actually ever used. I do however think that it is useful to

Re: Classpath bug re Clojure 1.10.1.645 when using Figwheel.Main

2020-08-12 Thread Thomas Heller
> > None of these libraries are broken. They just include resources. Also, I > don't think it is realistic to tell library authors to please move certain > files out of the way because my build tool randomizes my classpath. That is > not going to happen. People will keep including things like

Re: Curious behaviour when requiring clojure.tools.cli

2021-06-14 Thread Thomas Heller
clojure.string/starts-with? was added in Clojure 1.8.0, I see 1.7.0 in the project.clj? See https://github.com/clojure/clojure/blob/b1b88dd25373a86e41310a525a21b497799dbbf2/src/clj/clojure/string.clj#L362 What exactly else is going on I don't know but it all starts from the wrong Clojure versi

Re: How to compile with optimizations none when using web workers

2016-05-30 Thread Thomas Heller
Not sure I understand what you mean. What do you mean by "main module"? cljs has a notion of a base module, while shadow-build does not. Typically your ns structure and the requires are enough to establish relationships between them so shadow-build can figure out what needs to be where. If that

Re: should edn/read call close() on the PushbackReader?

2016-09-02 Thread Thomas Heller
In general Java it is up to the creator of a "stream" to close it, the same applies to Clojure pretty much. Java has "try with resources" and in Clojure you can use "with-open": (with-open [rdr (open-the-reader)] (edn/read rdr {})) This will ensure .close is called in a finally block. HTH, T

Re: Possible ClojureScript compiler issue...

2016-10-16 Thread Thomas Heller
FWIW I investigated the check with "true" and a sentinel value and found them to both have a small performance impact over just checking for a true-ish property. http://dev.clojure.org/jira/browse/CLJS-1658 The impact is really small so it might be worth the trade-off. /thomas On Sunday, Octo

Re: Possible ClojureScript compiler issue...

2016-10-17 Thread Thomas Heller
maintain our own fork > of Closure Compiler. Which is not that scary with git. It is pretty easy to > automate rebasing of a few patch-commits on top of arbitrary complex > foreign repo. > > [1] > https://github.com/google/closure-compiler/blob/5616a66e40c5dc6ec9be9beacfc0ea20d

Re: Possible ClojureScript compiler issue...

2016-10-18 Thread Thomas Heller
0:21:21 AM UTC+2, John Szakmeister wrote: > > On Tue, Oct 18, 2016 at 2:59 AM, Thomas Heller > wrote: > [snip] > > While this issue can be very confusing you will hardly ever run into it > when > > following best practices. As David suggested using a custom js->clj h

Re: need help on `pprint/write` code with better readability

2016-10-24 Thread Thomas Heller
Try https://github.com/weavejester/cljfmt It is specifically written for clj code and not general pprinter. /thomas On Sunday, October 23, 2016 at 1:28:23 PM UTC+2, Jiyin Yiyong wrote: > > I'm using `write` function to generate code very heavily. But small part > of the code are hard to read.

Re: defrecord in cljc

2016-11-12 Thread Thomas Heller
You may overwrite the default IPrintWriter by doing calling extend-type after the defrecord. But CLJS should probably allow the protocol in defrecord itself instead of forcing the default. Not sure if there is an open issue for it. On Friday, November 11, 2016 at 9:29:25 PM UTC+1, William la Fo

Re: Prgram uses a lot of swap

2017-02-26 Thread Thomas Heller
Ideally you would run your program without lein, probably as an uberjar. But if you insist on lein you can do "lein trampoline run -m your.main/fn" which will allow the lein process to exit after setting up your program leaving you with only one JVM. To control the memory you can add :jvm-opts

Re: Prgram uses a lot of swap

2017-02-26 Thread Thomas Heller
Maybe you are running an old version of leiningen? This might work although JVM_OPTS works fine for me as well :jvm-opts ^:replace ["-Xmx512m"] Maybe you have some other conflicting configuration somewhere that sets it explicitly to 4G? Usually no maximum is set and the JVM will automatically

Re: Prgram uses a lot of swap

2017-02-27 Thread Thomas Heller
Last thing I can come up with is your environment variables or something in your ~/.lein/* folder. Beyond that I'm out of ideas. On Monday, February 27, 2017 at 2:15:18 PM UTC+1, Cecil Westerhof wrote: > > 2017-02-27 13:57 GMT+01:00 Cecil Westerhof >: > >> Maybe you have some other conflicting c

Re: Prgram uses a lot of swap

2017-02-27 Thread Thomas Heller
> > ​What is the best way to determine the right value for this? I remember > that in the past I had a lot of little Java​ > > ​programs running and got a much better performance by limiting memory > usage. > That is not an easy question to answer. If you make it too small your process may

Re: [Violation] Parser was blocked due to document.write(

2017-11-05 Thread Thomas Heller
This is only an issue in unoptimized code, ie. :none. Without optimizations all code is in separate files which are loaded in dependency order. The default debug loader will load them by appending a script tag to the document. This has pretty terrible performance characteristics but is OK durin

Re: :npm-deps and transitive dependencies

2018-01-16 Thread Thomas Heller
You can create a deps.cljs in the root of your classpath for Y and declare :npm-deps there ;; src/deps.cljs {:npm-deps {"the-thing" "version"}} This way the compiler can pick up your npm dependency and install it. On Monday, January 15, 2018 at 9:01:55 AM UTC+1, Lucas Wiener wrote: > > Hi, > >

Re: try catch leaking exception

2018-02-14 Thread Thomas Heller
lazy-seq is the short answer. You are constructing the seq inside the try/catch but it is realized outside of that so no exceptions will be caught. (defn gen-ym-list [from to] (try (->> (p/periodic-seq (f/parse ym-fmt from) (t/months 1)) (take-while #(not (t/after? % (f/parse ym-f

Re: Invalid-token when dereferencing namespaced keywords.

2019-01-30 Thread Thomas Heller
To expand on what Alex already mentioned. There is no such thing as double-colon keywords. Double-colon is a reader alias mechanism that let the reader resolve them so you can type less. (ns foo.bar.xyz) ::hello this is resolved at read-time and identical to actually writing :foo.bar.xyz/hell

Re: [Q] Deploying two artefacts/jars with same group/artefactid via Leiningen

2019-03-28 Thread Thomas Heller
I'm doing this in shadow-cljs deploying a normal jar and one with aot. I'm not exactly sure how you'd do that for an uberjar though. https://github.com/thheller/shadow-cljs/blob/master/project.clj#L96-L103 On Thursday, March 28, 2019 at 7:05:39 PM UTC+1, henrik42 wrote: > > Hi, > > I have an ube

Re: Blocking behavior of >!! ?

2019-05-19 Thread Thomas Heller
( > The documentation for >!! reads: > > - > clojure.core.async/>!! > ([port val]) > puts a val into port. nil values are not allowed. Will block if no > buffer space is available. Returns true unless port is already closed. > > > I have a case where I believe that the c

Re: Blocking behavior of >!! ?

2019-05-20 Thread Thomas Heller
ding is correct, then > (>!! c 42) should block because there is no buffer available. > > On Sunday, May 19, 2019 at 1:48:16 PM UTC-7, Thomas Heller wrote: >> >> (> by the first go (running in a different thread). So it is blocking until >> something puts another val

Re: Custom test assertions in ClojureScript

2019-09-28 Thread Thomas Heller
Hey, cljs.test/assert-expr is part of the CLJ macro side so it can't be extended from a CLJS REPL. You can write it in a .clj file and use (require-macros 'that.ns) from the CLJS REPL or use :require-macros in the ns form that uses the new assert-expr. HTH, Thomas On Thursday, September 26, 2

Re: Custom test assertions in ClojureScript

2019-09-29 Thread Thomas Heller
Self-hosted should work the same way but it does require compiling the macro namespace in an extra step (ie. the $macros ns is created separately). I don't know how this is done for regular self-hosted. shadow-cljs has an extra build step for this that should take care of creating everything.

Re: Using go/

2015-07-30 Thread Thomas Heller
Hey, I made a similar suggestion (minus the ThreadLocal) a few weeks ago, although for slightly different reasons. [1] It should be noted that your async macro does in fact use the dispatcher just like a normal go would, the only difference is that it will start executing immediately in the cu

Re: when the body of the request is HttpInputOverHTTP, how do I get the string representation?

2015-08-19 Thread Thomas Heller
No idea what HttpInputOverHTTP is but I'd guess that it is an InputStream implementation. Try (slurp (:body request)) HTH, /thomas On Wednesday, August 19, 2015 at 9:57:57 PM UTC+2, Lawrence Krubner wrote: > > I know this has been asked before, but Google is interpreting > "HttpInputOverHTTP"

Re: Just found out about Elixirs function argument pattern matching...

2015-09-07 Thread Thomas Heller
FWIW before I came to Clojure I did a lot of Erlang and in the beginning I was at the exact same spot wanting to use pattern matching everywhere because it is so damn cool. Same goes for tagged literals. After a little while I realized that it is just not the way to do it in Clojure and forcing

  1   2   >