Skip to content

Instantly share code, notes, and snippets.

View simongray's full-sized avatar

Simon Gray simongray

View GitHub Profile
@joyheron
joyheron / custom-elements.cljs
Last active January 22, 2020 10:02
Define Custom Elements in ClojureScript
;; Solution based on https://stackoverflow.com/questions/50295703/create-custom-elements-v1-in-es5-not-es6
(defn define-element! [name on-connect]
(let [my-el (fn [] (this-as this (.construct js/Reflect js/HTMLElement #js [] (.-constructor this))))
_ (set! (.. my-el -prototype) (.create js/Object (.-prototype js/HTMLElement)))
_ (set! (.. my-el -prototype -constructor) my-el)
_ (.setPrototypeOf js/Object my-el js/HTMLElement)
_ (set! (.. my-el -prototype -connectedCallback) on-connect)]
(.define js/customElements name my-el)))
(define-element! :my-element #(.log js/console "hi!"))
@pesterhazy
pesterhazy / reagent-react-virtualized.cljs
Last active October 1, 2020 21:16
react-virtualized used from reagent
;; [cljsjs/react-virtualized "7.11.8-1" :exclusions [cljsjs/react]]
(ns react-virtualized.example
(:require [cljsjs.react-virtualized]
[clojure.string]
goog.date.DateTime
[reagent.core :as r]))
(defn fmt-value [v]
(cond
@brymck
brymck / clojure_big_o.md
Created January 5, 2014 09:36
Clojure Big-O

Clojure Big-O

op hash-map sorted-map hash-set sorted-set vector queue list lazy seq
conj log32n log2n log32n log2n 1 1 1 1
assoc log32n log2n - - log32n - - -
dissoc log32n log2n - - - - - -
disj - - log32n log2n - - - -
nth - - - - log32n n n n
get log32n log2n log32
@pesterhazy
pesterhazy / react_cljs_es6_classes.cljs
Last active November 7, 2021 17:54
ClojureScript: bare React with ES6 classes (extending React.Component, no createClass or reagent)
(ns demo.react-cljs-es6-classes
(:require [goog.object :as gobj]))
;; Demo of using bare React using ES6 classes (without createClass or reagent)
;;
;; Equivalent of Javascript/JSX:
;;
;; class MyComponent extends React.Component {
;; constructor(props) {
;; super(props);
@lagenorhynque
lagenorhynque / interceptors-into-the-core-of-pedestal.md
Last active November 11, 2022 07:11
Interceptors: Into the Core of Pedestal

Interceptors

Into the Core of Pedestal


カマイルカ🐬/laʒenɔʁɛ̃k/

(defprofile lagénorhynque
@nwh
nwh / naur.md
Created July 20, 2021 22:52 — forked from dpritchett/naur.md
Programming as Theory Building

Programming as Theory Building

Peter Naur, 1985

(copied from http://alistair.cockburn.us/ASD+book+extract%3A+%22Naur,+Ehn,+Musashi%22)

Introduction

The present discussion is a contribution to the understanding of what programming is. It suggests that programming properly should be regarded as an activity by which the programmers form or achieve a certain kind of insight, a theory, of the matters at hand. This suggestion is in contrast to what appears to be a more common notion, that programming should be regarded as a production of a program and certain other texts.

(ns app.mappy
#?(:cljs (:require-macros app.mappy))
(:require #?(:clj [datascript.core :as d]) ; database on server
#?(:clj [clojure.data.csv :as csv])
[hyperfiddle.electric :as e]
[hyperfiddle.electric-dom2 :as dom]
[hyperfiddle.electric-ui4 :as ui]
#?(:cljs ["@openlayers-elements/core/ol-map" :as ol-map])
#?(:cljs ["@openlayers-elements/maps/ol-layer-openstreetmap" :as ol-layer-openstreetmap])
#?(:cljs ["@openlayers-elements/core/ol-layer-vector" :as ol-layer-vector])

React.js interop POC — Electric Clojure

20220729.photon.reagent.react.interop.mp4
@leoapost
leoapost / gist:4318441
Created December 17, 2012 13:55
Delete all remote branches, except master
# Replace REMOTE_NAME with your remote name (e.g. origin)
git branch -r | grep REMOTE_NAME/ | grep -v 'master$' | grep -v HEAD| cut -d/ -f2 | while read line; do git push REMOTE_NAME :$line; done;
Goal CSS 3 XPath
All Elements * //*
All P Elements p //p
All Child Elements p>* //p/*
Element By ID #foo //*[@id=’foo’]
Element By Class .foo //*[contains(@class,’foo’)]
Element With Attribute *[title] //*[@title]
First Child of All P p>*:first-child //p/*[0]
All P with an A child Not possible //p[a]
Next Element p + * //p/following-sibling::*[0]