Skip to content

Instantly share code, notes, and snippets.

Идея - валидировать данные, задавая путь к значению и проверющий предикат.

Проблема в том, что не понятно какой формат должен иметь отчет об ошибках. Допустим, ошиибка в множестве, или в ключе мапы. Как указать путь к ошибочному значению? Что потом с этим путем делать?

#{ {:key :correct}  {:key :wrong} }

{ {:key :wrong} :value }
@ruanbekker
ruanbekker / setup-kubernetes-ubuntu-16.md
Last active October 21, 2023 08:25
Install a 3 Node Kubernetes Cluster on Ubuntu 16

Master: Dependencies

apt update && apt upgrade -y
curl https://packages.cloud.google.com/apt/doc/apt-key.gpg | apt-key add -

cat <<EOF > /etc/apt/sources.list.d/kubernetes.list
deb http://apt.kubernetes.io/ kubernetes-xenial main
EOF
@kvahuja
kvahuja / Items.php
Created March 4, 2017 04:55
Vainglory Items
<?php
return [
'*1000_Item_HalcyonPotion*' => 'halcyon-potion',
'Mulled Wine' => 'halcyon-potion',
'*1002_Item_WeaponBlade*' => 'weapon-blade',
'Weapon Blade' => 'weapon-blade',
'*1003_Item_CrystalBit*' => 'crystal-bit',
'Crystal1' => 'crystal-bit',

Synopsis

Implement an efficient datastructure that allows FAST access to the nth datom of a datomic index. This allows getting the "most recent post", "most popular post" etc.

;; API: to implement:
(nth-datoms db :avet :post/date 2284) ;; == (drop 2284 (d/datoms ...))
(rdatoms db :avet :post/date 50) ;; 50 last datoms of the index
(rdatoms-skip db :avet :post/date 150 50) ;; skip 150 datoms, get 50.
@hswick
hswick / pca.md
Last active August 23, 2018 12:21
Principal Component Analysis in pure Clojure

Visualizing the Iris with Principal Component Analysis

This post will teach you how to visualize higher dimensional datasets in lower dimensions using Principal Component Analysis. And guess what?! Its all in Clojure! I was inspired to write this because I was curious how Principal Component Analysis worked, and there aren't a lot of data analysis resources out there for Clojure.

The best one I could find was from Data Sorcery https://data-sorcery.org/category/pca/.

Now that blog post was very informative on how to do Principal Component Analysis (will be referring to this as PCA as well) in Clojure. However, when I decided to use it on a larger dataset I got an out of memory exception because the pca function incanter provides requires a matrix as input. The input matrix requires a lot of memory if the dataset is rather large. So I decided to write my own implementation which could calculate the covariance matrix with an input as a lazyseq. That way my input could be as big as I wanted. And learning

@acdlite
acdlite / app.js
Last active January 20, 2023 08:23
Quick and dirty code splitting with React Router v4
// getComponent is a function that returns a promise for a component
// It will not be called until the first mount
function asyncComponent(getComponent) {
return class AsyncComponent extends React.Component {
static Component = null;
state = { Component: AsyncComponent.Component };
componentWillMount() {
if (!this.state.Component) {
getComponent().then(Component => {
(ns om.next.spec
(:require [cljs.spec :as s]
[clojure.test.check :as tc]
[clojure.test.check.properties :as tcp]))
(s/def ::statics
(s/cat
:static '#{static}
:protocol-name '#{om.next/Ident om.next/IQuery om.next/IQueryParams}
:impls (s/* seq?)))
@mrmcc3
mrmcc3 / tokens.clj
Created April 2, 2016 04:13
Generate Firebase JWTs in Clojure (with buddy-sign)
(ns tokens
(:require [buddy.sign.jws :as jws]
[buddy.sign.util :refer [to-timestamp]]
[clj-time.core :as time]))
;; see https://www.firebase.com/docs/rest/guide/user-auth.html#section-token-generation
(defn firebase-token
"generates a firebase JWT. (generated JWT must be less than 1024 characters)
a nil token is returned if requirements aren't met
@idibidiart
idibidiart / GraphQL-Architecture.md
Last active September 16, 2023 18:36
Building an Agile, Maintainable Architecture with GraphQL

Building a Maintainable, Agile Architecture for Realtime, Transactional Apps

A maintainable application architecture requires that the UI only contain the rendering logic and execute queries and mutations against the underlying data model on the server. A maintainable architecture must not contain any logic for composing "app state" on the client as that would necessarily embed business logic in the client. App state should be persisted to the database and the client projection of it should be composed in the mid tier, and refreshed as mutations occur on the server (and after network interruption) for a highly interactive, realtime UX.

With GraphQL we are able to define an easy-to-change application-level data schema on the server that captures the types and relationships in our data, and wiring it to data sources via resolvers that leverage our db's own query language (or data-oriented, uniform service APIs) to resolve client-specified "queries" and "mutations" against the schema.

We use GraphQL to dyn

@robphoenix
robphoenix / spacemacs-cheshe.md
Last active February 6, 2024 23:11
[DEPRECATED] Spacemacs Cheat Sheet - Visit https://github.com/Ben-PH/spacemacs-cheatsheet

This is unmaintained, please visit Ben-PH/spacemacs-cheatsheet

Useful Spacemacs commands

  • SPC q q - quit
  • SPC w / - split window vertically
  • SPC w - - split window horizontally
  • SPC 1 - switch to window 1
  • SPC 2 - switch to window 2
  • SPC w c - delete current window