Moved to https://github.com/kbilsted/Functional-core-imperative-shell/blob/master/README.md
#!/usr/bin/env python3 | |
from yaml import load, dump, FullLoader | |
import sys | |
file_name = sys.argv[1] | |
def process_ua(data): | |
for node in data: | |
if 'family_replacement' not in node: |
(defn take-first-sorted-by | |
"Performs the same result as (take n (sort-by keyfn comp coll)) | |
but more efficient in terms of time and memory" | |
([n keyfn coll] (take-first-sorted-by n keyfn compare coll)) | |
([n keyfn ^java.util.Comparator comp coll] | |
(if (pos? n) | |
(let [m ^java.util.TreeMap (java.util.TreeMap. comp) | |
m-size (volatile! 0) | |
;; if it is guaranteed that (keyfn v) will be unique for all v in coll | |
;; we can attach :unique? key to keyfn meta and algorythm will use single val map |
#!/bin/bash | |
# Custom scripts here | |
echo "This is an extended entrypoint!" | |
# Run the original entrypoint located at | |
# /docker-entrypoint.sh | |
exec /docker-entrypoint.sh "$@" |
(require '[datomic.api :as d]) | |
(d/create-database "datomic:mem://counter-example") | |
;=> true | |
(def c (d/connect "datomic:mem://counter-example")) | |
;=> #'user/c | |
;; The essential features of creating and using an auto-increment counter in datomic: | |
;; | |
;; 1. A counter entity must store the current value and a nonce. |
(ns foo.test-helper | |
(:require [clojure.spec :as s] | |
[clojure.spec.test :as st] | |
[clojure.string :as str] | |
[clojure.test :refer :all] | |
[clojure.test.check.generators :as gen] | |
[clojure.test.check.random :refer [IRandom]] | |
[clojure.test.check.rose-tree :as rose])) | |
(defn instrument-all |
/** | |
* Proxy for accessing ES6 Maps like objects. | |
* Usage example: | |
* | |
* var p = new MapProxy(); | |
* p['key'] = 'value'; | |
* if ('key' in p) { | |
* console.log(p.key); | |
* } | |
* delete p.key; |
(defmacro try* | |
"Macro to catch multiple exceptions with one catch body. | |
Usage: | |
(try* | |
(println :a) | |
(println :b) | |
(catch* [A B] e (println (class e))) | |
(catch C e (println :C)) | |
(finally (println :finally-clause))) |
I'm hunting for the best solution on how to handle keeping large sets of DB records "sorted" in a performant manner.
Most of us have work on projects at some point where we have needed to have ordered lists of objects. Whether it be a to-do list sorted by priority, or a list of documents that a user can sort in whatever order they want.
A traditional approach for this on a Rails project is to use something like the acts_as_list
gem, or something similar. These systems typically add some sort of "postion" or "sort order" column to each record, which is then used when querying out the records in a traditional order by position
SQL query.
This approach seems to work fine for smaller datasets, but can be hard to manage on large data sets with hundreds (or thousands) of records needing to be sorted. Changing the sort position of even a single object will require updating every single record in the database that is in the same sort group. This requires potentially thousands of wri
# install and make run basic bootstrap date-picker functionality described here http://www.eyecon.ro/bootstrap-datepicker/ | |
# app/assets/javascript/datepicker.js.coffee | |
$(document).on 'pageChanged', -> | |
# datepicker for simple_form & Ransack | |
$(".custom_datepicker_selector").datepicker().on 'changeDate', (en) -> | |
correct_format = en.date.getFullYear() + '-' + ('0' + (en.date.getMonth() + 1)).slice(-2) + '-' + ('0' + en.date.getDate()).slice(-2) # date format yyyy-mm-dd | |
$(this).parent().find("input[type=hidden]").val(correct_format) |