Skip to content

Instantly share code, notes, and snippets.

@geraldodev
geraldodev / bound-input
Last active November 23, 2015 00:11
bound-input function to be called in place of dom/input when you want to update the underlying state key by key. It assumes a component with Ident
(ns credito.core
(:require
[cljs.pprint :refer [pprint]]
[datascript.core :as d]
[goog.dom :as gdom]
[om.dom :as dom]
[om.next :as om :refer-macros [defui]]
))
(enable-console-print!)
@jackrusher
jackrusher / webview-for-martin.clj
Last active December 29, 2016 22:24
An example boot-ified Swing app that contains a JavaFX WebView (Webkit instance).
#!/usr/bin/env boot
;; -*- mode: Clojure;-*-
(set-env! :dependencies '[[seesaw "1.4.5"]])
(use 'seesaw.core)
(import '(javafx.scene.web WebView)
'(javafx.scene SceneBuilder)
'(javafx.scene.layout VBoxBuilder))
@robert-stuttaford
robert-stuttaford / config.edn
Last active May 1, 2017 07:07
Using Onyx with Trapperkeeper
{:environment :production
:global {:logging-config "./logback.xml"}
:onyx {:job-scheduler :onyx.job-scheduler/balanced
:task-scheduler :onyx.task-scheduler/balanced
:peer-config {:onyx.messaging/impl :netty
:onyx.messaging/peer-port-range [40200 40220]
:onyx.messaging/peer-ports [40199]
:onyx.messaging/bind-addr "localhost"
:onyx.messaging/backpressure-strategy :high-restart-latency}
:peer-count 20
@scttnlsn
scttnlsn / core.cljs
Created July 1, 2015 17:58
Reagent/Secretary nested routing
(ns nested-routing.core
(:require [goog.events :as events]
[goog.history.EventType :as EventType]
[reagent.core :as reagent]
[reagent.ratom :refer-macros [reaction]]
[re-frame.core :refer [dispatch dispatch-sync register-handler register-sub subscribe]]
[secretary.core :as secretary :refer-macros [defroute]])
(:import goog.History))
(declare route-components
;; Lambkin, a garbage-collected heap suitable for microcontrollers.
;; Copyright (C) 2015 Andy Wingo <wingo@igalia.com>.
;;
;; This program is free software: you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation, either version 3 of the License, or
;; (at your option) any later version.
;;
;; This program is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
@bhauman
bhauman / composable_build.md
Last active August 29, 2015 14:23
Composable cljs build scripts

Independent composable build scripts for cljs

There is a need more complex build scripts for ClojureScript. It would be nice to have a minmal interface and method for composing these scripts. Somehting like:

(-> (watch-cljs ["src"])
    (watch-sass [""])
    (compile-sass)
    (watch-css [""])
 (mark-macro-affected-source build-options)
@non
non / answer.md
Last active January 9, 2024 22:06
answer @nuttycom

What is the appeal of dynamically-typed languages?

Kris Nuttycombe asks:

I genuinely wish I understood the appeal of unityped languages better. Can someone who really knows both well-typed and unityped explain?

I think the terms well-typed and unityped are a bit of question-begging here (you might as well say good-typed versus bad-typed), so instead I will say statically-typed and dynamically-typed.

I'm going to approach this article using Scala to stand-in for static typing and Python for dynamic typing. I feel like I am credibly proficient both languages: I don't currently write a lot of Python, but I still have affection for the language, and have probably written hundreds of thousands of lines of Python code over the years.

Practical Considerations of Intercepting Clojure evaluation

One important extension that Gradually Typed Clojure will require is hooking into the standard Clojure evaluation process. There are at least two motivations for this:

  1. As discussed in previous articles, it is often necessary to insert extra checks in code depending on how it is used.
  2. Typed Clojure can uncover type-based optimisations, such as identifying a missing type hint, and we want to automatically apply this.

The existing prototype has been a useful experiment which has revealed some of the subtleties of Clojure evaluation.

The basic approach is to use nREPL middleware to type check REPL interactions.

@cemerick
cemerick / repl_interaction.txt
Created April 26, 2015 01:12
using cljs.jar + nREPL + piggieback
chas@t440p:~/Downloads$ java -cp cljs.jar:/home/chas/.m2/repository/org/clojure/tools.nrepl/0.2.10/tools.nrepl-0.2.10.jar:/home/chas/.m2/repository/com/cemerick/piggieback/0.2.1/piggieback-0.2.1.jar clojure.main nrepl_piggieback.clj &
nREPL server running on port 7888
# using Leiningen here _only_ to connect to the running nREPL server
# any nREPL client will do
chas@t440p:~/Downloads$ lein repl :connect 7888
Connecting to nREPL at 127.0.0.1:7888
REPL-y 0.3.5, nREPL 0.2.10
Clojure 1.7.0-beta1
@cgrand
cgrand / transmogrify.clj
Last active August 29, 2015 14:18
transmogrify->> rewrites last-threaded forms to use transducers.
(defmulti transmogrify
"Rewrites the last form of a thread-last to use transducer (if possible)."
(fn [f xform src & args] f))
(defmacro transmogrify->>
"Like ->> but uses transducers"
([x] x)
([src & xs]
(let [end (last xs)
xforms (butlast xs)