Skip to content

Instantly share code, notes, and snippets.

@rastandy
rastandy / mkfavicon.sh
Created October 23, 2018 13:10 — forked from pfig/mkfavicon.sh
Make a multi-resolution favicon.ico from a source image, using ImageMagick
#!/bin/bash
# from
# http://bergamini.org/computers/creating-favicon.ico-icon-files-with-imagemagick-convert.html
convert source-WxW.png -resize 256x256 -transparent white favicon-256.png
convert favicon-256.png -resize 16x16 favicon-16.png
convert favicon-256.png -resize 32x32 favicon-32.png
convert favicon-256.png -resize 64x64 favicon-64.png
convert favicon-256.png -resize 128x128 favicon-128.png
@rastandy
rastandy / cljs-main.md
Created July 11, 2018 22:53 — forked from mfikes/cljs-main.md
Command to get a preview of cljs.main

Usage

Start up the new cljs.main with Node:

clj -Sdeps '{:deps {org.clojurescript {:git/url "https://github.com/clojure/clojurescript" :sha "3f4084efcb5cd92cceb8ca30765144691d8cfd7e"}}}' -m cljs.main -re node

The above works by specifying ClojureScript as a "git dep" and you can ensure that you are running the very latest by replacing the :sha value with the latest commit SHA at https://github.com/clojure/clojurescript.

@rastandy
rastandy / cljs-serverless.md
Created July 11, 2018 22:25 — forked from lilactown/cljs-serverless.md
CLJS in AWS Lambda Quick Start
@rastandy
rastandy / lambda-basic-auth.js
Created April 30, 2018 13:08 — forked from lmakarov/lambda-basic-auth.js
Basic HTTP Authentication for CloudFront with Lambda@Edge
'use strict';
exports.handler = (event, context, callback) => {
// Get request and request headers
const request = event.Records[0].cf.request;
const headers = request.headers;
// Configure authentication
const authUser = 'user';
const authPass = 'pass';
@rastandy
rastandy / replace.clj
Created November 22, 2017 11:29 — forked from chrismurrph/replace.clj
Search and replace for going to Fulcro 2.0
(ns general.replace
(:require [clojure.string :as s]
[clojure.java.io :as io]
[clojure.pprint :as pp]))
(defn indexes-of [in-str find-str]
(loop [idx 0
indexes []]
(let [found-idx (s/index-of in-str find-str idx)]
(if found-idx
@rastandy
rastandy / client.cljs
Last active November 22, 2017 11:21
Fulcro client creation
(ns data-portal.client
(:require [om.next :as om]
[fulcro.client.core :as uc]
[data-portal.ui.html5-routing :as routing]
[data-portal.ui.root :as root]
[fulcro.client.logging :as log]
[data-portal.api.core :refer [make-rest-network]]))
(defonce app
(atom (uc/new-fulcro-client
@rastandy
rastandy / spec.cljs
Last active November 15, 2017 14:43 — forked from swannodette/spec.cljs
om.next query spec
(ns om.next.spec
(:require [cljs.spec.alpha :as s]))
(s/def ::ident (s/and vector? (s/cat :ident keyword? :value #(not (coll? %)))))
(s/def ::join-key (s/or :prop keyword? :ident ::ident))
(s/def ::join (s/and (s/map-of ::join-key ::query) #(= (count %) 1)))
(s/def ::union (s/and (s/map-of keyword? ::query) #(> (count %) 1)))
(s/def ::param-expr
(s/cat :query-expr ::query-expr
@rastandy
rastandy / bbox.cljs
Last active November 11, 2017 12:16
Clojure specs for a geographical bounding box
(ns data-portal.specs.bbox
(:require [clojure.spec.alpha :as s]))
(s/def :geo/latitude (s/and number? #(<= -90 % 90)))
(s/def :geo/longitude (s/and number? #(<= -180 % 360)))
(s/def :geo/north :geo/latitude)
(s/def :geo/south :geo/latitude)
(s/def :geo/east :geo/longitude)
(s/def :geo/west :geo/longitude)
@rastandy
rastandy / fulcro reference query
Last active November 11, 2017 12:16
Ask for a specific entity in a Fulcro query
static om/IQuery
(query [this] [{:panels {:panelA [:boo], :panelB [:goo], :panelC [:sticky]}}
{[:panelB 1] [*]}
{[:current-panel _] [*]}])
@rastandy
rastandy / GraphQL-Architecture.md
Last active November 8, 2017 15:00 — forked from idibidiart/GraphQL-Architecture.md
Building an Agile, Maintainable Architecture with GraphQL

Building a Maintainable, Agile Architecture for Realtime, Transactional Apps

A maintainable application architecture requires that the UI only contain the rendering logic and execute queries and mutations against the underlying data model on the server. A maintainable architecture must not contain any logic for composing "app state" on the client as that would necessarily embed business logic in the client. App state should be persisted to the database and the client projection of it should be composed in the mid tier, and refreshed as mutations occur on the server (and after network interruption) for a highly