Skip to content

Instantly share code, notes, and snippets.

View fogus's full-sized avatar
💭
attempting to learn how to better learn

Fogus fogus

💭
attempting to learn how to better learn
View GitHub Profile
@fogus
fogus / units.clj
Created April 19, 2018 15:50 — forked from Chouser/units.clj
(ns party.units
(:refer-clojure :exclude [+ - * /])
(:require [clojure.algo.generic.arithmetic :as ari :use [+ - * /]]))
(defrecord Measurement [factor units]
clojure.lang.IFn
(invoke [a b] (* a b)))
(defn ^:private short-name [sym]
(if (= (namespace sym) (namespace `foo))
@fogus
fogus / service.clj
Last active December 1, 2017 19:38 — forked from mtnygard/service.clj
Using the not-found-interceptor as a catchall
(ns support.service
(:require [io.pedestal.http :as http]
[io.pedestal.http.route :as route]))
(defn about-page
[request]
{:status 200 :body (format "Clojure %s - served from %s"
(clojure-version)
(route/url-for ::about-page))})

Rich Already Answered That!

A list of commonly asked questions, design decisions, reasons why Clojure is the way it is as they were answered directly by Rich (even when from many years ago, those answers are pretty much valid today!). Feel free to point friends and colleagues here next time they ask (again). Answers are pasted verbatim (I've made small adjustments for readibility, but never changed a sentence) from mailing lists, articles, chats. The link points back at them.

If you are talking about the aspect of pattern matching that acts as a conditional based upon structure, I'm not a big fan. I feel about them the way I do about switch statements - they're brittle and

@fogus
fogus / j.c
Created June 19, 2017 19:26 — forked from piotrklibert/j.c
typedef char C;
typedef long I;
typedef struct a {
I t, r, d[3], p[2];
} *A;
#define P printf
#define R return
#define V1(f) A f(w)A w;
@fogus
fogus / dc_2017_biblio.md
Created April 24, 2017 17:42 — forked from BaseCase/dc_2017_biblio.md
List of resources recommended or mentioned by the speakers at Deconstruct 2017

Deconstruct 2017 Bibliography

Here are all of the resources mentioned by Deconstruct 2017 speakers, along with who recommended what. Please post a comment if I missed something or have an error!

DC 2017 Speakers' Choice Gold Medalist

  • Seeing Like a State by James Scott

Books

  • Public Opinion by Walter Lippmann (Evan Czaplicki)
  • A Pattern Language by Christopher Alexander (Brian Marick)
  • Domain Driven Design by Eric Evans (Brian Marick)
(ns unrepl.evented-reader)
(defprotocol Closeable
(close [_]))
(defprotocol Stream
(read! [stream])
(unread! [stream])
(on-more [stream f]
"f is a function of two arguments: stream and an array where to push values.
@fogus
fogus / set-game.clj
Created June 30, 2016 15:24 — forked from cgrand/set-game.clj
the SET game in clojure.spec
;; the SET game in clojure.spec
;; inspired by https://github.com/jgrodziski/set-game
(require '[clojure.spec :as s])
(s/def ::shape #{:oval :diamond :squiggle})
(s/def ::color #{:red :purple :green})
(s/def ::value #{1 2 3})
(s/def ::shading #{:solid :striped :outline})
(s/def ::card (s/keys :req [::shape ::color ::value ::shading]))
@fogus
fogus / Unify.agda
Created April 19, 2016 17:27 — forked from copumpkin/Unify.agda
Structurally recursive unification à la McBride
module Unify where
-- Translated from http://strictlypositive.org/unify.ps.gz
open import Data.Empty
import Data.Maybe as Maybe
open Maybe hiding (map)
open import Data.Nat
open import Data.Fin
open import Data.Product hiding (map)
@fogus
fogus / combinators.forth
Created March 22, 2016 16:12 — forked from crcx/combinators.forth
Port of Retro's combinator implementations to Forth. This also has a gForth implementation of quotations from Alexander Skobelev.
\ This is an implementation of quotations and some combinators
\ for use with Forth. The combinators should work with most
\ Forth systems; the quotation implementation here is gForth
\ specific.
\ ************************************************************
\ dip
\ Stack: value quote -- value
\ Executes a quotation with a value being temporarily removed
;; setup db to test with
;; note that this setup uses a local dev transactor
;; you can use a different transactor, but you cannot
;; use a mem db because it does not support the log API
(require '[datomic.api :as d])
(def uri "datomic:dev://localhost:4334/reified-txes")
(d/delete-database uri)
(d/create-database uri)
(def conn (d/connect uri))