Skip to content

Instantly share code, notes, and snippets.

@akond
akond / todo.clj
Created December 20, 2018 15:09
Clear the inputbox after an item was added
(ns javafx-app.todo
(:require
[flatland.useful.debug :refer [?]]
[fn-fx.fx-dom :as dom]
[fn-fx.diff :refer [component defui render should-update?]]
[fn-fx.controls :as ui]))
(def main-font (ui/font :family "Helvetica" :size 20))
(defui TodoItem
@akond
akond / random.clj
Created March 25, 2018 10:59
Random string
(defn rand-str [len]
(apply str (take len (repeatedly #(char (+ (* 32 (rand-int 2)) (rand 26) 65))))))
(defmacro defattrs [ & params ]
(let [forms# (map (fn [[a# b#]] (conj (list a# (conj (list b# :attributes) 'comp)) 'def)) (partition 2 params))]
`(list ~@forms#)
))
(ns component.core
(:require [reagent.core :as r]
[com.stuartsierra.component :as component]))
(enable-console-print!)
(defrecord Database [host port]
component/Lifecycle
(start [component]
{
:id "dev"
:source-map true
:source-map-timestamp true
:source-map-path "public/js"
:output-to "public/js/main.js"
:output-dir "public/js"
:asset-path "js"
:foreign-libs [
{:file "http://ariutta.github.io/svg-pan-zoom/dist/svg-pan-zoom.min.js"
(defn replace-nth [col n v]
(let [index (dec n)
eq? (partial = index)
to (empty col)]
(into to (map #(if (eq? %2) v %1) col (range)))))
(replace-nth [7 1 2 3 4 5 6 8] 4 "tttt")
/*
*
* A simple JavaScript dependency injection container
* By Monroe Thomas http://blog.coolmuse.com
*
* http://blog.coolmuse.com/2012/11/11/a-simple-javascript-dependency-injection-container/
*
* MIT Licensed.
*
* Unit tests can be found at https://gist.github.com/4270523
// unit tests for ServiceKernel.js (https://gist.github.com/4089076)
// requires QUnit test framework
module("ServiceKernelTests");
if (typeof throws === "undefined") throws = raises;
test("require unregistered service throws", function () {
var kernel = new ServiceKernel();