Skip to content

Instantly share code, notes, and snippets.

@kybernetikos
kybernetikos / readme.md
Last active March 25, 2017 20:24
Receivers and Receiver Transformers

Transducers Primer

function reducerFn(output, value) {
	// reducer functions know how to build a structure when repeatedly given
	// that structure and values (think of it as 'builder')
	return output
}
function reduceFn(collection, reducerFn, output) {
@swannodette
swannodette / om_data.cljs
Last active January 9, 2021 16:09
Om + DataScript
(ns om-data.core
(:require [om.core :as om :include-macros true]
[om.dom :as dom :include-macros true]
[datascript :as d]))
(enable-console-print!)
(def schema {})
(def conn (d/create-conn schema))
@bitoiu
bitoiu / missionariesAndCannibals
Last active January 6, 2020 19:19
Prolog: Missionaries and Cannibals
% Run missionaries(((3,3),(0,0),1),[],Path).
validMove(Position, Visited):-
notMember(Position,Visited),
positiveCount(Position),
noEatingAnyone(Position).
positiveCount(((LeftCannibals,LeftMissionaries), (RightCannibals,RightMissionaries),_)):-
LeftCannibals >=0,
LeftMissionaries >=0,
@mstade
mstade / view.md
Last active January 4, 2016 23:12
Some thoughts on application/view

Application views using HTTP trickery

If the client makes a request, let's say this is an initial request to a resource that the client knows nothing about. It goes along and does a little something like this:

GET /foo HTTP/1.1
Accept: text/html
(ns react-cljs.core
(:require-macros [cljs.core.async.macros :refer [go]])
(:require [om.core :as om]
[om.dom :as dom :include-macros true]
[cljs.core.async :refer [>! <! chan put! sliding-buffer]]))
(enable-console-print!)
(def app-state
(atom {:counters (into [] (map (fn [n] {:id n :count 0}) (range 10)))}))
@mstade
mstade / bridging-the-gap.md
Last active December 30, 2015 17:59
Programmable Hypermedia Client Blues

Programmable Hypermedia Client Blues (Part I)

In Restful Web APIs it is argued that one of the major problems with APIs (arguably regardless of whether they are RESTful) is that they don't convey enough semantics so a client unfamiliar with implementation details (media type, URL structures, HTTP methods etc.) could still make use of it. On the "human web" this isn't really a problem, as the book rightly points out, because humans are much better at making decisions despite considerable semantic gaps. For example, if a site contains a link with the text:

Click here to buy our most popular product!

It's easy for us to understand that we can click on it to purchase an item; a computer however would just see some additional markup and realize it's a link, but not where it points to, why or what it is:

(ns react-cljs.core
(:require React))
(declare render)
(defn handle-change [e]
(render {:text (.. e -target -value)}))
(defn render [{:keys [text]}]
(React/renderComponent
@sammyt
sammyt / index.html
Last active December 10, 2015 17:48
using d3 to render a list with a template
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<script type="text/javascript" src="d3.js"></script>
<script type="text/javascript" src="list.js"></script>
<title>d3 demo</title>
</head>
<body onload="init()">
<ul>
@piscisaureus
piscisaureus / pr.md
Created August 13, 2012 16:12
Checkout github pull requests locally

Locate the section for your github remote in the .git/config file. It looks like this:

[remote "origin"]
	fetch = +refs/heads/*:refs/remotes/origin/*
	url = [email protected]:joyent/node.git

Now add the line fetch = +refs/pull/*/head:refs/remotes/origin/pr/* to this section. Obviously, change the github url to match your project's URL. It ends up looking like this: