Skip to content

Instantly share code, notes, and snippets.

@p-himik
p-himik / text_field.cljs
Last active January 11, 2021 11:40
Material-UI TextField with Reagent
(ns text-field
(:require
[goog.object :as gobj]
[reagent.core]
;; Note that this particular `:require` vector is for shadow-cljs.
;; Other build tools might use different conventions.
["@material-ui/core/TextField" :default TextField]))
;; Copied from `re-com.util`.
(defn deref-or-value
@jmlsf
jmlsf / js-in-cljs.md
Last active January 25, 2024 23:15
Using JavaScript modules in ClojureScript

Using JavaScript Libraries from ClojureScript

Using JavaScript libraries from ClojureScript involves two distinct concerns:

  1. Packaging the code and delivering it to the browser
  2. Making ClojureScript code that accesses JavaScript libraries safe for advanced optimization

Right now, the only single tool that solves these probems reliably, optimally, and with minimal configuration is shadow-cljs, and so that is what I favor. In paricular, shadow-cljs lets you install npm modules using npm or yarn and uses the resulting package.json to bundle external dependencies. Below I describe why, what alternatives there are, and what solutions I disfavor at this time.

Packaging and Delivering Code

(require '[clojure.set :as set])
(def info
[{:year 2017
:month 4
:data "x"}
{:year 2017
:month 4
:data "y"}
@Pyppe
Pyppe / README.md
Last active May 23, 2020 08:55
Suomen kuntakartta 2017 GeoJSON

1. Load and transform TietoaKuntajaosta_2017_4500k.zip from kartat.kapsi.fi

wget "http://kartat.kapsi.fi/files/kuntajako/kuntajako_4500k/etrs89/shp/TietoaKuntajaosta_2017_4500k.zip"
unzip TietoaKuntajaosta_2017_4500k.zip
ogr2ogr -f GeoJSON -t_srs crs:84 SuomenKuntajako_2017_4500k.geo.json SuomenKuntajako_2017_4500k.shp

2. Transform and enhance GeoJSON

  • Added "maakunta" information from Wikipedia
@eunomie
eunomie / README.md
Created April 27, 2017 09:44
How to send containers log to ELK using gelf log driver

Send docker logs to ELK through gelf log driver

There's so many way to send logs to an elk... logspout, filebeat, journalbeat, etc.

But docker has a gelf log driver and logstash a gelf input. So here we are.

Here is a docker-compose to test a full elk with a container sending logs via gelf.

@andrewvc
andrewvc / count-clj-sloc.sh
Created July 23, 2012 04:19
Counting SLOC in clojure is pretty easy since the syntax is so simple.
# Count SLOC
export SLF=`mktemp -t cljsloc`; find src test -name "*.clj" | xargs egrep -v "(^[[:space:]]*$|^[[:space:]]*;)" | cut -d: -f1 > $SLF && echo "Files"; uniq -c $SLF; echo "Total" `cat $SLF | wc -l`; rm $SLF