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 cljs-engine.api.preload | |
(:refer-clojure :exclude [dissoc update-in assoc-in]) | |
(:require [applied-science.js-interop :as j])) | |
(extend-type object | |
ILookup | |
(-lookup |
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] |
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
(defmacro deftickscheduler [name ticks-per-sec & body] | |
`(when-not *compile-files* | |
(def ~name (let [ticks-per-sec# (/ 1000 ~ticks-per-sec) | |
running?# (volatile! true)] | |
{:var (var ~name) | |
:channel (a/go-loop [] | |
(when @running?# | |
(let [start# (System/currentTimeMillis) | |
_# (do ~@body) | |
elapsed# (- (+ start# ticks-per-sec#) (System/currentTimeMillis))] |
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 | |
(require '[babashka.curl :as curl]) | |
(require '[clojure.java.io :as io]) | |
(require '[cheshire.core :as json]) | |
(defn- call [q page] | |
(-> (curl/get "https://api.github.com/search/code" | |
{:headers {"Accept" "application/vnd.github.previe"} | |
:query-params {"q" (str q " language:Clojure") |
NewerOlder