Skip to content

Instantly share code, notes, and snippets.

@rastandy
rastandy / docx2md.md
Created March 13, 2019 12:03 — forked from aembleton/docx2md.md
Convert a Word Document into MD

Converting a Word Document to Markdown in One Move

The Problem

A lot of important government documents are created and saved in Microsoft Word (*.docx). But Microsoft Word is a proprietary format, and it's not really useful for presenting documents on the web. So, I wanted to find a way to convert a .docx file into markdown.

Installing Pandoc

On a mac you can use homebrew by running the command brew install pandoc.

The Solution

@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 _] [*]}])