This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ns nightcoders.fruit-checkboxes | |
(:require [reagent.core :as r])) | |
;; Initial State | |
(def choices [:apple :apricot :banana :mango :orange :plum]) | |
(def max-choices 2) | |
(def state (r/atom [])) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(require '[clojure.core.async :refer [<!!]] | |
'[datomic.client :as client]) | |
; Connection config incomplete for brevity | |
(def conn (<!! (client/connect {:db-name "mydb"}))) | |
(<!! (client/pull (client/db conn) {:selector [:db/doc]})) | |
; Produces data as error message. | |
; Value on path [:datomic.client/http-error :cause] is a spec explaination: | |
{:cognitect.anomalies/category :cognitect.anomalies/incorrect |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ns my-project.core | |
(:require-macros [my-project.macros :refer [style-el]])) | |
(defn create-el [kind] | |
(. js/document (createElement (name kind)))) | |
(let [div (create-el :div)] | |
;; Works as expected | |
(style-el div :width "50%") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(* | |
* An OCaml implementation of object algebras, inspired from this article by Oleksandr Manzyuk: | |
* https://oleksandrmanzyuk.wordpress.com/2014/06/18/from-object-algebras-to-finally-tagless-interpreters-2/ | |
*) | |
module ObjectAlgebras = struct | |
(* We technically don't need these interfaces; | |
* added here to compare between the Java implementation *) | |
type 'a expAlg = < lit : int -> 'a; add : 'a -> 'a -> 'a > | |
type 'a mulAlg = < mul : 'a -> 'a -> 'a > |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module ListExtra = struct | |
open Core.Std | |
(*- Maps a function to each "column" in a list of "rows". | |
mapv [[1;2;3]; [3;4;5]] ~f:(List.fold ~init:0 ~f:(+));; | |
- : int list = [4; 6; 8] | |
*) | |
let mapv ls ~f = let open List in | |
let cmp x y = if length x = length y then 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# A side effect-less Factor operation. | |
[ ] call |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
transfer() { | |
echo $(gpg -ac --cipher-algo AES256 --sign --force-mdc < $1) | curl http://transfer.sh/$1 -T - | |
} | |
recover() { | |
curl $1 | gpg -ad | |
} | |
alias transfer=transfer |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Data.Text (split, pack, unpack) | |
splitStr :: Char -> String -> [String] | |
splitStr c str = map unpack $ split (== c) (pack str) |
NewerOlder