Skip to content

Instantly share code, notes, and snippets.

@mynomoto
mynomoto / missing_keys_specs.clj
Created October 16, 2017 12:43 — forked from stuarthalloway/missing_keys_specs.clj
I think it would be a mistake to introduce temporal coupling to prevent typos.
;; I think it would be a mistake to introduce temporal coupling to prevent typos.
;; The example program below lets you identify "missing" keys specs at
;; the time and place of your choosing, and then handle them as you
;; deem appropriate, without imposing those decisions on other
;; users of spec.
(require '[clojure.spec.alpha :as s]
'[clojure.set :as set])
@mynomoto
mynomoto / explorando_marte.md
Created October 25, 2017 14:56 — forked from nirev/explorando_marte.md
Teste de Programação - Backend - XERPA

Teste de Programação - Backend - XERPA

Olá! Como parte do processo de seleção da Xerpa, gostaríamos que você fizesse uma pequena tarefa. Esperamos que ela seja feita preferencialmente em uma das nossas linguagens principais: Elixir, Erlang ou Clojure.

A ideia é olhar como é seu estilo de programação e quais decisões você toma ao resolver um problema. Para isso, crie um projeto no seu Github para podermos acompanhar a árvore de commits!

Sinta-se à vontade para criar em cima do problema abaixo.

@mynomoto
mynomoto / Datomic-HSQLDB Storage.md
Created December 5, 2017 13:32 — forked from jamesnyika/Datomic-HSQLDB Storage.md
Datomic - HSQLDB Storage Setup

Howto - Setting Up an HSQLDB Storage for Datomic

This gist walks you through the steps of setting up a storage for your datomic starter instance to use an HSQLDB instance (running as a standalone server - i do not address embedded, http, in memory or other forms of the server). I am sure the same can be applied to any other SQL based storage so it should be portable to Apache Derby. I am writing this for those who may find it useful in getting this done quickly without spending a week as I did trying to figure out what I was doing wrong.

Part I : Install & Setup Your Storage: the HSQLDB Server

  1. Download the latest version of the database from here
  2. The most important file you will need is the hsqldb.jar file. This is the database. This will need to be in your classpath to be able to run the server.
  3. I then create a bash script for easy execution of the Network Server version of the database as shown below.
FROM openjdk:8u121-jdk-alpine
RUN apk update && apk add curl bash
ADD https://private/url/for/datomic-pro.zip /datomic-pro.zip
RUN mkdir /datomic && unzip /datomic-pro.zip -d /datomic
ADD go.sh /go.sh
RUN chmod 755 /go.sh
@mynomoto
mynomoto / cats.clj
Created April 24, 2019 22:11
Sample of using funcool/cats {:mvn/version "2.3.2"}
(ns kondo.cats
(:require
[cats.core :as m]
[cats.monad.either :refer [left left? right right?]]))
(defn assoc-b
[m v]
(right (assoc m :b v)))
(defn merge-2
@mynomoto
mynomoto / gist:11928f70aa9273f8e9f4
Created August 12, 2014 14:40
Reactive font size and grid
(page "index.html")
(defc t "Grumpy wizards make toxic brew for the evil Queen and Jack.")
(defc size 16)
(defn r [size] (range 1 size))
(defc= make-grid
(str "background-size: " size "px, " size "px; background-image:repeating-linear-gradient(0deg, #000, #000 1px, transparent 1px, transparent "
size "px); height:100%; width:100%; position:absolute;z-index: 1"))
(ns view.index
(:require
[hoplon.core :as h]
[javelin.core :as j]))
(j/defc cond-tpl-number 4)
(j/defc= is-4 (= cond-tpl-number 4))
(defn cond-tpl-example
[]
(ns view.index
(:require
[hoplon.core :as h]
[javelin.core :as j]))
(j/defc i 0)
(j/defc j 1)
(j/defc k 2)
(def formula-of-test (j/formula-of [i j k] (+ i j k)))
(ns view.index
(:require
[hoplon.core :as h]
[javelin.core :as j]))
(def a (j/cell 42))
(def b (j/cell {:x 100 :y 200}))
(def formulet-test
(j/formulet [v (j/cell= (inc a))
w (+ 1 2)
(require '[hoplon.core :as h])
(require '[javelin.core :as j])
(defn random-string
[]
(apply str (repeatedly 20 (fn [] (rand-nth "abcdefghijklmnopqrstuvwxyz0123456789")))))
(j/defc title "From Hoplon")
(def next-title
{"From Hoplon" "Clicked button"