Сообщения

Сообщения за 2017
Мало того, что управление зависимостями в Rails то еще занятие, но упражнение по сборке бандла под Docker Alpine вообще за границами добра и зла. не libmysql-dev, блеать, а libmariadb-dev. и так далее
вот такие ментальные упражнения в маппинге DSL на SQL запросы просто демотивируют использовать рельсы и джемы https://stackoverflow.com/questions/42288875/constructing-an-activerecord-with-nested-joins-rails-4

Это пять!

А-а-а! "There is a gem for exevrything" rails mantra seems to be true! I've a problem assets precompilation in docker environment, and here is solution! Null DB Active record driver. Awesome! Meet the gem, that solves the problem, which should not exist at all! http://blog.zeit.io/use-a-fake-db-adapter-to-play-nice-with-rails-assets-precompilation/

clojure handy tips

use cond-> when you need to add optional parameter, like this (let [x 2]   (cond->  {:a 1}   (= x 2)  (assoc :b 2})) result will be {:a 1 :b 2}
what to do, when clojure map contains reserved kewords, like :@number? it's ok, in code you can use (keyword "@number") and be happy with that, but what to do to serialize map, or, when you need it as sample data for tests? in that case you can use clojure.walk (clojure.walk/stringify-keys m) and after that (clojure.walk/keywordize-keys m)

clojurescript and google closure compiler

I've just discovered joy of the Google Closure compiler, just when I've turned on warnings on infer when I started to get awkward errors upon javascript execution on minified CLJS. First, I've changed all (.-prop entity) to (goog.obj/get entity "prop") (.. % -target -value) to (goog.obj/getValuesByKey entity "target" "value") which is, as for me is more concise and crisp. Then, Delay class is much more clear and convenient then setInterval function. (.FileReader reader) was replaced by (goog.fs/FileReader.). "onload" event handler has been replaced by (.listen reader goog.fs/FileReader.EventType.LOAD_END) So, my code become much more clean and maintainable.

how to switch figwheel build for emacs cider

So, you can not be connected to two build simultaneously. for instance you have "dev" and "vote" builds, To make proper switching to another build you should do (swith-to-build "vote") in figwheel window :cljs/quit then (cljs-repl) and then open your page in browser, go to your namespace and voila!

clojurescript externs

Someday you try integration with other APIs, and ... here is a list of useful externs Most popular Google and Facebook externs http://closureplease.com/externs/ Firebase https://raw.githubusercontent.com/isabo/firebase-externs/master/firebase-externs.js And here is script for externs generation  http://jmmk.github.io/javascript-externs-generator/

layout for material-ui clojurescript

There will be layouts! https://material-ui-1dab0.firebaseapp.com/#/customization/api But for now you should still use react-flexbox-grid http://roylee0704.github.io/react-flexbox-grid/

Bug with Figwheel Client Version 0.5.8 is not equal to Figwheel Sidecar Version 0.5.9.

Figwheel Client Version 0.5.8 is not equal to Figwheel Sidecar Version 0.5.9. Just shift-reload your page in Google Chrome and that's it!

ClojureScript lifehacks

After ClojureScript Hackaton I've discovered several interesting tips. 1. Bug with loosing focus on input is due to nil value for string. In case you supply "" instead of nil bug dissapears. 2. Sometimes with RUM when you use for to loop through react components you should use with-keys 3. Nice desctructure for RUM when use local atoms can be done without let, right in parameters! Pushy and Bide are right choice for routing!

Dependency hell

Изображение
You can't imaging   how this shit depicts dependency hell , which was brilliantly discussed by Rich Hickey in his great talk Speculation.

New atom plugin for Clojure editing

Изображение
While Emacs is for brave and true, Atom is for the rest. But it's really interesting!

Using bower with clojurescript

Easy peasy.    :plugins [[lein-cljsbuild "1.1.4"]              [lein-bower "0.5.1"]] Connect bower plugin for lein and  do like following  lein bower install gentelella all resources will be fetched into resources/public folder of your project.

Tricks for namespaced and weird keywords

# :person { :first "Han" :last "Solo" :ship #:ship{ :name "Millenium Falcon" :model "YT-1300f light freighter" }} is read as: { :person/first "Han" :person/last "Solo" :person/ship { :ship/name "Millenium Falcon" :ship/model "YT-1300f light freighter" }} Also you can use this syntax (keyword :counters :fb) -> :counters/fb And to use spatial characters like :last_insert_rowid() from return value of Korma insert sql statement, I've found that way (keyword "last_insert_rowid()") -> :last_insert_rowid()

My Datascript tips and tricks

Sometimes you're using something like root structure with entity-id 0, that's convenient to do some routing and stuff like that I used to query this attrs like this (let [edit? (first (d/q '[:find [?v] :where [0 :person/edit ?v]] @conn))]]   edit?) But it's much better to use is like this via entity (let [edit? (:person/edit (d/entity @conn 0))]  edit?)