Skip to content

Instantly share code, notes, and snippets.

@polymeris
polymeris / core.cljs
Last active June 24, 2023 03:39
re-frame + reagent + figwheel app running in the console
(ns hello-react-blessed.core
(:require
[cljs.nodejs :as nodejs]
[reagent.core :as reagent]
[re-frame.core :as rf]
[blessed :as blessed] ; or use neo-blessed
["react-blessed" :as rb]
[ws]))
(defonce logger (reagent/atom []))
@polymeris
polymeris / core.cljs
Created December 2, 2018 18:52
proton-native in clojurescript via reagent
;; Add the following to cljsbuild :compiler options
;; :npm-deps {:proton-native "1.1.10"}
;; :install-deps true
(ns hello-proton-native.core
(:require [cljs.nodejs :as nodejs]
[reagent.core :as reagent]
["proton-native" :as proton :refer [App Window Button]]))
(nodejs/enable-util-print!)
@polymeris
polymeris / graphql.cljs
Created November 24, 2018 00:34
GraphQL subscriptions over Websockets from Clojurescript on Node
;; Add to cljsbuild
;; :npm-deps {:graphql-tag "2.10.0"
;; :apollo-link "1.2.4"
;; :apollo-link-ws "1.0.10"
;; :subscriptions-transport-ws "0.9.15"
;; :ws "6.1.2"}
;; :install-deps true
(ns example.graphql
(:require
(defn- parse-cron-part-range
[p]
(let [ab (split p #"-")
a (read-string (first ab))
b (read-string (second ab))]
(assert (< a b))
(range a (inc b))))
(defn- parse-cron-part
[p]
@polymeris
polymeris / lisp.lua
Created September 15, 2015 15:10
Toy Lisp interpreter in Lua / LPEG
local lpeg = require'lpeg'
local P, R, S = lpeg.P, lpeg.R, lpeg.S --patterns
local C, Ct = lpeg.C, lpeg.Ct --capture
local V = lpeg.V --variable
local parser = P {
'program', -- initial rule
program = Ct(V'sexpr' ^ 0),
wspace = S' \n\r\t' ^ 0,
atom = V'boolean' + V'integer' + V'string' + V'symbol',
@polymeris
polymeris / tasks.json
Created May 7, 2015 19:30
Visual Studio Code tasks.json for Lua projects (busted + luacheck)
// Available variables which can be used inside of strings.
// ${workspaceRoot}: the root folder of the team
// ${file}: the current opened file
// ${fileBasename}: the current opened file's basename
// ${fileDirname}: the current opened file's dirname
// ${fileExtname}: the current opened file's extension
// ${cwd}: the current working directory of the spawned process
{
"version": "0.1.0",