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 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 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 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 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 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 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 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 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 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") |
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
;; Please have a look https://github.com/ertugrulcetin/jme-clj for more. | |
;; Demo video used this gist: https://www.youtube.com/watch?v=IOPz9I49snM | |
(ns examples.beginner-tutorials.hello-collision | |
"Clojure version of https://wiki.jmonkeyengine.org/docs/3.3/tutorials/beginner/hello_collision.html" | |
(:require [jme-clj.core :refer :all]) | |
(:import | |
(com.jme3.asset.plugins ZipLocator) | |
(com.jme3.input KeyInput) | |
(com.jme3.math ColorRGBA))) |
NewerOlder