Skip to content

Instantly share code, notes, and snippets.

@daveduthie
daveduthie / sokuza-kanren.scm
Created February 14, 2017 16:10 — forked from Pet3ris/sokuza-kanren.scm
Mini-kanren like logic programming in Scheme
; Quick miniKanren-like code
;
; written at the meeting of a Functional Programming Group
; (Toukyou/Shibuya, Apr 29, 2006), as a quick illustration of logic
; programming. The code is really quite trivial and unsophisticated:
; it was written without any preparation whatsoever. The present file
; adds comments and makes minor adjustments.
;
; $Id: sokuza-kanren.scm,v 1.1 2006/05/10 23:12:41 oleg Exp oleg $
(ns schejule.core
(:require [clojure.core.logic :as lg]
[clojure.core.logic.pldb :as pldb]))
;; Declare database relations
(pldb/db-rel tasko ^:index id)
(pldb/db-rel precedo ^:index id other-id bool)
;; Make example db
@daveduthie
daveduthie / 00_destructuring.md
Created February 21, 2017 08:29 — forked from john2x/00_destructuring.md
Clojure Destructuring Tutorial and Cheat Sheet

Clojure Destructuring Tutorial and Cheat Sheet

(Related blog post)

Simply put, destructuring in Clojure is a way extract values from a datastructure and bind them to symbols, without having to explicitly traverse the datstructure. It allows for elegant and concise Clojure code.

Vectors

; Church Numerals in Clojure
;
; Church numerals use anonymous functions to represent numbers.
;
; ((zero f) x) -- returns x
; ((one f) x) -- return (f x)
; ((two f) x) -- return (f (f x))
; ...
(def zero (fn [f] (fn [x] x)))
@daveduthie
daveduthie / core.clj
Last active April 24, 2017 15:10
tic-tac-toe
(ns toe.core
(:gen-class)
(:require [clojure.string :as str]))
;; # Create board
(defn new-board [size]
(vec (repeat size (vec (repeat size :-)))))
;; # Draw board on screen
(defn int->char [i]
@daveduthie
daveduthie / Ansible-Vault how-to.md
Created October 10, 2017 07:28 — forked from tristanfisher/Ansible-Vault how-to.md
A short tutorial on how to use Vault in your Ansible workflow. Ansible-vault allows you to more safely store sensitive information in a source code repository or on disk.

##Working with ansible-vault

I've been using a lot of Ansible lately and while almost everything has been great, finding a clean way to implement ansible-vault wasn't immediately apparent.

What I decided on was the following: put your secret information into a vars file, reference that vars file from your task, and encrypt the whole vars file using ansible-vault encrypt.

Let's use an example: You're writing an Ansible role and want to encrypt the spoiler for the movie Aliens.

(ns lazy.partition)
;; returns tuple: [(take-while pred coll) rest-of-coll]
(defn split-with [acc pred coll]
(lazy-seq
(let [h (first coll)]
(if (and h (pred h))
(split-with (lazy-cat acc [h]) pred (rest coll))
[acc coll]))))
(function webpackUniversalModuleDefinition(root, factory) {
if(typeof exports === 'object' && typeof module === 'object')
module.exports = factory(require("react"), require("react-dom"));
else if(typeof define === 'function' && define.amd)
define(["react", "react-dom"], factory);
else if(typeof exports === 'object')
exports["ReactDataGrid"] = factory(require("react"), require("react-dom"));
else
root["ReactDataGrid"] = factory(root["React"], root["ReactDOM"]);
})(this, function(__WEBPACK_EXTERNAL_MODULE_2__, __WEBPACK_EXTERNAL_MODULE_6__) {
@daveduthie
daveduthie / README.md
Created July 20, 2018 21:39 — forked from bhb/README.md
Clojure friendly mode, inspired by https://github.com/slipset/friendly

Keybase proof

I hereby claim:

  • I am daveduthie on github.
  • I am daveduthie (https://keybase.io/daveduthie) on keybase.
  • I have a public key whose fingerprint is F9BA 7DBA 1883 7562 7626 9146 9312 1846 0BD0 1150

To claim this, I am signing this object: