Skip to content

Instantly share code, notes, and snippets.

# all indexes are 0-based
2 def page_map(page, count, vidaas_count = 20)
3
4 start_idx = page * count
5
6 first_page = start_idx / vidaas_count
7 last_page = first_page + (count / vidaas_count)
8
9 start_offset = start_idx % vidaas_count
10 end_offset = start_idx + count
1 # all indexes are 0-based
2 def page_map(page, count, vidaas_count = 20)
3
4 start_idx = page * count
5
6 first_page = start_idx / vidaas_count
7 last_page = first_page + (count / vidaas_count)
8
9 start_subset = start_idx % vidaas_count
10 end_subset = start_subset + count
def page_map(page, count, vidaas_count = 20)
  start_idx = page * count
  first_page = start_idx / vidaas_count
  last_page = first_page + (count / vidaas_count)
  start_subset = start_idx % vidaas_count
  end_subset = start_subset + count
@levand
levand / cider-opinions.md
Last active November 20, 2023 07:50
Why I don't use cider

Why I don't use cider.

This is all personal opinion and a matter of taste. I'm putting it here because people have asked - I'm glad Cider exists and that a lot of people are obviously using it to great effect. This is not an attack on Cider or a an attempt to negate the experience of those who like it, just my own experience.

Also some of the critiques are more properly aimed at nRepl than Cider - I don't use nRepl either, in Emacs. For some reason I have fewer issues with it in Cursive (though I still do have some).

  1. With Cider, there's too much "going on" between Emacs and Clojure. When something glitches, hangs, doesn't return a value, throws an excption, etc (as it does, multiple times a day), I don't know whether the problem is in Emacs, in the Cider client, the nRepl server, one of any of the default middlewares or in my actual program. I run Emacs in inferior lisp using lein trampoline -m clojure.main - if something goes wrong, it's either in Emacs (which is usually obvious) or my program. Mi

So, I was having a twitter discussion with the esteemed @alandipert and @swannodette that has gone beyond the scope of what can be effectively communicated in 140 characters.

It was on the perceived value of Clojure's new feature expressions and whether they are worth the complexity cost of adding to Clojure and all its dialects.

Alan's contention (and forgive me if I am misconstruing this, Alan) is that feature expressions make the Clojure reader considerably more complex, and so it becomes that much more difficult to write any software which reads Clojure code (except for Clojure's own reader, of course, where the work is already done). As best I understand Alan's argument, this is a significant enough effect to undermine or negate the value proposition of Feature Expressions all together.

I disagree, so I'd like to go through the pros and cons of each use case.

  • Application developers (single-platform codebase): No impact.
  • Application developers (multi-platform codebase): FX are strictly easier to u
(deftype MyCountable [delegate]
#+clj clojure.lang.Counted #+cljs ICounted
#+clj (count [_] (.count delegate))
#+cljs (-count [_] (-count delegate)))
@levand
levand / gist:5f89e5831c0f9e75b748
Created July 9, 2015 16:28
datomic repo profile example
;;profiles.clj
{:user {:repositories {"my.datomic.com" {:url "https://my.datomic.com/repo"
:username "luke@cognitect.com"
:password "MY SUPER SECRET PASSWORD"}}}}
### Keybase proof
I hereby claim:
* I am levand on github.
* I am vanderhart (https://keybase.io/vanderhart) on keybase.
* I have a public key whose fingerprint is 033A 1E51 4A22 2CC4 5C34 E6C2 F8E0 3980 F58B C1B7
To claim this, I am signing this object:
#my/str [
"The first line"
"The second line"
"The third line"
]
@levand
levand / asset-dsl.clj
Last active January 10, 2017 15:48
What style of asset/cljs DSL do you find more natural?
;; Both of these code samples do exactly the same thing: define an asset pipeline
;; with a ClojureScript build that reads from "src/cljs/*" and compiles to "out/*".
;;The question is, which style of DSL is more readable/natural?
(require '[arachne.assets.dsl :as a])
(require '[arachne.cljs.dsl :as cljs])
(def opts {:output-to "js/main.js"
:output-dir "js"
:asset-path "js"