This file contains hidden or 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
;; ClojureScript macro alet that enables async/await-like syntax for JavaScript Promises and core.async channels. | |
;; It supports sequential binding with optional (await ...) expressions and body steps, and includes an optional (catch err ...) clause for error handling. | |
(defmacro alet [bindings & body] | |
(let [last-expr (last body) | |
[body catch] | |
(if (and (seq? last-expr) (= 'catch (first last-expr))) | |
[(butlast body) last-expr] | |
[body nil]) | |
;; Parse bindings into pairs like let does |
This file contains hidden or 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 bpy | |
def make_animation_in_place(anim_name="rotate"): | |
""" | |
Modifies the given animation to be in-place by setting | |
X, Y, and Z location keyframe values to 0. | |
""" | |
action = bpy.data.actions.get(anim_name) | |
if not action: |
This file contains hidden or 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
;; ClojureScript Patch: assoc, dissoc, update-in for JS Objects | |
;; Extends assoc, dissoc, and update-in to work seamlessly with native JavaScript objects in ClojureScript. | |
;; This namespace bridges the gap between idiomatic ClojureScript data manipulation and JavaScript interop, enabling structural updates on #js objects using familiar Clojure semantics. | |
(ns preload | |
(:refer-clojure :exclude [dissoc update-in assoc-in]) | |
(:require | |
[applied-science.js-interop :as j] | |
[clojure.string :as str])) | |
(def kw->str |
This file contains hidden or 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 app.core | |
(:require | |
[cljs.spec.alpha :as s] | |
[clojure.edn :as edn] | |
[uix.core :as uix :refer [defui $]] | |
[uix.dom]) | |
(:require-macros | |
[app.macros :as m])) | |
(m/defui header [] |
This file contains hidden or 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
var Terrain = pc.createScript('terrain'); | |
Terrain.attributes.add('heightMap', { | |
type: 'asset', | |
assetType: 'texture' | |
}); | |
Terrain.attributes.add('minHeight', { | |
type: 'number', | |
default: 0 |
This file contains hidden or 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
// Download Violentmonkey -> https://chrome.google.com/webstore/detail/violentmonkey/jinjaccalgkegednnccohejagnlnfdag/related | |
// Paste the code for https://playcanvas.com | |
// Sample project: https://playcanvas.com/project/1002857/overview/render-heightmap-in-the-editor | |
// ==UserScript== | |
// @name PlayCanvas | |
// @namespace Violentmonkey Scripts | |
// @match https://playcanvas.com/editor/scene/* | |
// @grant none | |
// @version 1.0 |
This file contains hidden or 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
#!/usr/bin/env bb | |
;; To install babashka -> https://github.com/babashka/babashka#quickstart | |
(require '[babashka.curl :as curl]) | |
(require '[babashka.tasks :as tasks]) | |
(require '[cheshire.core :as json]) | |
(require '[clojure.java.io :as io]) | |
(def project-id 1111) |
This file contains hidden or 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
;; https://www.reddit.com/r/Clojure/comments/ufa8e0/clojure_sort_by_multiple_keys_with_different/ | |
(let [sort-fns-map {:asc (fn [a b] (. clojure.lang.Util compare a b)) | |
:desc (fn [a b] (. clojure.lang.Util compare b a))}] | |
(defn by [& keys-orderings] | |
(fn [a b] | |
(loop [[key ordering & keys-orderings] keys-orderings] | |
(let [order ((get sort-fns-map ordering ordering) (key a) (key b))] | |
(if (and (zero? order) keys-orderings) | |
(recur keys-orderings) |
This file contains hidden or 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
// https://www.gabrielgambetta.com/client-side-prediction-live-demo.html | |
// ============================================================================= | |
// An Entity in the world. | |
// ============================================================================= | |
var Entity = function() { | |
this.x = 0; | |
this.speed = 2; // units/s | |
this.position_buffer = []; | |
} |
This file contains hidden or 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 interceptors | |
(:require | |
[clojure.data :as d] | |
[malli.core :as m] | |
[malli.error :as me])) | |
(def prev-state (atom nil)) | |
;; Applies schema only changed parts (diff) of the app-db (state) | |
(defn check-and-throw [schema state event] |
NewerOlder