Skip to content

Instantly share code, notes, and snippets.

View attentive's full-sized avatar

Tom attentive

View GitHub Profile
@attentive
attentive / swagger.json
Last active October 4, 2019 02:46
EML Data Services Swagger
{
"swagger": "2.0",
"info": {
"description": "This is a partial Swagger representation of the EML Data Services API documentation version 1.0 that will be used to generate a .NET client. See https://developer.emerchants.com.au/paywith/eml.v1.html# for vendor documentation.",
"version": "1.0",
"title": "EML Data Services API",
"contact": {
"email": "tom.lynch@radicalsystems.com.au"
}
},
@attentive
attentive / core.cljs
Last active March 11, 2019 08:56
Unexpected clojure.spec behaviour
(namespace foo.core
(:require [clojure.spec.alpha :as s]))
(s/def ::n (s/or :integer integer? :string string?))
(s/def ::m (s/keys :req-un [::n]))
(defn m-even? [m] (even? (:n m)))
(s/def ::m-even (s/and ::m m-even?))
@attentive
attentive / console.js
Last active July 11, 2019 13:30
Unlike tweets from the Twitter Likes page, via JavaScript in console
// See https://www.quora.com/How-do-I-bulk-delete-likes-on-Twitter
inter = setInterval(() => {
$("html, body").animate({
scrollTop: $(document).height()-$(window).height(),
complete: setTimeout(() => {$('.ProfileTweet-action--unfavorite').click().remove()}, 1000)
})
if($('.has-more-items').length == 0) {
clearInterval(inter)
@attentive
attentive / core.cljs
Last active February 12, 2019 04:53
How to integrate react-native-splash-screen with ClojureScript
(ns rnss.core
(:require [oops.core :refer [oget ocall]]
[reagent.core :as r]
["react-native" :as RN]
["react-native-splash-screen" :as RNSS]))
;; The code below depends on the existence of a separate splash screen
;; layout in your app, as per the react-native-splash-screen doco.
;; This sample shows only how to reference the splash screen library and
@attentive
attentive / pg2mvt.sh
Created November 26, 2018 03:11
Connect to PostGIS and export vector tiles
# This rigmarole should connect successfully first
ogrinfo PG:"dbname='databasename' host='addr' port='5432' user='x' password='y'" layername
# Requires GDAL 2.3 or higher (current stable Ubuntu packages for Bionic are only 2.2.x)
ogr2ogr -f MVT out.mbtiles PG:"dbname='databasename' host='addr' port='5432' user='x' password='y'" layername
(ns fizzbuzz
(:require [clojure.core.match :refer [match]]))
(defn interpret [x y i]
(match [x y i]
[true true _] "FizzBuzz"
[true false _] "Fizz"
[false true _] "Buzz"
:else i))
@attentive
attentive / add-watch.cljc
Created May 5, 2017 04:09
Using Clojure add-watch to track the previous state of an atom
(def current (atom 1))
(def previous (atom nil))
(add-watch current :dontcare
(fn [_ _ old-state _]
(reset! previous old-state)))
(repeatedly 10 #(do (swap! current * 2)
(println "Current:" @current "Previous:" @previous)))
@attentive
attentive / leaflet.cljs
Last active September 16, 2017 09:25
Adapting React components in Rum
(ns project.leaflet
(:require-macros [project.macros :as m])
(:require [rum.core :as rum]
cljsjs.react-leaflet)) ;; js/ReactLeaflet
(m/adapt-react leaflet-map js/ReactLeaflet.Map)
(m/adapt-react tile-layer js/ReactLeaflet.TileLayer)
(m/adapt-react marker js/ReactLeaflet.Marker)
(m/adapt-react popup js/ReactLeaflet.Popup)
(ns vchain.graph
(:require [om.core :as om :include-macros true]
[cljs.core.async :as async :refer [put! chan mult]]
[clojure.string :as string :refer [join]]
[sablono.core :as html :refer-macros [html]]
[strokes :refer [d3]]
vchain.links
vchain.routes
vchain.slug
vchain.wrap))
@attentive
attentive / goban.clj
Last active January 5, 2020 02:41
SVG goban in Hiccup
(ns goban
(:require [clojure.string :as string]
hiccup.core))
(let [CEL 5.0 ; cell dimension in SVG viewport units
BDR 3.0 ; border width
PXR 10 ; ratio of pixels to SVG vw
BOA (* CEL 18) ; board side
DIM (+ BOA (* BDR 2))] ; goban side