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
(defn tree-seq-depth | |
"Returns a lazy sequence of vectors of the nodes in a tree and their | |
depth as [node depth], via a depth-first walk. branch? must be a fn | |
of one arg that returns true if passed a node that can have | |
children (but may not). children must be a fn of one arg that | |
returns a sequence of the children. Will only be called on nodes for | |
which branch? returns true. Root is the root node of the tree." | |
[branch? children root] | |
(let [walk (fn walk [depth node] | |
(lazy-seq |
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
(def x [["/foo" | |
["/bar" :bar] | |
["/baz" | |
["/quux" :quux]]] | |
["/yo" | |
[["/man" :man] | |
["/manman" :manman]]]]) | |
(require '[clojure.zip :as z] | |
'[clojure.string :as str]) |
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 sat.core | |
(:require [rolling-stones.core :as sat :refer [!]] | |
[clojure.string :as str])) | |
(def rows 9) | |
(def cols 9) | |
(def values 9) | |
(defn possible-square-values |
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 skija.core | |
(:import [org.jetbrains.skija Canvas Surface Paint Color4f | |
EncodedImageFormat] | |
[java.nio.file Path Files OpenOption])) | |
(defn write-bytes [#^bytes b path] | |
(Files/write (Path/of "output.png" (make-array String 0)) b (make-array OpenOption 0))) | |
(defn show [] | |
(let [surface (Surface/makeRasterN32Premul 100 100) |
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
(defn seq!! | |
"Returns a (blocking!) lazy sequence read from a channel." | |
[c] | |
(lazy-seq | |
(when-let [v (<!! c)] | |
(cons v (seq!! c))))) | |
(comment | |
(def stream (chan)) | |
(go (dotimes [x 16] |
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
package test; | |
import java.util.HashMap; | |
public class HashOfHashes { | |
public static void main(String[] args) { | |
//deep's type is a HashMap with String keys. Its values are Hashes with String keys and values | |
//Notice how you have to say all that twice, just to be sure :-/ | |
HashMap<String, HashMap<String, String>> deep = new HashMap<String, HashMap<String, String>>(); |
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 not-posh | |
(:require [clojure.string :as str] | |
[clojure.data :as data] | |
[datascript.core :as d] | |
[clojure.set :as set] | |
[seesaw.core :as ss])) | |
(defn- diff [a b] | |
;;TODO make diff ignore :swing/component key but include it in result | |
(let [[removed added] (data/diff a b) |
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
{:resources | |
[{:duna/type :provider/aws | |
:region "eu-west-1"} | |
{:duna/type :data/aws_ami | |
:duna/id :ubuntu | |
:most_recent true | |
:filter [{:name "name" | |
:values ["ubuntu/images/hvm-ssd/ubuntu-trusty-14.04-amd64-server-*"]} | |
{:name "virtualization-type" | |
:values ["hvm"]}] |
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
;; This will open a window with a single textfield where you can paste some HTML, | |
;; press <enter> and you should see a valid Clojure string get printed in your REPL, | |
;; without having to worry about escaping double quotes etc. | |
;; AND it fits a single tweet. :) | |
(import '[javax.swing JFrame JTextField] | |
'[java.awt.event ActionListener]) | |
(doto (JFrame.) | |
(.add (doto (JTextField.) |
NewerOlder