lumo

:lumo: Standalone ClojureScript environment. Currently at version 1.9.0
lepistane 2017-11-22T09:24:38.000053Z

How can i uninstall lumo? i tried

npm uninstall -g lumo-cljs
i even used sudo but it didn't help
which lumo
/usr/local/bin/lumo
i'd like to uninstall lumo 1.8.0-beta and install lumo 1.7.0`

2017-11-22T11:43:34.000428Z

@lepistane installing lumo-cljs to global for me starts an installation script that downloads zip and extracts it to /usr/lib/node_modules/lumo-cljs/bin and uninstalling it should remove that directory. Makes me suspect you manually copied the binary to your path?

lepistane 2017-11-22T11:56:22.000297Z

that is possible, i installed lumo like 2 weeks ago was very hangover was just trying to get it working. is there anyway i could remove it completely from my system and then install it normally? @hlolli

2017-11-22T11:57:56.000374Z

yes just remove this one binary, it's safe and the only thing that needs removeing. You can also confirm that there's not lumo-cljs directory in your global node_modules directory (on my fedora it's located /usr/lib/node_modules/)

lepistane 2017-11-22T12:10:11.000353Z

thank you to @hlolli he helped me a lot!!

2017-11-22T17:07:15.000068Z

I finally did it, I believe this to be the first functioning application bundled into the lumo binary that has both .jar and node_module dependencies https://s3.amazonaws.com/hlolli/lumo_quiz_game runs on Linux64Bits, of course you should never ever run a binary that someone posts on the internet, but essentially this binary packs https://github.com/hlolli/lumo-quiz-game takes ~2 seconds to boot so I'm actually not sure if this all hassle was worth it.

2017-11-22T17:12:42.000786Z

its size 113 mb can be explained by 53 mb database of jepordy questions I found online in json format.

dominicm 2017-11-22T17:33:01.000582Z

@hlolli is it possible you need more caching going on?

2017-11-22T17:33:47.000254Z

every cljs file is cached. But when I think about it, how long time does it take to convert 53mb json into edn πŸ˜• maybe these 2 seconds.

2017-11-22T17:34:45.000130Z

in practice, there's no cljs file being run, it's just js files along the _cache.json counterparts.

dominicm 2017-11-22T18:29:49.000426Z

Maybe println before and after load can quickly answer that question? Would be good to resolve the doubt.

richiardiandrea 2017-11-22T18:32:46.000080Z

woah

richiardiandrea 2017-11-22T18:33:09.000416Z

interesting

richiardiandrea 2017-11-22T18:33:43.000399Z

maybe this will trigger binary cache for cljs πŸ˜„

2017-11-22T18:35:34.000031Z

@dominicm I give it a try

2017-11-22T18:45:22.000148Z

unbundled it takes 4,5 seconds, so it's bit faster bundled I guess. I think this is the bottleneck here. And if you start this terminal game, you see delays between questions, this is explicit with core.async timouts.

2017-11-22T18:46:21.000330Z

(def questions-db
  (let [time-before (.now js/Date)
        _ (println "Loading 53mb bundle...")
        db (-> "resources/questions.json"
               io/resource
               io/slurp
               js/JSON.parse
               (js->clj :keywordize-keys true))
        time-elapsed (- (.now js/Date) time-before)
        _ (println (str "Loading complete " time-elapsed) " ms.")]
    db))

Loading 53mb bundle...
Loading complete 4545  ms.

mfikes 2017-11-22T18:49:26.000327Z

@hlolli I would suspect js->clj, and if it is the culprit, I would consider storing the DB as Transit instead.

mfikes 2017-11-22T18:50:01.000232Z

Or, if your app structure is not that complicated and can afford it, just leave the DB as JSON.

2017-11-22T18:51:57.000133Z

@mfikes ok that's actually a good idea. But this app is very meaningless, made it only to make sure that I could bundle code with lumo that uses every type of dependency.

2017-11-22T18:53:14.000210Z

and json to transit sounds like a good idea for a global node module if one doesn't already exists.

mfikes 2017-11-22T18:54:42.000218Z

@hlolli I just tried in Planck, and the overall numbers I got for your questions.json file: slurp: 244 ms js/JSON.parse: 517 ms js->clj: 1890 ms

2017-11-22T18:54:58.000321Z

ho! wow

2017-11-22T18:56:05.000234Z

yes it really makes sense to store it as transit, thanks for this!

2017-11-22T18:57:02.000008Z

or edn, would that matter when it's not traveling across the wire?

mfikes 2017-11-22T18:57:58.000436Z

Yeah, or, even just leave it as JSON and interoperate with it as such in your app. Like

cljs.user=> (aget j 10)
#js {:category "EPITAPHS & TRIBUTES",
     :air_date "2004-12-31",
     :question "'\"And away we go\"'",
     :value "$400",
     :answer "Jackie Gleason",
     :round "Jeopardy!",
     :show_number "4680"}

mfikes 2017-11-22T18:58:35.000532Z

If your app depends on it being a vector of maps, then Transit

πŸ‘ 1
rauh 2017-11-22T18:58:41.000240Z

@hlolli Edn would be slower. But transit might be able to parse your JSON string, I don't think it requires transit. Worth a shot

πŸ‘ 1
richiardiandrea 2017-11-22T18:59:09.000148Z

can't transit work out of MessagePack as well? That would be way faster

mfikes 2017-11-22T19:07:58.000188Z

Yeah, @hlolli, @rauh is right, the Transit lib can directly read the JSON string. It produces a vector of maps in 724 ms for me. The resulting maps are keyed with strings.... wonder if there is an option to have it use keywords instead.

rauh 2017-11-22T19:08:25.000114Z

Yeah I realized that the keys will be strings afterwards 😞

dotemacs 2017-11-22T19:10:11.000521Z

Hi, need to stub out an env var which my lumo script expects, in order to test it. As a workaround I’m doing this, within the test ns: (def process.env.FOO "bar"). If I run the tests with: lumo -c src:test -m foo.main-test, the tests pass. But when I try to load the foo.main-test ns at the REPL, it bombs out. If I then go in and (def process.env.FOO "bar"), I can run the functions that I need to just fine. I’ve put a sample repo with just this example described above: https://github.com/dotemacs/faker How should I stub out env variables in the test ns, so that when I load it at the REPL, it doesn’t blow up?

mfikes 2017-11-22T19:10:19.000185Z

Hmm. (mapv clojure.walk/keywordize-keys ...) is no good from a perf perspective. It does the right thing but takes 6 seconds on that data.

2017-11-22T19:14:27.000605Z

@dotemacs maybe this is what you're trying to achieve?

cljs.user=> (set! js/process.env.FOO "bar")
"bar"
cljs.user=> js/process.env.FOO
"bar"
cljs.user=> 

dotemacs 2017-11-22T19:16:30.000086Z

looks so obvious now πŸ™‚ sorry for the noise and thanks @hlolli

rauh 2017-11-22T19:18:33.000323Z

@hlolli @mfikes You can use a custom mapbuilder with transit to parse the JSON string: https://gist.github.com/rauhs/301f59e0e2f94db4f22a4724fe50bd5f

rauh 2017-11-22T19:18:56.000176Z

Note line 13. If you don't have namespaces can be further sped up by writing (keyword nil s)

2017-11-22T19:25:16.000666Z

@rauh yes from the original it's bit over twice as fast. This looks like voodoo magic to me (in a good way).