Parsing and querying binary .fit files in Clojure

2017-04-05 Thread Jan Herich
As an active cyclist, I always wanted to do power-data analysis in my favourite language, so I finally put together this little tool: https://github.com/janherich/fit-to-edn. I hope it will be useful for someone else as well, what it does & how to use it is pretty well documented in the readme

Re: When to use metadata

2015-01-29 Thread Jan Herich
Solussd is absolutely correct, but maybe even more simplistic (or easier to grasp) explanation would be to use metadata if you don't want the additional (meta)data to change the equality semantics of the map, for example: (def test-desc1 {:number-of-threads 10}) (def test-desc2 ^{:integration t

Re: Idiomatic clojure on building a sequence

2014-05-21 Thread Jan Herich
Hi Colin, Have a look at the 'as->' macro, its very helpful in some cases, as: (-> [] (conj some-element) (as-> some-seq (if some-condition? (conj some-seq some-element) some-seq) (if some-other-condition? (conj some-seq some-other-element) some-seq)) (t

Re: Comparing classes in case statement

2014-02-27 Thread Jan Herich
>From official clojure documentation: "The test-constants are not evaluated. They must be compile-time literals" Dňa štvrtok, 27. februára 2014 14:03:04 UTC+1 Markus Bader napísal(-a): > > Hello, > > if I am not too dumb, it seems that comparing for classes does not work in > case statements, li

Re: Comparing Regular Expression pattens for equality?

2014-02-26 Thread Jan Herich
Clojure re-uses java.util.regex.Pattern objects. This object doesn't override equals method, so object references are always compared. But you can easily get pattern string from compiled pattern and then compare just them: user=> (= (.pattern #"test") (.pattern #"test")) true Dňa streda, 26.

Re: Latest web framework for clojure

2014-02-25 Thread Jan Herich
It depends also on your requirements. For example if you want your app to work in many deployment scenarios (standalone Jetty or Tomcat, J2EE web containers...) and you may have to use servlet 3.0 API asynchronous features, nothing beats pedestal currently. The concept of interceptors is lit

Re: Shutting down core.async executors threadpool

2014-02-24 Thread Jan Herich
ybe it is a tomcat issue. > > > On Mon, Feb 24, 2014 at 7:06 PM, Jan Herich > > wrote: > >> Hi Folks, >> >> I developed an pedestal application which uses core.async for real-time >> server push. >> Everything works fine, except little problem w

Shutting down core.async executors threadpool

2014-02-24 Thread Jan Herich
Hi Folks, I developed an pedestal application which uses core.async for real-time server push. Everything works fine, except little problem when i run the application as the Servlet in Tomcat (7.0.52). The problem is, that if i shutdown the tomcat instance with shutdown script (default bin/shu

Re: (series of swap! on atom) ==> single swap!

2014-02-16 Thread Jan Herich
=== > > To everyone: > > Why can swap! be retried? This confuses me -- to implement swap!, why > can't we > > * have a lock > > * ensure that only one swap! is in session at any given time > > * have the given swap! complete before ru

Re: (series of swap! on atom) ==> single swap!

2014-02-16 Thread Jan Herich
I'm afraid your understanding of atom swap! operations is not quite correct -> update function must (or should) be pure as well. See the documentationfor swap!, update function could be potentially called multiple times if there are more t

Re: Example in Joy of Clojure, 2nd edition (MEAP)

2014-02-15 Thread Jan Herich
Hello Eric, You can rewrite this functionality with key# and r# instead of ~'key and ~'r and it would work just as well, it's only not necessary to use unique symbols here, because you are not using them in the function body anyway, so there is no danger of accidental var capture. To be hones

Re: Handy clojure function to transform prepared statement queries

2014-02-10 Thread Jan Herich
6>. > > And until I do, I'm not going to document it, or make it official. But it's > there in v0.3.0, so if you want to field-test it, do let me know your > experiences. :-) > > (And, FWIW, I completely agree with Sean. This kind of thing definitely > be

Re: Handy clojure function to transform prepared statement queries

2014-02-10 Thread Jan Herich
discuss this topic. Dňa pondelok, 10. februára 2014 0:16:01 UTC+1 Sean Corfield napísal(-a): > > As maintainer of java.jdbc I'd say this is a more appropriate feature > for a DSL library like SQLingvo or HoneySQL (which may already support > something like this - I haven&#x

Handy clojure function to transform prepared statement queries

2014-02-09 Thread Jan Herich
Hello folks, In the last days, i was working with clojure/java.jdbc and yesql libraries (which are both great piece of work), the experience was overall very positive, but one thing bothered me, that i was unable to use plain prepared statements (and sadly, yesql) when working with IN clauses

Re: Idiomatic way to construct potentially time bound target channel in core.async

2014-02-03 Thread Jan Herich
Ok, so i'm thinking about such one-shot detachable input pipe channels... (ns async-util.input-pipe (:require [clojure.core.async.impl.protocols :as impl] [clojure.core.async :refer [ > Hello Folks, > > I need to construct core.async channel with following semantics: > > 1. When the

Re: Idiomatic way to construct potentially time bound target channel in core.async

2014-02-02 Thread Jan Herich
If anyone is interested, that's roughly what i'm currently thinking about... (ns async-util.input-pipe (:require [clojure.core.async.impl.protocols :as impl] [clojure.core.async :refer [ > Hello Folks, > > I need to construct core.async channel with following semantics: > > 1. When t

Idiomatic way to construct potentially time bound target channel in core.async

2014-01-31 Thread Jan Herich
Hello Folks, I need to construct core.async channel with following semantics: 1. When the channel is created, timeout is attached to channel 2. After timeout passes out, channel is closed 3. It's possible to detach timeout from the channel before it passes out Now i implemented it with something

Re: side-effect only function with map-like syntax (again)

2014-01-27 Thread Jan Herich
How about doseq ? Dňa utorok, 28. januára 2014 5:28:04 UTC+1 Mars0i napísal(-a): > > Back in 2007 ( > https://groups.google.com/forum/#!searchin/clojure/mapc/clojure/x0PDu_D6mP0/3A7CZe-ZDWAJ), > > Henk Boom raised the possibility of inclu

Re: Read file contents as map

2014-01-26 Thread Jan Herich
And if you are not sure about that, just use edn-only reader: (require '[clojure.tools.reader.edn :as edn]) (edn/read-string (slurp "file")) Dňa nedeľa, 26. januára 2014 17:12:32 UTC+1 mynomoto napísal(-a): > > If you are sure that the file doesn't contain malicious code you can use: > > (read-s

Re: core.async count in a channel

2014-01-21 Thread Jan Herich
Hello Paul, Why not just adjust the number of workers based on actual workload instead of monitoring the source channel for average depth ? Have a look at this codefrom clojure

Re: Servlet adapter for ring handlers with support for asynchronous processing

2014-01-18 Thread Jan Herich
.0 methods, you might want to use lein-servlet to run the servlet using > Jetty 9 maybe. > > https://github.com/kumarshantanu/lein-servlet > > Shantanu > > On Saturday, 18 January 2014 16:01:02 UTC+5:30, Jan Herich wrote: >> >> Hi Folks, >> >> Is someone

Servlet adapter for ring handlers with support for asynchronous processing

2014-01-18 Thread Jan Herich
Hi Folks, Is someone aware of servlet adapter (other then pedestal-service) for ring based handlers with support for asynchronous processing as specified in Servlet 3.0+ api ? Given that ring core was already refactored to support such solutions (middleware had been split into wrapping and re

Re: Grouping and nested keys in a hash

2014-01-16 Thread Jan Herich
e Jan? I ask because I often > don't know where to begin when approaching a problem with Clojure, and it > can be quite frustrating. > > On Thursday, January 16, 2014 2:45:48 PM UTC, Jan Herich wrote: >> >> Another way of doing that: >> >> (def data {:b--name

Re: Grouping and nested keys in a hash

2014-01-16 Thread Jan Herich
Oh, yes, my mistake, it should be data instead of s Dňa štvrtok, 16. januára 2014 15:56:18 UTC+1 James napísal(-a): > > Thank you for sharing. > > I think the final `s` needs to be `data`, right? > > On 16 Jan 2014, at 14:53, Jan Herich > > wrote: > > Here we go, mo

Re: Grouping and nested keys in a hash

2014-01-16 Thread Jan Herich
Here we go, more generic solution: (defn transform [data delimiter] (reduce (fn [acc [k v]] (let [key-strs (-> k (name) (str/split delimiter))] (assoc-in acc (mapv keyword key-strs) v))) {} s)) Dňa štvrtok, 16. januára 2014 14:46:46 UTC+1 James napísal(-a): > > Hello all, > > I've fo

Re: Grouping and nested keys in a hash

2014-01-16 Thread Jan Herich
My solution would work only for fixed 2 level deep maps, but it would be not so hard to modify it that it will be much more generic :) Dňa štvrtok, 16. januára 2014 14:46:46 UTC+1 James napísal(-a): > > Hello all, > > I've found myself stuck trying to move matching keys in a hash into a > nested

Re: Grouping and nested keys in a hash

2014-01-16 Thread Jan Herich
Another way of doing that: (def data {:b--name "B", :a--id 1, :b--id 2, :a--name "A"}) (defn transform [data delimiter] (reduce (fn [acc [k v]] (let [[f-k s-k] (-> k (name) (str/split delimiter))] (assoc-in acc [(keyword f-k) (keyword s-k)] v))) {} s)) (transform data #"--") ;; {:a

Re: [ANN] incise 0.1.0 - An extensible static site generator

2014-01-14 Thread Jan Herich
Hello Ryan, Thank you for the project, i was always missing a good static site generator written in clojure ! You took some interesting design decisions with extensibility. I'm currently working on the similar project , even if my design is very differe

Re: A question about lazy seq with io

2014-01-13 Thread Jan Herich
As Mauricio already mentioned, map is not meant to be used for side-effects, if you want to need to evaluate a sequence for side-effects, use doseq instead. Regarding your first question about explicit loop-recur, i think it's reasonable w

Re: Adding query customization to Ring-based REST APIs

2014-01-12 Thread Jan Herich
Hello Alexander, I did some work in this area some time ago, and the result was service-hub library - created to simplify basic CRUD services. It's designed to allow more then one type of data-store, currently it supports SQL databases (i use my own fork

Re: HttpKit, Enlive (html retrieval and parsing)

2014-01-11 Thread Jan Herich
I don't recommend using java's built in HTTP retrieval (by passing java.net.URL object to enlive html-resource function). Not only is it significantly slower then using clj-http (which uses apache-http client under the hood), but it's also unreliable when issuing more parallel requests. Current

Re: Sorting Nested Vectors and filter out some

2014-01-04 Thread Jan Herich
Hello Jeff, This should do the trick, at least it worked with data set you provided :) Dňa sobota, 4. januára 2014 11:31:07 UTC+1 Jeff Angle napísal(-a): > > Hi...I get my nested vector from a database, then map a function that > fo

Re: Parallel http requests

2013-12-31 Thread Jan Herich
Maybe it's not exactly what you need, but i did similar thing once - i needed to scrape many linked html resources to extract tree data structure, each request/parse operation took considerable time - around 2 seconds - i was using clj-http/enlive combo (which is actualy Apache HttpClient/ TagS

Re: Akka-like framework in Clojure ?

2013-12-27 Thread Jan Herich
Hi Eric, Maybe pulsar is what you are looking for, but i recommend you to also discover the other way of doing concurrency in clojure instead of the actor model -> have a look at CSP and its

Re: [ANN] Component: dependency injection and state management

2013-11-21 Thread Jan Herich
This is simple brilliant... The approach proposed and the component "framework" implementing it finally solves the issue with the "necessary evil" (start/stop interactions with statefull components in any bigger Clojure app) by cleverly taking only the best ideas (like using inferred dependency

[ANN] Service-hub - Library for building service-oriented applications

2013-11-11 Thread Jan Herich
https://github.com/ITEdge/service-hub Service-hub is a modular library for building service-oriented applications with fine grained authentication, authorization and validation rules. The library is centered around idea of "handlers" as light-weight abstractions to CRUD interactions and "service