Clojure/Java: Prevent Exceptions With "trace missing"

The other day I got this little helpful exception from Clojure:

Continue reading →

ClojureScript/Om: Spurious "Minified exception occured" With Advanced Optimizations

After having upgraded to Om 0.6.3. and ClojureScript 2197, I suddenly got the following error in the browser when loading the .js compiled with :optimizations :advanced
Continue reading →

core.async: "Can't recur here" in ClojureScript but OK in Clojure

With the latest core.async and ClojureScript (core.async "0.1.303.0-886421-alpha"
Continue reading →

Graphite Shows Metrics But No Data - Troubleshooting

My Graphite has all the metrics I expect but shows no data for them. Communication between my app and Graphite clearly works otherwise the metrics would not have appeared in the list but why is there no data?

Update: Graphite data gotchas that got me

(These gotchas explain why I did not see any data.)
  1. Graphite shows aggregated, not raw data if the selected query period (24h by default) is greater than the retention period of the highest precision. F.ex. with the schema "1s:30m,1m:1d,5m:2y" you will see data at the 1s precision only if you select period less than or equal to the past 30 minutes. With the default one, you will see the 1-minute aggregates. This applies both to the UI and whisper-fetch.py.
  2. Aggregation drops data unless by default at least 50% of available data slots have values (xFilesFactor=0.5). I.e. if your app sends data at a rate more than twice slower than Graphite expects them, they will never show up in aggregates. F.ex. with the schema "1s:30m,1m:1d,5m:2y"  you must sends data at least 30 times within a minute for them to show in an aggregate.
I suppose that whisper-dump.py would show the raw data.

Lesson learned: Always send data to Graphite in *exactly* same rate as its highest resolution

As described above, if you send data less frequently than twice the highest precision (if 1s => send at least every 2s), aggregation will ignore the data, with the default xFilesFactor=0.5 (a.k.a. min 50% of values reqired factor). On the other hand, if you send data more frequently than the highest precision, only the last data point received in each of the highest precision periods is recorded, others ignored - that's why f.ex. statsD flush period must = Graphite period.


Continue reading →

Most interesting links of April '14

Recommended Readings


Continue reading →

Clojure: How To Prevent "Expected Map, Got Vector" And Similar Errors

What my Clojure code is doing most of the time is transforming data. Yet I cannot see the shape of data being transformed - I have to know what the data looks like on the input and hold a mental model of how they change at each step. But I make mistakes. I make mistakes in my code so that the data does not correspond anymore to the model it should follow. And I make mistakes in my mental model of what the data currently looks like, leading likely to a code error later on. The end result is the same - a little helpful exception at some later step regarding wrong shape of data. There are two problems here: The error typically provides too little useful information and it usually manifests later than where the code/model mistake actually is. I therefore easily spend an hour or more troubleshooting these mistakes. In addition to that, it is also hard to read such code because a reader lacks the writer's mental model of the data and has to derive it herself - which is quite hard especially if the shape of the input data is not clear in the first place.

I should mention that I of course write tests and experiment in the REPL but I still hit these problems so it is not enough for me. Tests cannot protect me from having a wrong model of the input data (since I write the [unit] tests based on the same assumptions as the code and only discover the error when I integrate all the bits) and even if they help to discover an error, it is still time-consuming the root cause.

Can I do better? I believe I can.


Continue reading →

How to create and run Gatling 2.0 tests

Getting up and running with Gatling perf. tests as I would like so I record this for my future reference.

0. Create a project:



$ mvn archetype:generate \
   -DarchetypeCatalog=http://repository.excilys.com/content/groups/public/archetype-catalog.xml
   -Dfilter=io.gatling:


(The trailing ":" in the filter is important.)

1. Import to IntelliJ

In IntelliJ choose to import an object, instead of "from sources" select "from external model" and then Maven. You will also need to have the Scala plugin installed and, when imported, you will likely need to right-click on pom.xml and Maven - Reimport.

2. Record a simulation

  1. Run the src/test/scala/Recorder.scala (right-click - Run 'Recorder')
  2. Set the port it should listen on, f.ex. 8000 (maybe you also need to set port for HTTPS, f.ex. 8001), set the target app (perhaps localhost, <some port>, <some https/dummy port>)
  3. Optionally set the class name of the recorded simulation and the target package (the output goes to src/test/scala/<package>/<name>.scala)
  4. Click [Start !]
  5. Go to your browser and configure it to use the recorder as its HTTP[s] proxy
  6. Browse localhost:8000/your_app as you want for the test
  7. Click [Stop and save] in the Recorder UI

Continue reading →

Kioo: How to Troubleshoot Template Processing

So you have created an Om/Reagent/React component using a Kioo template and the result is not as you expected, perhaps just an empty element? Let me share what I have discovered about troubleshooting this (though I am no expert). You will se how to invoke the underlying Clojure function component* manually, how to expand the deftemplate macro, how to call the resulting JavaScript function, and what the intermediate forms look like.


Continue reading →

Kioo: How To Replace The Whole Body

This whole post in unnecessary since it is simply possible to use a snippet directly without a template, as kindly explained by Creighton Kirkendall.

Kioo, the enlive-inspired templating library for React.js and derived libs such as Om, normally works by matching selectors against elements inside <body> and transforming the matched elements while also keeping all the other ones. But what if you want to keep just the single matched element and drop all the others? You need some tricks and I will demonstrate one possible way.

Dislaimer: This is a result of my experimentation, not deep knowledge if Kioo.


Continue reading →

Most interesting links of March '14

Recommended Readings

Clojure Corner


Continue reading →

Framework Joy: Load in Hibernate Updates Data

Would you ever guess that this line

Continue reading →

How To Generate A Valid Credit Card Number For A Bin (First 6 Digits)

There is plenty of generators that can produce numbers that are valid credit card numbers according to the Luhn check
Continue reading →

HttpServletRequest: requestURI/requestURL/contextPath/servletPath/pathInfo/queryString

I never remember what some of these HttpServletRequest
Continue reading →

Ansible: Best practices for deriving host-level var from a group var

I have a cluster and a group variable (in test/staging/prod) holding the hostname of the cluster master. For each host, I want to derive a variable which is set to either "slave" or "master" and use it in templates.

Continue reading →

Frustration-Driven Development - Towards DevOps, Lean, Clojure

A post about development practices, speed, and frustration.



My wife has mentioned that she likes my passion for doing things right in software development. That made me thinking, why do I actually care so much and do not just enjoy the coding itself? It boils down to that I am not happy until my code is in production. Seeking the satisfaction of having my code used by and helping people while trying to eliminate all unnecessary mental drain is behind all the practices that I embrace and evangelize. It's a drug I like to take often, in small doses.

practices = f(max(delivered value), min(mental energy))


So how does this relate to DevOps, Continuous Delivery, testing, single-piece-flow, Lean Startup, Clojure? It is simple.


Continue reading →

Copyright © 2024 Jakub Holý
Powered by Cryogen
Theme by KingMob