Skip to content

Instantly share code, notes, and snippets.

Avatar

Isak Sky isaksky

View GitHub Profile
@isaksky
isaksky / reframe-helper.cljs
Last active Sep 15, 2020
Register delayed subscription
View reframe-helper.cljs
(ns foo
(:require [re-frame.core :as rf]
[re-frame.db]
[reagent.ratom :as ra :refer [reaction]])
(:import goog.async.Debouncer))
(defn reg-sub-delayed
"Similar to reg-sub, except the computation is debounced.
It can be called like this:
@isaksky
isaksky / Working-with-SQL-syntax-trees-in-F.md
Last active Dec 14, 2019
Working with SQL syntax trees in F#
View Working-with-SQL-syntax-trees-in-F.md

Working with SQL syntax trees in F#

Update 12/15/2016 - Added Sql generation

Welcome to my blog post for #FsAdvent 2016.

If you're using a relational database, as your application grows in size, at some point you may find yourself looking for an SQL parser. This can give you lots of leverage, for example allowing you to:

  • Do permission checks on queries before executing them
  • Rewrite incorrect or inefficient queries
@isaksky
isaksky / i18n-impl.cljs
Created Nov 5, 2019
Handling translations in ClojureScript
View i18n-impl.cljs
(ns front.utilities.i18n-impl
(:require [front.i18n]))
(defn build-domain-index [text-vec]
(let [by-msgid (atom (transient {}))
by-msg (atom (transient {}))]
(doseq [{:keys [s_message s_message_id] :as text} text-vec]
(when-not (clojure.string/blank? s_message_id)
(swap! by-msgid assoc! s_message_id text))
(when-not (clojure.string/blank? s_message)
View solution.sql
declare @input nvarchar(max) =
N'1 1 E
RFRFRFRF
1 1 E
3 2 N
FRRFLLFFRRFLL
3 3 N
0 3 W
@isaksky
isaksky / gist:f693864aeedef8b54c1163342b36d788
Created Oct 8, 2019
Watch fancy CSS (less, scsss, etc) via shadow-cljs
View gist:f693864aeedef8b54c1163342b36d788
(ns front.tasks.watch-css
(:require [clojure.java.io]
[clojure.java.shell :refer [sh]]
[juxt.dirwatch :refer [watch-dir]]
[clojure.core.async :as a]
[clojure.string :as str]
#_[shadow.cljs.devtools.api :refer [send-to-runtimes!]]))
(defn debounce-chan
"Taken from https://gist.github.com/xfsnowind/e15cc2e6da74df81f129"
@isaksky
isaksky / no-stutter.cljs
Last active Sep 17, 2019
Non stuttering text control in re-frame
View no-stutter.cljs
(require '[reagent.ratom :as ra])
(require '[reagent.core :as reagent])
(require '[re-frame.core :as rf])
(defn non-stuttering-text-control [props]
(let [text-value-atom (atom "")
outside-change-counter (ra/atom 0)
to-dispose (atom [])]
(fn [props]
@isaksky
isaksky / Foo.ex
Created May 23, 2019
Update URL via Liveview
View Foo.ex
# In somethingLive.ex:
def handle_event("some_event", _params, socket) do
assign(socket, :updated_url, Routes.project_path(MyApp.Endpoint, :index))
end
# In template: <%= js_url_update_script(assigns[:updated_url]) %>
# In form_helpers.ex, or similar:
@isaksky
isaksky / codemirror.cljs
Created Dec 12, 2018
Reframe codemirror
View codemirror.cljs
(ns mything.components.codemirror
(:require [reagent.core :as reagent]
[re-frame.core :as rf]
[reagent.interop :refer [$]]
cljsjs.codemirror
cljsjs.codemirror.mode.clojure
cljsjs.codemirror.mode.sql))
(def codemirror-defaults {:lineNumbers true
:lineWrapping true
@isaksky
isaksky / Results.txt
Created Apr 25, 2018
Gjallarhorn read consistency
View Results.txt
..................................X...X....X.X.X.X....XX.XXX...X.....XX....X..........XX.....X..X..XX..X.......X....X...XXX.X..X..XX....X.X..XX.X..X.X....X....X.X.XX.X..........XX..X....X.XX.X.XX..XXX.XXXXXX............X.....X..XX..XXX.....X.X.X.X....X..X.XX.XX.X..XX....X.......X..X.X...XX.XX..X..X..X..XX..X......X..XX.XX.XX..X.....X...XX..X.....XX......X.......X....X.................X.....................X...............X............X.X.......XX..XX......X.X.X...XXXX.X.XXXXXX.X.XX..X...X........X.....XX...X.XXXXXX.....XXXX.......X.X.X...XX..X.X....XXX...X....X..X.......X.X.........X.XX....X.........XX.XX.XX.X..X...X.X.X...XX....XX...........X........................X..X.X.X...XX....................X........XX.......X........X....X...............X............X..X.X.XXX...XXXX.....XX...X...X.....X......XX.X.X...X....X..X.X..X..X..XXX.X.XXXXX........XX....XX.X.XXXXX..X.X........X...........X..X.X.X...X......XX...X......X..X.X..X.X..X.....XX...X...X.....XX..X......X..X....X.XX.X..X.X.X.X.X.X..X....X.X....XX.X...