Skip to content

Instantly share code, notes, and snippets.

View MichaelDrogalis's full-sized avatar

Michael Drogalis MichaelDrogalis

  • Confluent
  • Seattle, WA
View GitHub Profile
(seed-table
{:database {:vendor :mysql :db "simulation" :user "root" :password ""} :table :persons :policy :clean-slate :n 50}
(seed
(randomized :name)
(randomized :number)
(randomized :age {:min 0 :max 90})
(randomized :nickname {:length 15})))
(def db {:vendor :mysql :db "simulation" :user "root" :password ""})
(defseed pet-rooms
{:database db :table :rooms}
(inherit :name))
(defseed pets
{:database db :table :pets}
(inherit :pid)
(randomized :name {:fk [pet-rooms :name]}))
mysql> describe persons;
+--------+---------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+--------+---------------+------+-----+---------+-------+
| name | varchar(32) | YES | | NULL | |
| number | int(11) | YES | | NULL | |
| money | decimal(10,2) | YES | | NULL | |
| about | varchar(50) | YES | | NULL | |
| secret | float(10,2) | YES | | NULL | |
+--------+---------------+------+-----+---------+-------+
@MichaelDrogalis
MichaelDrogalis / gist:4111672
Created November 19, 2012 16:34
Mongo draft
(seed-table
{:database {:db "stuff" :username "xx" :password "xx" :vendor :mongo} :policy :clean-slate :n 50
:types {:name {:type :string :min 5 :max 10}
:age {:type :integer :min 0 :max 99}
:zip {:type :string :exactly 5}}
(randomized :name)
(randomized :age)
(randomized :zip))
@MichaelDrogalis
MichaelDrogalis / gist:4116265
Created November 20, 2012 05:48
Things to fix in next Dibble release
  • Tests for the core.
@MichaelDrogalis
MichaelDrogalis / gist:4247217
Created December 9, 2012 22:03
Femor draft
(request!
{:url "http://localhost:3000/api/v1/sensor/:id"}
(url-params> (randomized-integer :id))
(query-string> (randomized-string :name)
(value-of :auth_token "ABCDEF0123456789")))
@MichaelDrogalis
MichaelDrogalis / gist:4381990
Last active December 10, 2015 04:38
Draft for dibble 0.2.0 release
(ns rjm-seeding.core
(:require [dibble.core :refer [defseed]]))
(defseed users
{:database {:db "rjmadmin" :user "root" :password "" :vendor :mysql} :table :rjm_users}
[:inherit :uid]
[:randomized :salt :length 5]
[:randomized :saltedpw :length 5]
[:randomized :email :length 5]
[:value-of :browser (rand-nth ["firefox" "chrome" "ie"])]
@MichaelDrogalis
MichaelDrogalis / gist:4393850
Last active December 10, 2015 06:18
Another draft for Pierce
(request
[:post :to "http://localhost:3000/books"]
[:edn {:title "A Tale of Two Cities" :year 1859}])
(request
[:post :to "http://localhost:3000/books"]
{:headers {:X-Api-Version "2"}
:socket-timeout 1000
:conn-timeout 1000
:body [:json {:title "A Tale of Two Cities" :year 1859}]})
;;; Form 1
(defprecondition some-func
(fn [& args]
(assert-conditions args))
(fn [e & args]
(error-handling args)))
;;; Form 2
(defprotocol Fly
(fly [this] "Method to fly"))
(defn bird-fly [this]
(str (:name this) " flies..."))
(with-precondition! #'bird-fly
:not-crow
(fn [this] (not= (:name this) "Crow")))