Skip to content

Instantly share code, notes, and snippets.

@xeqi
xeqi / macro.js
Created December 7, 2023 14:31
Battle stats update macro
const enemyTokens = game.canvas.scene.tokens.filter(entry => entry.disposition == -1);
const enemyDrawings = [
// Name, Amount
["0HRRJvAy0DL9fZYj", "xOkLUlaf66MIWaEg"],
["fvEtY6HXxuWZwTaM", "3ZpYPphDlKP0qocJ"],
["BxYhCFss1Hxeubg1", "1cyj6HHCq1Dy5y9C"],
["0zVx7PfduwZbNqnj", "kkoOJOPxo6K8hIhV"],
].map(uis => uis.map(id => canvas.scene.drawings.get(id)));
@xeqi
xeqi / ukanren_transducers.clj
Last active November 13, 2018 06:38
ukanren in almost transducers
(ns ukanren-transducers
(:refer-clojure :exclude [== disj conj]))
(defrecord Lvar [name])
(defn lvar [] (->Lvar (gensym "lvar")))
(defn lvar? [v] (instance? Lvar v))
(def empty-state {})
(defn walk [u s]
(defrecord JimFSFactory []
component/Lifecycle
(start [t] (Jimfs/newFileSystem (Configuration/unix))))
(extend-protocol component/Lifecycle
Jimfs
(stop [t] (.close t)))
(defrecord PathFactory [fs]
component/Lifecycle
(defrecord JimFSFactory []
component/Lifecycle
(start [t] (Jimfs/newFileSystem (Configuration/unix))))
(extend-protocol component/Lifecycle
Jimfs
(stop [t] (.close t)))
(defrecord PathFactory [fs]
component/Lifecycle
@xeqi
xeqi / sudoku.clj
Last active August 29, 2015 14:21
(ns sudoku
(:refer-clojure :exclude [==])
(:use clojure.core.logic)
(:require [clojure.core.logic.fd :as fd]))
(defn get-square [rows x y]
(for [x (range x (+ x 3))
y (range y (+ y 3))]
(get-in rows [x y])))
{ :repl {:plugins [[cider/cider-nrepl "0.9.0-SNAPSHOT"]]
:dependencies [[org.clojure/tools.nrepl "0.2.7"]]}
@xeqi
xeqi / build.clj
Last active August 29, 2015 14:17
(require 'cljs.closure)
(require 'cljs.js-deps)
(import 'java.net.URLClassLoader)
(import 'java.net.URL)
(def react-url
"https://clojars.org/repo/cljsjs/react/0.13.0-0/react-0.13.0-0.jar")
@xeqi
xeqi / gist:6227351
Created August 14, 2013 01:45
bob exercism
class Bob
def hey(message)
behaviors = {
-> {message.nil? || message.strip.empty?} => 'Fine. Be that way!',
-> {message.upcase == message} => 'Woah, chill out!',
-> {message[-1].chr == '?'} => 'Sure.'
}
behaviors.fetch(behaviors.keys.find(&:call), "Whatever.")
end
end
@xeqi
xeqi / pallet.clj
Last active December 14, 2015 23:39
immutant and pallet
(require
'[pallet.crate.git :refer [git clone]]
'[pallet.crate.java :refer [java]]
'[pallet.crate.lein :refer [lein leiningen]])
(def repo "git://github.com/jcrossley3/random-apps-of-kindness.git")
(def demo-directory "random-apps-of-kindness/demo")
(defplan setup-machine
@xeqi
xeqi / output.txt
Created March 1, 2012 06:20
clojure.java.jdbc, sqlite3, transactions, and resultsets
$ TEST_DBS=sqlite mvn clojure:test
[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] Building java.jdbc
[INFO] task-segment: [clojure:test]
[INFO] ------------------------------------------------------------------------
Downloading: http://repo1.maven.org/maven2/net/sourceforge/jtds/jtds/1.2.4/jtds-1.2.4.pom
Downloading: http://repo1.maven.org/maven2/net/sourceforge/jtds/jtds/1.2.4/jtds-1.2.4.jar