View json-schema-in-plumatic-schema.clj
(require '[schema.core :as s])
(def StrOrKeyword (s/cond-pre s/Str s/Keyword))
(declare Schema)
(declare SchemaValue)
(def SchemaMap {s/Keyword (s/recursive #'SchemaValue)})
(def SchemaArray [(s/recursive #'SchemaValue)])
(def SchemaValue (s/cond-pre s/Str s/Num Nil s/Bool SchemaMap SchemaArray))
(def SchemaType (s/enum "string" "number" "integer" "null" "boolean" "array" "object"))
View clojure-spec-plumatic-schema-comparison.clj
(ns versioned.crud-api-attributes
(:require [versioned.model-support :as model-support]
[versioned.model-spec :as model-spec :refer [Model]]
[versioned.json-api :as json-api]
[versioned.model-attributes :refer [api-writable-attributes api-readable-attributes]]
[versioned.crud-api-audit :refer [updated-by created-by save-changelog]]
[versioned.crud-api-types :refer [coerce-attribute-types]]
[clojure.spec :as s]
[schema.core :as schema]))


We are using the Builder pattern here. Notice how each field is duplicated about five times and how we need to implement equals and hashCode manually (left as an exercise for the reader):

import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;

@JsonDeserialize(builder = User.Builder.class)


public Optional<String> getType() {
    return this.types.isEmpty() ?
        Optional.empty() :
        Optional.of(String.join(",", (Iterable);
View synchronized_function.js
'use strict';
// NOTE: this in memory locking approach will only work with a single process
// You might use something like Redis och memcachached for storing the lock if you need to lock
// across several processes.
var synchronizedFunction = function(lockIdFn, fn) {
var locks = {};
var synchronized = function() {
var args =,
lockId = lockIdFn.apply(null, args);
View clojure-derive-multimethods-example.clj
; public class ContentItem {
; public String foobar() {
; return "content_item";
; }
; }
View gist:b07ed9377153c5ced7e6
'use strict';
var R = require('ramda');
{category_type: 'cuisine', id: 1, name: 'French', type: 'categroy'},
{category_type: 'diets', id: 2, name: 'Vegetarian', type: 'category'}
var children = {
View gist:496e99b118e7688e2cab
'use strict';
var R = require('ramda');
var blank = function(value) {
return value == null || (typeof value === 'string' && value.trim().length === 0);
var present = function(value) {
return !blank(value);
View gist:75aa6cf67f370b5bae4e
var filteredLinks = [];
var weekdayCounts = {};
// Limit to 4 links per weekday.
// Loop through all links and keep track of
// how many are in each weekday.
widget.links.forEach(function(link) {
var weekday =;
if (weekdayCounts[weekday] === undefined) {
weekdayCounts[weekday] = 0;
View es6-uncensored.js
// 1. Swith two variables
// ES5
var temp = a;
a = b;
b = temp;
// ES6 - destructuring assignment
[b, a] = [a, b];