Skip to content

Instantly share code, notes, and snippets.

@carson-katri
carson-katri / cloth.py
Created December 1, 2022 13:18
Verlet integration in Geometry Script
from geometry_script import *
# Constants
SAMPLES = 3
# Inputs
class ClothInputs(InputGroup):
gravity: Vector = (0, 0, -0.5)
friction: Vector = (0.999, 0.999, 0.999)
stick_length: Float = 0.1
@peterwang
peterwang / my-macros.clj
Last active November 11, 2021 09:48
Clojure Macro-writing Macros step by step.
;;; Clojure Macro-writing Macros step by step.
(ns my.macros)
;; => nil
;;;;;;;; ns and vars
*ns*
;; => #namespace[my.macros]
(def x 3)
;; => #'my.macros/x

This is probably going to be the next iteration of the declarative CRUD metamodel that powers Hyperfiddle. It's just a design sketch, the current metamodel in prod is different. Hyperfiddle is an easy way to make a CRUD app. Hyperfiddle is based on Datomic, a simple graph database with the goal of "enabling declarative data programming in applications."

CRUD UI definition

This extends Datomic pull syntax into something that composes in richer ways. The key idea is that Pull notation expresses implicit joins and thus can be used to declare data dependencies implicitly, without needing to name them. We also handle tempids, named transactions, and hyperlinks to other pages. We satisfy the hypermedia constraint, like HTML and the web.

{identity                                                   ; Pass through URL params to query
 [{:dustingetz/event-registration                           ; virtual attribute identif
@tin2tin
tin2tin / basic_ui_documented.py
Last active May 22, 2024 13:24 — forked from AzureDVBB/basic_ui_documented.py
A commented template for making simple UI in blender using the bpy python API
#import the bpy module to access blender API
import bpy
#WARNING: this is written and tested for blender 2.79
#blender 2.8 and newer will likely have a different python API
#create a property group, this is REALLY needed so that operators
#AND the UI can access, display and expose it to the user to change
#in here we will have all properties(variables) that is neccessary
class CustomPropertyGroup(bpy.types.PropertyGroup):
@borkdude
borkdude / reagent_blessed.cljs
Last active July 1, 2021 15:21
Create a NodeJS CLI app using Reagent
(ns reagent-blessed.core
(:require
[cljs.nodejs :as node :refer [require]]
[react]
[reagent.core :as r]))
(def v8 (js/require "v8"))
(.setFlagsFromString v8 "--no-use_strict")
(def blessed (node/require "blessed"))
@bhb
bhb / blockchain-w-spec.md
Last active July 1, 2022 11:24
Building a blockchain, assisted by Clojure spec

Building a blockchain, assisted by Clojure spec

In an effort to gain at least a superficial understanding of the technical implementation of cryptocurrencies, I recently worked my way through "Learn Blockchains by Building One" using Clojure.

This was a good chance to experiment with using spec in new ways. At work, we primarily use spec to validate our global re-frame state and to validate data at system boundaries. For this project, I experimented with using instrumentation much more pervasively than I had done elsewhere.

This is not a guide to spec (there are already many excellent resources for this). Rather, it's an experience report exploring what went well, what is still missing, and quite a few unanswered questions for future research. If you have solutions for any of the problems I've presented, please let me know!

You don't need to know or care about blockchains to understand the code be

@taylorwood
taylorwood / infix-spec.clj
Created October 8, 2017 00:56
Recursive clojure.spec for grouped/nested infix expressions http://taylorwood.github.io/2017/10/04/clojure-spec-boolean.html
(ns playground.test
(:require [clojure.spec.alpha :as s]
[clojure.spec.gen.alpha :as sgen]
[clojure.spec.test.alpha :as stest]
[clojure.string :as cs]
[clojure.walk :as walk]))
(def op-keys #{:and :or})
(s/def ::expression
@sam95
sam95 / install_kafka.md
Last active June 13, 2019 19:45
Installation and Getting started with Apache-Kafka for OSX

Apache Kafka is a highly-scalable publish-subscribe messaging system that can serve as the data backbone in distributed applications. With Kafka’s Producer-Consumer model it becomes easy to implement multiple data consumers that do live monitoring as well persistent data storage for later analysis. You can assume that RabbitMQ is similar to Kafka, You do get an option for message-sending or Broadcasting. The installation process for OSX is as below.

  1. The best way to install the latest version of the Kafka server on OS X and to keep it up to date is via Homebrew.

     brew search kafka
     brew install kafka 
    
  2. The above commands will install a dependency called zookeeper which is required to run kafka. Start the zookeeper service.

zkserver start

@dvingo
dvingo / es6-class-react.cljs
Created February 11, 2017 13:22 — forked from pesterhazy/es6-class-react.cljs
React component in pure cljs using ES6 class inheritance
;; implementing a React component in pure cljs, no reagent necessary
;; using goog.object.extend to create a ES6 class that inherits from
;; React.Component
;; credit to @thheller
(defn MyReact [props context updater]
(this-as this
(js/React.Component.call this props context updater)))