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 '[buddy.core.codecs.base64 :as base64] | |
'[cognitect.aws.util :as util] | |
'[clojure.string :as str] | |
'[jsonista.core :as json] | |
'[cognitect.aws.credentials :as creds] | |
'[cognitect.aws.http :as http]) | |
(import '[java.util Date]) | |
(defn host-style-bucket-uri [bucket] | |
(str "http://" bucket ".s3.amazonaws.com/")) |
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
{:deps {net.cgrand/xforms {:mvn/version "0.19.0"} | |
org.clojure/clojure {:mvn/version "1.10.1"} | |
org.clojure/core.async {:mvn/version "0.4.500"}}} |
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
;; P.S. 閱讀指引,在 Code Snippet(白色的地方)按Ctrl+Enter看結果。也可以修改後按Ctrl+Enter~ | |
;; 假設我想寫一個簡單的猜字遊戲。 | |
;; 首先,我應該要有一本字典提供生字。 | |
(def dict ["Clojure" "Java" "Go" "Javascript" "Haskell" "Scala" "C" "C++" "Rust" "C#" "Prolog"]) | |
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.set :as s]) | |
;; Graph Data from the Picture | |
(def graph [#{:a :b} | |
#{:a :d} | |
#{:a :h} | |
#{:b :c} | |
#{:b :d} | |
#{:d :c} | |
#{:d :e} |
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
(defproject test-cljail "0.1.0-SNAPSHOT" | |
:description "FIXME: write description" | |
:url "http://example.com/FIXME" | |
:license {:name "Eclipse Public License" | |
:url "http://www.eclipse.org/legal/epl-v10.html"} | |
:dependencies [[org.clojure/clojure "1.8.0"] | |
[clojail "1.0.6"]]) |
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 com.example.bst) | |
; using {:val :left :right} as tree data structure | |
(defn node [val & [left right other]] | |
{:val val :left left :right right :bag other}) | |
(defn insert [parent i-node] | |
(let [i-val (:val i-node) | |
p-val (:val parent) | |
side (cond (> i-val p-val) :left |
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
(use 'clojure.core.logic) | |
(require '[clojure.core.logic.fd :as fd]) | |
(def result | |
(run* [q] | |
(fresh [a b c d e f g h p ab cd ef gh ppp] | |
(fd/in a b c d e f g h p (fd/interval 1 9)) ; why not zero? | |
(fd/in ab cd ef gh (fd/interval 10 99)) | |
(fd/in ppp (fd/interval 100 999)) | |
(fd/eq |
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
; copy from https://github.com/daveray/seesaw/blob/develop/src/seesaw/options.clj | |
(defrecord Option [name setter getter examples]) | |
(defmacro bean-option | |
[name-arg target-type & [set-conv get-conv examples]] | |
(let [[option-name bean-property-name] (split-bean-option-name name-arg) | |
target (gensym "target")] | |
`(Option. ~option-name | |
(fn [~(with-meta target {:tag target-type}) value#] |
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
(-> (frame :title "Why Swing, why?" | |
:on-close :exit | |
:content (label :text "Hiya" | |
:border 5 | |
:background "#888" | |
:foreground :blue)) | |
pack! | |
show!) |
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
(bean (java.util.Date.)) | |
{:seconds 40, :date 23, :class java.util.Date, | |
:minutes 47, :hours 21, :year 113, | |
:timezoneOffset -480, :month 1, :day 6, | |
:time 1361627260711} |
NewerOlder